From e334354ea301367c18d34947c8d3304291cb23cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Wed, 7 Dec 2016 16:00:01 +0000 Subject: [PATCH] build improved for fedora, centos, opensuse --- scripts/ax_init_standard_project.m4 | 4 +-- scripts/bootstrap.sh | 19 +++++++++----- scripts/build-in-docker.sh | 40 ++++++++++++++++++----------- scripts/resolve-rpmbuilddeps.sh | 32 ++++++++++------------- 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/scripts/ax_init_standard_project.m4 b/scripts/ax_init_standard_project.m4 index 44f8bac..e356162 100644 --- a/scripts/ax_init_standard_project.m4 +++ b/scripts/ax_init_standard_project.m4 @@ -422,7 +422,7 @@ EOF # use this in configure.ac to support CppUnit for C++ unit tests AC_DEFUN([AX_USE_CPPUNIT], [ - AM_PATH_CPPUNIT([1.0.0], [have_cppunit="yes"], [have_cppunit="no"]) + PKG_CHECK_MODULES(CPPUNIT, cppunit, [have_cppunit="yes"], [have_cppunit="no"]) # infos and warnings if test "$have_cppunit" = "no"; then AC_MSG_WARN([Missing cppunit development library! @@ -646,7 +646,7 @@ AC_DEFUN([AX_USE_PERLDOC], [ PERL_SOURCES="m4_default([$1], [perl])" AX_SUBST(PERL_SOURCES) if test -z "$PERL_SOURCES"; then - AC_MSG_ERROR([You must specify the path to per files + AC_MSG_ERROR([You must specify the path to perl files - use [AX]_[USE]_PERLDOC([[pathes to perldoc]])]); fi AC_CHECK_PROG(have_perldoc, pods2html, yes, no) if test "$have_doxygen" = "no"; then diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 3a4d2fc..a033b7d 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1535,8 +1535,14 @@ fi) Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: gnupg, ${VCSDEPENDS} make, automake, autoconf, rpm-build$( + if testtag AX_USE_CXX; then + echo -n ", binutils-devel, gcc-c++" + fi + if testtag AX_USE_LIBTOOL; then + echo -n ", libtool"; + fi if testtag AX_USE_DOXYGEN; then - echo -n ", doxygen, default-jre-headless"; + echo -n ", doxygen, java-openjdk"; fi if testtag AX_USE_PERLDOC; then echo -n ", libpod-tree-perl"; @@ -1546,10 +1552,11 @@ BuildRequires: gnupg, ${VCSDEPENDS} make, automake, autoconf, rpm-build$( $(if testtag AX_USE_DOXYGEN; then echo -n "BuildRequires: graphviz"; fi) %endif %if 0%{?fedora} || 0%{?rhel} || 0%{?rhl} || 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version} -BuildRequires: pkgconfig, redhat-lsb$( - if testtag AX_USE_CPPUNIT; then - echo -n ", cppunit-devel"; - fi) +BuildRequires: which, svn2cl, pkgconfig, redhat-lsb$( + if testtag AX_USE_LIBTOOL; then + echo -n ", libtool-ltdl"; + fi +) %if ! ( 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version} ) $(if testtag AX_USE_DOXYGEN; then echo -n "BuildRequires: mscgen"; fi) $(if testtag AX_REQUIRE_QT || testtag AX_CHECK_QT AX_REQUIRE_QT; then echo -n "BuildRequires: qt5-qtbase-devel, qt5-qttools, qt5-qtwebkit-devel"; fi) @@ -1668,7 +1675,7 @@ for d in src test scripts doc examples html; do done to --mode "u=rwx,g=rwx,o=rx" autogen.sh < ChangeLog";; diff --git a/scripts/build-in-docker.sh b/scripts/build-in-docker.sh index 2967ff4..06c01c0 100755 --- a/scripts/build-in-docker.sh +++ b/scripts/build-in-docker.sh @@ -6,12 +6,12 @@ myarch=$(dpkg --print-architecture) if test "${arch}" = "amd64"; then myarch="amd64|i386" fi -mode="apt" +mode="deb" img="ubuntu:latest" repos=() keys=() -envs=("-e DEBIAN_FRONTEND=noninteractive" "-e DEBCONF_NONINTERACTIVE_SEEN=true") -dirs=("-v $(pwd):/workdir") +envs=("-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:ro") packages=() targets="all check distcheck" commands=() @@ -30,7 +30,7 @@ while test $# -gt 0; do echo "OPTIONS:" echo echo " -h, --help show this help" - echo " -m, --mode mode: apt or yum, default: ${mode}" + echo " -m, --mode mode: deb, rpm, default: ${mode}" echo " -i, --image use given docker image instead of ${img}" echo " -a, --arch build for given hardware architecture" echo " -t, --targets targets specify build targets, default: ${targets}" @@ -43,6 +43,8 @@ while test $# -gt 0; do echo " -w, --wait on error keep docker container and wait for enter" 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 " If target is either deb or rpm, mode is set to the same value" echo echo " The options -r -k -e -d -p -c can be repeated several times." echo @@ -73,8 +75,10 @@ while test $# -gt 0; do (-m|--mode) shift; mode="$1" case "$mode" in - (apt) img="ubuntu:latest";; + (deb|apt) img="ubuntu:latest";; + (rpm|zypper) img="opensuse:latest";; (yum) img="centos:latest";; + (dnf) img="fedora:latest";; (*) echo "**** ERROR: unknown mode '$1', try --help" 1>&2 exit 1 @@ -87,8 +91,13 @@ 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" $@ + continue + fi ;; (-r|--repo) shift; repos+=("$1") @@ -192,15 +201,20 @@ function ifthenelse() { set -x 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 if ! [[ $arch =~ $myarch ]]; then docker cp "/usr/bin/qemu-${arch}-static" "${DOCKER_ID}:/usr/bin/qemu-${arch}-static" fi 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 -u) -d"${HOME}" $(id -un) +fi case $mode in - (apt) + (deb|apt) 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 docker exec ${DOCKER_ID} bash -c "echo 'Package: $f' >> /etc/apt/preferences" @@ -228,8 +242,7 @@ case $mode in done docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh ;; - (yum) - ./bootstrap.sh -t dist + (rpm|yum|dnf|zypper) if [[ "$img" =~ "centos" ]]; then docker exec ${DOCKER_ID} yum install -y redhat-lsb docker exec -i ${DOCKER_ID} bash -c 'cat > /etc/yum.repos.d/wandisco-svn.repo' <&1 | sed -n 's, is needed by.*,,p') + rm $TGZFILE if test -n "${FILES}"; then - FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}") - if test -n "${FIRST}"; then - schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FIRST} || \ - schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FIRST} || \ - schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FIRST} - fi - schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FILES} || \ - schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FILES} || \ - schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FILES} + schroot -c ${SCHROOTNAME} -u root -- ${INSTALL_TOOL} install -y ${FILES} fi else + ${INSTALL_TOOL} install -y rpm-build automake libtool subversion gcc-c++ pkgconfig + ./bootstrap.sh -c + TGZFILE=$(grep PACKAGE_STRING= configure | sed "s, ,-,g;s,PACKAGE_STRING=',,g;s,',.tar.gz,g") + touch $TGZFILE FILES=$(LANG= rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p') + rm $TGZFILE if test -n "${FILES}"; then - FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}") - if test -n "${FIRST}"; then - yum install -y ${FIRST} || \ - zypper install -y ${FIRST} || \ - dnf install -y ${FIRST} - fi - yum install -y ${FILES} || \ - zypper install -y ${FILES} || \ - dnf install -y ${FILES} + ${INSTALL_TOOL} install -y ${FILES} fi fi