3 # Purpose: build process script for generating a (grml based) Linux Live-ISO
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 ################################################################################
9 # read configuration files, set some misc variables {{{
17 GRML_LIVE_VERSION='0.9.9'
20 ISO_DATE="$(date +%Y-%m-%d)"
22 # usage information {{{
26 $PN - build process script for generating a (grml based) Linux Live-ISO
28 Usage: $PN [options, see as follows]
30 -a <architecture> architecture; available values: i386 and amd64
31 -b build the ISO without updating the chroot via FAI
32 -B build the ISO without touching the chroot (skips cleanup)
33 -c <classe[s]> classes to be used for building the ISO via FAI
34 -C <configfile> configuration file for grml-live
35 -F force execution without prompting
36 -g <grml_name>] set the grml flavour name
37 -h display short usage information and exit
38 -i <iso_name> name of ISO
39 -o <output_directory> main output directory of the build process
41 -r <release_name< release name
42 -s <suite> Debian suite; values: etch, lenny, squeeze, sid
43 -t <template_directory> place of the templates
44 -u update existing chroot instead of rebuilding it from scratch
45 -v <version_number> specify version number of the release
46 -V increase verbosity in the build process
47 -z use ZLIB instead of LZMA compression (depends on
48 squashfs-tools version)
53 $PN -c GRMLBASE,GRML_MEDIUM,I386 -o /dev/shm/grml
54 $PN -c GRMLBASE,GRML_SMALL,REMOVE_DOCS,I386 -g grml-small -v 1.0
55 $PN -c GRMLBASE,GRML_FULL,I386 -i grml_0.0-1.iso -v 0.0-1
56 $PN -c GRMLBASE,GRML_FULL,I386 -s sid -V -r 'grml-live rocks'
58 More details: man grml-live + /usr/share/doc/grml-live/grml-live.html
59 http://grml.org/grml-live/
61 Please send your bug reports and feedback to the grml-team: http://grml.org/bugs/
65 # make sure it's possible to get usage information without being
66 # root or actually executing the script
67 if [ "$1" = '-h' -o "$1" = '--help' ] ; then
69 [ "$(id -u 2>/dev/null)" != 0 ] && echo "Please notice that this script requires root permissions."
74 # we need root permissions for the build-process:
75 if [ "$(id -u 2>/dev/null)" != 0 ] ; then
76 echo "Error: please run this script with uid 0 (root)." >&2
80 if [ -r /var/run/fai/FAI_INSTALLATION_IN_PROGRESS ] ; then
81 echo "/usr/sbin/fai already running or was aborted before.">&2
82 echo "You may remove /var/run/fai/FAI_INSTALLATION_IN_PROGRESS and try again.">&2
87 if [ -r /var/run/fai/fai_softupdate_is_running ] ; then
88 echo "/usr/sbin/fai softupdate already running or was aborted before.">&2
89 echo "You may remove /var/run/fai/fai_softupdate_is_running and try again.">&2
93 # make sure they are not set by default
101 if [ -r /etc/grml/lsb-functions ] ; then
102 . /etc/grml/lsb-functions
104 einfo() { echo " [*] $*" ;}
105 eerror() { echo " [!] $*">&2 ;}
106 ewarn() { echo " [x] $*" ;}
110 # source main configuration file:
111 LIVE_CONF=/etc/grml/grml-live.conf
118 rm -f /var/run/fai/fai_softupdate_is_running \
119 /var/run/fai/FAI_INSTALLATION_IN_PROGRESS
120 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
121 [ -n "$1" ] && EXIT="$1" || EXIT="1"
122 [ -n "$2" ] && eerror "$2">&2
123 log "------------------------------------------------------------------------------"
126 trap bailout 1 2 3 3 6 9 14 15
129 # check for important variables {{{
130 [ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG=/etc/grml/fai
131 [ -n "$HOSTNAME" ] || HOSTNAME=grml
132 [ -n "$USERNAME" ] || USERNAME=grml
133 [ -n "$CLASSES" ] || CLASSES="GRML,I386"
134 [ -n "$BOOT_METHOD" ] || BOOT_METHOD='isolinux'
135 [ -n "$OUTPUT" ] || bailout 1 "${PN}: \$OUTPUT not specified. Please adjust $LIVE_CONF. Exiting."
137 [ -n "$VERSION" ] || VERSION="0.0.1"
138 [ -n "$RELEASENAME" ] || RELEASENAME="grml-live rocks"
139 [ -n "$GRML_NAME" ] || GRML_NAME='grml'
142 if [ -z "$LOGFILE" ] ; then
143 LOGFILE=/var/log/grml-live.log
146 chown root:adm $LOGFILE
149 NFSROOT_CONF=/etc/grml/fai/make-fai-nfsroot.conf
153 # some important functions {{{
156 # usage: log "string to log"
157 log() { echo "$*" >> $LOGFILE ; }
159 # cut string at character number int = $1
160 # usage: cut_string 5 "1234567890" will output "12345"
162 [ -n "$2" ] || return 1
163 echo "$2" | head -c "$1"; echo -ne "\n"
166 # prepend int = $1 spaces before string = $2
167 # usage: extend_string_begin 5 "123" will output " 123"
168 extend_string_begin() {
169 [ -n "$2" ] || return 1
170 local COUNT="$(echo $2 | wc -c)"
171 local FILL="$(expr $COUNT - $1)"
172 while [ "$FILL" -gt 1 ] ; do
174 local FILL=$(expr $FILL - 1)
176 while [ "$FILL" -lt 1 ] ; do
178 local FILL=$(expr $FILL + 1)
180 echo "$2" | head -c "$1"; echo -ne "\n"
183 # append int = $1 spaces to string = $2
184 # usage: extend_string_begin 5 "123" will output "123 "
185 extend_string_end() {
186 [ -n "$2" ] || return 1
187 echo -n "$2" | head -c "$1"
188 local COUNT="$(echo $2 | wc -c)"
189 local FILL="$(expr $COUNT - $1)"
190 while [ "$FILL" -gt 1 ] ; do
192 local FILL=$(expr $FILL - 1)
194 while [ "$FILL" -lt 1 ] ; do
196 local FILL=$(expr $FILL + 1)
202 # read local (non-packaged) configuration {{{
203 LOCAL_CONFIG=/etc/grml/grml-live.local
204 if [ -r "$LOCAL_CONFIG" ] ; then
205 log "Sourcing $LOCAL_CONFIG"
208 log "No $LOCAL_CONFIG found, not sourcing it"
213 # command line parsing {{{
214 while getopts "a:C:c:g:i:o:r:s:t:v:bBFuqVz" opt; do
219 c) CLASSES="$OPTARG" ;;
220 C) CONFIG="$OPTARG" ;;
221 g) GRML_NAME="$OPTARG" ;;
222 i) ISO_NAME="$OPTARG" ;;
224 CHROOT_OUTPUT="$OUTPUT/grml_chroot"
225 BUILD_OUTPUT="$OUTPUT/grml_cd"
226 ISO_OUTPUT="$OUTPUT/grml_isos"
228 q) SKIP_MKSQUASHFS=1 ;;
229 r) RELEASENAME="$OPTARG" ;;
230 s) SUITE="$OPTARG" ;;
231 t) TEMPLATE_DIRECTORY="$OPTARG";;
232 v) VERSION="$OPTARG" ;;
236 z) SQUASHFS_ZLIB="-nolzma" ;;
237 ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
240 shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter
243 # some misc checks before executing FAI {{{
244 [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in $LIVE_CONF or
245 specify it on the command line using the -c option."
246 [ -n "$OUTPUT" ] || bailout 1 "Error: \$OUTPUT unset, please set it in $LIVE_CONF or
247 specify it on the command line using the -o option."
249 # trim characters that are known to cause problems inside $GRML_NAME;
250 # for example isolinux does not like '-' inside the directory name
251 [ -n "$GRML_NAME" ] && export SHORT_GRML_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')"
253 # export variables to have them available in fai scripts:
254 [ -n "$GRML_NAME" ] && export GRML_NAME="$GRML_NAME"
255 [ -n "$RELEASENAME" ] && export RELEASENAME="$RELEASENAME"
258 # clean/zero grml-live logfile {{{
259 if [ -n "$ZERO_LOGFILE" ] ; then
264 # clean/zero/remove old FAI directory {{{
265 if [ -n "$ZERO_FAI_LOGFILE" ] ; then
266 if [ -d /var/log/fai/"$HOSTNAME" ] ; then
267 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last)"
268 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-dirinstall)"
269 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-softupdate)"
270 rm -f /var/log/fai/"$HOSTNAME"/last \
271 /var/log/fai/"$HOSTNAME"/last-dirinstall \
272 /var/log/fai/"$HOSTNAME"/last-softupdate
277 # ask user whether the setup is ok {{{
278 if [ -z "$FORCE" ] ; then
280 echo "${PN} [${GRML_LIVE_VERSION}]: check your configuration (or use -F to force execution):"
282 echo " FAI classes: $CLASSES"
283 [ -r "$LOCAL_CONFIG" ] && echo " local config: /etc/grml/grml-live.local"
284 [ -n "$CONFIG" ] && echo " configuration: $CONFIG"
285 echo " main directory: $OUTPUT"
286 [ -n "$CHROOT_OUTPUT" ] && echo " chroot target: $CHROOT_OUTPUT"
287 [ -n "$BUILD_OUTPUT" ] && echo " build target: $BUILD_OUTPUT"
288 [ -n "$ISO_OUTPUT" ] && echo " ISO target: $ISO_OUTPUT"
289 [ -n "$GRML_NAME" ] && echo " grml name: $GRML_NAME"
290 [ -n "$RELEASENAME" ] && echo " release name: $RELEASENAME"
291 [ -n "$VERSION" ] && echo " grml version: $VERSION"
292 [ -n "$SUITE" ] && echo " Debian suite: $SUITE"
293 [ -n "$ARCH" ] && echo " Architecture: $ARCH"
294 [ -n "$BOOT_METHOD" ] && echo " Boot method: $BOOT_METHOD"
295 [ -n "$TEMPLATE_DIRECTORY" ] && echo " Template files: $TEMPLATE_DIRECTORY"
296 [ -n "$FAI_ARGS" ] && echo " additional arguments for FAI: $FAI_ARGS"
297 [ -n "$LOGFILE" ] && echo " Logging to file: $LOGFILE"
298 [ -n "$SQUASHFS_ZLIB" ] && echo " Using ZLIB (instead of LZMA) compression."
299 [ -n "$SQUASHFS_OPTIONS" ] && echo " Using SQUASHFS_OPTIONS ${SQUASHFS_OPTIONS}"
300 [ -n "$VERBOSE" ] && echo " Using VERBOSE mode."
301 [ -n "$UPDATE" ] && echo " Executing UPDATE instead of fresh installation."
302 [ -n "$SKIP_MKSQUASHFS" ] && echo " Skipping creation of SQUASHFS file."
303 [ -n "$BUILD_ONLY" ] && echo " Executing BUILD_ONLY instead of fresh installation or UPDATE."
304 [ -n "$BUILD_DIRTY" ] && echo " Executing BUILD_DIRTY to leave chroot untouched."
306 echo -n "Is this ok for you? [y/N] "
308 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
309 bailout 1 "Exiting as requested."
314 if [ -n "$CONFIG" ] ; then
315 if ! [ -f "$CONFIG" ] ; then
316 log "Sorry, $CONFIG could not be read. Exiting. [$(date)]"
317 eerror "Sorry, $CONFIG could not be read. Exiting."
320 log "Sourcing $CONFIG"
325 start_seconds=$(cut -d . -f 1 /proc/uptime)
326 log "------------------------------------------------------------------------------"
327 log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
328 log "Executed grml-live command line:"
331 einfo "Logging actions to logfile $LOGFILE"
334 # on-the-fly configuration {{{
335 if [ -n "$MIRROR_DIRECTORY" ] ; then
336 if ! [ -d "$MIRROR_DIRECTORY/debian" ] ; then
337 log "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting. [$(date)]"
338 eerror "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting."
341 echo "$MIRROR_SOURCES" > /etc/grml/fai/apt/sources.list
342 if [ -n "$GRML_LIVE_SOURCES" ] ; then
343 echo "$GRML_LIVE_SOURCES" >> /etc/grml/fai/apt/sources.list
345 elif [ -n "$GRML_LIVE_SOURCES" ] ; then
346 echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
349 if [ -n "$FAI_DEBOOTSTRAP" ] ; then
350 sed "s#^FAI_DEBOOTSTRAP=.*#FAI_DEBOOTSTRAP=\"$FAI_DEBOOTSTRAP\"#" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
353 # does this suck? YES!
354 if [ -n "$SUITE" ] ; then
356 DIST=" etch\| stable\| lenny\| squeeze\| testing\| sid\| unstable"
357 sed "s/\(deb .\+\)\([ \t]*\) $DIST\([ \t]*\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list | sponge /etc/grml/fai/apt/sources.list
358 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
359 if [ -n "$file" ] ; then
360 sed "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF | sponge $LIVE_CONF
361 sed "s/\(deb .\+\)\([ \t]*\) $DIST\([ \t]*\)\(main \)/\1\2 $SUITE \3\4/" "$file" | sponge "$file"
365 # notice: activate grml-live pool only if we are building against unstable:
366 if grep -qe unstable -qe sid /etc/grml/fai/apt/sources.list ; then
367 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list || \
368 grep grml-stable /etc/grml/fai/apt/sources.list | \
369 sed 's/grml-stable/grml-live/' >> /etc/grml/fai/apt/sources.list
371 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list && \
372 sed 's/.*grml-live.*/# removed grml-live repository/' /etc/grml/fai/apt/sources.list | sponge /etc/grml/fai/apt/sources.list
375 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
376 if [ -n "$file" ] ; then
377 sed "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file" | sponge "$file"
381 sed "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
385 [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
386 if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' "$NFSROOT_CONF" ; then
387 sed "s/--arch [a-z0-9]* /--arch $ARCH /" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
389 sed "s|FAI_DEBOOTSTRAP_OPTS=\"\(.*\)|FAI_DEBOOTSTRAP_OPTS=\"--arch $ARCH \1|" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
393 # CHROOT_OUTPUT - execute FAI {{{
394 if [ -n "$BUILD_DIRTY" ]; then
395 einfo "Skipping FAI" ; eend 0
397 [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
399 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
400 FAI_ACTION=softupdate
402 FAI_ACTION=dirinstall
405 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
406 if ! [ -r "$CHROOT_OUTPUT/etc/grml_version" ] ; then
407 log "Error: does not look like you have a working chroot. Updating/building not possible."
408 eerror "Error: does not look like you have a working chroot. Updating/building not possible. (Drop -u/-b option?)"
414 if [ -d "$CHROOT_OUTPUT/bin" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
415 log "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'"
416 ewarn "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'" ; eend 0
418 mkdir -p "$CHROOT_OUTPUT" || bailout 5 "Problem with creating $CHROOT_OUTPUT for FAI"
420 if [ -n "${MIRROR_DIRECTORY}" ] ; then
421 mkdir -p "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
422 mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
425 log "Executed FAI command line:"
426 log "BUILD_ONLY=$BUILD_ONLY fai $VERBOSE -C $GRML_FAI_CONFIG -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
427 BUILD_ONLY="$BUILD_ONLY" fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" -u \
428 "$HOSTNAME" $FAI_ACTION "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
429 RC="$PIPESTATUS" # notice: bash-only
431 if [ "$RC" != 0 ] ; then
432 log "Error while executing fai [exit code ${RC}]. Exiting."
433 eerror "Error while executing fai [exit code ${RC}]. Exiting." ; eend 1
436 log "Setting /etc/grml_version to $GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]"
437 echo "$GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]" > $CHROOT_OUTPUT/etc/grml_version
438 chmod 644 $CHROOT_OUTPUT/etc/grml_version
439 einfo "Rebuilding initramfs"
440 # make sure new /etc/grml_version reaches the initramfs:
441 chroot $CHROOT_OUTPUT update-initramfs -u -t
445 # Remove all FAI logs from chroot if class RELEASE is used:
446 if [ -f "$CHROOT_OUTPUT"/etc/grml_fai_release ] ; then
447 rm -rf "$CHROOT_OUTPUT"/var/log/fai/*
450 # make sure we don't leave any mounts - FAI doesn't remove them always
451 umount $CHROOT_OUTPUT/proc 2>/dev/null || /bin/true
452 umount $CHROOT_OUTPUT/sys 2>/dev/null || /bin/true
453 umount $CHROOT_OUTPUT/dev/pts 2>/dev/null || /bin/true
454 umount $CHROOT_OUTPUT/dev 2>/dev/null || /bin/true
456 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
458 # notice: 'fai dirinstall' does not seem to exit appropriate, so:
460 CHECKLOG=/var/log/fai/$HOSTNAME/last
461 if [ -r "$CHECKLOG/software.log" ] ; then
462 # 1 errors during executing of commands
463 grep 'dpkg: error processing' $CHECKLOG/software.log >> $LOGFILE && ERROR=1
464 grep 'E: Method http has died unexpectedly!' $CHECKLOG/software.log >> $LOGFILE && ERROR=2
465 grep 'ERROR: chroot' $CHECKLOG/software.log >> $LOGFILE && ERROR=3
466 grep 'E: Failed to fetch' $CHECKLOG/software.log >> $LOGFILE && ERROR=4
467 grep 'Unable to write mmap - msync (28 No space left on device)' $CHECKLOG/software.log >> $LOGFILE && ERROR=5
470 if [ -r "$CHECKLOG/shell.log" ] ; then
471 grep 'FAILED with exit code' $CHECKLOG/shell.log >> $LOGFILE && ERROR=2
474 if [ -n "$ERROR" ] ; then
475 log "There was an error [${ERROR}] during execution of stage 'fai dirinstall' [$(date)]"
476 eerror "There was an error during execution of stage 'fai dirinstall'"
477 echo " Check out ${CHECKLOG}/ for details. [exit ${ERROR}]"
481 log "Finished execution of stage 'fai dirinstall' [$(date)]"
482 einfo "Finished execution of stage 'fai dirinstall'"
489 # BUILD_OUTPUT - execute arch specific stuff and squashfs {{{
490 [ -n "$BUILD_OUTPUT" ] || BUILD_OUTPUT="$OUTPUT/grml_cd"
491 mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for stage ARCH"
494 if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
495 if [ -d "$BUILD_OUTPUT"/boot -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
496 log "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'"
497 ewarn "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" ; eend 0
500 [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux
501 [ -d "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}" ] || mkdir -p "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"
503 if [ -z "$NO_ADDONS" ] ; then
504 [ -d "$BUILD_OUTPUT"/boot/addons ] || mkdir -p "$BUILD_OUTPUT"/boot/addons
505 cp /boot/memtest86+.bin "$BUILD_OUTPUT"/boot/addons/memtest
508 # if we don't have an initrd we a) can't boot and b) there was an error
509 # during build, so check for the file:
510 INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
511 if [ -n "$INITRD" ] ; then
512 cp $INITRD "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/initrd.gz
513 find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
515 log "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
516 eerror "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
520 KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
521 if [ -n "$KERNEL_IMAGE" ] ; then
522 cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/linux26
524 log "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
525 eerror "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
529 [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
530 if ! [ -d "${TEMPLATE_DIRECTORY}"/boot ] ; then
531 log "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting."
532 eerror "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting." ; eend 1
536 cp ${TEMPLATE_DIRECTORY}/boot/isolinux/* "$BUILD_OUTPUT"/boot/isolinux/
538 if [ -z "$NO_ADDONS" ] ; then
539 cp ${TEMPLATE_DIRECTORY}/boot/addons/* "$BUILD_OUTPUT"/boot/addons/
542 if ! [ -d "${BUILD_OUTPUT}/boot/grub" ] ; then
543 cp -a ${TEMPLATE_DIRECTORY}/boot/grub "$BUILD_OUTPUT"/boot/
546 if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
547 log "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
548 eerror "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting." ; eend 1
552 [ -d "$BUILD_OUTPUT"/GRML ] || mkdir "$BUILD_OUTPUT"/GRML
553 cp -a ${TEMPLATE_DIRECTORY}/GRML/* "$BUILD_OUTPUT"/GRML/
555 # adjust boot splash information:
556 RELEASE_INFO="$GRML_NAME $VERSION - Release Codename $RELEASENAME"
557 RELEASE_INFO="$(cut_string 68 "$RELEASE_INFO")"
558 RELEASE_INFO="$(extend_string_end 68 "$RELEASE_INFO")"
560 sed -i "s/%RELEASE_INFO%/$GRML_NAME $VERSION - $RELEASENAME/" "$BUILD_OUTPUT"/GRML/grml-version
561 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/GRML/grml-version
563 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
564 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
566 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
567 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
569 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
570 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
572 sed -i "s/%VERSION%/$VERSION/" "$BUILD_OUTPUT"/boot/grub/menu.lst
573 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/grub/menu.lst
575 # make sure the squashfs filename is set accordingly:
576 GRML_NAME_SQUASHFS="$GRML_NAME.squashfs"
577 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
578 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
580 GRML_NAME_SQUASHFS="$(cut_string 20 "$GRML_NAME_SQUASHFS")"
581 GRML_NAME_SQUASHFS="$(extend_string_end 20 "$GRML_NAME_SQUASHFS")"
582 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f4
584 # autostart for Windows:
585 if [ -d "${TEMPLATE_DIRECTORY}/windows/autostart/" ] ; then
586 cp ${TEMPLATE_DIRECTORY}/windows/autostart/* "$BUILD_OUTPUT"/
590 if [ -n "$WINDOWS_BINARIES" ] ; then
591 if [ -f "$BUILD_OUTPUT"/windows/putty.exe ] ; then
592 log "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'"
593 ewarn "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'" ; eend 0
595 if ! [ -d "$BUILD_OUTPUT"/windows ] ; then
596 mkdir "$BUILD_OUTPUT"/windows
597 ( cd "$BUILD_OUTPUT"/windows
598 for file in pageant plink pscp psftp putty puttygen ; do
599 wget -O ${file}.exe ${WINDOWS_BINARIES}/${file}.exe
600 md5sum ${file}.exe > ${file}.exe.md5
604 log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
605 einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
607 einfo "Finished execution of stage 'boot'" ; eend 0
610 elif [ "$ARCH" = powerpc ] ; then
611 ewarn 'Warning: formorer, it is your turn. :)'>&2
614 eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
617 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$BUILD_DIRTY" ] ; then
618 log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
619 ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
620 elif [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -n "$SKIP_MKSQUASHFS" ] ; then
621 log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs' as requested"
622 ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs' as requested" ; eend 0
624 [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
625 # make sure we don't leave (even an empty) base.tgz:
626 [ -f "$CHROOT_OUTPUT/base.tgz" ] && rm -f "$CHROOT_OUTPUT/base.tgz"
628 # make sure mksquashfs can handle the according option:
629 if [ -n "$SQUASHFS_ZLIB" ] ; then
630 mksquashfs --help 2>&1 | grep -q -- "$SQUASHFS_ZLIB" || SQUASHFS_ZLIB=''
633 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-nolzma" ; then
634 if ! mksquashfs --help 2>&1 | grep -q -- '-nolzma' ; then
635 ewarn "mksquashfs does NOT support the nolzma option, just using default zlib mode."
636 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-nolzma//g')"
641 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-lzma" ; then
642 if ! mksquashfs --help 2>&1 | grep -q -- '-lzma' ; then
643 ewarn "mksquashfs does NOT support the lzma option, falling back to zlib mode."
644 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-lzma//g')"
649 # support exclusion of files via exclude-file:
650 if [ -n "$SQUASHFS_EXCLUDES_FILE" -a "$SQUASHFS_EXCLUDES_FILE" ] ; then
651 SQUASHFS_OPTIONS="$SQUASHFS_OPTIONS -ef $SQUASHFS_EXCLUDES_FILE"
654 # get rid of unnecessary files when building grml-small for final release:
655 if echo "$CLASSES" | grep -q GRML_SMALL ; then
656 SQUASHFS_OPTIONS="$SQUASHFS_OUTPUT -e initrd.img* vmlinuz*"
659 SQUASHFS_OUTPUT="$(mktemp -t grml-live.XXXXXX)"
660 log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/${GRML_NAME}.squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB"
661 if mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/"${GRML_NAME}".squashfs \
662 -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB 2>"${SQUASHFS_OUTPUT}" ; then
663 echo "${GRML_NAME}.squashfs" > $BUILD_OUTPUT/live/filesystem.module
664 log "Finished execution of stage 'squashfs' [$(date)]"
665 einfo "Finished execution of stage 'squashfs'" ; eend 0
666 rm -f "${SQUASHFS_OUTPUT}"
668 log "There was an error executing stage 'squashfs' [$(date)]:"
669 log "$(cat $SQUASHFS_OUTPUT)"
670 eerror "There was an error executing stage 'squashfs':" ; eend 1
671 cat "${SQUASHFS_OUTPUT}"
672 rm -f "${SQUASHFS_OUTPUT}"
677 # create md5sum file:
678 ( cd $BUILD_OUTPUT/GRML &&
679 find .. -type f -not -name md5sums -not -name isolinux.bin -exec md5sum {} \; > md5sums )
682 # ISO_OUTPUT - mkisofs {{{
683 [ -n "$ISO_OUTPUT" ] || ISO_OUTPUT="$OUTPUT/grml_isos"
684 [ -n "$ISO_NAME" ] || ISO_NAME="${GRML_NAME}_${VERSION}.iso"
686 if [ "$BOOT_METHOD" = "isolinux" ] ; then
687 BOOT_FILE="boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat"
688 elif [ "$BOOT_METHOD" = "grub" ] ; then
689 BOOT_FILE="boot/grub/stage2_eltorito"
692 if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$BUILD_DIRTY" ] ; then
693 log "$ISO_OUTPUT exists already, skipping stage 'iso build'"
694 ewarn "$ISO_OUTPUT exists already, skipping stage 'iso build'" ; eend 0
696 mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
699 if cd "$BUILD_OUTPUT" ; then
700 log "mkisofs -V '${GRML_NAME} ${VERSION}' -publisher 'grml-live | grml.org' -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b $BOOT_FILE -o ${ISO_OUTPUT}/${ISO_NAME} ."
701 mkisofs -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
702 -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
704 -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
706 # generate md5sum and sha1sum of ISO if we are using class 'RELEASE':
707 case $CLASSES in *RELEASE*)
710 if cd $ISO_OUTPUT ; then
711 md5sum ${ISO_NAME} > ${ISO_NAME}.md5 && \
712 touch -r ${ISO_NAME} ${ISO_NAME}.md5
713 sha1sum ${ISO_NAME} > ${ISO_NAME}.sha1 && \
714 touch -r ${ISO_NAME} ${ISO_NAME}.sha1
723 if [ "$RC" = 0 ] ; then
724 log "Finished execution of stage 'iso build' [$(date)]"
725 einfo "Finished execution of stage 'iso build'" ; eend 0
727 log "There was an error ($RC) executing stage 'iso build' [$(date)]"
728 eerror "There was an error executing stage 'iso build'" ; eend 1
735 [ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown"
736 einfo "Sucessfully finished execution of $PN [running ${SECONDS} seconds]" ; eend 0
737 log "Sucessfully finished execution of $PN [running ${SECONDS} seconds]"
741 ## END OF FILE #################################################################
742 # vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=3