File module-init-tools.spec of Package module-init-tools

#
# spec file for package module-init-tools (Version 3.12)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           module-init-tools
BuildRequires:  zlib-devel
Version:        3.12
Release:        5
License:        GPLv2+
Group:          System/Kernel
# for grepping /etc/SUSE-release
PreReq:         grep
# nm and rpmsort (rpm) are required by the weak-modules script which is invoked
# in post, it also requires getopt (coreutils) and sed
PreReq:         coreutils rpm
# XXX: this should be nm OR eu-nm, the script works with both
PreReq:         /usr/bin/eu-nm /bin/sed
Provides:       modules modutils
Obsoletes:      modules modutils
# needed by 11.1 / SLE11 kernel
Provides:       module-init-tools_fix_bnc480524
AutoReqProv:    on
Summary:        Utilities to Load Modules into the Kernel
Url:            http://www.kerneltools.org/
Source0:        http://www.kernel.org/pub/linux/kernel/people/jcm/module-init-tools/module-init-tools-3.12-pre3.tar.bz2
Source1:        README.SUSE
Source2:        modprobe.conf.tar.bz2
Source3:        depmod-00-system.conf
Source4:        10-unsupported-modules.conf
Source5:        weak-modules
Source6:        weak-modules2
Patch1:         module-init-tools-upstream.diff
Patch2:         module-init-tools-suse.diff
Patch3:         module-init-tools-manpages.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Utilities for loading kernel modules. Included are 'insmod', 'lsmod',
'rmmod', 'depmod', and 'modprobe'. The configuration file
/etc/modprobe.* can be used to pass parameters to the modules. 'depmod'
should be used after compiling a new kernel to generate the dependency
information. 'insmod' does not use the dependency nor the options file.
Therefore, 'modprobe' is normally used to load a module.



Authors:
--------
    Rusty Russell <rusty@rustcorp.com.au>
    Adam J. Richter <adam@yggdrasil.com>
    Jon Masters <jcm@jonmasters.org>

%prep
%setup -q -n module-init-tools-3.12-pre3 -a2
%patch1 -p1
%patch2 -p1
%patch3 -p1

%build
autoreconf --force --install
CFLAGS="$RPM_OPT_FLAGS" \
	./configure \
	--prefix=/ \
	--mandir=%{_mandir} \
	--enable-zlib-dynamic \
	--disable-static-utils
make %{?_smp_mflags}

%install
make DESTDIR=$RPM_BUILD_ROOT install
install -m644 %_sourcedir/README.SUSE .
ln -sf /bin/lsmod $RPM_BUILD_ROOT/sbin/lsmod
#
# now assemble the parts for modprobe.conf
#
cd modprobe.conf
cp modprobe.conf.common 00-system.conf
if [ -f modprobe.conf.$RPM_ARCH ] ; then
	cat modprobe.conf.$RPM_ARCH >> 00-system.conf
fi
install -d -m 755 $RPM_BUILD_ROOT/etc/modprobe.d
install -m644 %_sourcedir/10-unsupported-modules.conf \
	$RPM_BUILD_ROOT/etc/modprobe.d/
install -m644 00-system.conf $RPM_BUILD_ROOT/etc/modprobe.d/
install -m644 modprobe.conf.local $RPM_BUILD_ROOT/etc/modprobe.d/99-local.conf
install -d -m 755 $RPM_BUILD_ROOT/etc/depmod.d
install -m 644 %_sourcedir/depmod-00-system.conf \
	$RPM_BUILD_ROOT/etc/depmod.d/00-system.conf
install -d -m 755 $RPM_BUILD_ROOT/usr/lib/%name
#install -m 755 modindex $RPM_BUILD_ROOT/usr/lib/%name/
install -m 755 %_sourcedir/weak-modules{,2} $RPM_BUILD_ROOT/usr/lib/%name/

%clean
rm -rf $RPM_BUILD_ROOT

%post
test_allow_on_install()
{
	# configure handling of unsupported modules
	# default is to allow them
	allow=1
	# if the obsolete LOAD_UNSUPPORTED_MODULES_AUTOMATICALLY variable is
	# set to no, don't allow (this was used in SLES 9 and 10)
	if test -e /etc/sysconfig/hardware/config; then
		. /etc/sysconfig/hardware/config
		if test "x$LOAD_UNSUPPORTED_MODULES_AUTOMATICALLY" = "xno"; then
			allow=0
		fi
		# obsolete
		rm /etc/sysconfig/hardware/config
	fi
	# don't change the setting during upgrade
	if test "$1" != 1; then
		return
	fi
	# on SLES, the default is not to allow unsupported modules
	if grep -qs "Enterprise Server" /etc/SuSE-release; then
		allow=0
	else
		return
	fi
	# unless the admin passed "oem-modules=1" to the kernel during install
	if grep -qs '\<oem-modules=1\>' /proc/cmdline; then
		allow=1
		return
	fi
	# or if the installer already loaded some unsupported modules
	# (see TAINT_NO_SUPPORT in /usr/src/linux/include/linux/kernel.h)
	tainted=$(cat /proc/sys/kernel/tainted 2>/dev/null || echo 0)
	if test $((tainted & (1<<30))) != 0; then
		allow=1
		return
	fi
}
# upgrade from old locations
if test -e /etc/modprobe.d/unsupported-modules; then
	mv -f /etc/modprobe.d/unsupported-modules \
		/etc/modprobe.d/10-unsupported-modules.conf
fi
if test -e /etc/modprobe.conf.local; then
	mv -f /etc/modprobe.conf.local \
		/etc/modprobe.d/99-local.conf
fi
test_allow_on_install "$@"
if test "$allow" = "0"; then
	sed -ri 's/^( *allow_unsupported_modules *) 1/\1 0/' \
		/etc/modprobe.d/10-unsupported-modules.conf
fi

%files
%defattr(-,root,root)
%dir               /etc/modprobe.d
%config            /etc/modprobe.d/00-system.conf
%config(noreplace) /etc/modprobe.d/10-unsupported-modules.conf
%config(noreplace) /etc/modprobe.d/99-local.conf
%dir               /etc/depmod.d
%config            /etc/depmod.d/00-system.conf
%doc AUTHORS COPYING ChangeLog FAQ NEWS README TODO
%doc README.SUSE
%doc %{_mandir}/man?/*
/bin/*
/sbin/*
/usr/lib/%name

%changelog
openSUSE Build Service is sponsored by