updated 'patch-kernel' script.

ADAM Sulmicki (adam@cfar.umd.edu)
Sun, 28 Dec 1997 19:57:35 -0500 (EST)


Hi,

I have patched the patch-kernel script so that it does
automagically handles bzip2, uncompressed and other formats of patches
besides of gzipped patches. I think it is quite handy now that we use
bzip2 format to distribute patches as well as in case one just decide to
uncompress patch to take a look at it before applying it. It should work
well for both 2.1.x and 2.0.x kernels, but as 'feature' I guess it would
go only into 2.1.x. It is also easy to add support for other formats as
well.

Commenents are welcome.

-Adam

[an expample of using it]

[root@eax Linux.all]# ls -dlg *2.1*
drw-r--r-- 1 root root 1024 Dec 9 21:24 linux-2.1.72
-rw-r--r-- 1 root root 361915 Dec 19 00:59 patch-2.1.73.bz2
-rw-r--r-- 1 root root 68181 Dec 20 01:17 patch-2.1.74.bz
-rw-r--r-- 1 adam adam 245314 Dec 21 21:09 patch-2.1.75.gz
-rw-r--r-- 1 root root 554856 Dec 24 00:29 patch-2.1.76
[root@eax linux]# ./scripts/patch-kernel . ..
Current kernel version is 2.1.72
Applying patch-2.1.73 (bzip2)... done.
Applying patch-2.1.74 (bzip)... done.
Applying patch-2.1.75 (gzip)... done.
Applying patch-2.1.76 (plaintext)... done.
[root@eax linux]#

[the patch itself follows.]
=====================================================================
=====================================================================
diff -ubwi linux/scripts/patch-kernel{.old,} > patch.p-k
=====================================================================
--- linux/scripts/patch-kernel.old Sun Dec 28 19:42:39 1997
+++ linux/scripts/patch-kernel Sun Dec 28 19:50:55 1997
@@ -11,6 +11,7 @@
# successful. If it is, then all of the "*.orig" files are removed.
#
# Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
+# Adam Sulmicki <adam@cfar.umd.edu>, 28th December 1997.

# Set directories from arguments, or use defaults.
sourcedir=${1-/usr/src/linux}
@@ -29,14 +30,33 @@
while :
do
SUBLEVEL=`expr $SUBLEVEL + 1`
- patch=patch-$VERSION.$PATCHLEVEL.$SUBLEVEL.gz
- if [ ! -r $patchdir/$patch ]
- then
+ patch=patch-$VERSION.$PATCHLEVEL.$SUBLEVEL
+ if [ -r $patchdir/${patch}.gz ]; then
+ ext=".gz"
+ name="gzip"
+ uncomp="gunzip -dc"
+ elif [ -r $patchdir/${patch}.bz ]; then
+ ext=".bz"
+ name="bzip"
+ uncomp="bunzip -dc"
+ elif [ -r $patchdir/${patch}.bz2 ]; then
+ ext=".bz2"
+ name="bzip2"
+ uncomp="bunzip2 -dc"
+ elif [ -r $patchdir/${patch}.zip ]; then
+ ext=".zip"
+ name="zip"
+ uncomp="unzip -c"
+ elif [ -r $patchdir/${patch} ]; then
+ ext=""
+ name="plaintext"
+ uncomp="cat"
+ else
break
fi

- echo -n "Applying $patch... "
- if gunzip -dc $patchdir/$patch | patch -p1 -s -N -E -d $sourcedir
+ echo -n "Applying ${patch} (${name})... "
+ if $uncomp ${patchdir}/${patch}${ext} | patch -p1 -s -N -E -d $sourcedir
then
echo "done."
else
=====================================================================