diff options
author | Ben Lutgens <blutgens@gentoo.org> | 2002-06-16 14:24:47 +0000 |
---|---|---|
committer | Ben Lutgens <blutgens@gentoo.org> | 2002-06-16 14:24:47 +0000 |
commit | 098531d10e7bf97ae1dbda03844c53725b7847b4 (patch) | |
tree | 35d047db9850e8ccfc435cef806bf39ff0538194 /app-admin | |
parent | ditto (diff) | |
download | historical-098531d10e7bf97ae1dbda03844c53725b7847b4.tar.gz historical-098531d10e7bf97ae1dbda03844c53725b7847b4.tar.bz2 historical-098531d10e7bf97ae1dbda03844c53725b7847b4.zip |
Committed this at the request of mjc. Apparently it's a patch managment
script to be used in conjuction with his mjc-sources package.
Diffstat (limited to 'app-admin')
-rw-r--r-- | app-admin/addpatches/addpatches-0.1.ebuild | 13 | ||||
-rw-r--r-- | app-admin/addpatches/files/addpatches | 117 |
2 files changed, 130 insertions, 0 deletions
diff --git a/app-admin/addpatches/addpatches-0.1.ebuild b/app-admin/addpatches/addpatches-0.1.ebuild new file mode 100644 index 000000000000..4c9a26b3cdc1 --- /dev/null +++ b/app-admin/addpatches/addpatches-0.1.ebuild @@ -0,0 +1,13 @@ +# Copyright 1999-2002 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# Author: Ben Lutgens <lamer@gentoo.org> +# $Header: /var/cvsroot/gentoo-x86/app-admin/addpatches/addpatches-0.1.ebuild,v 1.1 2002/06/16 14:24:47 lamer Exp $ + +# Short one-line description of this package. +DESCRIPTION="patch management script." + +LICENSE="as-is" +RDEPEND="sys-devel/patch" +src_install () { + dobin ${FILESDIR}/addpatches +} diff --git a/app-admin/addpatches/files/addpatches b/app-admin/addpatches/files/addpatches new file mode 100644 index 000000000000..9b16d68a00ad --- /dev/null +++ b/app-admin/addpatches/files/addpatches @@ -0,0 +1,117 @@ +#! /bin/sh +# +# addpatches - a script to apply a kernel patch set. +# +# In a patch directory, the patches are organized with a numeric prefix: +# 00_* +# 01_* +# 02_* +# ... +# 99_* +# They should be sortable by the wildcard expression '*_*'. +# +# Usage: addpatches [ patcharg [ sourcedir [ patchdir ] ] ] +# The source directory defaults to /usr/src/linux, and the patch +# directory defaults to the current directory +# +# addpatches determines the current kernel version from the top-level Makefile. +# It then looks for patches for the next sublevel in the patch directory. +# This is applied using "patch -p1 -s" from within the kernel directory. +# A check is then made for "*.rej" files to see if the patch was +# successful. If it is, then all of the "*.orig" files are removed. +# +# Thanks to +# Nick Holloway <Nick.Holloway@alfie.demon.co.uk> +# Adam Sulmicki <adam@cfar.umd.edu> +# Dave Gilbert <linux@treblig.org> +# for the scripts/patch-kernel script. + +# Set directories from arguments, or use defaults. +patcharg=${1-default} +sourcedir=${2-/usr/src/linux} +patchdir=${3-.} +PATCHES="" + +# Find a file, first parameter is basename of file +# it tries many compression mechanisms and sets variables to say how to get it +function findFile { + filebase=$1; + + if [ -r `basename ${filebase} .gz`.gz ]; then + name="gzip format" + uncomp="zcat" + elif [ -r `basename ${filebase} .bz2`.bz2 ]; then + name="bzip2 format" + uncomp="bzcat" + elif [ -r ${filebase} ]; then + name="plain text format" + uncomp="cat" + else + return 1; + fi + + return 0; +} + +# Apply a patch and check it goes in cleanly +# First param is patch name + +function applyPatch { + echo -n "Checking $1 (${name})... " + if $uncomp ${patchdir}/$1 | patch -p1 --dry-run -s -N -E -d $sourcedir + then + echo -n "looks good. Applying... " + $uncomp ${patchdir}/$1 | patch -p1 -s -N -E -d $sourcedir + PATCHES="$1 $PATCHES" + echo "done." + else + echo "can't be applied. Please modify the patch." + unroll="unroll" + if [ $patcharg == $unroll ] ; + then + echo "Trying to unroll patches applied so far" + for i in $PATCHES + do + echo -n "Reverting $i ..." + findFile $patchdir/$i || break + $uncomp ${patchdir}/$i | patch -p1 -R -s -E -d $sourcedir + echo "done." + done + fi + return 1; + fi + if [ "`find $sourcedir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] + then + echo "Hmm. Reject files found." + return 1; + fi + # Remove backup files + find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \; + + return 0; +} + +# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTERVERSION +eval `sed -n -e 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' -e 's/^\([A-Z]*\) = \(-[-a-z0-9]*\)$/\1=\2/p' $sourcedir/Makefile` +if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ] +then + echo "unable to determine current kernel version" >&2 + exit 1 +fi + +echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION}" + +if [ -d $patchdir ] +then + echo "Scanning patch directory: '$patchdir'" + for i in `ls *_*` + do + findFile $patchdir/$i || break + applyPatch $i || break + done + +else + echo "Patch directory not found" + exit 1 +fi + |