File: patch.file.sh

package info (click to toggle)
cook 2.5-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,860 kB
  • ctags: 3,247
  • sloc: ansic: 41,260; sh: 10,022; yacc: 3,397; makefile: 3,244; awk: 136
file content (85 lines) | stat: -rw-r--r-- 1,966 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
#	cook - file construction tool
#	Copyright (C) 1993, 1994, 1997 Peter Miller;
#	All rights reserved.
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 2 of the License, or
#	(at your option) any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program; if not, write to the Free Software
#	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
#
# MANIFEST: shell script to generate the patch for one file
#
case $# in
4)
	project=$1
	change=$2
	filename=$3
	path=$4
	;;
*)
	echo "usage: $0 <project> <change> <filename> <path>" 1>&2
	exit 1
	;;
esac

tmp=/tmp/$$
tmp2=/tmp/$$.2

#
# the patchlevel patch can be generated accurately
#
if test "$filename" = "common/patchlevel.h"
then
	echo "Index: common/patchlevel.h"
	prev=`aegis -list version -p $project -c $change | awk -F'"' '/previous/{print $2}'`
	echo "Prereq: \"$prev\""
	echo "#define PATCHLEVEL \"$prev\"" > $tmp
	diff -c $tmp common/patchlevel.h | sed '1,2d'
	rm -f $tmp
	exit 0
fi

#
# fake patches for the generated files
#
changes=`echo $project | awk -F. '{print "etc/CHANGES."$1"."$2}'`
if test "$filename" = "$changes"
then
	echo "Index: $filename"
	diff -c /dev/null $path | sed '1,2d'
	exit 0
fi

#
# construct a diff listing for the file
#
if aegis -cp $filename -delta 1 -output $tmp -p $project -c $change
then
	in=$tmp
else
	in=/dev/null
fi
if diff -c $in $path > $tmp2 2> /dev/null
then
	echo $filename unchanged 1>&2
else
	echo "Index: $filename"
	sed '1,2d' < $tmp2
fi

#
# clean up and go home
#
rm -f $tmp $tmp2
exit 0