mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 12:05:03 +00:00
contrib/rpm: support default options for debug,test in generated spec file
"build_clean.sh" (and "build.sh") scripts can both create a source tarball (via `make dist`/`make distcheck`), an SRPM (and a spec file), or build RPMs from the SRPM. Note that the generated spec file has various options, like %bcond_without nmtui %bcond_without debug %bcond_without test When building an RPM from the SRPM, you can specify the "--with" or "--without" option for rpmbuild. This is also what the "-w" / "-W" options for "build_clean.sh" do. However, the SRPM still has the intrinsic defaults, and if you later build an RPM from it, you would have to pass "--with" / "--without" to rpmbuild. Often that is not conveniently possible, for example, when you build the SRPM in koji. Extend the scripts so that also the defaults for "-w debug" and "-w test" can be specified when generating the SRPM. You can do that with the new options "--default-for-{debug,test}" to "build_clean.sh". Alternatively, it suffices to specify the previously supported "-w" / "-W" options. That way, we will pass those options to rpmbuild, but also set them as defaults in the generate spec file. The new options "--default-for-{debug,test}" are only needed if you want the default in the spec file to be different then what you use when creating the SRPM.
This commit is contained in:
parent
3bf367594a
commit
a3f2cee0e6
|
@ -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_with meson
|
||||||
%bcond_without adsl
|
%bcond_without adsl
|
||||||
%bcond_without bluetooth
|
%bcond_without bluetooth
|
||||||
|
@ -57,8 +73,12 @@
|
||||||
%bcond_without nmtui
|
%bcond_without nmtui
|
||||||
%bcond_without nm_cloud_setup
|
%bcond_without nm_cloud_setup
|
||||||
%bcond_without regen_docs
|
%bcond_without regen_docs
|
||||||
|
%if %{bcond_default_debug}
|
||||||
|
%bcond_without debug
|
||||||
|
%else
|
||||||
%bcond_with debug
|
%bcond_with debug
|
||||||
%if 0%{?rhel} >= 9
|
%endif
|
||||||
|
%if %{bcond_default_test}
|
||||||
%bcond_without test
|
%bcond_without test
|
||||||
%else
|
%else
|
||||||
%bcond_with test
|
%bcond_with test
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
# SOURCE_SYSCTL_RP_FILTER_REDHAT=
|
# SOURCE_SYSCTL_RP_FILTER_REDHAT=
|
||||||
# SIGN_SOURCE=
|
# SIGN_SOURCE=
|
||||||
# DO_RELEASE=
|
# DO_RELEASE=
|
||||||
|
# BCOND_DEFAULT_DEBUG=
|
||||||
|
# BCOND_DEFAULT_TEST=
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "$*" >&2
|
echo "$*" >&2
|
||||||
|
@ -48,6 +50,15 @@ coerce_bool() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
in_set() {
|
||||||
|
local v="$1"
|
||||||
|
shift
|
||||||
|
for v2; do
|
||||||
|
test "$v" == "$v2" && return 0
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
abs_path() {
|
abs_path() {
|
||||||
local F="$1"
|
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 "SOURCE_SYSCTL_RP_FILTER_REDHAT=$SOURCE_SYSCTL_RP_FILTER_REDHAT"
|
||||||
LOG "BUILDTYPE=$BUILDTYPE"
|
LOG "BUILDTYPE=$BUILDTYPE"
|
||||||
LOG "NM_RPMBUILD_ARGS=$NM_RPMBUILD_ARGS"
|
LOG "NM_RPMBUILD_ARGS=$NM_RPMBUILD_ARGS"
|
||||||
|
LOG "BCOND_DEFAULT_DEBUG=$BCOND_DEFAULT_DEBUG"
|
||||||
|
LOG "BCOND_DEFAULT_TEST=$BCOND_DEFAULT_TEST"
|
||||||
LOG ""
|
LOG ""
|
||||||
LOG "UUID=$UUID"
|
LOG "UUID=$UUID"
|
||||||
LOG "BASEDIR=$TEMP"
|
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 -snf "$TEMPBASE" ./latest0
|
||||||
ln "$BUILDLOG" "$TEMPBASE/build.log"
|
ln "$BUILDLOG" "$TEMPBASE/build.log"
|
||||||
rm -f "$BUILDLOG"
|
rm -f "$BUILDLOG"
|
||||||
|
@ -186,6 +202,8 @@ sed -e "s/__VERSION__/$VERSION/g" \
|
||||||
-e "s/__COMMIT_FULL__/$COMMIT_FULL/g" \
|
-e "s/__COMMIT_FULL__/$COMMIT_FULL/g" \
|
||||||
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \
|
-e "s/__SNAPSHOT__/$SNAPSHOT/g" \
|
||||||
-e "s/__SOURCE1__/$(basename "$SOURCE")/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" |
|
"$SPECFILE" |
|
||||||
sed -e "/^__CHANGELOG__$/ \
|
sed -e "/^__CHANGELOG__$/ \
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,18 @@ usage() {
|
||||||
echo " -W|--without \$OPTION: pass --without \$OPTION to rpmbuild. For example --without debug"
|
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 " -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 " -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")"
|
ORIGDIR="$(readlink -f "$PWD")"
|
||||||
SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
|
SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
|
||||||
|
@ -45,6 +55,8 @@ WITH_LIST=()
|
||||||
SOURCE_FROM_GIT=0
|
SOURCE_FROM_GIT=0
|
||||||
SNAPSHOT="$NM_BUILD_SNAPSHOT"
|
SNAPSHOT="$NM_BUILD_SNAPSHOT"
|
||||||
DO_RELEASE=0
|
DO_RELEASE=0
|
||||||
|
unset BCOND_DEFAULT_DEBUG
|
||||||
|
unset BCOND_DEFAULT_TEST
|
||||||
|
|
||||||
ADD_WITH_TEST=1
|
ADD_WITH_TEST=1
|
||||||
|
|
||||||
|
@ -94,17 +106,29 @@ while [[ $# -gt 0 ]]; do
|
||||||
-w|--with)
|
-w|--with)
|
||||||
[[ $# -gt 0 ]] || die "Missing argument to $A"
|
[[ $# -gt 0 ]] || die "Missing argument to $A"
|
||||||
WITH_LIST=("${WITH_LIST[@]}" "--with" "$1")
|
WITH_LIST=("${WITH_LIST[@]}" "--with" "$1")
|
||||||
if [[ "$1" == test ]]; then
|
case "$1" in
|
||||||
ADD_WITH_TEST=0
|
debug)
|
||||||
fi
|
[[ -z ${BCOND_DEFAULT_DEBUG+.} ]] && BCOND_DEFAULT_DEBUG=1
|
||||||
|
;;
|
||||||
|
test)
|
||||||
|
ADD_WITH_TEST=0
|
||||||
|
[[ -z ${BCOND_DEFAULT_TEST+.} ]] && BCOND_DEFAULT_TEST=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-W|--without)
|
-W|--without)
|
||||||
[[ $# -gt 0 ]] || die "Missing argument to $A"
|
[[ $# -gt 0 ]] || die "Missing argument to $A"
|
||||||
WITH_LIST=("${WITH_LIST[@]}" "--without" "$1")
|
WITH_LIST=("${WITH_LIST[@]}" "--without" "$1")
|
||||||
if [[ "$1" == test ]]; then
|
case "$1" in
|
||||||
ADD_WITH_TEST=0
|
debug)
|
||||||
fi
|
[[ -z ${BCOND_DEFAULT_DEBUG+.} ]] && BCOND_DEFAULT_DEBUG=0
|
||||||
|
;;
|
||||||
|
test)
|
||||||
|
ADD_WITH_TEST=0
|
||||||
|
[[ -z ${BCOND_DEFAULT_TEST+.} ]] && BCOND_DEFAULT_TEST=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--no-auto-with-test)
|
--no-auto-with-test)
|
||||||
|
@ -115,6 +139,18 @@ while [[ $# -gt 0 ]]; do
|
||||||
# or "-W test".
|
# or "-W test".
|
||||||
ADD_WITH_TEST=0
|
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
|
usage
|
||||||
die "Unexpected argument \"$A\""
|
die "Unexpected argument \"$A\""
|
||||||
|
@ -184,6 +220,8 @@ export BUILDTYPE
|
||||||
export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
|
export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
|
||||||
export SNAPSHOT
|
export SNAPSHOT
|
||||||
export DO_RELEASE
|
export DO_RELEASE
|
||||||
|
export BCOND_DEFAULT_DEBUG="$BCOND_DEFAULT_DEBUG"
|
||||||
|
export BCOND_DEFAULT_TEST="$BCOND_DEFAULT_TEST"
|
||||||
|
|
||||||
"$SCRIPTDIR"/build.sh
|
"$SCRIPTDIR"/build.sh
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue