|
|
@ -6,16 +6,18 @@ myarch=$(dpkg --print-architecture) |
|
|
|
if test "${arch}" = "amd64"; then |
|
|
|
if test "${arch}" = "amd64"; then |
|
|
|
myarch="amd64|i386" |
|
|
|
myarch="amd64|i386" |
|
|
|
fi |
|
|
|
fi |
|
|
|
mode="apt" |
|
|
|
mode="deb" |
|
|
|
img="ubuntu:latest" |
|
|
|
img="ubuntu:latest" |
|
|
|
repos=() |
|
|
|
repos=() |
|
|
|
keys=() |
|
|
|
keys=() |
|
|
|
envs=("-e DEBIAN_FRONTEND=noninteractive" "-e DEBCONF_NONINTERACTIVE_SEEN=true") |
|
|
|
envs=("-e LANG=${LANG}" "-e HOME=/home/$(id -un)" "-e TERM=xterm" "-e DEBIAN_FRONTEND=noninteractive" "-e DEBCONF_NONINTERACTIVE_SEEN=true") |
|
|
|
dirs=("-v $(pwd):/workdir") |
|
|
|
dirs=("-v $(pwd):/workdir" "-v ${HOME}/.gnupg:/home/$(id -un)/.gnupg") |
|
|
|
packages=() |
|
|
|
packages=() |
|
|
|
targets="all check distcheck" |
|
|
|
targets="all check distcheck" |
|
|
|
commands=() |
|
|
|
commands=() |
|
|
|
arch=$(dpkg --print-architecture) |
|
|
|
arch=$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64) |
|
|
|
|
|
|
|
host= |
|
|
|
|
|
|
|
flags=() |
|
|
|
wait=0 |
|
|
|
wait=0 |
|
|
|
if test -e ./build-in-docker.conf; then |
|
|
|
if test -e ./build-in-docker.conf; then |
|
|
|
# you can preconfigure the variables in file build-in-docker.conf |
|
|
|
# you can preconfigure the variables in file build-in-docker.conf |
|
|
@ -30,10 +32,12 @@ while test $# -gt 0; do |
|
|
|
echo "OPTIONS:" |
|
|
|
echo "OPTIONS:" |
|
|
|
echo |
|
|
|
echo |
|
|
|
echo " -h, --help show this help" |
|
|
|
echo " -h, --help show this help" |
|
|
|
echo " -m, --mode <type> mode: apt or yum, default: ${mode}" |
|
|
|
echo " -m, --mode <type> mode: deb, rpm, win, default: ${mode}" |
|
|
|
echo " -i, --image <image> use given docker image instead of ${img}" |
|
|
|
echo " -i, --image <image> use given docker image instead of ${img}" |
|
|
|
echo " -a, --arch <arch> build for given hardware architecture" |
|
|
|
echo " -a, --arch <arch> build for given hardware architecture" |
|
|
|
echo " -t, --targets targets specify build targets, default: ${targets}" |
|
|
|
echo " -t, --targets targets specify build targets, default: ${targets}" |
|
|
|
|
|
|
|
echo " --host <target-arch> host for cross compiling, e.g. i686-w64-mingw32" |
|
|
|
|
|
|
|
echo " -f, --flag <flag> add flag to ./bootstrap.sh or ./configure" |
|
|
|
echo " -r, --repo <url> add given apt repository" |
|
|
|
echo " -r, --repo <url> add given apt repository" |
|
|
|
echo " -k, --key <url> add public key from url" |
|
|
|
echo " -k, --key <url> add public key from url" |
|
|
|
echo " -e, --env <var>=<val> set environment variable in docker" |
|
|
|
echo " -e, --env <var>=<val> set environment variable in docker" |
|
|
@ -43,6 +47,10 @@ while test $# -gt 0; do |
|
|
|
echo " -w, --wait on error keep docker container and wait for enter" |
|
|
|
echo " -w, --wait on error keep docker container and wait for enter" |
|
|
|
echo |
|
|
|
echo |
|
|
|
echo " The option -i must be after -m, because mode sets a new default image" |
|
|
|
echo " The option -i must be after -m, because mode sets a new default image" |
|
|
|
|
|
|
|
echo " The option -m must be after -t, because mode may be auto detected from targets" |
|
|
|
|
|
|
|
echo " The option -m must be after -h, because mode may set a host" |
|
|
|
|
|
|
|
echo " If target is either deb or rpm, mode is set to the same value" |
|
|
|
|
|
|
|
echo " If target is win, host is set to i686-w64-mingw32" |
|
|
|
echo |
|
|
|
echo |
|
|
|
echo " The options -r -k -e -d -p -c can be repeated several times." |
|
|
|
echo " The options -r -k -e -d -p -c can be repeated several times." |
|
|
|
echo |
|
|
|
echo |
|
|
@ -73,8 +81,11 @@ while test $# -gt 0; do |
|
|
|
(-m|--mode) shift; |
|
|
|
(-m|--mode) shift; |
|
|
|
mode="$1" |
|
|
|
mode="$1" |
|
|
|
case "$mode" in |
|
|
|
case "$mode" in |
|
|
|
(apt) img="ubuntu:latest";; |
|
|
|
(deb|apt) img="ubuntu:latest";; |
|
|
|
|
|
|
|
(rpm|zypper) img="opensuse:latest";; |
|
|
|
(yum) img="centos:latest";; |
|
|
|
(yum) img="centos:latest";; |
|
|
|
|
|
|
|
(dnf) img="fedora:latest";; |
|
|
|
|
|
|
|
(win) img="ubuntu:latest"; host="${host:---host=i686-w64-mingw32}";; |
|
|
|
(*) |
|
|
|
(*) |
|
|
|
echo "**** ERROR: unknown mode '$1', try --help" 1>&2 |
|
|
|
echo "**** ERROR: unknown mode '$1', try --help" 1>&2 |
|
|
|
exit 1 |
|
|
|
exit 1 |
|
|
@ -89,6 +100,17 @@ while test $# -gt 0; do |
|
|
|
;; |
|
|
|
;; |
|
|
|
(-t|--targets) shift; |
|
|
|
(-t|--targets) shift; |
|
|
|
targets="$1" |
|
|
|
targets="$1" |
|
|
|
|
|
|
|
if test "$1" = "deb" -o "$1" = "rpm"; then |
|
|
|
|
|
|
|
# set mode to same value |
|
|
|
|
|
|
|
set -- "-m" $@ |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
(--host) shift; |
|
|
|
|
|
|
|
host="--host=$1" |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
(-f|--flag) shift; |
|
|
|
|
|
|
|
flags+=("$1") |
|
|
|
;; |
|
|
|
;; |
|
|
|
(-r|--repo) shift; |
|
|
|
(-r|--repo) shift; |
|
|
|
repos+=("$1") |
|
|
|
repos+=("$1") |
|
|
@ -149,7 +171,8 @@ function traperror() { |
|
|
|
read |
|
|
|
read |
|
|
|
fi |
|
|
|
fi |
|
|
|
echo -n " ... cleanup docker: " |
|
|
|
echo -n " ... cleanup docker: " |
|
|
|
docker rm -f "${DOCKER_ID}" |
|
|
|
docker stop "${DOCKER_ID}" || true |
|
|
|
|
|
|
|
docker rm "${DOCKER_ID}" |
|
|
|
echo "returning status: $e" |
|
|
|
echo "returning status: $e" |
|
|
|
echo "--->" |
|
|
|
echo "--->" |
|
|
|
exit $e |
|
|
|
exit $e |
|
|
@ -176,14 +199,14 @@ function ifthenelse() { |
|
|
|
os="${arg%%:::*}" |
|
|
|
os="${arg%%:::*}" |
|
|
|
thenpart="${arg#*:::}" |
|
|
|
thenpart="${arg#*:::}" |
|
|
|
if test "${thenpart/:::/}" = "${thenpart}"; then |
|
|
|
if test "${thenpart/:::/}" = "${thenpart}"; then |
|
|
|
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$(dpkg --print-architecture)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; fi' |
|
|
|
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; fi' |
|
|
|
else |
|
|
|
else |
|
|
|
elsepart="${thenpart##*:::}" |
|
|
|
elsepart="${thenpart##*:::}" |
|
|
|
thenpart="${thenpart%:::*}" |
|
|
|
thenpart="${thenpart%:::*}" |
|
|
|
if test -n "${thenpart}"; then |
|
|
|
if test -n "${thenpart}"; then |
|
|
|
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$(dpkg --print-architecture)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; else '"${cmd//ARG/${elsepart}}"'; fi' |
|
|
|
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; else '"${cmd//ARG/${elsepart}}"'; fi' |
|
|
|
else |
|
|
|
else |
|
|
|
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$(dpkg --print-architecture)" =~ ${os} ]]; then true; else '"${cmd//ARG/${elsepart}}"'; fi' |
|
|
|
docker exec ${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)-$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64)" =~ ${os} ]]; then true; else '"${cmd//ARG/${elsepart}}"'; fi' |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
@ -192,15 +215,24 @@ function ifthenelse() { |
|
|
|
set -x |
|
|
|
set -x |
|
|
|
|
|
|
|
|
|
|
|
docker pull $img |
|
|
|
docker pull $img |
|
|
|
DOCKER_ID=$(docker create ${dirs[@]} ${envs[@]} -e HOME="${HOME}" -w /workdir $img sleep infinity) |
|
|
|
DOCKER_ID=$(docker create ${dirs[@]} ${envs[@]} -w /workdir $img sleep infinity) |
|
|
|
trap 'traperror '"${DOCKER_ID}"' "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' SIGINT INT TERM EXIT |
|
|
|
trap 'traperror '"${DOCKER_ID}"' "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' SIGINT INT TERM EXIT |
|
|
|
if ! [[ $arch =~ $myarch ]]; then |
|
|
|
if ! [[ $arch =~ $myarch ]]; then |
|
|
|
docker cp "/usr/bin/qemu-${arch}-static" "${DOCKER_ID}:/usr/bin/qemu-${arch}-static" |
|
|
|
docker cp "/usr/bin/qemu-${arch}-static" "${DOCKER_ID}:/usr/bin/qemu-${arch}-static" |
|
|
|
fi |
|
|
|
fi |
|
|
|
docker start "${DOCKER_ID}" |
|
|
|
docker start "${DOCKER_ID}" |
|
|
|
docker exec ${DOCKER_ID} useradd -u$(id -u) -m -d"${HOME}" $(id -un) |
|
|
|
if ! docker exec ${DOCKER_ID} getent group $(id -g) > /dev/null 2>&1; then |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} groupadd -g $(id -g) $(id -gn) |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
if ! docker exec ${DOCKER_ID} getent passwd $(id -u) > /dev/null 2>&1; then |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} useradd -m -u $(id -u) -g $(id -g) -d"${HOME}" $(id -un) |
|
|
|
|
|
|
|
fi |
|
|
|
case $mode in |
|
|
|
case $mode in |
|
|
|
(apt) |
|
|
|
(deb|apt) |
|
|
|
|
|
|
|
if [[ "${img}" =~ "ubuntu" ]]; then |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} locale-gen ${LANG} |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} update-locale LANG=${LANG} |
|
|
|
|
|
|
|
fi |
|
|
|
OPTIONS='-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew -y --force-yes --no-install-suggests --no-install-recommends' |
|
|
|
OPTIONS='-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confnew -y --force-yes --no-install-suggests --no-install-recommends' |
|
|
|
for f in 'libpam-systemd:amd64' 'policykit*' 'colord'; do |
|
|
|
for f in 'libpam-systemd:amd64' 'policykit*' 'colord'; do |
|
|
|
docker exec ${DOCKER_ID} bash -c "echo 'Package: $f' >> /etc/apt/preferences" |
|
|
|
docker exec ${DOCKER_ID} bash -c "echo 'Package: $f' >> /etc/apt/preferences" |
|
|
@ -228,8 +260,7 @@ case $mode in |
|
|
|
done |
|
|
|
done |
|
|
|
docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh |
|
|
|
docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh |
|
|
|
;; |
|
|
|
;; |
|
|
|
(yum) |
|
|
|
(rpm|yum|dnf|zypper|urpmi) |
|
|
|
./bootstrap.sh -t dist |
|
|
|
|
|
|
|
if [[ "$img" =~ "centos" ]]; then |
|
|
|
if [[ "$img" =~ "centos" ]]; then |
|
|
|
docker exec ${DOCKER_ID} yum install -y redhat-lsb |
|
|
|
docker exec ${DOCKER_ID} yum install -y redhat-lsb |
|
|
|
docker exec -i ${DOCKER_ID} bash -c 'cat > /etc/yum.repos.d/wandisco-svn.repo' <<EOF |
|
|
|
docker exec -i ${DOCKER_ID} bash -c 'cat > /etc/yum.repos.d/wandisco-svn.repo' <<EOF |
|
|
@ -242,10 +273,29 @@ enabled=1 |
|
|
|
gpgcheck=0 |
|
|
|
gpgcheck=0 |
|
|
|
EOF |
|
|
|
EOF |
|
|
|
fi |
|
|
|
fi |
|
|
|
docker exec ${DOCKER_ID} yum install -y rpm-build |
|
|
|
INSTALL_TOOL=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper install -y) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf install -y) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo yum install -y) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo urpmi --auto)) |
|
|
|
docker exec ${DOCKER_ID} groupadd -g $(id -g) build |
|
|
|
docker exec ${DOCKER_ID} ${INSTALL_TOOL} rpm-build automake libtool subversion gcc-c++ pkgconfig wget /usr/bin/lsb_release |
|
|
|
docker exec ${DOCKER_ID} useradd -g $(id -g) -u $(id -u) build |
|
|
|
i=0 |
|
|
|
docker exec ${DOCKER_ID} ./resolve-rpmbuilddeps.sh || true |
|
|
|
for key in "${keys[@]}"; do |
|
|
|
|
|
|
|
wget -Orpm-key "$key" |
|
|
|
|
|
|
|
docker exec -i ${DOCKER_ID} rpm --import rpm-key |
|
|
|
|
|
|
|
rm rpm-key |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
for repo in "${repos[@]}"; do |
|
|
|
|
|
|
|
INSTALL_REPO=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper ar) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf config-manager --add-repo) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo wget -O/etc/yum.repos.d/additional$i.repo) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo true)) |
|
|
|
|
|
|
|
ifthenelse "${repo}" "${INSTALL_REPO} ARG" |
|
|
|
|
|
|
|
((++i)) |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} ./resolve-rpmbuilddeps.sh |
|
|
|
|
|
|
|
;; |
|
|
|
|
|
|
|
(win) |
|
|
|
|
|
|
|
if [[ "${img}" =~ "ubuntu" ]]; then |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} locale-gen ${LANG} |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} update-locale LANG=${LANG} |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} apt-get update ${OPTIONS} |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} apt-get install -y mingw-w64 |
|
|
|
|
|
|
|
docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh |
|
|
|
;; |
|
|
|
;; |
|
|
|
esac |
|
|
|
esac |
|
|
|
docker exec -u $(id -u):$(id -g) ${DOCKER_ID} ./bootstrap.sh -t "${targets}" |
|
|
|
docker exec -u $(id -u):$(id -g) ${DOCKER_ID} ./bootstrap.sh -t "${targets}" ${host} ${flags[@]} |
|
|
|