better build in docker

master
Marc Wäckerlin 9 years ago
parent a9b552d182
commit 7e6e11e5ac
  1. 328
      ChangeLog
  2. 15
      ax_init_standard_project.m4
  3. 7
      bootstrap.sh
  4. 179
      build-in-docker.sh
  5. 6
      resolve-debbuilddeps.sh
  6. 2
      scripts/build-in-docker.sh
  7. 2
      scripts/resolve-debbuilddeps.sh

@ -1,328 +0,0 @@
2015-11-11 12:45 marc
* ChangeLog, README, bootstrap.sh, resolve-debbuilddeps.sh,
scripts/bootstrap.sh, scripts/test, scripts/test/runtests.sh,
sql-to-dot.sed: updated
2015-11-10 15:52 marc
* scripts/sql-to-dot.sed: making it more robust
2015-11-09 15:13 marc
* scripts/bootstrap.sh, scripts/resolve-debbuilddeps.sh,
scripts/sql-to-dot.sed: better documentation
2015-11-07 10:47 marc
* bootstrap.sh, scripts/bootstrap.sh: there is no qt4-default
2015-11-07 09:23 marc
* bootstrap.sh, scripts/bootstrap.sh: there is no qt4-default
2015-11-07 00:20 marc
* README: set Section
2015-11-07 00:11 marc
* ChangeLog, ax_init_standard_project.m4, bootstrap.sh,
scripts/ax_init_standard_project.m4, scripts/bootstrap.sh: fixed
debian readme issue
2015-11-06 15:34 marc
* scripts/sql-to-dot.sed: new script to convert sql schema files
into graphviz dot
2015-11-05 15:59 marc
* README, scripts/ax_init_standard_project.m4,
scripts/bootstrap.sh: some more improvements plus creation of
trunk branches and tags
2015-11-05 09:47 marc
* ChangeLog, ax_init_standard_project.m4, bootstrap.sh,
build-in-docker.sh, resolve-debbuilddeps.sh: updated build system
2015-11-04 10:36 marc
* scripts/bootstrap.sh, scripts/build-in-docker.sh,
scripts/makefile.am, scripts/resolve-debbuilddeps.sh: new feature
./build-in-docker.sh to start a temporary ubuntu docker container
where the project is built and tested in$
2015-11-04 08:52 marc
* README, bootstrap.sh, scripts/ax_init_standard_project.m4,
scripts/bootstrap.sh: the new tag AX_BUILD_TEST allows to use
tests without the need of AX_USE_CPPUNIT, so only AX_BUILD_TEST
can be used for testing scripts. AX_USE_CPPUNIT calls
AX_BUILD_TEST, so you don't need to specify both
2015-11-03 23:01 marc
* debian/control.in: set section
2015-11-03 22:02 marc
* AUTHORS: AUTHOR updated to new homepage
2015-11-03 15:38 marc
* AUTHORS, COPYING, ChangeLog, INSTALL, NEWS, README, aclocal.m4,
ax_check_qt.m4, ax_cxx_compile_stdcxx_11.m4,
ax_init_standard_project.m4, bootstrap-build-environment.spec.in,
bootstrap.sh, build-resource-file.sh, configure.ac, debian,
debian/changelog.in, debian/compat, debian/control.in,
debian/docs, debian/rules, doc, doc/doxyfile.in, doc/makefile.am,
mac-create-app-bundle.sh, makefile.am, resolve-debbuilddeps.sh,
resolve-rpmbuilddeps.sh, scripts, scripts/ax_check_qt.m4,
scripts/ax_cxx_compile_stdcxx_11.m4,
scripts/ax_init_standard_project.m4, scripts/bootstrap.sh,
scripts/build-resource-file.sh, scripts/mac-create-app-bundle.sh,
scripts/makefile.am, scripts/resolve-debbuilddeps.sh,
scripts/resolve-rpmbuilddeps.sh: initial release for packaging
2015-11-03 15:06 marc
* ax_init_standard_project.m4, resolve-debbuilddeps.sh: can be
built in fresh docker container
2015-11-03 15:05 marc
* bootstrap.sh, resolve-debbuilddeps.sh: some improvements
2015-11-03 09:22 marc
* resolve-debbuilddeps.sh: except for variants, install al at once
(it's faster); sudo or not is the problem of the caller; also
cleanup debian/control if created (importan, otherwise with sudo,
it belongs to root)
2015-11-03 09:22 marc
* ax_check_qt.m4, bootstrap.sh, resolve-debbuilddeps.sh: except for
variants, install al at once (it's faster); sudo or not is the
problem of the caller; also cleanup debian/control if created
(importan, otherwise with sudo, it belongs to root)
2015-10-10 18:05 marc
* ax_init_standard_project.m4, bootstrap.sh: no search index when
embedded in redmine
2015-10-10 10:44 marc
* ax_init_standard_project.m4, bootstrap.sh: updated extra dists
2015-10-07 07:42 marc
* ax_init_standard_project.m4: disable qt debug
2015-09-23 08:11 marc
* ax_check_qt.m4, ax_init_standard_project.m4,
resolve-rpmbuilddeps.sh: sereveral improvements, also now
possibility to use fixed version minor ba adding a diff for least
2015-09-09 15:01 marc
* ax_check_qt.m4, bootstrap.sh, build-resource-file.sh,
resolve-debbuilddeps.sh, resolve-rpmbuilddeps.sh: new features
and fixes
2015-09-04 13:05 marc
* resolve-builddeps.sh~: resolve build dependencies
2015-09-04 13:04 marc
* ax_init_standard_project.m4, bootstrap.sh, resolve-builddeps.sh~,
resolve-debbuilddeps.sh: resolve build dependencies
2015-08-31 12:30 marc
* bootstrap.sh: fixed share path in debian packages
2015-08-27 13:03 marc
* ax_check_qt.m4, ax_init_standard_project.m4, bootstrap.sh: fixes
from several projects
2015-08-20 08:00 marc
* ax_init_standard_project.m4, bootstrap.sh: improvements mainly
for rpm plus including make with flexible targets
2015-08-19 22:44 marc
* ax_init_standard_project.m4, bootstrap.sh: some small fixes for
prinary initialization - to do: create root makefile.am after
configure.ac is setup
2015-07-31 10:44 marc
* ax_init_standard_project.m4, bootstrap.sh: fixed version number
and rpm issues
2015-07-30 14:13 marc
* ax_check_qt.m4, ax_init_standard_project.m4, bootstrap.sh: lot of
improvements, i.e. for compiling rpms
2015-07-23 12:16 marc
* ax_check_qt.m4, ax_init_standard_project.m4: use ${PKG_CONFOG}
2015-07-23 12:02 marc
* ax_init_standard_project.m4, bootstrap.sh: typo in filename
2015-07-22 05:29 marc
* bootstrap.sh: added rpm spec file template
2015-07-21 13:44 marc
* ax_check_qt.m4, ax_init_standard_project.m4: improvements, mainly
for mingw
2015-07-16 13:54 marc
* ax_check_qt.m4, ax_init_standard_project.m4, bootstrap.sh,
mac-create-app-bundle.sh: improvements, mainly for mac
2015-07-13 14:57 marc
* ax_init_standard_project.m4: improve package detection
2015-07-13 12:18 marc
* bootstrap.sh: some bugfixes
2015-07-13 08:58 marc
* bootstrap.sh: some bugfixes
2015-07-09 12:22 marc
* ax_check_qt.m4, ax_init_standard_project.m4, bootstrap.sh: some
qt improvements
2015-07-02 13:11 marc
* ax_check_qt.m4, ax_init_standard_project.m4, bootstrap.sh: new qt
features: language and resources
2015-07-01 09:13 marc
* AUTHORS, ax_init_standard_project.m4, bootstrap.sh: updates, e.g.
AUTHORS
2015-06-24 09:26 marc
* ax_init_standard_project.m4: even more support for weird and
sloppy packages
2015-06-23 08:59 marc
* ax_init_standard_project.m4: even more improved way to find the
necessary include path
2015-06-23 08:48 marc
* ax_init_standard_project.m4: even more improved way to find the
necessary include path
2015-06-23 08:24 marc
* ax_init_standard_project.m4: improved way to find the necessary
include path, even if module writers did a sloppy job
2015-05-18 09:21 marc
* ax_init_standard_project.m4: fix build on mac, fix wrong
AX_PKG_CHECK
2015-05-18 09:10 marc
* ax_init_standard_project.m4: bugfix in AX_PKG_REQUIRE
2015-05-18 09:03 marc
* ax_init_standard_project.m4: bugfix in AX_PKG_REQUIRE
2015-05-13 13:36 marc
* ax_init_standard_project.m4: improved check for required packages
2015-05-12 13:33 marc
* ax_check_qt.m4, ax_init_standard_project.m4: allow package
versions in package config dependencies
2015-05-09 09:06 marc
* ax_check_qt.m4, ax_init_standard_project.m4, bootstrap.sh: fixed
dependencies in pkg-config
2015-05-08 23:37 marc
* ax_init_standard_project.m4, bootstrap.sh: fixed the mac bug
again, because last change was incompatible with debian changelog
format
2015-05-08 22:43 marc
* ax_init_standard_project.m4, bootstrap.sh: build system fixed
2015-05-07 14:35 marc
* ax_init_standard_project.m4: fixed mac issues
2015-05-07 14:11 marc
* ax_init_standard_project.m4: Mac OSX does not support date -R
2015-05-07 14:08 marc
* ax_init_standard_project.m4: Mac OSX does not support date -R
2015-05-07 14:06 marc
* ax_init_standard_project.m4: error finding pkcs11 on Mac
2015-05-07 14:04 marc
* ax_init_standard_project.m4: error finding pkcs11 on Mac
2015-05-07 13:07 marc
* bootstrap.sh: Mac OSX does not support date -R
2015-05-07 13:04 marc
* ax_init_standard_project.m4: Mac OSX does not support date -R
2015-05-06 23:09 marc
* bootstrap.sh: better doxygen support
2015-05-06 14:53 marc
* ax_init_standard_project.m4, bootstrap.sh: support scripts and
new parameters --build --overwrite --rebuild
2015-05-05 20:29 marc
* AUTHORS, aclocal.m4, ax_check_qt.m4, ax_cxx_compile_stdcxx_11.m4,
ax_init_standard_project.m4, bootstrap.sh: copied initial release
from webtester
2015-05-05 20:27 marc
* .: initial structure

@ -90,16 +90,19 @@ AC_DEFUN([AX_ADD_MAKEFILE_TARGET_DEP], [
fi
])
# Same as AC_SUBST, but adds -Dname="value" option to CPPFLAGS
# Same as AC_SUBST, but adds -Dname="value" option to CPPFLAGS and a
# notz only a @name@ replacement, but also a @name_ENCODED@ one to be
# used in code.
# - parameters:
# $1 = variable name
AC_DEFUN([AX_SUBST], [
[$1]_ENCODED=$(echo "${$1}" | awk 1 ORS='\\n' | sed 's,\\n$,,')
[$1]_ENCODED=${[$1]_ENCODED//\"/\\\"}
[$1]_ENCODED=${[$1]_ENCODED//\'/\'\"\'\"\'}
[$1]_ENCODED=${[$1]_ENCODED//#/\\#}
AM_CPPFLAGS+=" '-D$1=\"${[$1]_ENCODED}\"'"
AC_SUBST([$1])
tmp_var=$(echo "${$1}" | awk 1 ORS='\\n' | sed 's,\\n$,,')
tmp_var=${tmp_var//\"/\\\"}
tmp_var=${tmp_var//\'/\'\"\'\"\'}
tmp_var=${tmp_var//#/\\#}
AM_CPPFLAGS+=" '-D$1=\"${tmp_var}\"'"
AC_SUBST([$1]_ENCODED)
AC_SUBST(AM_CPPFLAGS)
])

@ -20,7 +20,7 @@ DEFAULT_PROJECT_NAME=${PROJECT_PATH##*/}
configure=0
build=0
docker=0
buildtarget="distcheck"
buildtarget=""
overwrite=0
rebuild=0
rebuildfiles=()
@ -28,8 +28,9 @@ while test $# -gt 0; do
case "$1" in
(--configure|-c) configure=1;;
(--docker|-d) docker=1;;
(--build|-b) configure=1; build=1;;
(--target|-t) shift; configure=1; build=1; buildtarget="$1";;
(--build|-b) configure=1; build=1; buildtarget+=" distcheck";;
(--target|-t) shift; configure=1; build=1; buildtarget+=" $1";;
(--clean) shift; configure=1; build=1; buildtarget+=" maintainer-clean";;
(--overwrite|-o) overwrite=1;;
(--rebuild|-r) rebuild=1;;
(--rebuild-file|-f) shift; rebuildfiles+=("$1");;

@ -1,15 +1,178 @@
#! /bin/bash -ex
#! /bin/bash -e
set -o errtrace
# build and test everything in a fresh docker installation
img="ubuntu:latest"
repos=()
keys=()
envs=()
dirs=("-v $(pwd):/workdir")
packages=()
targets="all check distcheck"
commands=()
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)
echo "$0 [OPTIONS]"
echo
echo "OPTIONS:"
echo
echo " -h, --help show this help"
echo " -i, --image <image> use given docker image instead of ${img}"
echo " -t, --targets targets specify build targets, default: ${targets}"
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"
echo " -d, --dir <dir> access given directory read only"
echo " -p, --package <pkg> install extra debian packages"
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 regular expression <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 Debian|precise:::curl:::npm"
echo
echo "EXAMPLE:"
echo
echo "$0 -i mwaeckerlin/ubuntu:trusty-i386 \\"
echo " -t deb \\"
echo " -e ANDROID_HOME=/opt/local/android \\"
echo " -d /opt/local/android \\"
echo " -r universe \\"
echo " -r https://dev.marc.waeckerlin.org/repository \\"
echo " -k https://dev.marc.waeckerlin.org/repository/PublicKey \\"
echo " -p mrw-c++"
echo
exit 0
;;
(-i|--image) shift;
img="$1"
;;
(-t|--targets) shift;
targets="$1"
;;
(-r|--repo) shift;
repos+=("$1")
;;
(-k|--key) shift;
keys+=("$1")
;;
(-e|--env) shift;
envs+=("-e $1")
;;
(-d|--dirs) shift;
dirs+=("-v $1:$1:ro")
;;
(-p|--package) shift;
packages+=("$1")
;;
(-c|--cmd) shift;
commands+=("$1")
;;
(*)
echo "**** ERROR: unknown option '$1', try --help" 1>&2
exit 1
;;
esac
if test $# -eq 0; then
echo "**** ERROR: missing value, try --help" 2>61
exit 1
fi
shift
done
DOCKER_ID=$(docker run -d -v $(pwd):/workdir -w /workdir ubuntu sleep infinity)
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-add-repository universe
docker exec ${DOCKER_ID} apt-add-repository https://dev.marc.waeckerlin.org/repository
wget -O- https://dev.marc.waeckerlin.org/repository/PublicKey \
function traperror() {
set +x
local DOCKER_ID="$1"
local err=($2) # error status
local line="$3" # LINENO
local linecallfunc="$4"
local command="$5"
local funcstack="$6"
for e in ${err[@]}; do
if test -n "$e" -a "$e" != "0"; then
echo "<---"
echo "ERROR: line $line - command '$command' exited with status: $e (${err[@]})"
if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then
echo -n " ... Error at ${funcstack} "
if [ "$linecallfunc" != "" ]; then
echo -n "called at line $linecallfunc"
fi
echo
fi
echo "**** Entering docker container ${DOCKER_ID}, exit with Ctrl-D"
echo -n " ... cleanup docker: "
docker rm -f "${DOCKER_ID}"
echo "returning status: $e"
echo "--->"
exit $e
fi
done
echo -n " SUCCESS ... cleanup docker: "
docker rm -f "${DOCKER_ID}"
exit 0
}
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 [[ "$(lsb_release -is)-$(lsb_release -cs)-$(dpkg --print-architecture)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; fi'
else
elsepart="${thenpart##*:::}"
thenpart="${thenpart%:::*}"
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'
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'
fi
fi
fi
}
set -x
docker pull $img
DOCKER_ID=$(docker run -d ${dirs[@]} ${envs[@]} -w /workdir $img sleep infinity)
trap 'traperror '"${DOCKER_ID}"' "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' SIGINT INT TERM EXIT
docker exec ${DOCKER_ID} apt-get update
docker exec ${DOCKER_ID} apt-get upgrade -y
docker exec ${DOCKER_ID} apt-get install -y python-software-properties software-properties-common apt-transport-https dpkg-dev lsb-release || \
docker exec ${DOCKER_ID} apt-get install -y software-properties-common apt-transport-https dpkg-dev lsb-release || \
docker exec ${DOCKER_ID} apt-get install -y python-software-properties apt-transport-https dpkg-dev lsb-release;
for repo in "${repos[@]}"; do
ifthenelse "${repo}" "apt-add-repository ARG"
done
for key in "${keys[@]}"; do
wget -O- "$key" \
| 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
ifthenelse "${command}" "ARG"
done
docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh
docker exec -u $(id -u) ${DOCKER_ID} svn upgrade || true
docker exec -u $(id -u) ${DOCKER_ID} ./bootstrap.sh -t "all check distcheck"
docker exec -u $(id -u) ${DOCKER_ID} ./bootstrap.sh -t "${targets}"

@ -16,7 +16,11 @@ if test -n "${SCHROOTNAME}"; then
SUDO="schroot -c "${SCHROOTNAME}" -u root -d / --"
else
DO=""
if grep -q '/docker/' /proc/1/cgroup; then
SUDO=""
else
SUDO="sudo"
fi
fi
function install() {
@ -41,7 +45,7 @@ if test -e debian/control.in -a ! -e debian/control; then
fi
install dpkg-dev
DEPS=$(${DO} dpkg-checkbuilddeps 2>&1 || true)
DEPS=$(LANG= ${DO} dpkg-checkbuilddeps 2>&1 || true)
DEPS=$(echo "$DEPS" | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')
for pa in ${DEPS}; do

@ -163,7 +163,7 @@ for repo in "${repos[@]}"; do
ifthenelse "${repo}" "apt-add-repository ARG"
done
for key in "${keys[@]}"; do
wget -O- \
wget -O- "$key" \
| docker exec -i ${DOCKER_ID} apt-key add -
done
docker exec ${DOCKER_ID} apt-get update

@ -45,7 +45,7 @@ if test -e debian/control.in -a ! -e debian/control; then
fi
install dpkg-dev
DEPS=$(${DO} dpkg-checkbuilddeps 2>&1 || true)
DEPS=$(LANG= ${DO} dpkg-checkbuilddeps 2>&1 || true)
DEPS=$(echo "$DEPS" | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')
for pa in ${DEPS}; do

Loading…
Cancel
Save