Added fix for TeX includes with same name as subdirs.
[scons.git] / bin / restore.sh
1 #!/usr/bin/env sh
2 #
3 # Simple hack script to restore __revision__, __COPYRIGHT_, __VERSION__
4 # and other similar variables to what gets checked in to source.  This
5 # comes in handy when people send in diffs based on the released source.
6 #
7
8 if test "X$*" = "X"; then
9     DIRS="src test"
10 else
11     DIRS="$*"
12 fi
13
14 SEPARATOR="================================================================================"
15
16 header() {
17     arg_space="$1 "
18     dots=`echo "$arg_space" | sed 's/./\./g'`
19     echo "$SEPARATOR" | sed "s;$dots;$arg_space;"
20 }
21
22 for i in `find $DIRS -name '*.py'`; do
23     header $i
24     ed $i <<EOF
25 g/Copyright (c) 2001.*SCons Foundation/s//__COPYRIGHT__/p
26 w
27 /^__revision__ = /s/= .*/= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"/p
28 w
29 q
30 EOF
31 done
32
33 for i in `find $DIRS -name 'scons.bat'`; do
34     header $i
35     ed $i <<EOF
36 g/Copyright (c) 2001.*SCons Foundation/s//__COPYRIGHT__/p
37 w
38 /^@REM src\/script\/scons.bat/s/@REM .* knight/@REM __FILE__ __REVISION__ __DATE__ __DEVELOPER__/p
39 w
40 q
41 EOF
42 done
43
44 for i in `find $DIRS -name '__init__.py' -o -name 'scons.py' -o -name 'sconsign.py'`; do
45     header $i
46     ed $i <<EOF
47 /^__version__ = /s/= .*/= "__VERSION__"/p
48 w
49 /^__build__ = /s/= .*/= "__BUILD__"/p
50 w
51 /^__buildsys__ = /s/= .*/= "__BUILDSYS__"/p
52 w
53 /^__date__ = /s/= .*/= "__DATE__"/p
54 w
55 /^__developer__ = /s/= .*/= "__DEVELOPER__"/p
56 w
57 q
58 EOF
59 done
60
61 for i in `find $DIRS -name 'setup.py'`; do
62     header $i
63     ed $i <<EOF
64 /^ *version = /s/= .*/= "__VERSION__",/p
65 w
66 q
67 EOF
68 done
69
70 for i in `find $DIRS -name '*.txt'`; do
71     header $i
72     ed $i <<EOF
73 g/Copyright (c) 2001.*SCons Foundation/s//__COPYRIGHT__/p
74 w
75 /# [^ ]* 0.96.[CD][0-9]* [0-9\/]* [0-9:]* knight$/s/.*/# __FILE__ __REVISION__ __DATE__ __DEVELOPER__/p
76 w
77 /Version [0-9][0-9]*\.[0-9][0-9]*/s//Version __VERSION__/p
78 w
79 q
80 EOF
81 done
82
83 for i in `find $DIRS -name '*.xml'`; do
84     header $i
85     ed $i <<EOF
86 g/Copyright (c) 2001.*SCons Foundation/s//__COPYRIGHT__/p
87 w
88 q
89 EOF
90 done