summaryrefslogtreecommitdiffstats
path: root/needs-checking/new-kernel
blob: a81be96dc5f40845cee4c462104827b5552f1a02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#! /bin/bash

#  This script is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License version 2 as
#  published by the Free Software Foundation.
#
#  See the COPYING and AUTHORS files for more details.

usage()
{
	echo "Usage: new-kernel linux-2.4.2-pre2 linux-2.4.3-pre3 linux-2.4.3 patch.gz cvs-dir"
	exit 1
}

wantdir()
{
	if [ x$1 = x ]
	then
		usage
	fi
	if [ ! -d $1 ]
	then
		echo "directory $1 does not exist"
		usage
	fi
}

wantfile()
{
	if [ x$1 = x ]
	then
		usage
	fi
	if [ ! -f $1 ]
	then
		echo "file $1 does not exist"
		usage
	fi
}

doit()
{
	echo $* 1>&2
	$* || {
		echo oops
		exit 1 
	}
}


CURRENT_KERNEL=$1
NEXT_KERNEL=$2
BASE_KERNEL=$3
PATCH_FILE=$4
CVS_DIR=$5

TEMP_PATCH=$(mktemp /tmp/patch-XXXXXX)
MY_DIFF="$CURRENT_KERNEL"--"$NEXT_KERNEL"

wantdir $CURRENT_KERNEL
wantdir $BASE_KERNEL
wantdir $CVS_DIR
wantfile $PATCH_FILE

doit rm -rf $NEXT_KERNEL
doit cp -a $BASE_KERNEL $NEXT_KERNEL
doit rm -f $TEMP_PATCH
doit gunzip < $PATCH_FILE > $TEMP_PATCH
cd $NEXT_KERNEL
doit patch -p1 --dry-run -i $TEMP_PATCH
doit patch -p1 -s -i $TEMP_PATCH
echo cd ..
cd ..

echo diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL
diff -uNrp $CURRENT_KERNEL $NEXT_KERNEL > $MY_DIFF

echo cd $CVS_DIR
cd $CVS_DIR
doit patch -p1 --dry-run -s -i ../$MY_DIFF
doit patch -p1 -s -i ../$MY_DIFF
cvs-take-patch ../$MY_DIFF
cvs commit -m "'doing $NEXT_KERNEL'"
cvs update -ko -d -P

TAG=$(echo $NEXT_KERNEL | sed -e 's@\.@_@g')
cvs tag -b $TAG
rm -f $TEMP_PATCH