|
|
|
@ -10,18 +10,21 @@ mode="deb" |
|
|
|
|
img="ubuntu:latest" |
|
|
|
|
repos=() |
|
|
|
|
keys=() |
|
|
|
|
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" "-v ${HOME}/.gnupg:/home/$(id -un)/.gnupg") |
|
|
|
|
envs=("-e LANG=${LANG}" "-e HOME=${HOME}" "-e TERM=xterm" "-e DEBIAN_FRONTEND=noninteractive" "-e DEBCONF_NONINTERACTIVE_SEEN=true") |
|
|
|
|
dirs=("-v $(pwd):/workdir" "-v ${HOME}/.gnupg:${HOME}/.gnupg") |
|
|
|
|
packages=() |
|
|
|
|
targets="all check distcheck" |
|
|
|
|
commands=() |
|
|
|
|
arch=$((which dpkg > /dev/null 2> /dev/null && dpkg --print-architecture) || echo amd64) |
|
|
|
|
host= |
|
|
|
|
flags=() |
|
|
|
|
wait=0 |
|
|
|
|
if test -e ./build-in-docker.conf; then |
|
|
|
|
# you can preconfigure the variables in file build-in-docker.conf |
|
|
|
|
# if you do so, add the file to EXTRA_DIST in makefile.am |
|
|
|
|
source ./build-in-docker.conf |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
while test $# -gt 0; do |
|
|
|
|
case "$1" in |
|
|
|
|
(-h|--help) |
|
|
|
@ -30,10 +33,12 @@ while test $# -gt 0; do |
|
|
|
|
echo "OPTIONS:" |
|
|
|
|
echo |
|
|
|
|
echo " -h, --help show this help" |
|
|
|
|
echo " -m, --mode <type> mode: deb, rpm, default: ${mode}" |
|
|
|
|
echo " -m, --mode <type> mode: deb, rpm, win, default: ${mode}" |
|
|
|
|
echo " -i, --image <image> use given docker image instead of ${img}" |
|
|
|
|
echo " -a, --arch <arch> build for given hardware architecture" |
|
|
|
|
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 " -k, --key <url> add public key from url" |
|
|
|
|
echo " -e, --env <var>=<val> set environment variable in docker" |
|
|
|
@ -44,7 +49,9 @@ while test $# -gt 0; do |
|
|
|
|
echo |
|
|
|
|
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 " The options -r -k -e -d -p -c can be repeated several times." |
|
|
|
|
echo |
|
|
|
@ -79,6 +86,7 @@ while test $# -gt 0; do |
|
|
|
|
(rpm|zypper) img="opensuse: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 |
|
|
|
|
exit 1 |
|
|
|
@ -91,15 +99,22 @@ while test $# -gt 0; do |
|
|
|
|
(-a|--arch) shift; |
|
|
|
|
arch="$1" |
|
|
|
|
;; |
|
|
|
|
(-t|--targets) shift |
|
|
|
|
(-t|--targets) shift; |
|
|
|
|
targets="$1" |
|
|
|
|
if test "$1" = "deb" -o "$1" = "rpm"; then |
|
|
|
|
# set mode to same value |
|
|
|
|
set -- "-m" $@ |
|
|
|
|
set -- "-m" "$@" |
|
|
|
|
continue |
|
|
|
|
fi |
|
|
|
|
;; |
|
|
|
|
(--host) shift; |
|
|
|
|
host="--host=$1" |
|
|
|
|
;; |
|
|
|
|
(-f|--flag) shift; |
|
|
|
|
flags+=("$1") |
|
|
|
|
;; |
|
|
|
|
(-r|--repo) shift; |
|
|
|
|
echo "OPTION: $1" |
|
|
|
|
repos+=("$1") |
|
|
|
|
;; |
|
|
|
|
(-k|--key) shift; |
|
|
|
@ -214,6 +229,7 @@ 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 |
|
|
|
|
docker exec ${DOCKER_ID} chown $(id -u):$(id -g) "${HOME}" |
|
|
|
|
case $mode in |
|
|
|
|
(deb|apt) |
|
|
|
|
if [[ "${img}" =~ "ubuntu" ]]; then |
|
|
|
@ -232,7 +248,7 @@ case $mode in |
|
|
|
|
docker exec ${DOCKER_ID} apt-get install ${OPTIONS} software-properties-common apt-transport-https dpkg-dev lsb-release || \ |
|
|
|
|
docker exec ${DOCKER_ID} apt-get install ${OPTIONS} python-software-properties apt-transport-https dpkg-dev lsb-release; |
|
|
|
|
for repo in "${repos[@]}"; do |
|
|
|
|
ifthenelse "${repo}" "apt-add-repository ARG" |
|
|
|
|
ifthenelse "${repo}" "apt-add-repository 'ARG'" |
|
|
|
|
done |
|
|
|
|
for key in "${keys[@]}"; do |
|
|
|
|
wget -O- "$key" \ |
|
|
|
@ -270,10 +286,19 @@ EOF |
|
|
|
|
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" |
|
|
|
|
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 |
|
|
|
|
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[@]} |
|
|
|
|