enhanced build in docker
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
packages+=" npm"
|
packages+=("wheezy:::curl:::npm")
|
||||||
repos+="universe"
|
packages+=("nodejs")
|
||||||
commands+=("npm install -g node" "npm install -g cordova")
|
repos+=("Ubuntu:::universe")
|
||||||
|
repos+=("wheezy:::'deb http://ftp.is.debian.org/debian wheezy-backports main'")
|
||||||
|
commands+=("wheezy:::update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100")
|
||||||
|
commands+=("wheezy:::curl https://www.npmjs.com/install.sh | sh")
|
||||||
|
commands+=("npm install -g cordova")
|
||||||
if test -n "${ANDROID_HOME}"; then
|
if test -n "${ANDROID_HOME}"; then
|
||||||
envs+=" -e ANDROID_HOME=${ANDROID_HOME}"
|
envs+=("-e ANDROID_HOME=${ANDROID_HOME}")
|
||||||
dirs+=" -v ${ANDROID_HOME}:${ANDROID_HOME}:ro"
|
dirs+=("-v ${ANDROID_HOME}:${ANDROID_HOME}:ro")
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -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
|
|
||||||
if test -n "${repos}"; then
|
|
||||||
for repo in ${repos}; do
|
|
||||||
docker exec ${DOCKER_ID} apt-add-repository ${repo}
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if test -n "${keys}"; then
|
|
||||||
for key in ${keys}; do
|
|
||||||
wget -O- ${key} \
|
|
||||||
| docker exec -i ${DOCKER_ID} apt-key add -
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
docker exec ${DOCKER_ID} apt-get update
|
docker exec ${DOCKER_ID} apt-get update
|
||||||
if test -n "${packages}"; then
|
docker exec ${DOCKER_ID} apt-get upgrade -y --force-yes
|
||||||
docker exec -i ${DOCKER_ID} apt-get install -y ${packages}
|
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-get install -y --force-yes software-properties-common apt-transport-https dpkg-dev lsb-release
|
||||||
fi
|
fi
|
||||||
|
for repo in "${repos[@]}"; do
|
||||||
|
ifthenelse "${repo}" "apt-add-repository ARG"
|
||||||
|
done
|
||||||
|
for key in "${keys[@]}"; do
|
||||||
|
wget -O- \
|
||||||
|
| docker exec -i ${DOCKER_ID} apt-key add -
|
||||||
|
done
|
||||||
|
docker exec ${DOCKER_ID} apt-get update
|
||||||
|
for package in "${packages[@]}"; do
|
||||||
|
ifthenelse "${package}" "apt-get install -y --force-yes ARG"
|
||||||
|
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
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ if test -n "${SCHROOTNAME}"; then
|
|||||||
SUDO="schroot -c "${SCHROOTNAME}" -u root -d / --"
|
SUDO="schroot -c "${SCHROOTNAME}" -u root -d / --"
|
||||||
else
|
else
|
||||||
DO=""
|
DO=""
|
||||||
SUDO="sudo"
|
if grep -q '/docker/' /proc/1/cgroup; then
|
||||||
|
SUDO=""
|
||||||
|
else
|
||||||
|
SUDO="sudo"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function install() {
|
function install() {
|
||||||
|
|||||||
Reference in New Issue
Block a user