-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstrip
More file actions
executable file
·191 lines (170 loc) · 6.09 KB
/
strip
File metadata and controls
executable file
·191 lines (170 loc) · 6.09 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
: "strip strip addon products from distribution tree"
#
# Most of this script is dedicated to making sure files don't get clobbered by
# out-of-date files in case an aborted strip or merge left some of the
# distributions incomplete.
#
if [ $# = 0 ]
then set cmacs viplus
fi
CONFIRM=confirm.sh
PATH=${PATH}:./config; export PATH
for ADDON
do
ADDONDIR=$ADDON
for i in . $ADDON
do if [ -f $i/config/add${ADDON}.sh ]
then FILES=`$i/config/add${ADDON}.sh list`
break
fi
done
if [ x"$FILES" = x ]
then echo "Sorry, but I can't locate the file config/add${ADDON}.sh"
echo "which would have told me which files make up the $ADDON"
echo "distribution. This means that there are files missing"
echo "entirely from the $ADDON distribution, which you had"
echo "better do your best to find again."
fi
# check for files missing from the main distribution, or whether the
# main distribution exists at all
#
MAINCOMPLETE=TRUE
MAINMISSING=TRUE
> /tmp/MainMissing
for i in $FILES
do if [ ! -f $i -a ! -d $i ]
then echo "$i" >>/tmp/MainMissing
MAINCOMPLETE=FALSE
else MAINMISSING=FALSE
fi
done
# Check to see if the addon directory is complete or missing entirely.
#
ADDONCOMPLETE=FALSE
ADDONMISSING=TRUE
if [ -d $ADDONDIR ]
then ADDONCOMPLETE=TRUE
> /tmp/${ADDON}Missing
for i in $FILES
do if [ ! -f $ADDONDIR/$i -a ! -d $ADDONDIR/$i ]
then echo "$i" >> /tmp/${ADDON}Missing
ADDONCOMPLETE=FALSE
else ADDONMISSING=FALSE
fi
done
fi
# Now:
# ADDONMISSING is TRUE if the addon directory is missing completely.
# ADDONCOMPLETE is TRUE if the addon has all the proper files in it.
# (they may not be up to date, however).
# MAINMISSING is TRUE if none of the addon files exist in the main
# distribution.
# MAINCOMPLETE is TRUE if all the addon files exist in the main
# distribution. They may not be up to date, however.
#
if [ $ADDONCOMPLETE = TRUE -a $MAINMISSING = TRUE ]
then echo "$ADDON distribution already stripped and is complete"
continue
fi
if [ $MAINCOMPLETE = TRUE ]
then echo "main distribution has all the $ADDON files it should"
rm /tmp/MainMissing
fi
if [ $ADDONCOMPLETE = TRUE ]
then echo "$ADDON distribution has all the files it should"
rm /tmp/${ADDON}Missing
fi
if [ $ADDONCOMPLETE = TRUE -a $MAINCOMPLETE = TRUE ]
then
echo "Both the main and the $ADDON distribution have all the files."
echo "However, one of them may be out of date."
echo "You'll have to figure out which files are newest and move"
echo "them into the main distribution. To help you do this,"
echo "here's a diff of the main (<) vs. $ADDON (>), which will be"
echo "left in /tmp/${ADDON}Diffs:"
(for i in $FILES
do diff -cr $i $ADDONDIR/$i
done
) | tee /tmp/${ADDON}Diffs
echo "If you say the word now I'll assume that the main"
echo "distribution is the good one, remove the redundant $ADDON,"
echo "and strip the files from the main one to create a new"
echo "$ADDON distribution."
if [ `$CONFIRM "Shall I replace the bad $ADDON with a new one ?"\
TRUE` = FALSE ]
then echo "Ok, go figure out which files in the redundant"
echo "$ADDON are ones you want to keep, move them"
echo "into the main distribution, and run $0 again."
echo "To help you, I'll leave a list of the $ADDON"
echo "files in /tmp/${ADDON}Files."
echo $FILES|tr ' ' '\012' >/tmp/${ADDON}Files
exit 1
fi
fi
if [ $MAINCOMPLETE = FALSE -a $MAINMISSING = FALSE -a $ADDONCOMPLETE = TRUE ]
then (
echo "There is a complete $ADDON distribution in $ADDONDIR,"
echo "but the main distribution is missing some $ADDON files."
echo "Most likely this happened because someone aborted a"
echo "merge, and the files in $ADDON represent a complete"
echo "up-to-date distribution."
echo "If you say the word now I'll assume that is so, remove"
echo "whatever $ADDON files are left in the main distribution,"
echo "and leave the files in $ADDONDIR as the $ADDON distribution."
echo "To help you decide, here's a list of the files that are"
echo "missing from the main distribution:"
cat /tmp/MainMissing
echo) | more
if [ `$CONFIRM "Shall I remove the $ADDON files from the main?"\
TRUE` = FALSE ]
then echo "Ok, go figure out which $ADDON files in the main"
echo "distribution are ones you want to keep, move them"
echo "into the $ADDON distribution by hand."
exit 1
else echo "Removing $ADDON from main distribution."
rm -rf $FILES
echo "A complete $ADDON distribution is still in $ADDONDIR."
exit 0
fi
fi
if [ $ADDONCOMPLETE = FALSE -a $ADDONMISSING = FALSE -a $MAINCOMPLETE = TRUE ]
then (
echo "There is an incomplete $ADDON distribution in $ADDONDIR."
echo "The main distribution has all the files it should."
echo "Most likely the main distribution is up-to-date, and the"
echo "incomplete $ADDON resulted when someone aborted a 'strip'."
echo "If you say the word now I'll assume that is so, remove"
echo "the incomplete $ADDON, and go on to strip the files from"
echo "the main one to create a new $ADDON distribution."
echo "Here's a list of the files that are missing from $ADDON:"
cat /tmp/${ADDON}Missing
echo) | more
if [ `$CONFIRM "Shall I replace the bad $ADDON with a new one ?"\
TRUE` = FALSE ]
then echo "Ok, go figure out which files in the incomplete"
echo "$ADDON are ones you want to keep, move them"
echo "into the main distribution, and run $0 again."
exit 1
fi
fi
# Now $MAINCOMPLETE = TRUE, and the addon is expendable. Remove the
# addon distribution and strip the files from the main distribution
# into it.
#
if [ $ADDONMISSING = FALSE ]
then echo "Removing old $ADDON distribution in $ADDONDIR"
(cd $ADDONDIR; rm -rf $FILES)
fi
if [ ! -d $ADDONDIR ]
then echo "Creating new directory '"$ADDONDIR"'"
mkdir $ADDONDIR
fi
echo "Moving files into $ADDONDIR:"
# the following tar pipe may not work on System V
#
if (tar cf - $FILES |(cd $ADDONDIR; tar x${V}f -))
then
echo "Removing $FILES"
rm -rf $FILES
fi
done