-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkiso
More file actions
executable file
·525 lines (439 loc) · 18.4 KB
/
mkiso
File metadata and controls
executable file
·525 lines (439 loc) · 18.4 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
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
#!/bin/bash
## Deepin LiveCD Build Tool <http://www.linuxdeepin.com/>
## 冷罡华 (Hiweed) <hiweed@gmail.com>
## 张 成 (Stephen) <zhangcheng@linuxdeepin.com>
## change directory to the working directory first and set WORK_PATH
export OLD_PWD=${PWD}
cd $(dirname $0)
export WORK_PATH=$(pwd)
export SCRIPT_NAME=$(basename $0)
export ALL_DONE="false"
[[ -f "${WORK_PATH}/common" ]] && source ${WORK_PATH}/common \
|| echo "[ERROR] common file does not exist."
source_local_if_exist "${WORK_PATH}/${SCRIPT_NAME}.conf"
clean_up ()
{
[[ -f "${CHROOT_LOCK}" ]] && postchroot
[[ -f "${BUILD_LOCK}" ]] && rm ${BUILD_LOCK}
}
do_help ()
{
echo "Usage:
$0 [option] action1 [action2 [action3..]]
Options:
-arch=i386|amd64 Default to the host arch
-scheme=SCHEME Default to "default"
-version=11.12|12.06|... Default to "current"
-output=FILENAME Output iso file name, default to \${DISTRO_NAME}-SCHEME-ARCH.iso
-outputbase=OUTPUT_BASE Where to put output files, default to ${OUTPUT_BASE}
-buildbase=BUILD_BASE Where to put files used to build, default to ${BUILD_BASE}
-copy-chroot-path=PATH If specified, copy the PATH to CHROOT_PATH instead of building a real base
-backup-chroot-path=PATH If specified, copy the chroot path to PATH right after finishing building base
Actions:
init Initialization work, only need to do once in one host
base Bootstrap a base system
desktop Install deepin-desktop related packages
custom Execute the customization scripts
casper Setting up for casper
iso Build the ISO image
chroot Get a shell in chroot environment
zsync Build the zsync index file
hashsum Generate md5sum/sha1sum/sha256sum to all iso files in output path
dailylink Update daily directory link
bt Make torrent files
help Display this help
"
}
## parse the commandline
check_commandline ()
{
ACTIONS=""
while [ $# -gt 0 ]; do
case "$1" in
-arch=*)
ARCH=${1##-arch=}
;;
-version=*)
VERSION=${1##-version=}
;;
-scheme=*)
SCHEME=${1##-scheme=}
;;
-output=*)
OUTPUT=${1##-output=}
;;
-outputbase=*)
OUTPUT_BASE=${1##-outputbase=}
if [[ $OUTPUT_BASE != /* ]]; then OUTPUT_BASE="${OLD_PWD}/$OUTPUT_BASE"; fi
;;
-buildbase=*)
BUILD_BASE=${1##-buildbase=}
if [[ $BUILD_BASE != /* ]]; then BUILD_BASE="${OLD_PWD}/$BUILD_BASE"; fi
;;
-copy-chroot-path=*)
COPY_CHROOT_PATH=${1##-copy-chroot-path=}
if [[ $COPY_CHROOT_PATH != /* ]]; then COPY_CHROOT_PATH="${OLD_PWD}/$COPY_CHROOT_PATH"; fi
;;
-backup-chroot-path=*)
BACKUP_CHROOT_PATH=${1##-backup-chroot-path=}
if [[ $BACKUP_CHROOT_PATH != /* ]]; then BACKUP_CHROOT_PATH="${OLD_PWD}/$BACKUP_CHROOT_PATH"; fi
;;
*)
ACTIONS="${ACTIONS}$1 "
;;
esac
shift
done
}
## initialize some variables for the script execution
script_init ()
{
[[ "$(arch)" == "x86_64" ]] && DEFAULT_ARCH="amd64" || DEFAULT_ARCH="i386"
ARCH=${ARCH:-${DEFAULT_ARCH}}
DEFAULT_VERSION=$(readlink ${WORK_PATH}/conf/current)
VERSION=${VERSION:-${DEFAULT_VERSION}}
DEFAULT_SCHEME=$(readlink ${WORK_PATH}/conf/${VERSION}/default)
SCHEME=${SCHEME:-${DEFAULT_SCHEME}}
CONF_PATH="${WORK_PATH}/conf/${VERSION}/${SCHEME}"
source_local_if_exist "${CONF_PATH}/${SCRIPT_NAME}.conf"
DISTRO_NAME=${DISTRO_NAME:-"deepin"}
DEFAULT_OUTPUT="${DISTRO_NAME}-${SCHEME}-${ARCH}.iso"
OUTPUT=${OUTPUT:-${DEFAULT_OUTPUT}}
DEFAULT_OUTPUT_PATH="${OUTPUT_BASE}/daily-live/${SCHEME}/$(date +%Y%m%d)"
OUTPUT_PATH=${OUTPUT_PATH:-${DEFAULT_OUTPUT_PATH}}
ISO_FILE="${OUTPUT_PATH}/${OUTPUT}"
## BUILD_BASE is already set
CHROOT_PATH="${BUILD_BASE}/${VERSION}/${SCHEME}/${ARCH}/chroot"
ISO_BUILD_PATH="${BUILD_BASE}/${VERSION}/${SCHEME}/${ARCH}/iso"
COPY_CHROOT_PATH="${COPY_CHROOT_PATH:-}"
BACKUP_CHROOT_PATH="${BACKUP_CHROOT_PATH:-}"
APT_ARCHIVE_PATH="${APT_ARCHIVE_BASE}/${VERSION}/${ARCH}"
## Don't use savelog to rotate log, instead, save all logs,
## postfix with the log start time
LOG_PATH="${LOG_BASE}/${VERSION}/${SCHEME}/${ARCH}"
LOG_TIME="$(date +%Y%m%d%H%M%S)"
LOG_FILE="${LOG_PATH}/${SCRIPT_NAME}.log.${LOG_TIME}"
[[ -d "${LOG_PATH}" ]] || mkdir -p ${LOG_PATH}
## mkiso.log points to the latest log
ln -sf ${SCRIPT_NAME}.log.${LOG_TIME} ${LOG_PATH}/${SCRIPT_NAME}.log
BUILD_LOCK="/tmp/${SCRIPT_NAME}-${VERSION}-${SCHEME}-${ARCH}.lock"
CHROOT_LOCK="/tmp/${SCRIPT_NAME}-${VERSION}-${SCHEME}-${ARCH}-chroot.lock"
source_local_if_exist "${CONF_PATH}/${DISTRO_NAME}.all.conf"
source_local_if_exist "${CONF_PATH}/${DISTRO_NAME}.${ARCH}.conf"
echo_and_log "[MKISO] ----- ISO parameters -----"
echo_and_log "[MKISO] Distro Name: ${DISTRO_NAME}"
echo_and_log "[MKISO] Distro Version: ${VERSION}"
echo_and_log "[MKISO] Distro Arch: ${ARCH}"
echo_and_log "[MKISO] Build Scheme: ${SCHEME}"
echo_and_log "[MKISO] Output File: ${OUTPUT}"
echo_and_log "[MKISO] Output Path: ${OUTPUT_PATH}"
echo_and_log "[MKISO] ISO Full Path: ${ISO_FILE}"
echo_and_log "[MKISO] Conf Path: ${CONF_PATH}"
echo_and_log "[MKISO] Chroot Path: ${CHROOT_PATH}"
echo_and_log "[MKISO] ISO Build Path: ${ISO_BUILD_PATH}"
echo_and_log "[MKISO] Log Path: ${LOG_PATH}"
echo_and_log "[MKISO] Copy Chroot Path: ${COPY_CHROOT_PATH}"
echo_and_log "[MKISO] Backup Chroot Path: ${BACKUP_CHROOT_PATH}"
echo_and_log "[MKISO] Actions: ${ACTIONS}"
echo_and_log ""
}
do_action ()
{
while [ $# -gt 0 ]; do
case "$1" in
help)
do_help ;;
clean)
do_clean ;;
init)
do_init ;;
base)
do_base ;;
desktop)
do_desktop ;;
custom)
do_custom ;;
casper)
do_casper ;;
iso)
do_iso ;;
chroot)
do_chroot ;;
zsync)
do_zsync ;;
hashsum)
do_hashsum ;;
dailylink)
do_dailylink ;;
bt)
do_bt ;;
*)
echo "Unknown Action: $1"
esac
shift
done
}
do_init () {
echo_and_log "[INIT] Initialize the host system to build ISO"
echo_and_log "[INIT] Installing tools need to build ISO"
echo_and_log "[INIT] Tools to be installed: debootstrap squashfs-tools genisoimage syslinux lzma mktorrent zsync"
sudo apt-get install -y --no-install-recommends \
debootstrap squashfs-tools genisoimage syslinux lzma mktorrent zsync | log
echo_and_log "[INIT] Checking if code name oneiric exists ..."
[[ -e /usr/share/debootstrap/scripts/oneiric ]] \
|| sudo ln -s gutsy /usr/share/debootstrap/scripts/oneiric
echo_and_log "[INIT] Finished initialization :-)"
echo_and_log ""
}
prechroot () {
lockfile ${CHROOT_LOCK}
sudo cp /etc/hosts ${CHROOT_PATH}/etc/
sudo cp /etc/resolv.conf ${CHROOT_PATH}/etc/
sudo mount --bind /dev ${CHROOT_PATH}/dev
sudo chroot ${CHROOT_PATH} mount -t proc none /proc
sudo chroot ${CHROOT_PATH} mount -t sysfs none /sys
sudo chroot ${CHROOT_PATH} mount -t devpts none /dev/pts
sudo chroot ${CHROOT_PATH} dbus-uuidgen | sudo tee ${CHROOT_PATH}/var/lib/dbus/machine-id | log
sudo chroot ${CHROOT_PATH} dpkg-divert --local --rename --add /sbin/initctl | log
sudo chroot ${CHROOT_PATH} ln -s /bin/true /sbin/initctl | log
echo -e "#!/bin/sh\nexit 101" | sudo tee ${CHROOT_PATH}/usr/sbin/policy-rc.d | log
sudo chmod +x ${CHROOT_PATH}/usr/sbin/policy-rc.d
[[ -d ${APT_ARCHIVE_PATH} ]] || mkdir -p ${APT_ARCHIVE_PATH}
sudo mount --bind ${APT_ARCHIVE_PATH} ${CHROOT_PATH}/var/cache/apt/archives/
}
postchroot () {
[[ -f ${CHROOT_LOCK} ]] || exit_with_msg "[POSTCHROOT] CHROOT_LOCK file does not exist, did you run postchroot by actident?"
sudo chroot ${CHROOT_PATH} umount /proc
sudo chroot ${CHROOT_PATH} umount /sys
sudo chroot ${CHROOT_PATH} umount /dev/pts
sudo rm -rf ${CHROOT_PATH}/tmp/* ${CHROOT_PATH}/root/.bash_history
sudo rm -f ${CHROOT_PATH}/etc/hosts
sudo rm -f ${CHROOT_PATH}/etc/resolv.conf
sudo umount ${CHROOT_PATH}/dev
[[ -f "${CHROOT_PATH}/var/lib/dbus/machine-id" ]] && sudo rm -f ${CHROOT_PATH}/var/lib/dbus/machine-id
[[ -f "${CHROOT_PATH}/sbin/initctl" ]] && sudo rm -f ${CHROOT_PATH}/sbin/initctl
[[ -f "${CHROOT_PATH}/usr/sbin/policy-rc.d" ]] && sudo rm -f ${CHROOT_PATH}/usr/sbin/policy-rc.d
sudo chroot ${CHROOT_PATH} dpkg-divert --rename --remove /sbin/initctl |& log
sudo umount ${CHROOT_PATH}/var/cache/apt/archives/
rm -f ${CHROOT_LOCK}
}
do_clean () {
echo "do_clean is not implemented"
clean_up
}
do_regular_base () {
echo_and_log "[BASE] Building base system with debootstrap ..."
echo_and_log "[BASE] Using local mirror: ${DEBOOTSTRAP_MIRROR}"
echo_and_log "[BASE] Using Code name: ${CODENAME}"
if [[ -d ${CHROOT_PATH} ]]; then sudo rm -rf ${CHROOT_PATH}; fi
mkdir -p ${CHROOT_PATH}
sudo debootstrap --arch=${ARCH} --include=dbus ${CODENAME} ${CHROOT_PATH} ${DEBOOTSTRAP_MIRROR} | log
echo_and_log "[BASE] Build base system finished"
if [ -n "$BACKUP_CHROOT_PATH" ]; then
echo_and_log "[BASE] Backing up CHROOT_PATH to BACKUP_CHROOT_PATH (${BACKUP_CHROOT_PATH}) ..."
[[ -d $(dirname ${BACKUP_CHROOT_PATH}) ]] || mkdir -p $(dirname ${BACKUP_CHROOT_PATH})
sudo rsync -a --delete --delete-after "${CHROOT_PATH}/" "${BACKUP_CHROOT_PATH}/"
fi
}
do_base () {
if [ -n "$COPY_CHROOT_PATH" ]; then
if [ -d "$COPY_CHROOT_PATH" ]; then
echo_and_log "[BASE] copy COPY_CHROOT_PATH (${COPY_CHROOT_PATH}) to CHROOT_PATH ..."
[[ -d $(dirname ${CHROOT_PATH}) ]] || mkdir -p $(dirname ${CHROOT_PATH})
sudo rsync -a --delete --delete-after "${COPY_CHROOT_PATH}/" "${CHROOT_PATH}/"
if [ -n "$BACKUP_CHROOT_PATH" ]; then
if [[ "$BACKUP_CHROOT_PATH" == "$COPY_CHROOT_PATH" ]]; then
echo_and_log "[BASE] BACKUP_CHROOT_PATH is the same as COPY_CHROOT_PATH, skip backup process"
else
echo_and_log "[BASE] backup CHROOT_PATH to BACKUP_CHROOT_PATH (${BACKUP_CHROOT_PATH}) ..."
[[ -d $(dirname ${BACKUP_CHROOT_PATH}) ]] || mkdir -p $(dirname ${BACKUP_CHROOT_PATH})
sudo rsync -a --delete --delete-after "${CHROOT_PATH}/" "${BACKUP_CHROOT_PATH}/"
fi
fi
else
echo_and_log "[BASE] Ignore non-exist COPY_CHROOT_PATH (${COPY_CHROOT_PATH}), doing a regular base"
do_regular_base
fi
else
do_regular_base
fi
echo_and_log ""
}
do_desktop () {
echo_and_log "[DESKTOP] Installing packages defined by scheme ..."
prechroot
echo "${SOURCES_LIST}" | sudo tee "${CHROOT_PATH}/etc/apt/sources.list" > /dev/null
echo "${APT_PREFERENCES}" | sudo tee "${CHROOT_PATH}/etc/apt/preferences" > /dev/null
wget -q "${DEEPIN_APTKEY_URL}" -O- | chroot_do ${CHROOT_PATH} apt-key add - > /dev/null
wget -q "${MEDIBUNTU_APTKEY_URL}" -O- | chroot_do ${CHROOT_PATH} apt-key add - > /dev/null
chroot_do ${CHROOT_PATH} apt-get --allow-unauthenticated update |& log
echo_and_log "[DESKTOP] Packages are: ${DEFAULT_PACKAGES}"
chroot_do ${CHROOT_PATH} apt-get install \
--no-install-recommends -y --force-yes \
--allow-unauthenticated \
${DEFAULT_PACKAGES} |& log
echo_and_log "[DESKTOP] Marking packages as manually installed ... "
chroot_do ${CHROOT_PATH} aptitude unmarkauto ~M |& log
echo_and_log "[DESKTOP] Install packages needed only by live cd: ${LIVE_ONLY_PACKAGES}"
chroot_do ${CHROOT_PATH} apt-get install \
--no-install-recommends -y --force-yes \
--allow-unauthenticated \
${LIVE_ONLY_PACKAGES} |& log
postchroot
echo_and_log "[DESKTOP] Installation finished"
}
do_custom () {
echo_and_log "[CUSTOM] Executing custom script (inside chroot) ..."
prechroot
chroot_source_local_if_exist "${CONF_PATH}/custom.chroot.sh" |& log
chroot_do ${CHROOT_PATH} apt-get --no-install-recommends -y --force-yes \
--allow-unauthenticated upgrade |& log
postchroot
echo_and_log "[CUSTOM] Executing custom script (outside chroot) ..."
source_local_if_exist "${CONF_PATH}/custom.sh"
echo_and_log "[CUSTOM] Customization finished ..."
echo_and_log ""
}
do_casper () {
echo_and_log "[CASPER] Generating casper directory ..."
[[ -d ${CHROOT_PATH} ]] || exit_with_msg "[CASPER] you must build a base system before doing casper"
[[ -d "${ISO_BUILD_PATH}/casper" ]] && sudo rm -rf "${ISO_BUILD_PATH}/casper"
mkdir -p "${ISO_BUILD_PATH}/casper"
echo_and_log "[CASPER] Generating filesystem.squashfs ..."
sudo mksquashfs ${CHROOT_PATH} ${ISO_BUILD_PATH}/casper/filesystem.squashfs -comp xz | log
echo_and_log "[CASPER] Generating filesystem.size ..."
sudo du -sx --block-size=1 ${CHROOT_PATH} | cut -f1 > ${ISO_BUILD_PATH}/casper/filesystem.size
echo_and_log "[CASPER] Generating filesystem.manifest ..."
chroot_do ${CHROOT_PATH} dpkg-query -W --showformat='${Package} ${Version}\n' \
> ${ISO_BUILD_PATH}/casper/filesystem.manifest
echo_and_log "[CASPER] Generating filesystem.manifest-desktop ..."
sudo cp ${ISO_BUILD_PATH}/casper/filesystem.manifest{,-desktop}
for i in $UBIQUITY_REMOVE
do
sudo sed -i /$i/d ${ISO_BUILD_PATH}/casper/filesystem.manifest-desktop
done
echo_and_log "[CASPER] Copying vmlinuz and initrd.lz to casper/ ..."
VMLINUZ_FILE="${CHROOT_PATH}/$(readlink ${CHROOT_PATH}/vmlinuz)"
[[ -f ${VMLINUZ_FILE} ]] \
&& sudo cp ${VMLINUZ_FILE} ${ISO_BUILD_PATH}/casper/vmlinuz \
|| exit_with_msg "[CASPER] vmlinuz not find in base system"
INITRD_FILE="${CHROOT_PATH}/$(readlink ${CHROOT_PATH}/initrd.img)"
[[ -f ${INITRD_FILE} ]] \
&& sudo cp ${INITRD_FILE} ${ISO_BUILD_PATH}/casper/initrd.lz \
|| exit_with_msg "[CASPER] initrd not find in base system"
echo_and_log "[CASPER] Finished generating casper directory"
echo_and_log ""
}
do_iso () {
echo_and_log "[ISO] Preparing to generating iso ..."
[[ -d "${ISO_BUILD_PATH}/casper" ]] || exit_with_msg "[ISO] You must generate casper before generating iso"
pushd ${ISO_BUILD_PATH} > /dev/null
echo_and_log "[ISO] Installing isolinux ..."
[[ -d ${ISO_BUILD_PATH}/isolinux ]] && sudo rm -rf ${ISO_BUILD_PATH}/isolinux
[[ -d ${CONF_PATH}/iso/isolinux/ ]] \
&& cp -r ${CONF_PATH}/iso/isolinux/ ${ISO_BUILD_PATH}/ \
|| exit_with_msg "[ISO] ${CONF_PATH}/iso/isolinux/ not found"
[[ -d ${CONF_PATH}/iso/preseed/ ]] && cp -r ${CONF_PATH}/iso/preseed/ ${ISO_BUILD_PATH}/
[[ -r ${CONF_PATH}/iso/DeepWin.exe ]] && cp ${CONF_PATH}/iso/DeepWin.exe ${ISO_BUILD_PATH}/
echo_and_log "[ISO] Refreshing MD5 checksum ..."
[[ -f ${ISO_BUILD_PATH}/md5sum.txt ]] && sudo rm -f ${ISO_BUILD_PATH}/md5sum.txt
find . -type f -print0 \
| xargs -0 sudo md5sum \
| grep -v isolinux/boot.cat > md5sum.txt
echo_and_log "[ISO] Generating README.diskdefines ..."
cat > ${ISO_BUILD_PATH}/README.diskdefines <<EOF
#define DISKNAME ${DISTRO_NAME} $VERSION "$CODENAME" - $STATUS $ARCH ($DATE)
#define TYPE binary
#define TYPEbinary 1
#define ARCH $ARCH
#define ARCH${ARCH} 1
#define DISKNUM 1
#define DISKNUM1 1
#define TOTALNUM 0
#define TOTALNUM0 1
EOF
[[ -d "${ISO_BUILD_PATH}/.disk" ]] || mkdir -p "${ISO_BUILD_PATH}/.disk"
echo_and_log "[ISO] Generating .disk/base_installable ..."
echo "full_cd/single" > ${ISO_BUILD_PATH}/.disk/cd_type
echo_and_log "[ISO] Generating .disk/info ..."
echo "${ISO_INFO}" > ${ISO_BUILD_PATH}/.disk/info
echo_and_log "[ISO] Generating .disk/release_notes_url ..."
echo "${RELEASE_URL}" > ${ISO_BUILD_PATH}/.disk/release_notes_url
echo_and_log "[ISO] Generating ISO: ${ISO_FILE} ..."
[[ -d ${OUTPUT_PATH} ]] || mkdir -p ${OUTPUT_PATH}
[[ -f ${ISO_FILE} ]] && sudo rm -f ${ISO_FILE}
sudo chown `whoami` -R .
genisoimage -D -r -V "$DISTRO_NAME $VERSION (${ARCH})" -cache-inodes -J -l \
-b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-input-charset utf-8 \
-o ${ISO_FILE} . |& log
isohybrid --partok ${ISO_FILE}
OUTPUT_BASENAME=$(basename ${OUTPUT} .iso)
echo_and_log "[ISO] Generating ${OUTPUT_BASENAME}.list ..."
find . -type f | cut -c 2- > ${OUTPUT_PATH}/${OUTPUT_BASENAME}.list
echo_and_log "[ISO] Generating ${OUTPUT_BASENAME}.manifest ..."
cp ${ISO_BUILD_PATH}/casper/filesystem.manifest ${OUTPUT_PATH}/${OUTPUT_BASENAME}.manifest
popd > /dev/null
echo_and_log "[ISO] Successfully generated ISO image: ${ISO_FILE} :)"
echo_and_log "[ISO] Size: `ls -lh ${ISO_FILE} |awk '{print $5}'`"
echo_and_log ""
}
do_chroot () {
echo_and_log "[MKISO] Preparing to chroot to build env ..."
if [ -d ${CHROOT_PATH} ]; then
prechroot
echo_and_log "[MKISO] Preparation done, now entering chroot ..."
chroot_do ${CHROOT_PATH} /bin/bash
echo_and_log "[MKISO] Exit from chroot environment"
postchroot
else
echo_and_log "[MKISO] Base system does not exist, exiting ..."
fi
echo_and_log ""
}
do_zsync () {
echo_and_log "[ZSYNC] Begin generating zsync index file ..."
[[ -d ${OUTPUT_PATH} ]] || exit_with_msg "[HASHSUM] Output path does not exist: ${OUTPUT_PATH}"
pushd ${OUTPUT_PATH} > /dev/null
zsyncmake -C ${OUTPUT} |& log
popd > /dev/null
echo_and_log "[ZSYNC] Finished generating zsync index file: ${ISO_FILE}.zsync"
echo_and_log ""
}
do_hashsum () {
echo_and_log "[HASHSUM] Calculating hashsums for all iso files in: ${OUTPUT_PATH}"
[[ -d ${OUTPUT_PATH} ]] || exit_with_msg "[HASHSUM] Output path does not exist: ${OUTPUT_PATH}"
pushd ${OUTPUT_PATH} > /dev/null
echo_and_log "[HASHSUM] Calculating md5sums on all iso files ..."
md5sum *.iso | tee MD5SUMS | log
echo_and_log "[HASHSUM] Calculating sha1sums on all iso files ..."
sha1sum *.iso | tee SHA1SUMS | log
echo_and_log "[HASHSUM] Calculating sha256sums on all iso files ..."
sha256sum *.iso | tee SHA256SUMS | log
popd > /dev/null
echo_and_log "[HASHSUM] Finished calculating hashsums for all iso files."
}
do_dailylink () {
DAILY_DIR=$(dirname ${OUTPUT_PATH})
DAILY_BASE=$(basename ${OUTPUT_PATH})
echo_and_log "[DAILYLINK] Update daily link: ${DAILY_DIR}/current -> ${DAILY_BASE})"
[[ -d ${OUTPUT_PATH} ]] || echo_and_log "[DAILYLINK][Warning] Daily output path does not exist: ${OUTPUT_PATH}"
ln -snf ${DAILY_BASE} ${DAILY_DIR}/current
}
do_bt () {
echo "do_bt is not implemented"
}
[[ $# -eq 0 ]] && do_help && exit
set -u -e -o pipefail
trap exit_fail ERR TERM EXIT KILL
check_commandline $*
script_init
[[ "x${ACTIONS}x" == "xx" ]] && do_help && exit
lockfile ${BUILD_LOCK}
do_action ${ACTIONS}
echo_and_log "[MKISO] Finished executing actions: ${ACTIONS}"
echo_and_log "[MKISO] See log for more details: ${LOG_FILE}"
clean_up
export ALL_DONE="true"
# vim:set ts=8 sts=4 sw=4 ft=sh: