summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-02-02 12:57:35 +0100
committerThomas Haller <thaller@redhat.com>2016-02-02 19:02:40 +0100
commit6d342fb4c7bf4272cb98b3e23c128aa30ddc0f0d (patch)
tree17b6cafa190bc8f1989cb06ead80eeadf0b36210
parent4037b6c8bb167b339dd9df09070741d20d7e06ff (diff)
downloadNetworkManager-6d342fb4c7bf4272cb98b3e23c128aa30ddc0f0d.tar.gz
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 (cherry picked from commit 87dc14476b81d6f540abbd935b611c4910dc91cd)
-rw-r--r--contrib/fedora/rpm/NetworkManager.spec115
-rwxr-xr-xcontrib/fedora/rpm/build.sh2
-rwxr-xr-xcontrib/fedora/rpm/build_clean.sh16
3 files changed, 90 insertions, 43 deletions
diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec
index 0bbe0808ea..5ed6f1dc70 100644
--- a/contrib/fedora/rpm/NetworkManager.spec
+++ b/contrib/fedora/rpm/NetworkManager.spec
@@ -27,44 +27,69 @@
%global systemd_dir %{_prefix}/lib/systemd/system
%global udev_dir %{_prefix}/lib/udev
-%global with_adsl 1
-%global with_bluetooth 1
-%global with_team 1
-%global with_wifi 1
-%global with_wimax 0
-%global with_wwan 1
-%global with_nmtui 1
-%global regen_docs 1
+%global _hardened_build 1
+
+%global git_sha_version %(test -n '%{git_sha}' && echo '.%{git_sha}')
+
+###############################################################################
+
+%bcond_without adsl
+
+%global default_with_bluetooth 1
+%global default_with_wwan 1
# WiMAX still supported on <= F19
%if ! 0%{?rhel} && (! 0%{?fedora} || 0%{?fedora} < 20)
-%global with_wimax 1
+%bcond_without wimax
+%else
+%bcond_with wimax
%endif
# ModemManager on Fedora < 20 too old for Bluetooth && wwan
%if (0%{?fedora} && 0%{?fedora} < 20)
-%global with_bluetooth 0
-%global with_wwan 0
+%global default_with_bluetooth 0
+%global default_with_wwan 0
%endif
# Bluetooth requires the WWAN plugin
-%if 0%{?with_bluetooth}
-%global with_wwan 1
+%if 0%{?default_with_bluetooth}
+%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
%if (0%{?fedora} && 0%{?fedora} <= 19)
-%global with_team 0
+%bcond_with team
+%else
+%bcond_without team
%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
%else
%global with_modem_manager_1 0
%endif
-%global _hardened_build 1
-
-%global git_sha_version %(test -n '%{git_sha}' && echo '.%{git_sha}')
+###############################################################################
Name: NetworkManager
Summary: Network connection manager and user applications
@@ -131,7 +156,7 @@ BuildRequires: ppp-devel >= 2.4.5
BuildRequires: nss-devel >= 3.11.7
BuildRequires: dhclient
BuildRequires: readline-devel
-%if %{regen_docs}
+%if %{with regen_docs}
BuildRequires: gtk-doc
%endif
BuildRequires: libudev-devel
@@ -139,10 +164,10 @@ BuildRequires: libuuid-devel
BuildRequires: libgudev1-devel >= 143
BuildRequires: vala-tools
BuildRequires: iptables
-%if 0%{?with_bluetooth}
+%if %{with bluetooth}
BuildRequires: bluez-libs-devel
%endif
-%if 0%{?with_wimax}
+%if %{with wimax}
BuildRequires: wimax-devel
%endif
BuildRequires: systemd >= 200-3 systemd-devel
@@ -151,7 +176,7 @@ BuildRequires: libndp-devel >= 1.0
%if 0%{?with_modem_manager_1}
BuildRequires: ModemManager-glib-devel >= 1.0
%endif
-%if 0%{?with_nmtui}
+%if %{with nmtui}
BuildRequires: newt-devel
%endif
BuildRequires: /usr/bin/dbus-launch
@@ -169,7 +194,7 @@ Ethernet, Bridge, Bond, VLAN, Team, InfiniBand, Wi-Fi, mobile broadband
services.
-%if 0%{?with_adsl}
+%if %{with adsl}
%package adsl
Summary: ADSL device plugin for NetworkManager
Group: System Environment/Base
@@ -182,7 +207,7 @@ This package contains NetworkManager support for ADSL devices.
%endif
-%if 0%{?with_bluetooth}
+%if %{with bluetooth}
%package bluetooth
Summary: Bluetooth device plugin for NetworkManager
Group: System Environment/Base
@@ -197,7 +222,7 @@ This package contains NetworkManager support for Bluetooth devices.
%endif
-%if 0%{?with_team}
+%if 0%{with team}
%package team
Summary: Team device plugin for NetworkManager
Group: System Environment/Base
@@ -210,7 +235,7 @@ This package contains NetworkManager support for team devices.
%endif
-%if 0%{?with_wifi}
+%if %{with wifi}
%package wifi
Summary: Wifi plugin for NetworkManager
Group: System Environment/Base
@@ -223,7 +248,7 @@ This package contains NetworkManager support for Wifi and OLPC devices.
%endif
-%if 0%{?with_wwan}
+%if %{with wwan}
%package wwan
Summary: Mobile broadband device plugin for NetworkManager
Group: System Environment/Base
@@ -236,7 +261,7 @@ This package contains NetworkManager support for mobile broadband (WWAN) devices
%endif
-%if 0%{?with_wimax}
+%if %{with wimax}
%package wimax
Summary: Intel WiMAX device support for NetworkManager
Group: System Environment/Base
@@ -346,7 +371,7 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
%build
-%if %{regen_docs}
+%if %{with regen_docs}
# back up pristine docs and use them instead of generated ones, which make
# multilib unhappy due to different timestamps in the generated content
cp -R docs ORIG-docs
@@ -360,13 +385,17 @@ intltoolize --automake --copy --force
--with-dhcpcd=no \
--with-crypto=nss \
--enable-more-warnings=error \
+%if %{with debug}
+ --with-more-logging \
+ --with-more-asserts=10000 \
+%endif
--enable-ppp=yes \
%if 0%{?with_modem_manager_1}
--with-modem-manager-1=yes \
%else
--with-modem-manager-1=no \
%endif
-%if 0%{?with_wifi}
+%if %{with wifi}
--enable-wifi=yes \
%if 0%{?fedora}
--with-wext=yes \
@@ -376,18 +405,18 @@ intltoolize --automake --copy --force
%else
--enable-wifi=no \
%endif
-%if 0%{?with_wimax}
+%if %{with wimax}
--enable-wimax=yes \
%else
--enable-wimax=no \
%endif
--enable-vala=yes \
-%if 0%{?regen_docs}
+%if %{with regen_docs}
--enable-gtk-doc \
%else
--disable-gtk-doc \
%endif
-%if 0%{?with_team}
+%if %{with team}
--enable-teamdctl=yes \
%else
--enable-teamdctl=no \
@@ -449,7 +478,7 @@ rm -f %{buildroot}%{_libdir}/*.la
rm -f %{buildroot}%{_libdir}/pppd/%{ppp_version}/*.la
rm -f %{buildroot}%{_libdir}/NetworkManager/*.la
-%if %{regen_docs}
+%if %{with regen_docs}
# install the pristine docs
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/
@@ -457,7 +486,9 @@ cp ORIG-docs/libnm-util/html/* %{buildroot}%{_datadir}/gtk-doc/html/libnm-util/
%check
+%if %{with test}
make check
+%endif
%post
@@ -514,7 +545,7 @@ fi
%{_libexecdir}/nm-iface-helper
%dir %{_libdir}/NetworkManager
%{_libdir}/NetworkManager/libnm-settings-plugin*.so
-%if 0%{?with_nmtui}
+%if %{with nmtui}
%exclude %{_mandir}/man1/nmtui*
%endif
%dir %{_sysconfdir}/%{name}
@@ -540,35 +571,35 @@ fi
%doc NEWS AUTHORS README CONTRIBUTING TODO
%license COPYING
-%if 0%{?with_adsl}
+%if %{with adsl}
%files adsl
%{_libdir}/%{name}/libnm-device-plugin-adsl.so
%else
%exclude %{_libdir}/%{name}/libnm-device-plugin-adsl.so
%endif
-%if 0%{?with_bluetooth}
+%if %{with bluetooth}
%files bluetooth
%{_libdir}/%{name}/libnm-device-plugin-bluetooth.so
%endif
-%if 0%{?with_team}
+%if %{with team}
%files team
%{_libdir}/%{name}/libnm-device-plugin-team.so
%endif
-%if 0%{?with_wifi}
+%if %{with wifi}
%files wifi
%{_libdir}/%{name}/libnm-device-plugin-wifi.so
%endif
-%if 0%{?with_wwan}
+%if %{with wwan}
%files wwan
%{_libdir}/%{name}/libnm-device-plugin-wwan.so
%{_libdir}/%{name}/libnm-wwan.so
%endif
-%if 0%{?with_wimax}
+%if %{with wimax}
%files wimax
%{_libdir}/%{name}/libnm-device-plugin-wimax.so
%endif
@@ -635,7 +666,7 @@ fi
%dir %{_sysconfdir}/%{name}/conf.d
%config(noreplace) %{_sysconfdir}/%{name}/conf.d/00-server.conf
-%if 0%{?with_nmtui}
+%if %{with nmtui}
%files tui
%{_bindir}/nmtui
%{_bindir}/nmtui-edit
diff --git a/contrib/fedora/rpm/build.sh b/contrib/fedora/rpm/build.sh
index c1ededb554..8fe8066391 100755
--- a/contrib/fedora/rpm/build.sh
+++ b/contrib/fedora/rpm/build.sh
@@ -128,7 +128,7 @@ case "$BUILDTYPE" in
;;
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
TEMP_LATEST="$(readlink -f .)"/latest
diff --git a/contrib/fedora/rpm/build_clean.sh b/contrib/fedora/rpm/build_clean.sh
index a63910ad41..30d3f727db 100755
--- a/contrib/fedora/rpm/build_clean.sh
+++ b/contrib/fedora/rpm/build_clean.sh
@@ -32,8 +32,15 @@ IGNORE_DIRTY=0
GIT_CLEAN=0
QUICK=0
NO_BUILD=0
+WITH_LIST=()
+_next_with=
for A; do
+ if [ -n "$_next_with" ]; then
+ WITH_LIST=("${WITH_LIST[@]}" "$_next_with" "$A")
+ _next_with=
+ continue
+ fi
case "$A" in
-h|--help|-\?|help)
usage
@@ -55,6 +62,12 @@ for A; do
NO_BUILD=1
IGNORE_DIRTY=1
;;
+ -w|--with)
+ _next_with=--with
+ ;;
+ -W|--without)
+ _next_with=--without
+ ;;
*)
usage
die "Unexpected argument \"$A\""
@@ -62,6 +75,8 @@ for A; do
esac
done
+test -n "$_next_with" && die "Missing argument to $_next_with"
+
if [[ $GIT_CLEAN == 1 ]]; then
git clean -fdx :/
fi
@@ -96,6 +111,7 @@ if [[ $NO_BUILD != 1 ]]; then
fi
export BUILDTYPE
+export NM_RPMBUILD_ARGS="${WITH_LIST[@]}"
"$SCRIPTDIR"/build.sh