-
Notifications
You must be signed in to change notification settings - Fork 4
/
populate
133 lines (125 loc) · 3.12 KB
/
populate
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/sh
# @(#)populate 1.1 94/10/31 SMI
#
# populate a source tree.
#
# We assume that we start out in a directory (presumably /usr/src)
# with the subdirectory 'SCCS_DIRECTORIES' which contains the SCCS source
# in the form:
#
# ...
# stuff
# stuff/SCCS
# stuff/SCCS/(SCCS source files for stuff...)
# stuff/morestuff
# stuff/morestuff/SCCS
# stuff/morestuff/SCCS/(SCCS source files for morestuff....)
# ...
#
# This script will make a directory tree rooted in this directory
# of the structure:
#
# ...
# stuff
# stuff/morestuff
# ...
# And add in, as relative path symbolic links the SCCS directories
# in the tree rooted in SCCS_DIRECTORIES...
#
# (e.g., stuff/SCCS is a symlink that points to ../SCCS_DIRECTORIES/stuff/SCCS)
#
#################
# set up a trap to clean up after ourselves if we are killed...
#
trap 'ln -s SCCS_DIRECTORIES/SCCS;make clobber;exit 100' 2 3 15
#
# Are we building a specific release? If we are and the corresponding
# SID list doesn't exist, we might as well quit right now.
#
if [ -f RELEASE ]; then
SID_FILE=`cat RELEASE`.SID
if [ ! -f SIDlist/$SID_FILE \
-a ! -f SCCS_DIRECTORIES/SIDlist/SCCS/s.$SID_FILE ]; then
echo "Error: SID file $1 does not exist"
exit 1
fi
fi
#
# The only real problem child is /usr/src/SCCS->/usr/src/SCCS_DIRECTORIES/SCCS
# which we'll handle as a special case...
#
echo "Finding sub-directories in SCCS_DIRECTORIES...."
rm -f SCCS
find SCCS_DIRECTORIES -type d -print | sed -e '/lost+found/d' \
-e '/^SCCS_DIRECTORIES$/d' -e '/^SCCS_DIRECTORIES\/SCCS/d' > major_list
#
# Make directories
#
echo " Making sub-directories in current directory...."
for i in `grep -v 'SCCS$' major_list| sed 's/^SCCS_DIRECTORIES\///'`
do
if [ ! -d $i ]
then
mkdir $i
if [ $? -ne 0 ]
then
echo "........mkdir failed on directory" $i
fi
fi
done
echo "Making relative path symbolic links to SCCS...."
for SCCS_DIR in `grep 'SCCS$' major_list`
do
#
# Trim off SCCS_DIRECTORIES
#
symln=`echo $SCCS_DIR| sed 's/SCCS_DIRECTORIES.//'`
#
# Calculate relative dot-dot....
#
dotdot=`echo $symln |sed -e 's/.SCCS//' -e 's/\// /g' -e 's/$/ /' \
-e 's/[^ ]* /..\//g'`
#
# put together full symlink name
#
realdir=${dotdot}${SCCS_DIR}
#
# command is ln -s relpath symln
#
ln -s $realdir $symln
if [ $? -ne 0 ]
then
echo "........symlink failed on command: ln -s " $realdir $symln
fi
done
ln -s SCCS_DIRECTORIES/SCCS
if [ $? -ne 0 ]
then
echo "........symlink failed on command: ln -s SCCS_DIRECTORIES/SCCS"
fi
rm -f major_list
#
# Are we building a specific release? If not, we're done.
#
if [ ! -f RELEASE ]; then
echo "Done...."
exit 0
fi
#
# Make sure the SID_FILE is checked out. (We already know it exists.)
#
if [ ! -f SIDlist/$SID_FILE ]; then
/usr/sccs/get -GSIDlist/$SID_FILE SIDlist/SCCS/s.$SID_FILE
fi
#
# Now descend through the tree and check out the files specified
# in the SID list.
#
echo "Checking out files for release `basename $SID_FILE .SID`..."
egrep -v '^#' SIDlist/$SID_FILE \
| awk '{ print $1" "$1" "$2 }' | sed 's/SCCS\/s\.//' \
| awk '{ printf "/usr/sccs/get -s -r%s -G%s %s;", $3, $1, $2 }' \
| tee errs.populate | sh -s
echo "Done...."
rm errs.populate
exit 0