diff --git a/SOURCES/depmod.conf.dist b/SOURCES/depmod.conf.dist new file mode 100644 index 0000000..8513288 --- /dev/null +++ b/SOURCES/depmod.conf.dist @@ -0,0 +1,6 @@ +# +# depmod.conf +# + +# override default search ordering for kmod packaging +search updates extra built-in weak-updates diff --git a/SOURCES/weak-modules b/SOURCES/weak-modules index 05d1b0f..52cd59e 100644 --- a/SOURCES/weak-modules +++ b/SOURCES/weak-modules @@ -71,6 +71,78 @@ read_modules_list() { done } +pad() { + local len=$1 + local padding=$2 + + echo "$(( $len + (($padding - ($len % $padding)) % $padding) ))" +} + +cpio_len() { + local input=$1 + local maxlen="$(( $(stat -c %s "$input") - 110))" + local len=0 + local cpio_filename + local cpio_namesize + local cpio_filename + local cpio_headersize + + while [ "$len" -lt "$maxlen" ]; do + cpio_filesize="0x$(dd if="$input" bs=1 skip="$(($len + 54))" count=8 2>/dev/null)" + cpio_namesize="0x$(dd if="$input" bs=1 skip="$(($len + 94))" count=8 2>/dev/null)" + cpio_filename="$(dd if="$input" bs=1 skip="$(($len + 110))" count="$(($cpio_namesize))" 2>/dev/null)" + + # Pad the header size to a multiple of 4 + cpio_headersize="$(pad "$((110 + $cpio_namesize))" 4)" + + # Pad the file length to a multiple of 4 + cpio_filesize="$(pad "$cpio_filesize" 4)" + + len="$(($len + $cpio_headersize + $cpio_filesize))" + + if [ "$cpio_filename" = "TRAILER!!!" ]; then + break + fi + done + + # Pad the whole thing to a multiple of 512 + echo "$(pad "$len" 512)" +} + +decompress_initramfs() { + local input=$1 + local output=$2 + + # First, check if this is compressed at all + if cpio -i -t < "$input" > /dev/null 2>/dev/null; then + # If this archive contains a file early_cpio, it's a trick. Strip off + # the early cpio archive and try again. + if cpio -i -t < "$input" 2>/dev/null | grep -q '^early_cpio$' ; then + dd if="$input" of="${tmpdir}/post_early_cpio.img" ibs=1 skip="$(cpio_len "$input")" 2>/dev/null + decompress_initramfs "${tmpdir}/post_early_cpio.img" "$output" + retval="$?" + rm -f "${tmpdir}/post_early_cpio.img" + return $retval + fi + + cp "$input" "$output" + return 0 + fi + + # Try gzip + if gzip -cd < "$input" > "$output" 2>/dev/null ; then + return 0 + fi + + # Next try xz + if xz -cd < "$input" > "$output" 2>/dev/null ; then + return 0 + fi + + echo "Unable to decompress $input: Unknown format" >&2 + return 1 +} + # read_old_initramfs: compare_initramfs_modules() { local old_initramfs=$1 @@ -81,16 +153,20 @@ compare_initramfs_modules() { mkdir "$tmpdir/old_initramfs" mkdir "$tmpdir/new_initramfs" + decompress_initramfs "$old_initramfs" "$tmpdir/old_initramfs.img" pushd "$tmpdir/old_initramfs" >/dev/null - zcat "$old_initramfs" | cpio -i 2>/dev/null + cpio -i < "$tmpdir/old_initramfs.img" 2>/dev/null + rm "$tmpdir/old_initramfs.img" n=0; for i in `find . -iname \*.ko|sort`; do old_initramfs_modules[n]="$i" n=$((n+1)) done popd >/dev/null + decompress_initramfs "$new_initramfs" "$tmpdir/new_initramfs.img" pushd "$tmpdir/new_initramfs" >/dev/null - zcat "$new_initramfs" | cpio -i 2>/dev/null + cpio -i < "$tmpdir/new_initramfs.img" 2>/dev/null + rm "$tmpdir/new_initramfs.img" n=0; for i in `find . -iname \*.ko|sort`; do new_initramfs_modules[n]="$i" n=$((n+1)) diff --git a/SPECS/kmod.spec b/SPECS/kmod.spec index 8053078..9c393a4 100644 --- a/SPECS/kmod.spec +++ b/SPECS/kmod.spec @@ -1,6 +1,6 @@ Name: kmod Version: 14 -Release: 2%{?dist} +Release: 9%{?dist} Summary: Linux kernel module management utilities Group: System Environment/Kernel @@ -8,6 +8,7 @@ License: GPLv2+ URL: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary Source0: ftp://ftp.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{version}.tar.xz Source1: weak-modules +Source2: depmod.conf.dist Exclusiveos: Linux BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -22,6 +23,12 @@ Provides: module-init-tools = 4.0-1 Obsoletes: module-init-tools < 4.0-1 Provides: /sbin/modprobe +# Required for the weak-modules script +Requires: /usr/bin/nm +Requires: /usr/bin/gzip +Requires: /usr/bin/xz +Requires: /usr/bin/cpio + %description The kmod package provides various programs needed for automatic loading and unloading of modules under 2.6, 3.x, and later kernels, as well @@ -79,6 +86,8 @@ mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/modprobe.d mkdir -p $RPM_BUILD_ROOT/sbin install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir}/weak-modules +install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf + %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig @@ -96,6 +105,7 @@ install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir}/weak-modules %{_sbindir}/lsmod %{_sbindir}/depmod %{_sbindir}/weak-modules +%{_sysconfdir}/depmod.d/dist.conf %attr(0644,root,root) %{_mandir}/man5/*.5* %attr(0644,root,root) %{_mandir}/man8/*.8* %doc NEWS README TODO COPYING @@ -109,6 +119,32 @@ install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir}/weak-modules %{_libdir}/libkmod.so %changelog +* Tue Apr 1 2014 David Shea - 14-9 +- Support initramfs files with early_cpio + Resolves: rhbz#1070035 + +* Wed Feb 26 2014 David Shea - 14-8 +- Support xz-compressed and uncompressed initramfs files + Resolves: rhbz#1070035 + +* Tue Feb 25 2014 David Shea - 14-7 +- Require binutils for weak-modules + Resolves: rhbz#1069612 + +* Mon Feb 17 2014 David Shea - 14-6 +- Added a depmod search order as /etc/depmod.d/dist.conf + Resolves: rhbz#1065354 + +* Fri Jan 24 2014 Daniel Mach - 14-5 +- Mass rebuild 2014-01-24 + +* Mon Jan 06 2014 Václav Pavlín - 14-4 +- Version bump due to build fail + Resolves: rhbz#1048868 + +* Fri Dec 27 2013 Daniel Mach - 14-3 +- Mass rebuild 2013-12-27 + * Wed Aug 07 2013 Václav Pavlín - 14-2 - Run tests during build