]> TLD Linux GIT Repositories - packages/dracut.git/commitdiff
- added update-initramfs script for mass updating initramfs images
authorMarcin Krol <hawk@tld-linux.org>
Wed, 2 Sep 2015 08:38:38 +0000 (08:38 +0000)
committerMarcin Krol <hawk@tld-linux.org>
Wed, 2 Sep 2015 08:38:38 +0000 (08:38 +0000)
dracut.spec
update-initramfs [new file with mode: 0755]

index bafeca95ded8c39d5937b8ab83458be4936a7f76..ff38a0d0620cd3ca93316f1b09f99c036c373345 100644 (file)
@@ -2,12 +2,13 @@ Summary:      Initramfs generator using udev
 Summary(pl.UTF-8):     Generator initramfs wykorzystujÄ…cy udev
 Name:          dracut
 Version:       043
-Release:       3
+Release:       4
 License:       GPL v2+
 Group:         Base
 Source0:       https://www.kernel.org/pub/linux/utils/boot/dracut/%{name}-%{version}.tar.xz
 # Source0-md5: 85de75ddf00962e7bb0ae387f05794e5
 Source1:       tld.conf
+Source2:       update-initramfs
 Patch1:                plymouth-libexec.patch
 Patch2:                os-release.patch
 Patch3:                plymouth-logo.patch
@@ -225,6 +226,7 @@ install -d $RPM_BUILD_ROOT{/boot/dracut,/etc/logrotate.d,/sbin} \
        DESTDIR=$RPM_BUILD_ROOT
 
 install -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/dracut.conf.d/01-dist.conf
+install -p %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}/update-initramfs
 install -p dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT%{_sysconfdir}/dracut.conf.d/40-fips.conf
 install -p dracut.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/dracut_log
 
@@ -258,6 +260,7 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_bindir}/dracut
 %attr(755,root,root) %{_bindir}/mkinitrd
 %attr(755,root,root) %{_bindir}/lsinitrd
+%attr(755,root,root) %{_bindir}/update-initramfs
 %dir %{dracutlibdir}
 %attr(755,root,root) %{dracutlibdir}/dracut-install
 %dir %{dracutlibdir}/modules.d
diff --git a/update-initramfs b/update-initramfs
new file mode 100755 (executable)
index 0000000..509060f
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+create_initramfs () {
+  if ! test -f /lib/modules/${1}/modules.dep; then
+    return 0
+  elif ! test -f /boot/vmlinuz-${1}; then
+    return 0
+  fi
+  echo -n "Generating initramfs image for kernel ${1} ... "
+  /sbin/dracut --force /boot/initramfs-${1}.img ${1} 1>/dev/null 2>&1
+  if [ $? -ne 0 ]; then
+    echo "\e[1;31mFailed\e[0m"
+    return 1
+  fi
+  echo "\e[1;32mOK\e[0m"
+  return 0
+}
+
+local status
+status=0
+
+if [ "x${1}" = "x" ]; then
+  echo "Usage: update-initramfs <all | kernel version>"
+  echo "Examples:"
+  echo "  update-initramfs all"
+  echo "  update-initramfs 3.14.51-3.14-vanilla-1"
+  exit 0
+elif [ "x${1}" = "xall" ]; then
+  for kernel in $(/bin/ls -1 /lib/modules/ 2>/dev/null); do
+    create_initramfs ${kernel}
+    if [ $? -ne 0 ]; then
+      status=1
+    fi
+  done
+else
+  create_initramfs ${1}
+  if [ $? -ne 0 ]; then
+    status=1
+  fi
+fi
+
+exit ${status}