contrib/rpm: add spec file and script to build a RPM package
This one spec file is intended to build packages for F18, F19, F20, and rhel-7.0. The build script can be tweaked by setting environment variables, but it is supposed to choose the right default values on it's own. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
3
contrib/fedora/rpm/.gitignore
vendored
Normal file
3
contrib/fedora/rpm/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/NetworkManager.*.??????/
|
||||
/latest0
|
||||
/latest
|
20
contrib/fedora/rpm/00-server.conf
Normal file
20
contrib/fedora/rpm/00-server.conf
Normal file
@@ -0,0 +1,20 @@
|
||||
# This configuration file, when placed into into
|
||||
# /etc/NetworkManager/conf.d changes NetworkManager's behavior to
|
||||
# what's expected on "traditional UNIX server" type deployments.
|
||||
#
|
||||
# See "man NetworkManager.conf" for more information about these
|
||||
# and other keys.
|
||||
#
|
||||
# Do not edit this file; it will be overwritten on upgrades. If you
|
||||
# want to override the values here, or set additional values, you can
|
||||
# do so by adding another file (eg, "99-local.conf") to this directory
|
||||
# and setting keys there.
|
||||
|
||||
[main]
|
||||
# Do not do automatic (DHCP/SLAAC) configuration on ethernet devices
|
||||
# with no other matching connections.
|
||||
no-auto-default=*
|
||||
|
||||
# Ignore the carrier (cable plugged in) state when attempting to
|
||||
# activate static-IP connections.
|
||||
ignore-carrier=*
|
2
contrib/fedora/rpm/NetworkManager.conf
Normal file
2
contrib/fedora/rpm/NetworkManager.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
[main]
|
||||
plugins=ifcfg-rh
|
463
contrib/fedora/rpm/NetworkManager.spec
Normal file
463
contrib/fedora/rpm/NetworkManager.spec
Normal file
@@ -0,0 +1,463 @@
|
||||
# SPEC file to build NetworkManager for testing. It aims for a similar
|
||||
# configuration as rhel-7.0 and Fedora rawhide
|
||||
#
|
||||
# This spec file is not used to create any packages for RHEL, Fedora or any
|
||||
# other distribution.
|
||||
|
||||
%define dbus_version 1.1
|
||||
%define dbus_glib_version 0.94
|
||||
|
||||
%define glib2_version 2.24.0
|
||||
%define wireless_tools_version 1:28-0pre9
|
||||
%define libnl3_version 3.2.7
|
||||
%define ppp_version 2.4.5
|
||||
%define nmtui_version __NMTUI_VERSION__
|
||||
|
||||
%define snapshot %{nil}
|
||||
%define git_sha __COMMIT__
|
||||
%define realversion __VERSION__
|
||||
|
||||
%if 0%{?fedora}
|
||||
%global regen_docs 1
|
||||
%else
|
||||
#%global regen_docs 0
|
||||
%global regen_docs 1
|
||||
%endif
|
||||
|
||||
%global with_nmtui __WITH_NMTUI__
|
||||
|
||||
%define systemd_dir %{_prefix}/lib/systemd/system
|
||||
%define udev_dir %{_prefix}/lib/udev
|
||||
|
||||
%if ! 0%{?rhel}
|
||||
%ifnarch s390 s390x
|
||||
# No wimax or bluetooth on s390
|
||||
%global with_wimax 1
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%global _hardened_build 1
|
||||
|
||||
Name: NetworkManager
|
||||
Summary: Network connection manager and user applications
|
||||
Epoch: 1
|
||||
Version: %{realversion}
|
||||
Release: __RELEASE_VERSION__%{snapshot}.%{git_sha}%{?dist}
|
||||
Group: System Environment/Base
|
||||
License: GPLv2+
|
||||
URL: http://www.gnome.org/projects/NetworkManager/
|
||||
|
||||
Source: __SOURCE1__
|
||||
Source1: NetworkManager.conf
|
||||
Source2: 00-server.conf
|
||||
#Source3: nmtui-%{nmtui_version}.tar.xz
|
||||
__SOURCE_NMTUI__3
|
||||
|
||||
#Patch1: some.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
%if 0%{?fedora}
|
||||
Requires(post): chkconfig
|
||||
Requires(preun): chkconfig
|
||||
%endif
|
||||
Requires(post): systemd-sysv
|
||||
Requires(post): systemd
|
||||
Requires(preun): systemd
|
||||
Requires(postun): systemd
|
||||
|
||||
Requires: dbus >= %{dbus_version}
|
||||
Requires: dbus-glib >= %{dbus_glib_version}
|
||||
Requires: glib2 >= %{glib2_version}
|
||||
Requires: iproute
|
||||
Requires: dhclient >= 12:4.1.0
|
||||
Requires: wpa_supplicant >= 1:0.7.3-1
|
||||
Requires: libnl3 >= %{libnl3_version}
|
||||
Requires: %{name}-glib%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: ppp = %{ppp_version}
|
||||
Requires: avahi-autoipd
|
||||
Requires: dnsmasq
|
||||
Requires: udev
|
||||
Requires: iptables
|
||||
Obsoletes: dhcdbd
|
||||
|
||||
Conflicts: NetworkManager-vpnc < 1:0.7.0.99-1
|
||||
Conflicts: NetworkManager-openvpn < 1:0.7.0.99-1
|
||||
Conflicts: NetworkManager-pptp < 1:0.7.0.99-1
|
||||
Conflicts: NetworkManager-openconnect < 0:0.7.0.99-1
|
||||
Conflicts: kde-plasma-networkmanagement < 1:0.9-0.49.20110527git.nm09
|
||||
|
||||
BuildRequires: dbus-devel >= %{dbus_version}
|
||||
BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
|
||||
%if 0%{?fedora}
|
||||
BuildRequires: wireless-tools-devel >= %{wireless_tools_version}
|
||||
%endif
|
||||
BuildRequires: glib2-devel >= %{glib2_version}
|
||||
BuildRequires: gobject-introspection-devel >= 0.10.3
|
||||
BuildRequires: gettext-devel
|
||||
BuildRequires: /usr/bin/autopoint
|
||||
BuildRequires: pkgconfig
|
||||
BuildRequires: wpa_supplicant
|
||||
BuildRequires: libnl3-devel >= %{libnl3_version}
|
||||
BuildRequires: perl(XML::Parser)
|
||||
BuildRequires: automake autoconf intltool libtool
|
||||
BuildRequires: ppp = %{ppp_version}
|
||||
BuildRequires: ppp-devel = %{ppp_version}
|
||||
BuildRequires: nss-devel >= 3.11.7
|
||||
BuildRequires: polkit-devel
|
||||
BuildRequires: dhclient
|
||||
%if %{regen_docs}
|
||||
BuildRequires: gtk-doc
|
||||
%endif
|
||||
BuildRequires: libudev-devel
|
||||
BuildRequires: libuuid-devel
|
||||
BuildRequires: libgudev1-devel >= 143
|
||||
BuildRequires: vala-tools
|
||||
BuildRequires: iptables
|
||||
%if 0%{?with_wimax}
|
||||
BuildRequires: wimax-devel
|
||||
%endif
|
||||
BuildRequires: systemd >= 200-3 systemd-devel
|
||||
BuildRequires: libsoup-devel
|
||||
BuildRequires: libndp-devel >= 1.0
|
||||
%if 0%{?rhel} || (0%{?fedora} && 0%{?fedora} > 19)
|
||||
BuildRequires: ModemManager-glib-devel >= 1.0
|
||||
%endif
|
||||
%if 0%{?with_nmtui}
|
||||
BuildRequires: newt-devel
|
||||
%endif
|
||||
%if 0%{?rhel}
|
||||
BuildRequires: teamd-devel
|
||||
%endif
|
||||
|
||||
|
||||
%description
|
||||
NetworkManager is a system network service that manages your network devices
|
||||
and connections, attempting to keep active network connectivity when available.
|
||||
It manages ethernet, WiFi, mobile broadband (WWAN), and PPPoE devices, and
|
||||
provides VPN integration with a variety of different VPN services.
|
||||
|
||||
|
||||
%if 0%{?with_wimax}
|
||||
%package wimax
|
||||
Summary: Intel WiMAX device support for NetworkManager
|
||||
Group: System Environment/Base
|
||||
Requires: wimax
|
||||
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
|
||||
%description wimax
|
||||
This package contains NetworkManager support for Intel WiMAX mobile broadband
|
||||
devices.
|
||||
%endif
|
||||
|
||||
|
||||
%package devel
|
||||
Summary: Libraries and headers for adding NetworkManager support to applications
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: dbus-devel >= %{dbus_version}
|
||||
Requires: dbus-glib >= %{dbus_glib_version}
|
||||
Requires: pkgconfig
|
||||
|
||||
%description devel
|
||||
This package contains various headers accessing some NetworkManager functionality
|
||||
from applications.
|
||||
|
||||
|
||||
%package glib
|
||||
Summary: Libraries for adding NetworkManager support to applications that use glib.
|
||||
Group: Development/Libraries
|
||||
Requires: dbus >= %{dbus_version}
|
||||
Requires: dbus-glib >= %{dbus_glib_version}
|
||||
|
||||
%description glib
|
||||
This package contains the libraries that make it easier to use some NetworkManager
|
||||
functionality from applications that use glib.
|
||||
|
||||
|
||||
%package glib-devel
|
||||
Summary: Header files for adding NetworkManager support to applications that use glib.
|
||||
Group: Development/Libraries
|
||||
Requires: %{name}-devel%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: %{name}-glib%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: glib2-devel
|
||||
Requires: pkgconfig
|
||||
Requires: dbus-glib-devel >= %{dbus_glib_version}
|
||||
|
||||
%description glib-devel
|
||||
This package contains the header and pkg-config files for development applications using
|
||||
NetworkManager functionality from applications that use glib.
|
||||
|
||||
%package config-server
|
||||
Summary: NetworkManager config file for "server-like" defaults
|
||||
Group: System Environment/Base
|
||||
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
|
||||
%description config-server
|
||||
This adds a NetworkManager configuration file to make it behave more
|
||||
like the old "network" service. In particular, it stops NetworkManager
|
||||
from automatically running DHCP on unconfigured ethernet devices, and
|
||||
allows connections with static IP addresses to be brought up even on
|
||||
ethernet devices with no carrier.
|
||||
|
||||
This package is intended to be installed by default for server
|
||||
deployments.
|
||||
|
||||
%if 0%{with_nmtui}
|
||||
%package tui
|
||||
Summary: NetworkManager curses-based UI
|
||||
Group: System Environment/Base
|
||||
Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
Requires: %{name}-glib%{?_isa} = %{epoch}:%{version}-%{release}
|
||||
|
||||
%description tui
|
||||
This adds a curses-based "TUI" (Text User Interface) to
|
||||
NetworkManager, to allow performing some of the operations supported
|
||||
by nm-connection-editor and nm-applet in a non-graphical environment.
|
||||
%endif
|
||||
|
||||
%prep
|
||||
%setup -q -n NetworkManager-%{realversion}
|
||||
|
||||
# nmtui
|
||||
%if 0%{with_nmtui}
|
||||
tar -xf %{SOURCE3}
|
||||
%endif
|
||||
|
||||
#%patch1 -p1 -b .some
|
||||
|
||||
%build
|
||||
|
||||
%if %{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
|
||||
%endif
|
||||
|
||||
#autopoint --force
|
||||
#intltoolize --force
|
||||
%configure \
|
||||
--disable-static \
|
||||
--with-dhclient=yes \
|
||||
--with-dhcpcd=no \
|
||||
--with-crypto=nss \
|
||||
--enable-more-warnings=error \
|
||||
--enable-ppp=yes \
|
||||
%if 0%{?rhel}
|
||||
--with-modem-manager-1=yes \
|
||||
%else
|
||||
--with-modem-manager-1=no \
|
||||
%endif
|
||||
%if 0%{?with_wimax}
|
||||
--enable-wimax=yes \
|
||||
%else
|
||||
--enable-wimax=no \
|
||||
%endif
|
||||
--enable-vala=yes \
|
||||
%if 0%{?regen_docs}
|
||||
--enable-gtk-doc \
|
||||
%endif
|
||||
%if 0%{?fedora}
|
||||
--with-wext=yes \
|
||||
%else
|
||||
--with-wext=no \
|
||||
%endif
|
||||
--enable-polkit=yes \
|
||||
--enable-modify-system=yes \
|
||||
--enable-concheck \
|
||||
--with-session-tracking=systemd \
|
||||
--with-suspend-resume=systemd \
|
||||
--with-systemdsystemunitdir=%{systemd_dir} \
|
||||
--with-udev-dir=%{udev_dir} \
|
||||
--with-system-ca-path=/etc/pki/tls/certs \
|
||||
--with-tests=yes \
|
||||
--with-valgrind=no \
|
||||
--enable-ifcfg-rh=yes \
|
||||
--with-system-libndp=yes \
|
||||
--with-pppd-plugin-dir=%{_libdir}/pppd/%{ppp_version} \
|
||||
--with-dist-version=%{version}-%{release}
|
||||
|
||||
make %{?_smp_mflags}
|
||||
|
||||
# nmtui
|
||||
%if 0%{with_nmtui}
|
||||
pushd nmtui-%{nmtui_version}
|
||||
NETWORKMANAGER_CFLAGS='-I$(top_builddir)/../include -I$(top_builddir)/../libnm-util -I$(top_builddir)/../libnm-glib `pkg-config --cflags gio-2.0 dbus-glib-1`'
|
||||
export NETWORKMANAGER_CFLAGS
|
||||
NETWORKMANAGER_LIBS='-L$(top_builddir)/../libnm-util/.libs -L$(top_builddir)/../libnm-glib/.libs -lnm-util -lnm-glib `pkg-config --libs gio-2.0 dbus-glib-1`'
|
||||
export NETWORKMANAGER_LIBS
|
||||
%configure
|
||||
make %{?_smp_mflags}
|
||||
popd
|
||||
%endif
|
||||
|
||||
%install
|
||||
%{__rm} -rf $RPM_BUILD_ROOT
|
||||
|
||||
# install NM
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
%{__cp} %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/conf.d
|
||||
%{__cp} %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/conf.d
|
||||
|
||||
# create a VPN directory
|
||||
%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/VPN
|
||||
|
||||
# create a keyfile plugin system settings directory
|
||||
%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/system-connections
|
||||
|
||||
# create a dnsmasq.d directory
|
||||
%{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dnsmasq.d
|
||||
|
||||
%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/gnome-vpn-properties
|
||||
|
||||
%{__mkdir_p} $RPM_BUILD_ROOT%{_localstatedir}/lib/NetworkManager
|
||||
|
||||
%find_lang %{name}
|
||||
|
||||
%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/*.la
|
||||
%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/pppd/%{ppp_version}/*.la
|
||||
%{__rm} -f $RPM_BUILD_ROOT%{_libdir}/NetworkManager/*.la
|
||||
|
||||
install -m 0755 test/.libs/nm-online %{buildroot}/%{_bindir}
|
||||
|
||||
%if %{regen_docs}
|
||||
# install the pristine docs
|
||||
%{__cp} ORIG-docs/libnm-glib/html/* $RPM_BUILD_ROOT%{_datadir}/gtk-doc/html/libnm-glib/
|
||||
%{__cp} ORIG-docs/libnm-util/html/* $RPM_BUILD_ROOT%{_datadir}/gtk-doc/html/libnm-util/
|
||||
%endif
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT%{systemd_dir}/network-online.target.wants
|
||||
ln -s ../NetworkManager-wait-online.service $RPM_BUILD_ROOT%{systemd_dir}/network-online.target.wants
|
||||
|
||||
# install nmtui
|
||||
%if 0%{with_nmtui}
|
||||
pushd nmtui-%{nmtui_version}
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
popd
|
||||
%endif
|
||||
|
||||
%clean
|
||||
%{__rm} -rf $RPM_BUILD_ROOT
|
||||
|
||||
|
||||
%post
|
||||
%systemd_post NetworkManager.service NetworkManager-wait-online.service NetworkManager-dispatcher.service
|
||||
|
||||
%preun
|
||||
if [ $1 -eq 0 ]; then
|
||||
# Package removal, not upgrade
|
||||
/bin/systemctl --no-reload disable NetworkManager.service >/dev/null 2>&1 || :
|
||||
|
||||
# Don't kill networking entirely just on package remove
|
||||
#/bin/systemctl stop NetworkManager.service >/dev/null 2>&1 || :
|
||||
fi
|
||||
%systemd_preun NetworkManager-wait-online.service NetworkManager-dispatcher.service
|
||||
|
||||
%postun
|
||||
%systemd_postun
|
||||
|
||||
%post glib -p /sbin/ldconfig
|
||||
%postun glib -p /sbin/ldconfig
|
||||
|
||||
|
||||
%files -f %{name}.lang
|
||||
%defattr(-,root,root,0755)
|
||||
%doc COPYING NEWS AUTHORS README CONTRIBUTING TODO
|
||||
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.NetworkManager.conf
|
||||
%{_sysconfdir}/dbus-1/system.d/nm-avahi-autoipd.conf
|
||||
%{_sysconfdir}/dbus-1/system.d/nm-dispatcher.conf
|
||||
%{_sysconfdir}/dbus-1/system.d/nm-ifcfg-rh.conf
|
||||
%{_sbindir}/%{name}
|
||||
%{_bindir}/nmcli
|
||||
%{_datadir}/bash-completion/completions/nmcli
|
||||
%dir %{_sysconfdir}/%{name}/
|
||||
%dir %{_sysconfdir}/%{name}/dispatcher.d
|
||||
%dir %{_sysconfdir}/%{name}/dnsmasq.d
|
||||
%dir %{_sysconfdir}/%{name}/VPN
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/NetworkManager.conf
|
||||
%{_bindir}/nm-online
|
||||
%{_libexecdir}/nm-dhcp-helper
|
||||
%{_libexecdir}/nm-avahi-autoipd.action
|
||||
%{_libexecdir}/nm-dispatcher.action
|
||||
%dir %{_libdir}/NetworkManager
|
||||
%{_libdir}/NetworkManager/libnm-settings-plugin*.so
|
||||
%{_mandir}/man1/*
|
||||
%{_mandir}/man5/*
|
||||
%{_mandir}/man8/*
|
||||
%dir %{_localstatedir}/lib/NetworkManager
|
||||
%dir %{_sysconfdir}/NetworkManager/system-connections
|
||||
%{_datadir}/dbus-1/system-services/org.freedesktop.NetworkManager.service
|
||||
%{_datadir}/dbus-1/system-services/org.freedesktop.nm_dispatcher.service
|
||||
%{_libdir}/pppd/%{ppp_version}/nm-pppd-plugin.so
|
||||
%{_datadir}/polkit-1/actions/*.policy
|
||||
%{udev_dir}/rules.d/*.rules
|
||||
# systemd stuff
|
||||
%{systemd_dir}/NetworkManager.service
|
||||
%{systemd_dir}/NetworkManager-wait-online.service
|
||||
%{systemd_dir}/NetworkManager-dispatcher.service
|
||||
%{systemd_dir}/network-online.target.wants/NetworkManager-wait-online.service
|
||||
%{_datadir}/doc/NetworkManager/examples/server.conf
|
||||
|
||||
%if 0%{?with_wimax}
|
||||
%files wimax
|
||||
%defattr(-,root,root,0755)
|
||||
%{_libdir}/%{name}/libnm-device-plugin-wimax.so
|
||||
%endif
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root,0755)
|
||||
%doc ChangeLog docs/api/html/*
|
||||
%dir %{_includedir}/%{name}
|
||||
%{_includedir}/%{name}/%{name}.h
|
||||
%{_includedir}/%{name}/NetworkManagerVPN.h
|
||||
%{_includedir}/%{name}/nm-version.h
|
||||
%{_libdir}/pkgconfig/%{name}.pc
|
||||
%dir %{_datadir}/gtk-doc/html/NetworkManager
|
||||
%{_datadir}/gtk-doc/html/NetworkManager/*
|
||||
%{_datadir}/vala/vapi/*.deps
|
||||
%{_datadir}/vala/vapi/*.vapi
|
||||
|
||||
%files glib
|
||||
%defattr(-,root,root,0755)
|
||||
%{_libdir}/libnm-glib.so.*
|
||||
%{_libdir}/libnm-glib-vpn.so.*
|
||||
%{_libdir}/libnm-util.so.*
|
||||
%{_libdir}/girepository-1.0/NetworkManager-1.0.typelib
|
||||
%{_libdir}/girepository-1.0/NMClient-1.0.typelib
|
||||
|
||||
%files glib-devel
|
||||
%defattr(-,root,root,0755)
|
||||
%dir %{_includedir}/libnm-glib
|
||||
%{_includedir}/libnm-glib/*.h
|
||||
%{_includedir}/%{name}/nm-setting*.h
|
||||
%{_includedir}/%{name}/nm-connection.h
|
||||
%{_includedir}/%{name}/nm-utils-enum-types.h
|
||||
%{_includedir}/%{name}/nm-utils.h
|
||||
%{_libdir}/pkgconfig/libnm-glib.pc
|
||||
%{_libdir}/pkgconfig/libnm-glib-vpn.pc
|
||||
%{_libdir}/pkgconfig/libnm-util.pc
|
||||
%{_libdir}/libnm-glib.so
|
||||
%{_libdir}/libnm-glib-vpn.so
|
||||
%{_libdir}/libnm-util.so
|
||||
%{_datadir}/gir-1.0/NetworkManager-1.0.gir
|
||||
%{_datadir}/gir-1.0/NMClient-1.0.gir
|
||||
%dir %{_datadir}/gtk-doc/html/libnm-glib
|
||||
%{_datadir}/gtk-doc/html/libnm-glib/*
|
||||
%dir %{_datadir}/gtk-doc/html/libnm-util
|
||||
%{_datadir}/gtk-doc/html/libnm-util/*
|
||||
|
||||
%files config-server
|
||||
%defattr(-,root,root,0755)
|
||||
%config %{_sysconfdir}/%{name}/conf.d/00-server.conf
|
||||
|
||||
%if 0%{with_nmtui}
|
||||
%files tui
|
||||
%{_bindir}/nmtui-edit
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
__CHANGELOG__
|
||||
|
145
contrib/fedora/rpm/build.sh
Executable file
145
contrib/fedora/rpm/build.sh
Executable file
@@ -0,0 +1,145 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -vx
|
||||
|
||||
die() {
|
||||
echo "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# copy output also to logfile
|
||||
LOG() {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
abs_path() {
|
||||
local F="$1"
|
||||
local ALT="$2"
|
||||
|
||||
if [[ "$F" != "" ]]; then
|
||||
(cd "$ORIGDIR" && readlink -f "$F") || die "Could not change into $ORIGDIR"
|
||||
else
|
||||
echo "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
get_version() {
|
||||
local major minor micro nano
|
||||
local F="${1:-"$GITDIR/configure.ac"}"
|
||||
|
||||
vars="$(sed -n 's/^m4_define(\[nm_\(major\|minor\|micro\|nano\)_version\], *\[\([0-9]\+\)\]) *$/local \1='\''\2'\''/p' "$F" 2>/dev/null)"
|
||||
eval "$vars"
|
||||
|
||||
[[ -n "$major" && -n "$minor" && "$micro" && "$nano" ]] || return 1
|
||||
echo "$major.$minor.$micro.$nano"
|
||||
}
|
||||
|
||||
|
||||
setup_nmtui() {
|
||||
NMTUI="$(abs_path "$NMTUI" "")"
|
||||
if [[ "$NMTUI" == "" ]]; then
|
||||
NMTUI="$(ls -1 "$GITDIR"/nmtui-*.tar* 2>/dev/null | sort | head -n1)"
|
||||
fi
|
||||
if [[ "$NMTUI" != "" ]]; then
|
||||
if [[ "$NMTUI_VERSION" == "" ]]; then
|
||||
NMTUI_VERSION="$(basename "$NMTUI" | sed -n 's/^nmtui-\([0-9]\+\.[0-9]\+\.[0-9]\+\)\.tar.*$/\1/p')"
|
||||
[[ "$NMTUI_VERSION" != "" ]] || die "error detecting nmtui version. Set NMTUI_VERSION?"
|
||||
fi
|
||||
WITH_NMTUI=1
|
||||
else
|
||||
echo "Build without nmtui"
|
||||
NMTUI_VERSION=0
|
||||
WITH_NMTUI=0
|
||||
fi
|
||||
}
|
||||
|
||||
ORIGDIR="$(readlink -f "$PWD")"
|
||||
SCRIPTDIR="$(readlink -f "$(dirname "$0")")"
|
||||
LOG "Change to directory \"$SCRIPTDIR\""
|
||||
cd "$SCRIPTDIR" || die "could not change into $SCRIPTDIR"
|
||||
GITDIR="$(cd "$SCRIPTDIR" && git rev-parse --show-toplevel || die "Could not get GITDIR")"
|
||||
|
||||
DATE="$(date '+%Y%m%d-%H%M%S')"
|
||||
|
||||
BUILDLOG="$(mktemp ./.build.log.XXXXXXX)"
|
||||
chmod +r "$BUILDLOG"
|
||||
|
||||
exec > >(tee "$BUILDLOG")
|
||||
exec 2>&1
|
||||
|
||||
setup_nmtui
|
||||
|
||||
UUID=`uuidgen`
|
||||
RELEASE_VERSION="${RELEASE_VERSION:-999}"
|
||||
VERSION="${VERSION:-$(get_version || die "Could not read $VERSION")}"
|
||||
COMMIT="${COMMIT:-$(git rev-parse --verify HEAD | sed 's/^\(.\{10\}\).*/\1/' || die "Error reading HEAD revision")}"
|
||||
USERNAME="${USERNAME:-"$(git config user.name) <$(git config user.email)>"}"
|
||||
SPECFILE="$(abs_path "$SPECFILE" "$SCRIPTDIR/NetworkManager.spec")"
|
||||
SOURCE="$(abs_path "$SOURCE" "$(ls -1 "$GITDIR/NetworkManager-$VERSION"*.tar* 2>/dev/null | head -n1)")"
|
||||
SOURCE_NETWORKMANAGER_CONF="$(abs_path "$SOURCE_NETWORKMANAGER_CONF" "$SCRIPTDIR/NetworkManager.conf")"
|
||||
SOURCE_SERVER_CONF="$(abs_path "$SOURCE_SERVER_CONF" "$SCRIPTDIR/00-server.conf")"
|
||||
LOG "UUID=$UUID"
|
||||
LOG "VERSION=$VERSION"
|
||||
LOG "RELEASE_VERSION=$RELEASE_VERSION"
|
||||
LOG "COMMIT=$COMMIT"
|
||||
LOG "USERNAME=$USERNAME"
|
||||
LOG "SPECFILE=$SPECFILE"
|
||||
LOG "SOURCE=$SOURCE"
|
||||
LOG "SOURCE_NETWORKMANAGER_CONF=$SOURCE_NETWORKMANAGER_CONF"
|
||||
LOG "SOURCE_SERVER_CONF=$SOURCE_SERVER_CONF"
|
||||
LOG "NMTUI=$NMTUI"
|
||||
LOG "NMTUI_VERSION=$NMTUI_VERSION"
|
||||
|
||||
TEMP="$(mktemp -d "$SCRIPTDIR/NetworkManager.$DATE.XXXXXX")"
|
||||
TEMPBASE="$(basename "$TEMP")"
|
||||
echo "BASEDIR=$TEMP"
|
||||
|
||||
ln -snf "$TEMPBASE" ./latest0
|
||||
ln "$BUILDLOG" "$TEMPBASE/build.log"
|
||||
rm -f "$BUILDLOG"
|
||||
|
||||
TEMPSPEC="$TEMP/SPECS/NetworkManager.spec"
|
||||
mkdir -p "$TEMP/SOURCES/" "$TEMP/SPECS/" || die "error creating SPECS directoy"
|
||||
|
||||
cp "$SOURCE" "$TEMP/SOURCES/" || die "Could not copy source $SOURCE to $TEMP/SOURCES"
|
||||
cp "$SOURCE_NETWORKMANAGER_CONF" "$TEMP/SOURCES/NetworkManager.conf" || die "Could not copy source $SOURCE_NETWORKMANAGER_CONF to $TEMP/SOURCES"
|
||||
cp "$SOURCE_SERVER_CONF" "$TEMP/SOURCES/00-server.conf" || die "Could not copy source $SOURCE_SERVER_CONF to $TEMP/SOURCES"
|
||||
if [[ "$NMTUI" != "" ]]; then
|
||||
cp "$NMTUI" "$TEMP/SOURCES/" || die "Could not copy source $NMTUI to $TEMP/SOURCES"
|
||||
fi
|
||||
|
||||
if [[ "x$CHANGELOG" == x ]]; then
|
||||
cat <<EOF > "$TEMP/SOURCES/CHANGELOG"
|
||||
* $(LOCALE= date '+%a %b %d %Y') $USERNAME - %{release}
|
||||
- Test build of NetworkManager ($DATE, $UUID)
|
||||
$(git log -n20 --date=local --format='- %h %s [%an] (%ci)')
|
||||
- ...
|
||||
EOF
|
||||
else
|
||||
echo "$CHANGELOG" 2>/dev/null > "$TEMP/SOURCES/CHANGELOG"
|
||||
fi
|
||||
|
||||
sed -e "s/__VERSION__/$VERSION/g" \
|
||||
-e "s/__COMMIT__/$COMMIT/g" \
|
||||
-e "s/__SOURCE1__/$(basename "$SOURCE")/g" \
|
||||
-e "s/__NMTUI_VERSION__/$NMTUI_VERSION/g" \
|
||||
-e "s/__WITH_NMTUI__/$WITH_NMTUI/g" \
|
||||
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
|
||||
"$SPECFILE" |
|
||||
if [[ "$NMTUI" != "" ]]; then
|
||||
sed -e 's/^__SOURCE_NMTUI__\([0-9]\+\)$/Source\1: '"$(basename "$NMTUI")"'/'
|
||||
else
|
||||
sed -e '/^__SOURCE_NMTUI__\([0-9]\+\)$/d'
|
||||
fi |
|
||||
sed -e "/^__CHANGELOG__$/ \
|
||||
{
|
||||
r $TEMPBASE/SOURCES/CHANGELOG
|
||||
d
|
||||
}" > "$TEMPSPEC" || die "Error reading spec file"
|
||||
|
||||
rpmbuild --define "_topdir $TEMP" -ba "$TEMPSPEC" || die "ERROR: rpmbuild FAILED"
|
||||
|
||||
ls -la "$TEMP"/RPMS/*/*.rpm "$TEMP"/SRPMS/*.rpm
|
||||
|
||||
ln -snf "$TEMPBASE" ./latest
|
||||
|
Reference in New Issue
Block a user