contrib: support disabling "LTO" in "nm-copr-build.sh"

The "nm-copr-build.sh" script is run by our copr to generate the SRPM of
NetworkManager (via `curl ... | bash`).

Building with LTO takes a long time, for testing it can be nice to disable
that. Add an environment variable for that. It can be used when manually
building an RPM in copr.
This commit is contained in:
Thomas Haller
2023-01-24 08:46:08 +01:00
parent 74f66ee276
commit 0566e9dc63

View File

@@ -2,7 +2,10 @@
# environment variables: # environment variables:
# - GIT_REF: the ref that should be build. Can be "main" or a git sha. # - GIT_REF: the ref that should be build. Can be "main" or a git sha.
# - DEBUG: set to 1 to build "--with debug". # - DEBUG: set to 1 to build "--with debug". Otherwise the default is a release
# build.
# - LTO: set to 1/0 to build "--with/--without lto", otherwise the default depends
# on the distribution.
# - NM_GIT_BUNDLE: set to a HTTP url where to fetch the nm-git-bundle-*.noarch.rpm # - NM_GIT_BUNDLE: set to a HTTP url where to fetch the nm-git-bundle-*.noarch.rpm
# from. Set to empty to skip it. By default, it fetches the bundle from copr. # from. Set to empty to skip it. By default, it fetches the bundle from copr.
@@ -14,6 +17,14 @@ else
DEBUG="--without debug" DEBUG="--without debug"
fi fi
if [ "$LTO" = 0 ]; then
LTO='--without -lto'
elif [ "$LTO" = 1 ]; then
LTO='--with -lto'
else
LTO=
fi
if [[ -z "$GIT_REF" ]]; then if [[ -z "$GIT_REF" ]]; then
echo "\$GIT_REF is not set!" echo "\$GIT_REF is not set!"
exit 1 exit 1
@@ -59,7 +70,7 @@ GIT_SHA="$(git show-ref --verify --hash "$GIT_REF" 2>/dev/null ||
git checkout -b tmp "$GIT_SHA" git checkout -b tmp "$GIT_SHA"
./contrib/fedora/rpm/build_clean.sh -g -S -w test $DEBUG -s copr ./contrib/fedora/rpm/build_clean.sh -g -S -w test $DEBUG $LTO -s copr
popd popd
mv ./NetworkManager/contrib/fedora/rpm/latest/{SOURCES,SPECS}/* . mv ./NetworkManager/contrib/fedora/rpm/latest/{SOURCES,SPECS}/* .