From 64168e00bc7e29ab9435267af4f6d5d9203b8079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 9 Jun 2017 14:57:33 +0000 Subject: [PATCH] improvements for deb and rpm docker builds --- scripts/ax_check_qt.m4 | 21 ++++++-- scripts/ax_init_standard_project.m4 | 84 ++++++++++++++++++----------- scripts/resolve-debbuilddeps.sh | 50 +++++++++++++++-- scripts/resolve-rpmbuilddeps.sh | 53 +++++++++++++++--- 4 files changed, 162 insertions(+), 46 deletions(-) diff --git a/scripts/ax_check_qt.m4 b/scripts/ax_check_qt.m4 index 7ba286f..ad59f21 100644 --- a/scripts/ax_check_qt.m4 +++ b/scripts/ax_check_qt.m4 @@ -230,6 +230,7 @@ AC_DEFUN([AX_CHECK_QT], [ AC_SUBST(CXXFLAGS) AC_SUBST(PKG_REQUIREMENTS) AX_ADDITIONAL_QT_RULES_HACK=' +#### Begin: Appended by $0 LANGUAGE_FILE_BASE ?= translations @@ -241,7 +242,6 @@ moc_%.cxx: %.hxx qrc_%.cxx: %.qrc $(RCC) -o [$][@] -name ${<:%.qrc=%} $< - AC_SUBST(AX_ADDITIONAL_QT_RULES_HACK) #%.qrc: % # cwd=$$(pwd) && cd $< && $(RCC) -project -o $${cwd}/[$][@] @@ -249,12 +249,15 @@ qrc_%.cxx: %.qrc %.qm: %.ts ${LRELEASE} $< -qm [$][@] -%.ts: ${LANGUAGE_FILES:%=%} +%.ts: ${LANGUAGE_FILES} ${LUPDATE} -no-obsolete \ - -target-language ${@:${LANGUAGE_FILE_BASE}_%.ts=%} \ - -ts [$][@] $< + -target-language [$]{@:${LANGUAGE_FILE_BASE}_%.ts=%} \ + [$][^] \ + -ts [$][@] -']) +#### End: $0 +' +]) AC_DEFUN([AX_REQUIRE_QT], [ AX_CHECK_QT([$1], [$2], [$3], [$4]) @@ -269,3 +272,11 @@ AC_DEFUN([AX_REQUIRE_QT], [ AC_DEFUN([AX_QT_NO_KEYWORDS], [ CPPFLAGS+=" -DQT_NO_KEYWORDS" ]) + +AC_DEFUN([AX_INIT_QT], [ + test -f src/makefile.in && cat >> src/makefile.in < -# special name for the RPM package -# - DEB_DIST_PKG= -# special name for the debian package -# - DIST_PKG= -# if the name of the package is different +# - DEV_RPM_DIST_PKG= +# special name for the RPM development package +# - DEV_DEB_DIST_PKG= +# special name for the debian development package # - DEV_DIST_PKG= # if the name of the development package is different # @@ -735,11 +733,6 @@ EOF AC_DEFUN([AX_PKG_REQUIRE], [ PKG_PROG_PKG_CONFIG optional_flags="$5" - $6 - if test -n "$DEV_DIST_PKG"; then - DEV_DEB_DIST_PKG=${DEV_DIST_PKG}-dev - DEV_RPM_DIST_PKG=${DEV_DIST_PKG}-devel - fi $1_found=no secondpar="m4_default([$2], [$1])" PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [ @@ -819,10 +812,6 @@ AC_DEFUN([AX_PKG_REQUIRE], [ AC_MSG_ERROR([Feature $1 not found please install module $secondpar]) fi fi - AX_DEB_BUILD_DEPEND([${DEV_DEB_DIST_PKG:-${DEB_DIST_PKG:-${DIST_PKG:-${$1_found}-dev}}}]) - AX_RPM_BUILD_DEPEND([${DEV_RPM_DIST_PKG:-${RPM_DIST_PKG:-${DIST_PKG:-${$1_found}-devel}}}]) - AX_DEB_DEPEND([${DEB_DIST_PKG:-${DIST_PKG:-${$1_found}}}]) - AX_RPM_DEPEND([${RPM_DIST_PKG:-${DIST_PKG:-${$1_found}}}]) [$1]_CPPFLAGS="${$1_CFLAGS}" [$1]_CXXFLAGS="${$1_CFLAGS}" AC_SUBST([$1]_CPPFLAGS) @@ -835,6 +824,33 @@ AC_DEFUN([AX_PKG_REQUIRE], [ else AC_MSG_NOTICE([To enable $1, add $1_CPPFLAGS, $1_CXXFLAGS and $1_LIBS]) fi + + DEV_DEB_DIST_PKG= + DEV_RPM_DIST_PKG= + DEV_DIST_PKG= + pkg=m4_default([$2], [$1]) + $6 + dep_pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev} + rpm_pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel} + if test -n "$4"; then + for f in $pkg $4; do + if test -n "$(apt-cache policy -q ${f}-dev 2> /dev/null)"; then + deb_pkg=${f}-dev + break + fi + done + for f in $pkg $4; do + if (test -x /usr/bin/zypper && zypper search -x "${f}-devel" 1>&2 > /dev/n ull) || \ + (test -x /usr/bin/dnf && dnf list -q "${f}-devel" 1>&2 > /dev/null) || \ + (test -x /usr/bin/yum && yum list -q "${f}-devel" 1>&2 > /dev/null) || \ + (test -x /usr/sbin/urpmq && urpmq "${f}-devel" 1>&2 > /dev/null); then + rpm_pkg=${f}-devel + break + fi + done + fi + AX_DEB_BUILD_DEPEND([$deb_pkg]) + AX_RPM_BUILD_DEPEND([$rpm_pkg]) ]) # check if a specific package exists @@ -844,12 +860,10 @@ AC_DEFUN([AX_PKG_REQUIRE], [ # $3 = optional flags: # manualflags if CXXFLAGS, CPPFLAGS, LIBS should remain unchanged # $4 = optional parameters, allowed are (evaluated in this order): -# - RPM_DIST_PKG= -# special name for the RPM package -# - DEB_DIST_PKG= -# special name for the debian package -# - DIST_PKG= -# if the name of the package is different +# - DEV_RPM_DIST_PKG= +# special name for the RPM development package +# - DEV_DEB_DIST_PKG= +# special name for the debian development package # - DEV_DIST_PKG= # if the name of the development package is different # @@ -858,11 +872,6 @@ AC_DEFUN([AX_PKG_REQUIRE], [ # sets all flags, so that the module can be used everywhere AC_DEFUN([AX_PKG_CHECK], [ optional_flags="$3" - $4 - if test -n "$DEV_DIST_PKG"; then - DEV_DEB_DIST_PKG=${DEV_DIST_PKG}-dev - DEV_RPM_DIST_PKG=${DEV_DIST_PKG}-devel - fi PKG_PROG_PKG_CONFIG PKG_CHECK_MODULES([$1], [m4_default([$2], [$1])], [ HAVE_$1=1 @@ -886,15 +895,29 @@ AC_DEFUN([AX_PKG_CHECK], [ ], [ HAVE_$1=0 ]) - AX_DEB_BUILD_DEPEND([${DEV_DEB_DIST_PKG:-${DEB_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])-dev}}}]) - AX_RPM_BUILD_DEPEND([${DEV_RPM_DIST_PKG:-${RPM_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])-devel}}}]) - AX_DEB_DEPEND([${DEB_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])}}]) - AX_RPM_DEPEND([${RPM_DIST_PKG:-${DIST_PKG:-m4_default([$2], [$1])}}]) AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1) AC_SUBST(HAVE_$1) AC_SUBST(CPPFLAGS) AC_SUBST(CXXFLAGS) AC_SUBST(PKG_REQUIREMENTS) + + DEV_DEB_DIST_PKG= + DEV_RPM_DIST_PKG= + DEV_DIST_PKG= + pkg=m4_default([$2], [$1]) + $4 + dep_pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev} + rpm_pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel} + if test -n "$(apt-cache policy -q ${deb_pkg} 2> /dev/null)"; then + AX_DEB_BUILD_DEPEND([$deb_pkg]) + fi + if (test -x /usr/bin/zypper && zypper search -x "$rpm_pkg" 1>&2 > /dev/n ull) || \ + (test -x /usr/bin/dnf && dnf list -q "$rpm_pkg" 1>&2 > /dev/null) || \ + (test -x /usr/bin/yum && yum list -q "$rpm_pkg" 1>&2 > /dev/null) || \ + (test -x /usr/sbin/urpmq && urpmq "$rpm_pkg" 1>&2 > /dev/null); then + AX_RPM_BUILD_DEPEND([$rpm_pkg]) + fi +) ]) # make sure, a specific header exists @@ -1179,4 +1202,5 @@ AC_DEFUN([AX_OUTPUT], [ AX_DEB_RESOLVE AX_RPM_RESOLVE AC_OUTPUT + AX_INIT_QT ]) diff --git a/scripts/resolve-debbuilddeps.sh b/scripts/resolve-debbuilddeps.sh index 4358e29..a6b7c4f 100755 --- a/scripts/resolve-debbuilddeps.sh +++ b/scripts/resolve-debbuilddeps.sh @@ -35,13 +35,56 @@ TO_INSTALL= DEPS= if test -e debian/control.in -a ! -e debian/control; then + function pkg_exists() { + test -n "$(${DO} apt-cache policy -q ${1})" \ + && ((! $(${DO} apt-cache policy ${1} 2>&1 \ + | grep -q 'N: Unable to locate package')) \ + && (! ${DO} dpkg -l "${1}" 1>&2 > /dev/null)) + } + function AX_PKG_CHECK() { + local DEV_DEB_DIST_PKG= + local DEV_DIST_PKG= + local pkg= + eval $4 + if test -z "$2"; then + pkg=$1 + else + pkg=$2 + fi + pkg=${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev} + if pkg_exists "${pkg}"; then + echo $pkg + fi + } + function AX_PKG_REQUIRE() { + local DEV_DEB_DIST_PKG= + local DEV_DIST_PKG= + local pkg= + eval $6 + if test -z "$2"; then + pkg=$1 + else + pkg=$2 + fi + if test -n "$4"; then + for f in $pkg $4; do + if pkg_exists "${f}-dev"; then + pkg=$f + break + fi + done + fi + echo ${DEV_DEB_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-dev} + } + DEPS+=" $(eval $(sed -n '/^ *AX_PKG_REQUIRE/{s,^ *\(AX_PKG_REQUIRE\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))" + DEPS+=" $(eval $(sed -n '/^ *AX_PKG_CHECK/{s,^ *\(AX_PKG_CHECK\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))" for f in $(sed -n 's, *AX_\(DEB\|ALL\)_DEPEND_IFEXISTS(\([^)]*\)).*,\2,p' configure.ac); do - if test -n "$(${DO} apt-cache policy -q ${f})" && ((! $(${DO} apt-cache policy ${f} 2>&1 | grep -q 'N: Unable to locate package')) && (! ${DO} dpkg -l "${f}")); then + if pkg_exists "${f}"; then DEPS+=" ${f}" fi done for f in $(sed -n 's, *AX_\(DEB\|ALL\)_DEPEND_IFEXISTS_DEV(\([^)]*\)).*,\2,p' configure.ac); do - if test -n "$(${DO} apt-cache policy -q ${f}-dev)" && ((! $(${DO} apt-cache policy ${f}-dev 2>&1 | grep -q 'N: Unable to locate package')) && (! ${DO} dpkg -l "${f}-dev")); then + if pkg_exists "${f}-dev"; then DEPS+=" ${f}-dev" fi done @@ -57,10 +100,11 @@ if test -e debian/control.in -a ! -e debian/control; then fi install dpkg-dev + DEPS+=" $(LANG= ${DO} dpkg-checkbuilddeps 2>&1 | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')" for pa in ${DEPS}; do - if test ${pa//|/} = ${pa}; then + if test "${pa//|/}" = "${pa}"; then TO_INSTALL+=" ${pa}" continue; fi diff --git a/scripts/resolve-rpmbuilddeps.sh b/scripts/resolve-rpmbuilddeps.sh index 4a64ada..5498e99 100755 --- a/scripts/resolve-rpmbuilddeps.sh +++ b/scripts/resolve-rpmbuilddeps.sh @@ -23,19 +23,56 @@ for f in BUILD BUILDROOT RPMS SPECS SRPMS; do fi done if test -e ${PACKAGE_NAME}.spec.in -a ! -e ${PACKAGE_NAME}.spec; then + function pkg_exists() { + (test -x /usr/bin/zypper && zypper search -x "$1" 1>&2 > /dev/null) || \ + (test -x /usr/bin/dnf && dnf list -q "$1" 1>&2 > /dev/null) || \ + (test -x /usr/bin/yum && yum list -q "$1" 1>&2 > /dev/null) || \ + (test -x /usr/sbin/urpmq && urpmq "$1" 1>&2 > /dev/null) + } + function AX_PKG_CHECK() { + local DEV_RPM_DIST_PKG= + local DEV_DIST_PKG= + local pkg= + eval $4 + if test -z "$2"; then + pkg=$1 + else + pkg=$2 + fi + pkg=${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel} + if pkg_exists "${pkg}"; then + echo ${pkg} + fi + } + function AX_PKG_REQUIRE() { + local DEV_RPM_DIST_PKG= + local DEV_DIST_PKG= + local pkg= + eval $6 + if test -z "$2"; then + pkg=$1 + else + pkg=$2 + fi + if test -n "$4"; then + for f in $pkg $4; do + if pkg_exists "${f}-devel"; then + pkg=$f + break + fi + done + fi + echo ${DEV_RPM_DIST_PKG:-${DEV_DIST_PKG:-${pkg}}-devel} + } + DEPS+=" $(eval $(sed -n '/^ *AX_PKG_REQUIRE/{s,^ *\(AX_PKG_REQUIRE\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))" + DEPS+=" $(eval $(sed -n '/^ *AX_PKG_CHECK/{s,^ *\(AX_PKG_CHECK\) *(\(.*\)).*,\1 \2,;s.\[\([^]]*\)\],\?."\1".g;s,$,;,g;p}' configure.ac))" for f in $(sed -n 's, *AX_\(RPM\|ALL\)_DEPEND_IFEXISTS(\([^)]*\)).*,\2,p' configure.ac); do - if (test -x /usr/bin/zypper && zypper search -x "$f" 1>&2 > /dev/null) || \ - (test -x /usr/bin/dnf && dnf list -q "$f" 1>&2 > /dev/null) || \ - (test -x /usr/bin/yum && yum list -q "$f" 1>&2 > /dev/null) || \ - (test -x /usr/sbin/urpmq && urpmq "$f" 1>&2 > /dev/null); then + if pkg_exists "${f}"; then DEPS+=" ${f}" fi done for f in $(sed -n 's, *AX_\(RPM\|ALL\)_DEPEND_IFEXISTS_DEV(\([^)]*\)).*,\2,p' configure.ac); do - if (test -x /usr/bin/zypper && zypper search -x "$f"-devel 1>&2 > /dev/null) || \ - (test -x /usr/bin/dnf && dnf list -q "$f"-devel 1>&2 > /dev/null) || \ - (test -x /usr/bin/yum && yum list -q "$f"-devel 1>&2 > /dev/null) || \ - (test -x /usr/sbin/urpmq && urpmq "$f"-devel 1>&2 > /dev/null); then + if pkg_exists "${f}-devel"; then DEPS+=" ${f}-devel" fi done