summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2005-11-22 20:41:34 +0000
committerJeremy Katz <katzj@redhat.com>2005-11-22 20:41:34 +0000
commit8c592d6ee43cfc1753844d616daf821975008f75 (patch)
tree9c7862ad21cd4dbc481ebee8af6c992502b4a819 /scripts
parentba67a958de422005364ce2a1963dc20264d1e880 (diff)
downloadanaconda-8c592d6ee43cfc1753844d616daf821975008f75.tar.gz
anaconda-8c592d6ee43cfc1753844d616daf821975008f75.tar.xz
anaconda-8c592d6ee43cfc1753844d616daf821975008f75.zip
2005-11-22 Jeremy Katz <katzj@redhat.com>
* scripts/upd-kernel: Add a script to create a new initrd for a new kernel version.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/upd-kernel65
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts/upd-kernel b/scripts/upd-kernel
new file mode 100755
index 000000000..16057198f
--- /dev/null
+++ b/scripts/upd-kernel
@@ -0,0 +1,65 @@
+#!/bin/sh
+# take a boot directory with kernel + initrd and create a new one
+# with a new kernel + initrd
+# Usage: ./upd-kernel <olddir> <newdir> <newkernelrpm>
+
+OLDDIR=`readlink -f $1`
+NEWDIR=$2
+KRPM=`readlink -f $3`
+ARCH=$(rpm -qp --qf "%{ARCH}" $KRPM)
+NEWVER=$(rpm -qp --qf "%{VERSION}" $KRPM)
+
+if [ -z "$OLDDIR" -o -z "$NEWDIR" -o -z "$KRPM" ]; then
+ echo "Usage: $0 <olddir> <newdir> <newkernelrpm>"
+ exit 1
+fi
+
+if [ ! -d $OLDDIR ]; then
+ echo "Directory $OLDDIR doesn't exist"
+ exit 1
+fi
+
+if [ -f $NEWDIR ]; then
+ NEWDIR=`readlink -f $NEWDIR`
+else
+ NEWDIR=`readlink -f .`/$NEWDIR
+ mkdir $NEWDIR
+fi
+
+WORKDIR=$(/bin/mktemp -d /tmp/kernrpm.XXXXXX)
+
+pushd $WORKDIR
+
+# explode the rpm
+mkdir rpm
+pushd rpm
+rpm2cpio $KRPM |cpio -id
+popd
+
+# explode the rpm
+mkdir initrd
+pushd initrd
+zcat $OLDDIR/initrd.img |cpio -id
+popd
+
+mkdir initrd/modules/mods
+# explode the moduleball
+pushd initrd/modules/mods
+zcat ../modules.cgz |cpio -id
+popd
+
+mkdir -p newmods/$NEWVER/$ARCH
+for i in $(find initrd/modules/mods -type f -name '*.ko' -exec basename {} \;); do find $WORKDIR/rpm/lib/modules/*/ -name $i -exec cp -v {} $WORKDIR/newmods/$NEWVER/$ARCH \; ; done
+rm -rf initrd/modules/mods
+
+pushd newmods
+find . |cpio --quiet -H crc -o |gzip -9 > $WORKDIR/initrd/modules/modules.cgz
+popd
+
+pushd initrd
+find . |cpio -c -o |gzip -9 > $NEWDIR/initrd.img
+popd
+
+cp -v $WORKDIR/rpm/boot/vmlinuz-* $NEWDIR/vmlinuz
+popd
+rm -rf $WORKDIR