-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmerge
More file actions
executable file
·183 lines (164 loc) · 6.01 KB
/
merge
File metadata and controls
executable file
·183 lines (164 loc) · 6.01 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
: "merge merge addon products into distribution tree"
# Use strip to move the addon products from the distribution tree into their
# own directories.
if [ $# = 0 ]
then set cmacs viplus adamacs
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 [ $MAINCOMPLETE = TRUE -a $ADDONMISSING = TRUE ]
then echo "$ADDON distribution already merged 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 and remove the redundant $ADDON."
echo "$ADDON distribution."
if [ `$CONFIRM "Shall I remove the redundant $ADDON ?"\
TRUE` = FALSE ]
then echo "Ok, go figure out which files in the redundant"
echo "$ADDON are ones you want to keep and move them"
echo "into the main distribution yourself."
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
else echo "Removing redundant $ADDONDIR directory..."
rm -rf $ADDONDIR
echo "A complete distribution still exists in the main."
exit 0
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, and replace"
echo "whatever old $ADDON files are left in the main distribution"
echo "with the ones now in 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 replace the files in main from $ADDON ?"\
TRUE` = FALSE ]
then echo "Ok, go figure out which $ADDON files in the main"
echo "distribution are ones you want to keep, and move them"
echo "into the $ADDON distribution by hand, and re-run $0."
exit 1
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 leave the complete $ADDON"
echo "distribution in the main one."
echo "Here's a list of the files that are missing from $ADDON:"
cat /tmp/${ADDON}Missing
echo) | more
if [ `$CONFIRM "Shall I remove the incomplete $ADDON ?"\
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 yourself."
exit 1
else echo "Removing $ADDON files from incomplete distribution in $ADDONDIR..."
(cd $ADDONDIR && rm -rf $FILES)
echo "A complete distribution still exists in the main."
exit 0
fi
fi
if [ $MAINMISSING = FALSE ]
then echo "Removing old files from main distribution"
rm -rf $FILES
fi
echo "Moving files from directory $ADDONDIR:"
# cd to $ADDONDIR so path names are relative to distribution root
# This would move binary files (in 'local') as well, which could
# trash some of them if they were linked, so we remove them from
# the addon.
rm -rf $ADDONDIR/local
if (cd $ADDONDIR; tar cf - .) | tar x${V}f -
then echo "Removing directory $ADDON"
rm -rf $ADDON
fi
done