build improved for fedora, centos, opensuse

master
Marc Wäckerlin 8 years ago
parent 3b535db748
commit e334354ea3
  1. 4
      scripts/ax_init_standard_project.m4
  2. 19
      scripts/bootstrap.sh
  3. 40
      scripts/build-in-docker.sh
  4. 32
      scripts/resolve-rpmbuilddeps.sh

@ -422,7 +422,7 @@ EOF
# use this in configure.ac to support CppUnit for C++ unit tests # use this in configure.ac to support CppUnit for C++ unit tests
AC_DEFUN([AX_USE_CPPUNIT], [ 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 # infos and warnings
if test "$have_cppunit" = "no"; then if test "$have_cppunit" = "no"; then
AC_MSG_WARN([Missing cppunit development library! AC_MSG_WARN([Missing cppunit development library!
@ -646,7 +646,7 @@ AC_DEFUN([AX_USE_PERLDOC], [
PERL_SOURCES="m4_default([$1], [perl])" PERL_SOURCES="m4_default([$1], [perl])"
AX_SUBST(PERL_SOURCES) AX_SUBST(PERL_SOURCES)
if test -z "$PERL_SOURCES"; then 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 - use [AX]_[USE]_PERLDOC([[pathes to perldoc]])]); fi
AC_CHECK_PROG(have_perldoc, pods2html, yes, no) AC_CHECK_PROG(have_perldoc, pods2html, yes, no)
if test "$have_doxygen" = "no"; then if test "$have_doxygen" = "no"; then

@ -1535,8 +1535,14 @@ fi)
Source0: %{name}-%{version}.tar.gz Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: gnupg, ${VCSDEPENDS} make, automake, autoconf, rpm-build$( 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 if testtag AX_USE_DOXYGEN; then
echo -n ", doxygen, default-jre-headless"; echo -n ", doxygen, java-openjdk";
fi fi
if testtag AX_USE_PERLDOC; then if testtag AX_USE_PERLDOC; then
echo -n ", libpod-tree-perl"; 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) $(if testtag AX_USE_DOXYGEN; then echo -n "BuildRequires: graphviz"; fi)
%endif %endif
%if 0%{?fedora} || 0%{?rhel} || 0%{?rhl} || 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version} %if 0%{?fedora} || 0%{?rhel} || 0%{?rhl} || 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version}
BuildRequires: pkgconfig, redhat-lsb$( BuildRequires: which, svn2cl, pkgconfig, redhat-lsb$(
if testtag AX_USE_CPPUNIT; then if testtag AX_USE_LIBTOOL; then
echo -n ", cppunit-devel"; echo -n ", libtool-ltdl";
fi) fi
)
%if ! ( 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version} ) %if ! ( 0%{?centos} || 0%{?centos_ver} || 0%{?centos_version} )
$(if testtag AX_USE_DOXYGEN; then echo -n "BuildRequires: mscgen"; fi) $(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) $(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 done
to --mode "u=rwx,g=rwx,o=rx" autogen.sh <<EOF to --mode "u=rwx,g=rwx,o=rx" autogen.sh <<EOF
#!/bin/bash -e #!/bin/bash -e
if test -n "$VCS" -a -d .$VCS -a -e -x $(which ${VCS}2cl); then if test -n "$VCS" -a -d ".$VCS" -a -e -x "\$(which ${VCS}2cl)"; then
$(case "$VCS" in $(case "$VCS" in
(svn) echo " ${VCS}2cl";; (svn) echo " ${VCS}2cl";;
(git) echo " ${VCS}2cl > ChangeLog";; (git) echo " ${VCS}2cl > ChangeLog";;

@ -6,12 +6,12 @@ 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 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:ro")
packages=() packages=()
targets="all check distcheck" targets="all check distcheck"
commands=() commands=()
@ -30,7 +30,7 @@ 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, 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}"
@ -43,6 +43,8 @@ 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 " If target is either deb or rpm, mode is set to the same value"
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 +75,10 @@ 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";;
(*) (*)
echo "**** ERROR: unknown mode '$1', try --help" 1>&2 echo "**** ERROR: unknown mode '$1', try --help" 1>&2
exit 1 exit 1
@ -87,8 +91,13 @@ while test $# -gt 0; do
(-a|--arch) shift; (-a|--arch) shift;
arch="$1" arch="$1"
;; ;;
(-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
;; ;;
(-r|--repo) shift; (-r|--repo) shift;
repos+=("$1") repos+=("$1")
@ -192,15 +201,20 @@ 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 -u) -d"${HOME}" $(id -un)
fi
case $mode in 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' 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 +242,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)
./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 +255,7 @@ enabled=1
gpgcheck=0 gpgcheck=0
EOF EOF
fi fi
docker exec ${DOCKER_ID} yum install -y rpm-build docker exec ${DOCKER_ID} ./resolve-rpmbuilddeps.sh
docker exec ${DOCKER_ID} groupadd -g $(id -g) build
docker exec ${DOCKER_ID} useradd -g $(id -g) -u $(id -u) build
docker exec ${DOCKER_ID} ./resolve-rpmbuilddeps.sh || true
;; ;;
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}"

@ -10,35 +10,29 @@
## 1 2 3 4 5 6 7 8 ## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890 ## 45678901234567890123456789012345678901234567890123456789012345678901234567890
INSTALL_TOOL=${INSTALL_TOOL:-$((test -x /usr/bin/zypper && echo zypper) || (test -x /usr/bin/dnf && echo dnf) || (test -x /usr/bin/yum && echo yum))}
SCHROOTNAME="$1" SCHROOTNAME="$1"
PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac) PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac)
PKGCONFIGS="${2:-epel-release}" # packages to configure yum
if test -n "${SCHROOTNAME}"; then if test -n "${SCHROOTNAME}"; then
schroot -c ${SCHROOTNAME} -u root -- ${INSTALL_TOOL} install -y rpm-build automake libtool subversion gcc-c++ pkgconfig
schroot -c ${SCHROOTNAME} -u root -- ./bootstrap.sh -c
TGZFILE=$(grep PACKAGE_STRING= configure | sed "s, ,-,g;s,PACKAGE_STRING=',,g;s,',.tar.gz,g")
touch $TGZFILE
FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --clean --nobuild --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p') FILES=$(LANG= schroot -c ${SCHROOTNAME} -- 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 if test -n "${FILES}"; then
FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}") schroot -c ${SCHROOTNAME} -u root -- ${INSTALL_TOOL} install -y ${FILES}
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}
fi fi
else 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') 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 if test -n "${FILES}"; then
FIRST=$(echo "${FILES}" | egrep -o "${PKGCONFIGS// /|}") ${INSTALL_TOOL} install -y ${FILES}
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}
fi fi
fi fi

Loading…
Cancel
Save