-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-cd
executable file
·353 lines (306 loc) · 9.68 KB
/
update-cd
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
#!/bin/bash
#
# $Id$
#
# (c) Steve McIntyre <stevem@chiark.greenend.org.uk> Released under
# GNU GPL v2 1st January 2001
#
# Quick and dirty script to create update CDs for people to upgrade
# from an initial stable release (r0) to the latest point release level
#
set -e
# Configuration goes here.
# Where is your mirror?
MIRROR_NORM=/srv/cdbuilder.debian.org/src/ftp/debian
MIRROR_AMD64=/srv/cdbuilder.debian.org/src/ftp/debian-amd64/debian
# Do you want non-free? 1 for yes, 0 for no
NONFREE=0
# What release version is this?
VER=6.0.2.1
# Is this an official CD?
OFFICIAL=Official
# OFFICIAL="Unofficial snapshot"
# Path to use with mkisofs/mkhybrid
MKISOFS="$PWD/../genisoimage -jigdo-template-compress bzip2 -r -checksum_algorithm_iso md5,sha1,sha256,sha512"
# Use JTE extensions to mkisofs to make jigdo files?
JTE=1
# Set up torrents too?
BT=1
# The working directory to use. MUST be on the same partition as the mirror.
TDIR=/srv/cdbuilder.debian.org/src/deb-cd/tmp/squeeze-update/cd-work
# Building squeeze cd set ...
CODENAME=squeeze
# Path where the images will be written
OUT=/srv/cdbuilder.debian.org/src/deb-cd/tmp/squeeze-update/cd-out
# Location(s) for the snapshot(s)
SNAPSHOT='Debian=http://us.cdimage.debian.org/cdimage/snapshot/Debian/ --try-last'
# Type of disc image, cd or dvd (lower case)
if [ "$1"x = ""x ] ; then
TYPE=cd
else
TYPE=$1
fi
case $TYPE in
cd|CD)
TYPE=cd
TYPEUP=CD;;
dvd|DVD)
TYPE=dvd
TYPEUP=DVD;;
*)
echo "Specify a disk type..."
exit 1;;
esac
# Location of the diff file to use to determine the changes. If you leave
# this blank, we'll try to determine the changes from the ChangeLog files,
# which is probably less accurate.
DIFF=/home/debian-cd/lists/squeeze/r0-r2.diff
if [ "$TYPE" = "cd" ] ; then
CDSIZE=644 # megabytes, leaving space for metadata
else
CDSIZE=4300 # megabytes, leaving space for metadata
fi
REL=Debian"$VER"
CLOG=dists/$CODENAME/ChangeLog
UPD=$TDIR/$CODENAME-update
DATE=`date +%Y%m%d`
BASEDIR=`pwd`
SECTS="main non-free contrib"
VERBOSE=2
GRAB_MD5=$BASEDIR/tools/grab_md5
export VERBOSE BASEDIR SECTS
FIRSTVER=`echo $VER | cut -c 1-4`0
CAPCODE=`perl -e "print ucfirst("$CODENAME")"`
export FIRSTVER CAPCODE
if [ "$ARCHLIST"x = ""x ] ; then
ARCHLIST="arm64 armel armhf amd64 i386 mips mipsel powerpc s390x source kfreebsd-amd64 kfreebsd-i386" # amd64 # all dealt with specially
fi
export TDIR NONFREE VER MIRROR CODENAME OUT BASEDIR
CDSIZE=$(($CDSIZE * 1024))
create_control=$BASEDIR/tools/create_control
set_mkisofs_opts=$BASEDIR/tools/set_mkisofs_opts
addfiles=$BASEDIR/tools/add_files
copy_file () {
ROOTDIR=$1
shift
FILE=$1
DIR=`dirname $FILE`
if [ ! -d $ROOTDIR/$DIR ] ; then
mkdir -p $ROOTDIR/$DIR
fi
if [ -e $MIRROR/$FILE ] ; then
cp -l $MIRROR/$FILE $ROOTDIR/$FILE
else
echo
echo "File $FILE not found!"
exit 1
fi
}
make_cd () {
CDNUM=$1
shift
THISNUM=$1
shift
THISARCH=$1
shift
SRCFILES=$1
shift
ARCHFILES=$1
shift
ALLFILES=$1
echo
echo " Creating Packages and Sources files for CD$CDNUM"
cd $UPD
$create_control CD$CDNUM $THISARCH
echo " Creating image for CD$CDNUM ($SRCFILES source files, $ARCHFILES $ARCH debs, $ALLFILES all debs)"
echo -n " "
BASENAME="debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM"
ISODIR=$OUT/$THISARCH/iso-$TYPE
JIGDODIR=$OUT/$THISARCH/jigdo-$TYPE
LISTDIR=$OUT/$THISARCH/list-$TYPE
BTDIR=$OUT/$THISARCH/bt-$TYPE
if [ ! -d ${ISODIR} ] ; then
mkdir -p ${ISODIR}
fi
if [ $JTE = 1 ] && [ ! -d ${JIGDODIR} ] ; then
mkdir -p ${JIGDODIR}
fi
if [ ! -d ${LISTDIR} ] ; then
mkdir -p ${LISTDIR}
fi
if [ $BT = 1 ] && [ ! -d ${BTDIR} ] ; then
mkdir -p ${BTDIR}
fi
if [ $JTE = 1 ] ; then
set +e
${MKISOFS} -J -r -V "Debian $VER update $TYPEUP" -o \
${ISODIR}/${BASENAME}.iso \
-jigdo-jigdo ${JIGDODIR}/${BASENAME}.jigdo \
-jigdo-template ${JIGDODIR}/${BASENAME}.template \
-jigdo-map Debian=$MIRROR/ \
-jigdo-force-md5 /pool/ \
-md5-list $UPD/md5-check \
$UPD/CD$CDNUM 2>&1 | grep "extents written"
if [ $? -ne 0 ] ; then
echo "${MKISOFS} failed, error $?"
exit 1
fi
set -e
$BASEDIR/tools/jigdo_cleanup \
${JIGDODIR}/${BASENAME}.jigdo \
${BASENAME}.iso \
$OUT ${BASENAME}.template \
"Debian ${DEBIAN_KERNEL} $VER - $OFFICIAL $THISARCH $FIRSTVER->$VER update $TYPEUP #$THISNUM"
echo $SNAPSHOT >> ${JIGDODIR}/${BASENAME}.jigdo
# Make sure that the ISO is as new/newer than the jigdo file; #587774
touch ${ISODIR}/${BASENAME}.iso
MD5=`cat ${JIGDODIR}/${BASENAME}.jigdo | \
awk '/Image Hex MD5Sum/ {print $5}'`
echo "$MD5 ${BASENAME}.iso" >> ${JIGDODIR}/MD5SUMS.update
echo "$MD5 ${BASENAME}.iso" >> ${ISODIR}/MD5SUMS.update
[ $BT = 1 ] && echo "$MD5 ${BASENAME}.iso" >> ${BTDIR}/MD5SUMS.update
for SHA_SIZE in 1 256 512; do
SHA=`cat ${JIGDODIR}/${BASENAME}.jigdo | \
awk "/Image Hex SHA${SHA_SIZE}Sum/ {print \\$5}"`
if [ "$SHA"x = ""x ] ; then
echo "SHA fail"
exit 1
fi
echo "$SHA ${BASENAME}.iso" >> ${JIGDODIR}/SHA${SHA_SIZE}SUMS.update
echo "$SHA ${BASENAME}.iso" >> ${ISODIR}/SHA${SHA_SIZE}SUMS.update
[ $BT = 1 ] && echo "$SHA ${BASENAME}.iso" >> ${BTDIR}/SHA${SHA_SIZE}SUMS.update
done
gzip -9 ${JIGDODIR}/${BASENAME}.jigdo
mv ${JIGDODIR}/${BASENAME}.jigdo.gz ${JIGDODIR}/${BASENAME}.jigdo
else
set +e
${MKISOFS} -J -r -V "Debian $VER update $TYPEUP" -o \
$OUT/iso-$TYPE/${BASENAME}.iso \
$UPD/CD$CDNUM 2>&1 | grep "extents written"
if [ $? -ne 0 ] ; then
echo "${MKISOFS} failed, error $?"
exit 1
fi
set -e
fi
find $UPD/CD$CDNUM/pool -type f | sed 's?^.*/??g' | gzip -9 > ${LISTDIR}/${BASENAME}.list.gz
}
add_file () {
file=$1
case "$THISARCH" in
source)
case "$file" in
*.xz|*.lzma|*.gz|*.bz2|*.dsc)
copy_file $UPD/CD$CDNUM $file
SRCFILES=$(($SRCFILES + 1))
;;
esac
echo -en "\r$SRCFILES copied"
;;
*)
case "$file" in
*_$THISARCH.deb)
copy_file $UPD/CD$CDNUM $file
ARCHFILES=$(($ARCHFILES + 1))
;;
*_all.deb)
copy_file $UPD/CD$CDNUM $file
ALLFILES=$(($ALLFILES + 1))
;;
esac
echo -en "\r$THISARCH:$ARCHFILES all:$ALLFILES copied"
;;
esac
}
start_new_disc () {
echo
cd $MIRROR
THISNUM=$((THISNUM + 1))
if [ $THISARCH = "source" ] ; then
echo "Creating $TYPEUP$CDNUM for source (part $THISNUM)"
else
echo "Creating $TYPEUP$CDNUM for binary-$THISARCH (part $THISNUM)"
fi
mkdir $UPD/CD$CDNUM $UPD/CD$CDNUM/.disk
INFO="Debian ${DEBIAN_KERNEL} $VER Update $TYPEUP $DATE: $THISARCH $TYPEUP $THISNUM"
echo $INFO > $UPD/CD$CDNUM/.disk/info
SIZE_USED=0
SRCFILES=0
ARCHFILES=0
ALLFILES=0
}
echo Cleaning up
rm -rf $UPD
mkdir -p $UPD
CDNUM=1
echo Creating file list
if [ ! -e $DIFF ] ; then
echo "NO DIFF FOUND. ABORT!"
exit 1
fi
cp $DIFF $UPD/list
if [ "$NONFREE"x != "1"x ] ; then
echo "Removing non-free files from the list"
grep -v non-free $UPD/list > $UPD/list1
mv -f $UPD/list1 $UPD/list
fi
$GRAB_MD5 $MIRROR_NORM "$ARCHLIST" $CODENAME $CODENAME $UPD/md5-check
for THISARCH in $ARCHLIST
do
THISNUM=0
MIRROR=$MIRROR_NORM
case "$THISARCH" in
kfreebsd) DEBIAN_KERNEL="GNU/kFreeBSD";;
hurd) DEBIAN_KERNEL="GNU/Hurd";;
source) DEBIAN_KERNEL="";;
*) DEBIAN_KERNEL="GNU/Linux";;
esac
export DEBIAN_KERNEL
rm -rf $OUT/$THISARCH/*-$TYPE
for file in `cat $UPD/list`
do
if [ ! -d $UPD/CD$CDNUM ] ; then
start_new_disc
fi
if [ "$BACKOUT_FILE"x != ""x ] ; then
echo "Starting with backed-out file $BACKOUT_FILE"
add_file $BACKOUT_FILE
BACKOUT_FILE=""
fi
size=$(stat -c %s $MIRROR/$file)
size_kib=$(($size / 1024))
if [ $size_kib -gt $CDSIZE ] ; then
echo "Ignoring file $file - it won't fit!"
else
add_file $file
SIZE_USED=`du -sk $UPD/CD$CDNUM | awk '{print $1}'`
if [ $SIZE_USED -gt $CDSIZE ] ; then
# Back out the last file added
size=`stat -c %s $UPD/CD$CDNUM/$file`
rm -f $UPD/CD$CDNUM/$file
echo
echo " Overfull: back out $file ($size bytes)"
DIR=`dirname $file`
rmdir $DIR > /dev/null 2>&1 || true
BACKOUT_FILE=$file
make_cd $CDNUM $THISNUM $THISARCH $SRCFILES $ARCHFILES $ALLFILES
CDNUM=$(($CDNUM + 1))
continue
fi
fi
done
echo
echo "Making last disc in set for $THISARCH: size $SIZE_USED, BACKOUT_FILE \"$BACKOUT_FILE\""
# Catch the case where we still have a backout file at the very
# end of the set
if [ "$BACKOUT_FILE"x != ""x ] ; then
if [ ! -d $UPD/CD$CDNUM ] ; then
start_new_disc
fi
echo "Starting last disc with backed-out file $BACKOUT_FILE"
add_file $BACKOUT_FILE
BACKOUT_FILE=""
fi
make_cd $CDNUM $THISNUM $THISARCH $SRCFILES $ARCHFILES $ALLFILES
CDNUM=$(($CDNUM + 1))
done