contrib/rpm: make build more configurable by using conditionals

Also add a new conditional "debug" to enable more assertions and
more logging, which is disabled by default.

Also add a conditional "test" to disable running the unit tests
(make check) while building the package.

http://rpm.org/wiki/PackagerDocs/ConditionalBuilds
This commit is contained in:
Thomas Haller 2016-02-02 12:57:35 +01:00
parent 3b01d25561
commit 87dc14476b
3 changed files with 83 additions and 37 deletions

View file

@ -28,38 +28,62 @@
%global udev_dir %{_prefix}/lib/udev %global udev_dir %{_prefix}/lib/udev
%global nmlibdir %{_prefix}/lib/%{name} %global nmlibdir %{_prefix}/lib/%{name}
%global with_adsl 1 %global _hardened_build 1
%global with_bluetooth 1
%global with_team 1 %global git_sha_version %(test -n '%{git_sha}' && echo '.%{git_sha}')
%global with_wifi 1
%global with_wwan 1 ###############################################################################
%global with_nmtui 1
%global regen_docs 1 %bcond_without adsl
%global default_with_bluetooth 1
%global default_with_wwan 1
# ModemManager on Fedora < 20 too old for Bluetooth && wwan # ModemManager on Fedora < 20 too old for Bluetooth && wwan
%if (0%{?fedora} && 0%{?fedora} < 20) %if (0%{?fedora} && 0%{?fedora} < 20)
%global with_bluetooth 0 %global default_with_bluetooth 0
%global with_wwan 0 %global default_with_wwan 0
%endif %endif
# Bluetooth requires the WWAN plugin # Bluetooth requires the WWAN plugin
%if 0%{?with_bluetooth} %if 0%{?default_with_bluetooth}
%global with_wwan 1 %global default_with_wwan 1
%endif
%if 0%{?default_with_bluetooth}
%bcond_without bluetooth
%else
%bcond_with bluetooth
%endif
%if 0%{?default_with_wwan}
%bcond_without wwan
%else
%bcond_with wwan
%endif %endif
%if (0%{?fedora} && 0%{?fedora} <= 19) %if (0%{?fedora} && 0%{?fedora} <= 19)
%global with_team 0 %bcond_with team
%else
%bcond_without team
%endif %endif
%if 0%{?with_bluetooth} || (0%{?with_wwan} && (0%{?rhel} || (0%{?fedora} && 0%{?fedora} > 19))) %bcond_without wifi
%bcond_without nmtui
%bcond_without regen_docs
%bcond_with debug
%bcond_without test
###############################################################################
%if %{with bluetooth} || (%{with wwan} && (0%{?rhel} || (0%{?fedora} && 0%{?fedora} > 19)))
%global with_modem_manager_1 1 %global with_modem_manager_1 1
%else %else
%global with_modem_manager_1 0 %global with_modem_manager_1 0
%endif %endif
%global _hardened_build 1 ###############################################################################
%global git_sha_version %(test -n '%{git_sha}' && echo '.%{git_sha}')
Name: NetworkManager Name: NetworkManager
Summary: Network connection manager and user applications Summary: Network connection manager and user applications
@ -125,7 +149,7 @@ BuildRequires: nss-devel >= 3.11.7
BuildRequires: dhclient BuildRequires: dhclient
BuildRequires: readline-devel BuildRequires: readline-devel
BuildRequires: audit-libs-devel BuildRequires: audit-libs-devel
%if %{regen_docs} %if %{with regen_docs}
BuildRequires: gtk-doc BuildRequires: gtk-doc
%endif %endif
BuildRequires: libudev-devel BuildRequires: libudev-devel
@ -133,7 +157,7 @@ BuildRequires: libuuid-devel
BuildRequires: libgudev1-devel >= 143 BuildRequires: libgudev1-devel >= 143
BuildRequires: vala-tools BuildRequires: vala-tools
BuildRequires: iptables BuildRequires: iptables
%if 0%{?with_bluetooth} %if %{with bluetooth}
BuildRequires: bluez-libs-devel BuildRequires: bluez-libs-devel
%endif %endif
BuildRequires: systemd >= 200-3 systemd-devel BuildRequires: systemd >= 200-3 systemd-devel
@ -142,7 +166,7 @@ BuildRequires: libndp-devel >= 1.0
%if 0%{?with_modem_manager_1} %if 0%{?with_modem_manager_1}
BuildRequires: ModemManager-glib-devel >= 1.0 BuildRequires: ModemManager-glib-devel >= 1.0
%endif %endif
%if 0%{?with_nmtui} %if %{with nmtui}
BuildRequires: newt-devel BuildRequires: newt-devel
%endif %endif
BuildRequires: /usr/bin/dbus-launch BuildRequires: /usr/bin/dbus-launch
@ -160,7 +184,7 @@ Ethernet, Bridge, Bond, VLAN, Team, InfiniBand, Wi-Fi, mobile broadband
services. services.
%if 0%{?with_adsl} %if %{with adsl}
%package adsl %package adsl
Summary: ADSL device plugin for NetworkManager Summary: ADSL device plugin for NetworkManager
Group: System Environment/Base Group: System Environment/Base
@ -173,7 +197,7 @@ This package contains NetworkManager support for ADSL devices.
%endif %endif
%if 0%{?with_bluetooth} %if %{with bluetooth}
%package bluetooth %package bluetooth
Summary: Bluetooth device plugin for NetworkManager Summary: Bluetooth device plugin for NetworkManager
Group: System Environment/Base Group: System Environment/Base
@ -188,7 +212,7 @@ This package contains NetworkManager support for Bluetooth devices.
%endif %endif
%if 0%{?with_team} %if 0%{with team}
%package team %package team
Summary: Team device plugin for NetworkManager Summary: Team device plugin for NetworkManager
Group: System Environment/Base Group: System Environment/Base
@ -203,7 +227,7 @@ This package contains NetworkManager support for team devices.
%endif %endif
%if 0%{?with_wifi} %if %{with wifi}
%package wifi %package wifi
Summary: Wifi plugin for NetworkManager Summary: Wifi plugin for NetworkManager
Group: System Environment/Base Group: System Environment/Base
@ -216,7 +240,7 @@ This package contains NetworkManager support for Wifi and OLPC devices.
%endif %endif
%if 0%{?with_wwan} %if %{with wwan}
%package wwan %package wwan
Summary: Mobile broadband device plugin for NetworkManager Summary: Mobile broadband device plugin for NetworkManager
Group: System Environment/Base Group: System Environment/Base
@ -323,7 +347,7 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
%build %build
%if %{regen_docs} %if %{with regen_docs}
# back up pristine docs and use them instead of generated ones, which make # back up pristine docs and use them instead of generated ones, which make
# multilib unhappy due to different timestamps in the generated content # multilib unhappy due to different timestamps in the generated content
cp -R docs ORIG-docs cp -R docs ORIG-docs
@ -337,6 +361,10 @@ intltoolize --automake --copy --force
--with-dhcpcd=no \ --with-dhcpcd=no \
--with-crypto=nss \ --with-crypto=nss \
--enable-more-warnings=error \ --enable-more-warnings=error \
%if %{with debug}
--with-more-logging \
--with-more-asserts=10000 \
%endif
--enable-ppp=yes \ --enable-ppp=yes \
--with-libaudit=yes-disabled-by-default \ --with-libaudit=yes-disabled-by-default \
%if 0%{?with_modem_manager_1} %if 0%{?with_modem_manager_1}
@ -344,7 +372,7 @@ intltoolize --automake --copy --force
%else %else
--with-modem-manager-1=no \ --with-modem-manager-1=no \
%endif %endif
%if 0%{?with_wifi} %if %{with wifi}
--enable-wifi=yes \ --enable-wifi=yes \
%if 0%{?fedora} %if 0%{?fedora}
--with-wext=yes \ --with-wext=yes \
@ -355,12 +383,12 @@ intltoolize --automake --copy --force
--enable-wifi=no \ --enable-wifi=no \
%endif %endif
--enable-vala=yes \ --enable-vala=yes \
%if 0%{?regen_docs} %if %{with regen_docs}
--enable-gtk-doc \ --enable-gtk-doc \
%else %else
--disable-gtk-doc \ --disable-gtk-doc \
%endif %endif
%if 0%{?with_team} %if %{with team}
--enable-teamdctl=yes \ --enable-teamdctl=yes \
%else %else
--enable-teamdctl=no \ --enable-teamdctl=no \
@ -425,7 +453,7 @@ rm -f %{buildroot}%{_libdir}/*.la
rm -f %{buildroot}%{_libdir}/pppd/%{ppp_version}/*.la rm -f %{buildroot}%{_libdir}/pppd/%{ppp_version}/*.la
rm -f %{buildroot}%{_libdir}/NetworkManager/*.la rm -f %{buildroot}%{_libdir}/NetworkManager/*.la
%if %{regen_docs} %if %{with regen_docs}
# install the pristine docs # install the pristine docs
cp ORIG-docs/libnm-glib/html/* %{buildroot}%{_datadir}/gtk-doc/html/libnm-glib/ cp ORIG-docs/libnm-glib/html/* %{buildroot}%{_datadir}/gtk-doc/html/libnm-glib/
cp ORIG-docs/libnm-util/html/* %{buildroot}%{_datadir}/gtk-doc/html/libnm-util/ cp ORIG-docs/libnm-util/html/* %{buildroot}%{_datadir}/gtk-doc/html/libnm-util/
@ -433,7 +461,9 @@ cp ORIG-docs/libnm-util/html/* %{buildroot}%{_datadir}/gtk-doc/html/libnm-util/
%check %check
%if %{with test}
make check make check
%endif
%post %post
@ -490,7 +520,7 @@ fi
%{_libexecdir}/nm-iface-helper %{_libexecdir}/nm-iface-helper
%dir %{_libdir}/NetworkManager %dir %{_libdir}/NetworkManager
%{_libdir}/NetworkManager/libnm-settings-plugin*.so %{_libdir}/NetworkManager/libnm-settings-plugin*.so
%if 0%{?with_nmtui} %if %{with nmtui}
%exclude %{_mandir}/man1/nmtui* %exclude %{_mandir}/man1/nmtui*
%endif %endif
%dir %{_sysconfdir}/%{name} %dir %{_sysconfdir}/%{name}
@ -518,29 +548,29 @@ fi
%doc NEWS AUTHORS README CONTRIBUTING TODO %doc NEWS AUTHORS README CONTRIBUTING TODO
%license COPYING %license COPYING
%if 0%{?with_adsl} %if %{with adsl}
%files adsl %files adsl
%{_libdir}/%{name}/libnm-device-plugin-adsl.so %{_libdir}/%{name}/libnm-device-plugin-adsl.so
%else %else
%exclude %{_libdir}/%{name}/libnm-device-plugin-adsl.so %exclude %{_libdir}/%{name}/libnm-device-plugin-adsl.so
%endif %endif
%if 0%{?with_bluetooth} %if %{with bluetooth}
%files bluetooth %files bluetooth
%{_libdir}/%{name}/libnm-device-plugin-bluetooth.so %{_libdir}/%{name}/libnm-device-plugin-bluetooth.so
%endif %endif
%if 0%{?with_team} %if %{with team}
%files team %files team
%{_libdir}/%{name}/libnm-device-plugin-team.so %{_libdir}/%{name}/libnm-device-plugin-team.so
%endif %endif
%if 0%{?with_wifi} %if %{with wifi}
%files wifi %files wifi
%{_libdir}/%{name}/libnm-device-plugin-wifi.so %{_libdir}/%{name}/libnm-device-plugin-wifi.so
%endif %endif
%if 0%{?with_wwan} %if %{with wwan}
%files wwan %files wwan
%{_libdir}/%{name}/libnm-device-plugin-wwan.so %{_libdir}/%{name}/libnm-device-plugin-wwan.so
%{_libdir}/%{name}/libnm-wwan.so %{_libdir}/%{name}/libnm-wwan.so
@ -608,7 +638,7 @@ fi
%dir %{nmlibdir}/conf.d %dir %{nmlibdir}/conf.d
%{nmlibdir}/conf.d/00-server.conf %{nmlibdir}/conf.d/00-server.conf
%if 0%{?with_nmtui} %if %{with nmtui}
%files tui %files tui
%{_bindir}/nmtui %{_bindir}/nmtui
%{_bindir}/nmtui-edit %{_bindir}/nmtui-edit

View file

@ -125,7 +125,7 @@ case "$BUILDTYPE" in
;; ;;
esac esac
rpmbuild --define "_topdir $TEMP" $RPM_BUILD_OPTION "$TEMPSPEC" || die "ERROR: rpmbuild FAILED" rpmbuild --define "_topdir $TEMP" $RPM_BUILD_OPTION "$TEMPSPEC" $NM_RPMBUILD_ARGS || die "ERROR: rpmbuild FAILED"
ln -snf "$TEMPBASE" ./latest ln -snf "$TEMPBASE" ./latest
TEMP_LATEST="$(readlink -f .)"/latest TEMP_LATEST="$(readlink -f .)"/latest

View file

@ -32,8 +32,15 @@ IGNORE_DIRTY=0
GIT_CLEAN=0 GIT_CLEAN=0
QUICK=0 QUICK=0
NO_BUILD=0 NO_BUILD=0
WITH_LIST=()
_next_with=
for A; do for A; do
if [ -n "$_next_with" ]; then
WITH_LIST=("${WITH_LIST[@]}" "$_next_with" "$A")
_next_with=
continue
fi
case "$A" in case "$A" in
-h|--help|-\?|help) -h|--help|-\?|help)
usage usage
@ -55,6 +62,12 @@ for A; do
NO_BUILD=1 NO_BUILD=1
IGNORE_DIRTY=1 IGNORE_DIRTY=1
;; ;;
-w|--with)
_next_with=--with
;;
-W|--without)
_next_with=--without
;;
*) *)
usage usage
die "Unexpected argument \"$A\"" die "Unexpected argument \"$A\""
@ -62,6 +75,8 @@ for A; do
esac esac
done done
test -n "$_next_with" && die "Missing argument to $_next_with"
if [[ $GIT_CLEAN == 1 ]]; then if [[ $GIT_CLEAN == 1 ]]; then
git clean -fdx :/ git clean -fdx :/
fi fi
@ -96,6 +111,7 @@ if [[ $NO_BUILD != 1 ]]; then
fi fi
export BUILDTYPE export BUILDTYPE
export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
"$SCRIPTDIR"/build.sh "$SCRIPTDIR"/build.sh