-
Notifications
You must be signed in to change notification settings - Fork 23
/
autodist.sh
executable file
·74 lines (54 loc) · 2.4 KB
/
autodist.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -e
# build the distribution tarball (in docker)
dimg="${1:-natefoo/slurm-drmaa-dist}"
dctx="$(mktemp -d)"
cat >$dctx/Dockerfile <<'EOF'
FROM debian:stable
LABEL maintainer="Nate Coraor <[email protected]>" \
description="Image used to build slurm-drmaa release tarballs"
VOLUME ["/slurm-drmaa"]
ENV DEBIAN_FRONTEND noninteractive
# slurm headers/libs are required to generate the build artifacts
RUN apt-get -qqy update && apt-get -y install --no-install-recommends build-essential gperf ragel m4 automake autoconf \
libtool libslurm-dev slurm-wlm git ca-certificates bison
RUN apt-get -y clean
RUN git clone https://github.com/bats-core/bats-core.git/ /bats
RUN echo 'PATH=/bats/bin:${PATH}' >> /etc/profile
ADD docker-make-release.sh /
ENTRYPOINT ["/bin/bash", "/docker-make-release.sh"]
EOF
cat >$dctx/docker-make-release.sh <<'EOF'
#!/bin/bash
set -e
if [ $(id -u) -eq 0 ]; then
uid=$(stat -c %u /slurm-drmaa)
gid=$(stat -c %g /slurm-drmaa)
if [ "$uid" -ne 0 ]; then
[ "$gid" -ne 0 ] && groupadd -g $gid build
useradd -u $uid -g $gid -s /bin/bash -d /slurm-drmaa build
exec su - build -c "/bin/bash /docker-make-release.sh"
fi
fi
[ ! -e "/slurm-drmaa/autogen.sh" ] && git clone --recursive https://github.com/natefoo/slurm-drmaa.git /slurm-drmaa
cd /slurm-drmaa
# replace rev fetching command with its output
sed -i -E -e 's/^(AC_INIT\(.*)m4_esyscmd_s\([^)]+\)(.*)$/\1'$(eval $(grep '^AC_INIT(' configure.ac | sed -E 's/^AC_INIT\(.*m4_esyscmd_s\(([^)]+).*$/\1/'))'\2/' \
-e 's/^(AC_REVISION\()\[m4_esyscmd_s\([^)]+\)\](.*)$/\1['$(eval $(grep '^AC_REVISION(' configure.ac | sed -E 's/^AC_REVISION\(\[m4_esyscmd_s\(\[([^]]+).*$/\1/'))']\2/' configure.ac
# also for drmaa_utils
cd drmaa_utils
sed -i -E -e 's/^(AC_REVISION\()\[m4_esyscmd_s\([^)]+\)\](.*)$/\1['$(eval $(grep '^AC_REVISION(' configure.ac | sed -E 's/^AC_REVISION\(\[m4_esyscmd_s\(\[([^]]+).*$/\1/'))']\2/' configure.ac
cd ..
./autoclean.sh || true
./autogen.sh
./configure
# fix up RPM specfile
eval `grep ^PACKAGE_VERSION= configure`
PACKAGE_RELEASE=`echo ${PACKAGE_VERSION#*-} | sed -e 's/[.-]/_/g'`
sed -i -e "s/^\(Version:\s*\).*$/\1${PACKAGE_VERSION%%-*}/" slurm-drmaa.spec
make dist
SLURM_CONF=/dev/null DISTCHECK_CONFIGURE_FLAGS="CFLAGS='-I../../../../drmaa_utils -I../../..'" make distcheck
EOF
docker build -t $dimg $dctx
docker run -v $(pwd):/slurm-drmaa $dimg
[ -e $dctx ] && rm -rf $dctx