diff options
author | Thomas Haller <thaller@redhat.com> | 2023-01-24 10:29:35 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-02-10 09:48:18 +0100 |
commit | 2fd7841f131d12f0d47e22d5637dc2ac4013085f (patch) | |
tree | f7f6496c3a648e00ffd95af8d0bacea8df72ff27 | |
parent | 965f2fcea139d46913a63f2eed2e37a53a0eb3a2 (diff) | |
download | NetworkManager-2fd7841f131d12f0d47e22d5637dc2ac4013085f.tar.gz |
contrib/fedora: make "lto" in the spec file configurable
When we build a copr image, we run the "nm-copr-build.sh" script.
That script, should honor "LTO=0|1|" to explicitly enable/disable
LTO. Since the copr script only builds a SRPM, which then gets build
we need that the default LTO flag in the SRPM is templated.
Fixes: 0566e9dc63fb ('contrib: support disabling "LTO" in "nm-copr-build.sh"')
(cherry picked from commit 096b9955d67d3c915c1a9599446aaff7fae60b99)
-rw-r--r-- | contrib/fedora/rpm/NetworkManager.spec | 9 | ||||
-rwxr-xr-x | contrib/fedora/rpm/build.sh | 5 | ||||
-rwxr-xr-x | contrib/fedora/rpm/build_clean.sh | 15 | ||||
-rwxr-xr-x | contrib/scripts/nm-copr-build.sh | 4 |
4 files changed, 31 insertions, 2 deletions
diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index c5b8fbf4b9..2f7a2d36ec 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -19,6 +19,7 @@ %global snapshot __SNAPSHOT__ %global git_sha __COMMIT__ %global bcond_default_debug __BCOND_DEFAULT_DEBUG__ +%global bcond_default_lto __BCOND_DEFAULT_LTO__ %global bcond_default_test __BCOND_DEFAULT_TEST__ %global obsoletes_device_plugins 1:0.9.9.95-1 @@ -69,11 +70,19 @@ %else %bcond_with test %endif +%if %{bcond_default_lto} == '' %if 0%{?fedora} >= 33 || 0%{?rhel} >= 9 %bcond_without lto %else %bcond_with lto %endif +%else +%if %{bcond_default_lto} +%bcond_without lto +%else +%bcond_with lto +%endif +%endif %bcond_with sanitizer %if 0%{?fedora} %bcond_without connectivity_fedora diff --git a/contrib/fedora/rpm/build.sh b/contrib/fedora/rpm/build.sh index e5a3d84468..777f9c4a53 100755 --- a/contrib/fedora/rpm/build.sh +++ b/contrib/fedora/rpm/build.sh @@ -25,6 +25,7 @@ # SIGN_SOURCE= # DO_RELEASE= # BCOND_DEFAULT_DEBUG= +# BCOND_DEFAULT_LTO= # BCOND_DEFAULT_TEST= die() { @@ -119,6 +120,7 @@ COMMIT_FULL="${COMMIT_FULL:-$(git rev-parse --verify HEAD || die "Error reading COMMIT="${COMMIT:-$(printf '%s' "$COMMIT_FULL" | sed 's/^\(.\{10\}\).*/\1/' || die "Error reading HEAD revision")}" BCOND_DEFAULT_DEBUG="${BCOND_DEFAULT_DEBUG:-0}" BCOND_DEFAULT_TEST="${BCOND_DEFAULT_TEST:-0}" +BCOND_DEFAULT_LTO="${BCOND_DEFAULT_LTO}" USERNAME="${USERNAME:-"$(git config user.name) <$(git config user.email)>"}" SPECFILE="$(abs_path "$SPECFILE" "$SCRIPTDIR/NetworkManager.spec")" || die "invalid \$SPECFILE argument" SOURCE_FROM_GIT="$(coerce_bool "$SOURCE_FROM_GIT" "")" @@ -174,12 +176,14 @@ LOG "SOURCE_README_IFCFG_FILES=$SOURCE_README_IFCFG_FILES" LOG "BUILDTYPE=$BUILDTYPE" LOG "NM_RPMBUILD_ARGS=$NM_RPMBUILD_ARGS" LOG "BCOND_DEFAULT_DEBUG=$BCOND_DEFAULT_DEBUG" +LOG "BCOND_DEFAULT_LTO=$BCOND_DEFAULT_LTO" 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_LTO" '' 0 1 || die "Invalid value for \$BCOND_DEFAULT_LTO: \"$BCOND_DEFAULT_LTO\"" in_set "$BCOND_DEFAULT_TEST" 0 1 || die "Invalid value for \$BCOND_DEFAULT_TEST: \"$BCOND_DEFAULT_TEST\"" ln -snf "$TEMPBASE" ./latest0 @@ -209,6 +213,7 @@ sed -e "s/__VERSION__/$VERSION/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_LTO__/$BCOND_DEFAULT_LTO/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 7c221d69a5..6ba202674e 100755 --- a/contrib/fedora/rpm/build_clean.sh +++ b/contrib/fedora/rpm/build_clean.sh @@ -26,6 +26,7 @@ usage() { 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-lto \$OPTION: set the default for "lto" option in the generated spec file" echo " --default-for-test \$OPTION: set the default for "test" option in the generated spec file" } @@ -56,6 +57,7 @@ SOURCE_FROM_GIT=0 SNAPSHOT="$NM_BUILD_SNAPSHOT" DO_RELEASE=0 unset BCOND_DEFAULT_DEBUG +unset BCOND_DEFAULT_LTO unset BCOND_DEFAULT_TEST ADD_WITH_TEST=1 @@ -110,6 +112,9 @@ while [[ $# -gt 0 ]]; do debug) [[ -z ${BCOND_DEFAULT_DEBUG+.} ]] && BCOND_DEFAULT_DEBUG=1 ;; + lto) + [[ -z ${BCOND_DEFAULT_LTO+.} ]] && BCOND_DEFAULT_LTO=1 + ;; test) ADD_WITH_TEST=0 [[ -z ${BCOND_DEFAULT_TEST+.} ]] && BCOND_DEFAULT_TEST=1 @@ -124,6 +129,9 @@ while [[ $# -gt 0 ]]; do debug) [[ -z ${BCOND_DEFAULT_DEBUG+.} ]] && BCOND_DEFAULT_DEBUG=0 ;; + lto) + [[ -z ${BCOND_DEFAULT_LTO+.} ]] && BCOND_DEFAULT_LTO=0 + ;; test) ADD_WITH_TEST=0 [[ -z ${BCOND_DEFAULT_TEST+.} ]] && BCOND_DEFAULT_TEST=0 @@ -145,6 +153,12 @@ while [[ $# -gt 0 ]]; do BCOND_DEFAULT_DEBUG="$1" shift ;; + --default-for-lto) + [[ $# -gt 0 ]] || die "Missing argument to $A" + in_set "$1" "" 0 1 || die "invalid argument $A \"$1\"" + BCOND_DEFAULT_LTO="$1" + shift + ;; --default-for-test) [[ $# -gt 0 ]] || die "Missing argument to $A" in_set "$1" "" 0 1 || die "invalid argument $A \"$1\"" @@ -226,6 +240,7 @@ export NM_RPMBUILD_ARGS="${WITH_LIST[@]}" export SNAPSHOT export DO_RELEASE export BCOND_DEFAULT_DEBUG="$BCOND_DEFAULT_DEBUG" +export BCOND_DEFAULT_LTO="$BCOND_DEFAULT_LTO" export BCOND_DEFAULT_TEST="$BCOND_DEFAULT_TEST" "$SCRIPTDIR"/build.sh diff --git a/contrib/scripts/nm-copr-build.sh b/contrib/scripts/nm-copr-build.sh index ed3fad8ef4..d16465b838 100755 --- a/contrib/scripts/nm-copr-build.sh +++ b/contrib/scripts/nm-copr-build.sh @@ -18,9 +18,9 @@ else fi if [ "$LTO" = 0 ]; then - LTO='--without -lto' + LTO='--without lto' elif [ "$LTO" = 1 ]; then - LTO='--with -lto' + LTO='--with lto' else LTO= fi |