diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 52097a176e..c5d3696eac 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -46,6 +46,22 @@ ############################################################################### +%if "x__BCOND_DEFAULT_DEBUG__" == "x1" || "x__BCOND_DEFAULT_DEBUG__" == "x0" +%global bcond_default_debug __BCOND_DEFAULT_DEBUG__ +%else +%global bcond_default_debug 0 +%endif + +%if "x__BCOND_DEFAULT_TEST__" == "x1" || "x__BCOND_DEFAULT_TEST__" == "x0" +%global bcond_default_test __BCOND_DEFAULT_TEST__ +%else +%if 0%{?rhel} >= 9 +%global bcond_default_test 1 +%else +%global bcond_default_test 0 +%endif +%endif + %bcond_with meson %bcond_without adsl %bcond_without bluetooth @@ -57,8 +73,12 @@ %bcond_without nmtui %bcond_without nm_cloud_setup %bcond_without regen_docs +%if %{bcond_default_debug} +%bcond_without debug +%else %bcond_with debug -%if 0%{?rhel} >= 9 +%endif +%if %{bcond_default_test} %bcond_without test %else %bcond_with test diff --git a/contrib/fedora/rpm/build.sh b/contrib/fedora/rpm/build.sh index d84dc44729..0e3b82c7e6 100755 --- a/contrib/fedora/rpm/build.sh +++ b/contrib/fedora/rpm/build.sh @@ -23,6 +23,8 @@ # SOURCE_SYSCTL_RP_FILTER_REDHAT= # SIGN_SOURCE= # DO_RELEASE= +# BCOND_DEFAULT_DEBUG= +# BCOND_DEFAULT_TEST= die() { echo "$*" >&2 @@ -48,6 +50,15 @@ coerce_bool() { esac } +in_set() { + local v="$1" + shift + for v2; do + test "$v" == "$v2" && return 0 + done + return 1 +} + abs_path() { local F="$1" @@ -157,10 +168,15 @@ LOG "SOURCE_CONFIG_CONNECTIVITY_REDHAT=$SOURCE_CONFIG_CONNECTIVITY_REDHAT" LOG "SOURCE_SYSCTL_RP_FILTER_REDHAT=$SOURCE_SYSCTL_RP_FILTER_REDHAT" LOG "BUILDTYPE=$BUILDTYPE" LOG "NM_RPMBUILD_ARGS=$NM_RPMBUILD_ARGS" +LOG "BCOND_DEFAULT_DEBUG=$BCOND_DEFAULT_DEBUG" +LOG "BCOND_DEFAULT_TEST=$BCOND_DEFAULT_TEST" LOG "" LOG "UUID=$UUID" LOG "BASEDIR=$TEMP" +in_set "$BCOND_DEFAULT_DEBUG" "" 0 1 || die "Invalid value for \$BCOND_DEFAULT_DEBUG: \"$BCOND_DEFAULT_DEBUG\"" +in_set "$BCOND_DEFAULT_TEST" "" 0 1 || die "Invalid value for \$BCOND_DEFAULT_TEST: \"$BCOND_DEFAULT_TEST\"" + ln -snf "$TEMPBASE" ./latest0 ln "$BUILDLOG" "$TEMPBASE/build.log" rm -f "$BUILDLOG" @@ -186,6 +202,8 @@ sed -e "s/__VERSION__/$VERSION/g" \ -e "s/__COMMIT_FULL__/$COMMIT_FULL/g" \ -e "s/__SNAPSHOT__/$SNAPSHOT/g" \ -e "s/__SOURCE1__/$(basename "$SOURCE")/g" \ + -e "s/__BCOND_DEFAULT_DEBUG__/$BCOND_DEFAULT_DEBUG/g" \ + -e "s/__BCOND_DEFAULT_TEST__/$BCOND_DEFAULT_TEST/g" \ "$SPECFILE" | sed -e "/^__CHANGELOG__$/ \ { diff --git a/contrib/fedora/rpm/build_clean.sh b/contrib/fedora/rpm/build_clean.sh index 1d889241f4..b26316be22 100755 --- a/contrib/fedora/rpm/build_clean.sh +++ b/contrib/fedora/rpm/build_clean.sh @@ -25,8 +25,18 @@ usage() { echo " -W|--without \$OPTION: pass --without \$OPTION to rpmbuild. For example --without debug" echo " -s|--snapshot TEXT: use TEXT as the snapshot version for the new package (overwrites \$NM_BUILD_SNAPSHOT environment)" echo " -r|--release: built a release tarball (this option must be alone)" + echo " --default-for-debug \$OPTION: set the default for "debug" option in the generated spec file" + echo " --default-for-test \$OPTION: set the default for "test" option in the generated spec file" } +in_set() { + local v="$1" + shift + for v2; do + test "$v" == "$v2" && return 0 + done + return 1 +} ORIGDIR="$(readlink -f "$PWD")" SCRIPTDIR="$(dirname "$(readlink -f "$0")")" @@ -45,6 +55,8 @@ WITH_LIST=() SOURCE_FROM_GIT=0 SNAPSHOT="$NM_BUILD_SNAPSHOT" DO_RELEASE=0 +unset BCOND_DEFAULT_DEBUG +unset BCOND_DEFAULT_TEST ADD_WITH_TEST=1 @@ -94,17 +106,29 @@ while [[ $# -gt 0 ]]; do -w|--with) [[ $# -gt 0 ]] || die "Missing argument to $A" WITH_LIST=("${WITH_LIST[@]}" "--with" "$1") - if [[ "$1" == test ]]; then - ADD_WITH_TEST=0 - fi + case "$1" in + debug) + [[ -z ${BCOND_DEFAULT_DEBUG+.} ]] && BCOND_DEFAULT_DEBUG=1 + ;; + test) + ADD_WITH_TEST=0 + [[ -z ${BCOND_DEFAULT_TEST+.} ]] && BCOND_DEFAULT_TEST=1 + ;; + esac shift ;; -W|--without) [[ $# -gt 0 ]] || die "Missing argument to $A" WITH_LIST=("${WITH_LIST[@]}" "--without" "$1") - if [[ "$1" == test ]]; then - ADD_WITH_TEST=0 - fi + case "$1" in + debug) + [[ -z ${BCOND_DEFAULT_DEBUG+.} ]] && BCOND_DEFAULT_DEBUG=0 + ;; + test) + ADD_WITH_TEST=0 + [[ -z ${BCOND_DEFAULT_TEST+.} ]] && BCOND_DEFAULT_TEST=0 + ;; + esac shift ;; --no-auto-with-test) @@ -115,6 +139,18 @@ while [[ $# -gt 0 ]]; do # or "-W test". ADD_WITH_TEST=0 ;; + --default-for-debug) + [[ $# -gt 0 ]] || die "Missing argument to $A" + in_set "$1" "" 0 1 || die "invalid argument $A \"$1\"" + BCOND_DEFAULT_DEBUG="$1" + shift + ;; + --default-for-test) + [[ $# -gt 0 ]] || die "Missing argument to $A" + in_set "$1" "" 0 1 || die "invalid argument $A \"$1\"" + BCOND_DEFAULT_TEST="$1" + shift + ;; *) usage die "Unexpected argument \"$A\"" @@ -184,6 +220,8 @@ export BUILDTYPE export NM_RPMBUILD_ARGS="${WITH_LIST[@]}" export SNAPSHOT export DO_RELEASE +export BCOND_DEFAULT_DEBUG="$BCOND_DEFAULT_DEBUG" +export BCOND_DEFAULT_TEST="$BCOND_DEFAULT_TEST" "$SCRIPTDIR"/build.sh