@ -2,11 +2,11 @@
# build and test everything in a fresh docker installation
# build and test everything in a fresh docker installation
img = "ubuntu:latest"
img = "ubuntu:latest"
repos = ""
repos = ( )
keys = ""
keys = ( )
envs = ""
envs = ( )
dirs = "-v $( pwd ) :/workdir "
dirs = ( "-v $( pwd ) :/workdir " )
packages = ""
packages = ( )
targets = "all check distcheck"
targets = "all check distcheck"
commands = ( )
commands = ( )
if test -e ./build-in-docker.conf; then
if test -e ./build-in-docker.conf; then
@ -20,6 +20,7 @@ while test $# -gt 0; do
echo " $0 [OPTIONS] "
echo " $0 [OPTIONS] "
echo
echo
echo "OPTIONS:"
echo "OPTIONS:"
echo
echo " -h, --help show this help"
echo " -h, --help show this help"
echo " -i, --image <image> use given docker image instead of ${ img } "
echo " -i, --image <image> use given docker image instead of ${ img } "
echo " -t, --targets targets specify build targets, default: ${ targets } "
echo " -t, --targets targets specify build targets, default: ${ targets } "
@ -28,7 +29,20 @@ while test $# -gt 0; do
echo " -e, --env <var>=<val> set environment variable in docker"
echo " -e, --env <var>=<val> set environment variable in docker"
echo " -d, --dir <dir> access given directory read only"
echo " -d, --dir <dir> access given directory read only"
echo " -p, --package <pkg> install extra debian packages"
echo " -p, --package <pkg> install extra debian packages"
echo " -x, --exe <command> execute commands as root in docker"
echo " -c, --cmd <command> execute commands as root in docker"
echo
echo " The options -r -k -e -d -p -c can be repeated several times."
echo
echo " The options -r -p -c allow an if-then-else contruct"
echo " depending on the operating system:"
echo " <os>:::<A>:::<B>"
echo " <os>:::<A>"
echo " Read as: On linux type <os> use <A> else use <B>"
echo " That means: If the distributer ID or codename in lsb_release"
echo " matches <os>, then <A> is replaced, else <B> is replaced."
echo " The three colons are for splitting <os> from <A> and <B> part."
echo " E.g.: Install package curl on wheezy and npm on olter systems:"
echo " $0 -p wheezy:::curl:::npm "
echo
echo
echo "EXAMPLE:"
echo "EXAMPLE:"
echo
echo
@ -50,21 +64,21 @@ while test $# -gt 0; do
targets = " $1 "
targets = " $1 "
; ;
; ;
( -r| --repo) shift;
( -r| --repo) shift;
repos += " $1 "
repos += ( " $1 " )
; ;
; ;
( -k| --key) shift;
( -k| --key) shift;
keys += " $1 "
keys += ( " $1 " )
; ;
; ;
( -e| --env) shift;
( -e| --env) shift;
envs += " -e $1 "
envs += ( "-e $1 " )
; ;
; ;
( -d| --dirs) shift;
( -d| --dirs) shift;
dirs += " -v $1 : $1 :ro "
dirs += ( "-v $1 : $1 :ro " )
; ;
; ;
( -p| --package) shift;
( -p| --package) shift;
packages += " $1 "
packages += ( " $1 " )
; ;
; ;
( -x| --exe ) shift;
( -c| --cmd ) shift;
commands += ( " $1 " )
commands += ( " $1 " )
; ;
; ;
( *)
( *)
@ -79,28 +93,47 @@ while test $# -gt 0; do
shift
shift
done
done
function ifthenelse( ) {
arg = " $1 "
shift
cmd = " $* "
if test " ${ arg / : : : / } " = " ${ arg } " ; then
docker exec ${ DOCKER_ID } bash -c " ${ cmd //ARG/ ${ arg } } "
else
os = " ${ arg %% : : : * } "
thenpart = " ${ arg #* : : : } "
if test " ${ thenpart / : : : / } " = " ${ thenpart } " ; then
docker exec ${ DOCKER_ID } bash -c 'os="' $os '"; if test "${os//$(lsb_release -is)/}${os//$(lsb_release -cs)/}" != "${os}${os}"; then ' " ${ cmd //ARG/ ${ thenpart } } " '; fi'
else
elsepart = " ${ thenpart ##* : : : } "
thenpart = " ${ thenpart % : : : * } "
docker exec ${ DOCKER_ID } bash -c 'os="' $os '"; if test "${os//$(lsb_release -is)/}${os//$(lsb_release -cs)/}" != "${os}${os}"; then ' " ${ cmd //ARG/ ${ thenpart } } " '; else ' " ${ cmd //ARG/ ${ elsepart } } " '; fi'
fi
fi
}
set -x
set -x
DOCKER_ID = $( docker run -d ${ dirs } ${ envs } -w /workdir $img sleep infinity)
DOCKER_ID = $( docker run -d ${ dirs [@] } ${ envs [@] } -w /workdir $img sleep infinity)
trap " docker rm -f ${ DOCKER_ID } " INT TERM EXIT
trap " docker rm -f ${ DOCKER_ID } " INT TERM EXIT
docker exec ${ DOCKER_ID } apt-get install -y software-properties-common apt-transport-https dpkg-dev
docker exec ${ DOCKER_ID } apt-get update
if test -n " ${ repos } " ; then
docker exec ${ DOCKER_ID } apt-get upgrade -y --force-yes
for repo in ${ repos } ; do
if ! docker exec ${ DOCKER_ID } apt-get install -y --force-yes python-software-properties apt-transport-https dpkg-dev lsb-release; then
docker exec ${ DOCKER_ID } apt-add-repository ${ repo }
docker exec ${ DOCKER_ID } apt-get install -y --force-yes software-properties-common apt-transport-https dpkg-dev lsb-release
done
fi
fi
if test -n " ${ keys } " ; then
for repo in " ${ repos [@] } " ; do
for key in ${ keys } ; do
ifthenelse " ${ repo } " "apt-add-repository ARG"
wget -O- ${ key } \
done
for key in " ${ keys [@] } " ; do
wget -O- \
| docker exec -i ${ DOCKER_ID } apt-key add -
| docker exec -i ${ DOCKER_ID } apt-key add -
done
done
fi
docker exec ${ DOCKER_ID } apt-get update
docker exec ${ DOCKER_ID } apt-get update
if test -n " ${ packages } " ; then
for package i n " ${ packages [@] } " ; do
docker exec -i ${ DOCKER_ID } apt-get install -y ${ packages }
ifthenelse " ${ package } " "apt-get install -y --force-yes ARG"
fi
done
for command in " ${ commands [@] } " ; do
for command in " ${ commands [@] } " ; do
docker exec -i ${ DOCKER_ID } ${ command }
ifthenelse " ${ command } " "ARG"
done
done
docker exec ${ DOCKER_ID } ./resolve-debbuilddeps.sh
docker exec ${ DOCKER_ID } ./resolve-debbuilddeps.sh
docker exec -u $( id -u) ${ DOCKER_ID } svn upgrade || true
docker exec -u $( id -u) ${ DOCKER_ID } svn upgrade || true