[beast: 9/11] MISC: shift bintray package upload into Dockerfile
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 9/11] MISC: shift bintray package upload into Dockerfile
- Date: Thu, 27 Oct 2016 19:56:06 +0000 (UTC)
commit f2927780d6586b36be92b2a8f47db17ba9eef307
Author: Tim Janik <timj gnu org>
Date: Wed Oct 19 22:13:07 2016 +0200
MISC: shift bintray package upload into Dockerfile
Signed-off-by: Tim Janik <timj gnu org>
misc/Dockerfile-apt.in | 141 ++++++++++++++++++++++++++++++++----------------
misc/dockerbuild.sh | 44 +++++++++++++++
2 files changed, 138 insertions(+), 47 deletions(-)
---
diff --git a/misc/Dockerfile-apt.in b/misc/Dockerfile-apt.in
index faa674f..c595b2e 100644
--- a/misc/Dockerfile-apt.in
+++ b/misc/Dockerfile-apt.in
@@ -4,47 +4,66 @@
FROM @DIST@
MAINTAINER Tim Janik <timj gnu org>
-# Carry over enviroment variables
-ENV EMAIL beast gnome org
-
# Automation tools and convenience commands
ENV DEBIAN_FRONTEND noninteractive
-RUN echo '#!/bin/bash\n"$@" || { sleep 10 ; "$@" ; } || { sleep 90 ; "$@" ; }' > /bin/retry && chmod +x
/bin/retry && \
+RUN echo '#!/bin/bash\n"$@" || { sleep 10 ; "$@" ; } || { sleep 90 ; "$@" ; }' > /bin/retry && \
+ echo '#!/bin/sh\ncase "$INTENT" in *$1*) echo true ;; *) echo "exit 0" ;; esac' > /bin/intent && \
+ chmod +x /bin/retry /bin/intent && \
echo '\n' \
"\nalias ls='ls --color=auto' ; alias l='ls -al' ;" \
"\nalias grep='grep --color=auto' ; alias fgrep='fgrep --color=auto' ; alias egrep='egrep --color=auto'
;" \
'\nfunction regrep { (shopt -s globstar extglob; IFS=; set - ; /usr/bin/nice /bin/egrep --color=auto -d
skip "") }' \
| tee -a /etc/bash.bashrc >> /root/.bashrc
-# Ensure uptodate distribution and access to the bintray.com repositories
-ENV http_proxy "@http_proxy@"
-RUN retry apt-get update && retry apt-get -y install apt-utils && retry apt-get -y upgrade && \
- apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61
+# Add bintray.com repo key for which dirmngr is needed and enable https apt sources
+RUN retry apt-get update && \
+ retry apt-get install -y apt-utils dirmngr apt-transport-https ca-certificates && \
+ retry apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61 && \
+ retry apt-get -y upgrade
+
+# Provide build essentials
+RUN retry apt-get install -y \
+ build-essential devscripts lintian automake autoconf autoconf-archive libtool intltool \
+ doxygen graphviz texlive-binaries pandoc git libxml2-utils
-# Install Rapicorn packages
-ENV BEASTAPTSOURCE "@BEASTAPTSOURCE@"
-RUN retry apt-get -y install apt-transport-https ca-certificates && \
- echo "$BEASTAPTSOURCE" | tee /etc/apt/sources.list.d/beast-team.list && \
- retry apt-get update && retry apt-get -y install rapicorn
+# Provide clang++ if needed
+ENV INTENT "@INTENT@"
+RUN `intent clangbuild` && \
+ retry apt-get install -y clang
-# Provide build essentials and dependencies
+# Provide dependencies
RUN retry apt-get install -y \
- build-essential devscripts lintian automake autoconf autoconf-archive libtool intltool git xvfb
libxml-parser-perl \
- gawk bison flex cython doxygen graphviz texlive-binaries pandoc \
+ cython gawk libxml-parser-perl \
libpango1.0-dev python2.7-dev libxml2-dev libreadline6-dev \
libreadline-dev python-all-dev \
- libasound2-dev libflac-dev libvorbis-dev libmad0-dev libgnomecanvas2-dev libxml2-utils guile-1.8-dev
+ libasound2-dev libflac-dev libvorbis-dev libmad0-dev libgnomecanvas2-dev guile-1.8-dev
+ENV BINTRAY_REPO "@BINTRAY_REPO@"
+ENV DISTRELEASE "@DISTRELEASE@"
+# Install Rapicorn
+RUN echo "deb [trusted=yes] https://dl.bintray.com/$BINTRAY_REPO $DISTRELEASE main" | \
+ tee /etc/apt/sources.list.d/bintray-source-line.list && \
+ retry apt-get update && \
+ retry apt-get install -y rapicorn && \
+ rm /etc/apt/sources.list.d/bintray-source-line.list && \
+ retry apt-get update
-# Setup build environment by copying the git history
-COPY .git /tmp/beast.git
-RUN cd /usr/src/ && git clone /tmp/beast.git
+# Setup build environment and provide the git repository
+ENV PROJECT @PROJECT@
+ENV EMAIL beast gnome org
+COPY tmp-mirror.git /tmp/$PROJECT.git
+RUN cd /usr/src/ && \
+ git clone /tmp/$PROJECT.git
-# Build sources in /usr/src/$PROJECT/
-WORKDIR /usr/src/beast
+# Build sources in project directory
+WORKDIR /usr/src/$PROJECT
# Build sources, run tests and create distribution tarball
# Carry out distcheck test if desired
-RUN nice ./autogen.sh --prefix=/usr --enable-devel-mode=no
+RUN : && \
+ case $INTENT in \
+ clangbuild) nice ./autogen.sh --prefix=/usr CC=clang CXX=clang++ ;; \
+ *) nice ./autogen.sh --prefix=/usr ;; \
+ esac
RUN nice make -j`nproc`
RUN nice make check
RUN nice make install
@@ -53,39 +72,67 @@ RUN nice make dist
RUN nice make uninstall
# Carry out distcheck test if desired
-ENV INTENT "@INTENT@"
-RUN [ $INTENT = distcheck ] || exit 0 && \
+RUN `intent distcheck` && \
nice make distcheck
# Cleanup, show tarball
RUN nice make clean
RUN ls -l *.tar.xz
-# Build packages in /usr/src/
-WORKDIR /usr/src/
-
# Create deb packages as follows:
-# Eval configuration, prepare debian source tarball, prepare debian/ directory,
-# update 'changelog', install dependencies, build debian packages.
-ENV DISTRELEASE "@DISTRELEASE@"
-ENV TRAVIS_JOB_NUMBER "@TRAVIS_JOB_NUMBER@"
-RUN [ $INTENT = package ] || exit 0 && \
- eval `beast/buildtool.sh config` && \
- DIST_TARBALL="$PACKAGE/$PACKAGE-$UPSVERSION.tar.xz" && \
- DEB_TARBALL="$PACKAGE"_"${DEBVERSION%-*}.orig.tar.xz" && \
- cp $DIST_TARBALL $DEB_TARBALL && tar xf $DEB_TARBALL && \
- cd $PACKAGE-$UPSVERSION/ && cp -r ../$PACKAGE/debian/ . && \
- dch -v "$DEBVERSION" "$CHANGELOGMSG" && dch -r "" && cat debian/changelog && \
- retry apt-get -y install $(dpkg-checkbuilddeps 2>&1 | sed 's/.*: //') && \
+# Figure Debian version, this must have a distribution specific suffix for bintray uploads.
+# Extract distribution from tarball, prepare debian source tarball, add debian/ directory,
+# update Debian's 'changelog', install build tools, build Debian packages in /usr/src/.
+ENV DIST "@DIST@"
+ENV TRAVIS_JOB_NUMBER "@TRAVIS_JOB_NUMBER@"
+RUN `intent package` && \
+ TARBALL=`echo *.tar.xz` && \
+ TARDIR=${TARBALL%.tar*} && \
+ TARPACKAGE=${TARDIR%-*} && \
+ TARVERSION=${TARDIR#*-} && \
+ BUILDID=`misc/mkbuildid.sh -p` && \
+ DEBVERSION=$BUILDID-0${DISTRELEASE:-local}${TRAVIS_JOB_NUMBER:+~travis${TRAVIS_JOB_NUMBER#*.}} && \
+ DEB_TARBALL="$TARPACKAGE"_"${DEBVERSION%-*}.orig.tar.xz" && \
+ COMMITID=`git rev-parse HEAD` && \
+ CHANGELOGMSG="Development snapshot, git commit $COMMITID" && \
+ cp $TARBALL ../$DEB_TARBALL && \
+ cd ../ && \
+ tar xf $DEB_TARBALL && \
+ cd $TARDIR/ && \
+ cp -r ../$TARPACKAGE/debian/ . && \
+ dch -v "$DEBVERSION" "$CHANGELOGMSG" && \
+ dch -r "" && \
+ cat debian/changelog && \
+ retry apt-get install -y $(dpkg-checkbuilddeps 2>&1 | sed 's/.*: //') && \
nice debuild -j`nproc` -rfakeroot -us -uc && \
- cd .. && ls -al
+ cd .. && \
+ ls -al
-# Test package installation and removal locally
-RUN [ $INTENT = package ] || exit 0 && \
+# Test package installation from /usr/src/ and removal locally
+RUN `intent package` && \
+ cd .. && \
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz && \
echo 'deb [trusted=yes] file:///usr/src ./' > /etc/apt/sources.list.d/usrsrc.list && \
- retry apt-get update && apt-get install -y beast libbse-dev && \
- apt-get purge -y beast libbse-dev && apt-get --purge -y autoremove
+ retry apt-get update && \
+ apt-get install -y beast libbse-dev && \
+ apt-get purge -y beast libbse-dev && \
+ apt-get --purge -y autoremove && \
+ rm /etc/apt/sources.list.d/usrsrc.list && \
+ retry apt-get update
+
+# Upload packages
+COPY tmp-bintray-token .bintraytoken
+RUN `intent bintrayup` && \
+ ls -al .. && \
+ misc/bintrayup.sh .bintraytoken $DIST $BINTRAY_REPO/beast ../*.deb && \
+ rm .bintraytoken
+
+# Test installation from remote (sleep & retry allow for extra bintray.com indexing time)
+RUN `intent bintrayup` && \
+ sleep 60 && \
+ echo "deb [trusted=yes] https://dl.bintray.com/$BINTRAY_REPO $DISTRELEASE main" | \
+ tee /etc/apt/sources.list.d/bintray-source-line.list && \
+ retry /bin/sh -c 'apt-get update && apt-get install -y beast libbse-dev'
-# nice -n19 docker build -t beast .
-# docker run -ti --rm beast /bin/bash
+# docker build -t @PROJECT@ .
+# docker run -ti --rm @PROJECT@ /bin/bash
diff --git a/misc/dockerbuild.sh b/misc/dockerbuild.sh
new file mode 100755
index 0000000..eeb7a4b
--- /dev/null
+++ b/misc/dockerbuild.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -e
+
+# setup
+SCRIPTNAME="$(basename "$0")" ; die() { e="$1"; shift; echo "$SCRIPTNAME: $*" >&2; exit "$e"; }
+SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
+PROJECT=`basename "$(git rev-parse --show-toplevel)"`
+
+# parse args
+test $# -gt 0 || die 1 "Usage: dockerbuild.sh <DIST> [INTENT]"
+DIST=debian:jessie
+INTENT=distcheck
+test $# -lt 1 || { DIST="$1"; shift; }
+test $# -lt 1 || { INTENT="$1"; shift; }
+DISTRELEASE="${DIST#*:}"
+
+# determine bintray repo for packaging
+case `$SCRIPTDIR/mkbuildid.sh -p` in # similar to 'git describe'
+ *-g*) BINTRAY_REPO=beast-team/devel ;; # work in progress
+ *) BINTRAY_REPO=beast-team/deb ;; # on release tag
+esac
+
+# configure Dockerfile
+export PROJECT DIST INTENT DISTRELEASE BINTRAY_REPO TRAVIS_JOB_NUMBER
+misc/applyenv.sh misc/Dockerfile-apt.in > Dockerfile
+
+# provide a full .git clone (which might be a worktree pointer)
+rm -rf tmp-bintray-token ./tmp-mirror.git/
+git clone --mirror .git tmp-mirror.git
+
+# store BINTRAY_APITOKEN for the docker image, while this is still recorded
+# in images, it's not automatically spilled into all RUN environments
+(umask 0377 && echo "$BINTRAY_APITOKEN" >tmp-bintray-token)
+
+# forward http_proxy if set
+BUILD_ARG_HTTP_PROXY=
+test -z "$http_proxy" || BUILD_ARG_HTTP_PROXY="--build-arg=http_proxy=$http_proxy"
+
+# build project in docker container
+docker build $BUILD_ARG_HTTP_PROXY -t $PROJECT .
+echo -e "OK, EXAMINE:\n docker run -ti --rm $PROJECT /bin/bash"
+
+# cleanup
+rm -rf tmp-bintray-token ./tmp-mirror.git/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]