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.4'
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 -c <classe[s]> classes to be used for building the ISO via FAI
33 -C <configfile> configuration file for grml-live
34 -F force execution without prompting
35 -g <grml_name>] set the grml flavour name
36 -h display short usage information and exit
37 -i <iso_name> name of ISO
38 -o <output_directory> main output directory of the build process
40 -s <suite> Debian suite; values: etch, lenny, sid
41 -t <template_directory> place of the templates
42 -u update existing chroot instead of rebuilding it from scratch
43 -v <version_number> specify version number of the release
44 -V increase verbosity in the build process
45 -z use ZLIB instead of LZMA compression (depends on
46 squashfs-tools version)
51 $PN -c GRMLBASE,GRML_MEDIUM,I386 -o /dev/shm/grml
52 $PN -c GRMLBASE,GRML_SMALL,I386 -g grml-small -v 1.0
53 $PN -c GRMLBASE,GRML_FULL,I386 -i grml_0.0-1.iso -v 0.0-1
54 $PN -c GRMLBASE,GRML_FULL,I386 -s sid -V -r 'grml-live rocks'
56 More details: man grml-live + /usr/share/doc/grml-live/grml-live.html
57 http://grml.org/grml-live/
59 Please send your bug reports and feedback to the grml-team: http://grml.org/bugs/
63 # make sure it's possible to get usage information without being
64 # root or actually executing the script
65 if [ "$1" = '-h' -o "$1" = '--help' ] ; then
67 [ "$(id -u 2>/dev/null)" != 0 ] && echo "Please notice that this script requires root permissions."
72 # we need root permissions for the build-process:
73 if [ "$(id -u 2>/dev/null)" != 0 ] ; then
74 echo "Error: please run this script with uid 0 (root)." >&2
78 if [ -r /var/run/fai/FAI_INSTALLATION_IN_PROGRESS ] ; then
79 echo "/usr/sbin/fai already running or was aborted before.">&2
80 echo "You may remove /var/run/fai/FAI_INSTALLATION_IN_PROGRESS and try again.">&2
85 if [ -r /var/run/fai/fai_softupdate_is_running ] ; then
86 echo "/usr/sbin/fai softupdate already running or was aborted before.">&2
87 echo "You may remove /var/run/fai/fai_softupdate_is_running and try again.">&2
91 # make sure they are not set by default
98 if [ -r /etc/grml/lsb-functions ] ; then
99 . /etc/grml/lsb-functions
101 einfo() { echo " [*] $*" ;}
102 eerror() { echo " [!] $*">&2 ;}
103 ewarn() { echo " [x] $*" ;}
107 # source main configuration file:
108 LIVE_CONF=/etc/grml/grml-live.conf
115 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
116 rm -f /var/run/fai/fai_softupdate_is_running \
117 /var/run/fai/FAI_INSTALLATION_IN_PROGRESS
118 [ -n "$1" ] && EXIT="$1" || EXIT="1"
119 [ -n "$2" ] && eerror "$2">&2
120 log "------------------------------------------------------------------------------"
123 # trap bailout 1 2 3 6 9 14 15
124 trap bailout 1 2 3 15
127 # check for important variables {{{
128 [ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG=/etc/grml/fai
129 [ -n "$HOSTNAME" ] || HOSTNAME=grml
130 [ -n "$USERNAME" ] || USERNAME=grml
131 [ -n "$CLASSES" ] || CLASSES="GRML,I386"
132 [ -n "$BOOT_METHOD" ] || BOOT_METHOD='isolinux'
133 [ -n "$OUTPUT" ] || bailout 1 "${PN}: \$OUTPUT not specified. Please adjust $LIVE_CONF. Exiting."
135 [ -n "$VERSION" ] || VERSION="0.0.1"
136 [ -n "$RELEASENAME" ] || RELEASENAME="grml-live rocks"
137 [ -n "$GRML_NAME" ] || GRML_NAME='grml'
140 if [ -z "$LOGFILE" ] ; then
141 LOGFILE=/var/log/grml-live.log
144 chown root:adm $LOGFILE
147 NFSROOT_CONF=/etc/grml/fai/make-fai-nfsroot.conf
151 # some important functions {{{
154 # usage: log "string to log"
155 log() { echo "$*" >> $LOGFILE ; }
157 # cut string at character number int = $1
158 # usage: cut_string 5 "1234567890" will output "12345"
160 [ -n "$2" ] || return 1
161 echo "$2" | head -c "$1"; echo -ne "\n"
164 # prepend int = $1 spaces before string = $2
165 # usage: extend_string_begin 5 "123" will output " 123"
166 extend_string_begin() {
167 [ -n "$2" ] || return 1
168 local COUNT="$(echo $2 | wc -c)"
169 local FILL="$(expr $COUNT - $1)"
170 while [ "$FILL" -gt 1 ] ; do
172 local FILL=$(expr $FILL - 1)
174 while [ "$FILL" -lt 1 ] ; do
176 local FILL=$(expr $FILL + 1)
178 echo "$2" | head -c "$1"; echo -ne "\n"
181 # append int = $1 spaces to string = $2
182 # usage: extend_string_begin 5 "123" will output "123 "
183 extend_string_end() {
184 [ -n "$2" ] || return 1
185 echo -n "$2" | head -c "$1"
186 local COUNT="$(echo $2 | wc -c)"
187 local FILL="$(expr $COUNT - $1)"
188 while [ "$FILL" -gt 1 ] ; do
190 local FILL=$(expr $FILL - 1)
192 while [ "$FILL" -lt 1 ] ; do
194 local FILL=$(expr $FILL + 1)
200 # read local (non-packaged) configuration {{{
201 LOCAL_CONFIG=/etc/grml/grml-live.local
202 if [ -r "$LOCAL_CONFIG" ] ; then
203 log "Sourcing $LOCAL_CONFIG"
206 log "No $LOCAL_CONFIG found, not sourcing it"
211 # command line parsing {{{
212 while getopts "a:C:c:g:i:o:r:s:t:v:bFhuVz" opt; do
216 c) CLASSES="$OPTARG" ;;
217 C) CONFIG="$OPTARG" ;;
218 g) GRML_NAME="$OPTARG" ;;
219 i) ISO_NAME="$OPTARG" ;;
221 CHROOT_OUTPUT="$OUTPUT/grml_chroot"
222 BUILD_OUTPUT="$OUTPUT/grml_cd"
223 ISO_OUTPUT="$OUTPUT/grml_isos"
225 r) RELEASENAME="$OPTARG" ;;
226 s) SUITE="$OPTARG" ;;
227 t) TEMPLATE_DIRECTORY="$OPTARG";;
228 v) VERSION="$OPTARG" ;;
230 h) usage ; bailout 0 ;;
233 z) SQUASHFS_ZLIB="-nolzma" ;;
234 ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
237 shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter
240 # some misc checks before executing FAI {{{
241 [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in $LIVE_CONF or
242 specify it on the command line using the -c option."
243 [ -n "$OUTPUT" ] || bailout 1 "Error: \$OUTPUT unset, please set it in $LIVE_CONF or
244 specify it on the command line using the -o option."
246 # trim characters that are known to cause problems inside $GRML_NAME;
247 # for example isolinux does not like '-' inside the directory name
248 [ -n "$GRML_NAME" ] && export SHORT_GRML_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')"
250 # export variables to have them available in fai scripts:
251 [ -n "$GRML_NAME" ] && export "$GRML_NAME"
252 [ -n "$RELEASENAME" ] && export "$RELEASENAME"
255 # clean/zero grml-live logfile {{{
256 if [ -n "$ZERO_LOGFILE" ] ; then
261 # clean/zero/remove old FAI directory {{{
262 if [ -n "$ZERO_FAI_LOGFILE" ] ; then
263 if [ -d /var/log/fai/"$HOSTNAME" ] ; then
264 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last)"
265 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-dirinstall)"
266 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-softupdate)"
267 rm -f /var/log/fai/"$HOSTNAME"/last \
268 /var/log/fai/"$HOSTNAME"/last-dirinstall \
269 /var/log/fai/"$HOSTNAME"/last-softupdate
274 # ask user whether the setup is ok {{{
275 if [ -z "$FORCE" ] ; then
277 echo "${PN} [${GRML_LIVE_VERSION}]: check your configuration (or use -F to force execution):"
279 echo " FAI classes: $CLASSES"
280 [ -r "$LOCAL_CONFIG" ] && echo " local config: /etc/grml/grml-live.local"
281 [ -n "$CONFIG" ] && echo " configuration: $CONFIG"
282 echo " main directory: $OUTPUT"
283 [ -n "$CHROOT_OUTPUT" ] && echo " chroot target: $CHROOT_OUTPUT"
284 [ -n "$BUILD_OUTPUT" ] && echo " build target: $BUILD_OUTPUT"
285 [ -n "$ISO_OUTPUT" ] && echo " ISO target: $ISO_OUTPUT"
286 [ -n "$GRML_NAME" ] && echo " grml name: $GRML_NAME"
287 [ -n "$RELEASENAME" ] && echo " release name: $RELEASENAME"
288 [ -n "$VERSION" ] && echo " grml version: $VERSION"
289 [ -n "$SUITE" ] && echo " Debian suite: $SUITE"
290 [ -n "$ARCH" ] && echo " Architecture: $ARCH"
291 [ -n "$BOOT_METHOD" ] && echo " Boot method: $BOOT_METHOD"
292 [ -n "$TEMPLATE_DIRECTORY" ] && echo " Template files: $TEMPLATE_DIRECTORY"
293 [ -n "$FAI_ARGS" ] && echo " additional arguments for FAI: $FAI_ARGS"
294 [ -n "$LOGFILE" ] && echo " Logging to file: $LOGFILE"
295 [ -n "$SQUASHFS_ZLIB" ] && echo " Using ZLIB (instead of LZMA) compression."
296 [ -n "$SQUASHFS_OPTIONS" ] && echo " Using SQUASHFS_OPTIONS ${SQUASHFS_OPTIONS}"
297 [ -n "$VERBOSE" ] && echo " Using VERBOSE mode."
298 [ -n "$UPDATE" ] && echo " Executing UPDATE instead of fresh installation."
299 [ -n "$BUILD_ONLY" ] && echo " Executing BUILD_ONLY instead of fresh installation or UPDATE."
301 echo -n "Is this ok for you? [y/N] "
303 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
304 bailout 1 "Exiting as requested."
309 if [ -n "$CONFIG" ] ; then
310 if ! [ -f "$CONFIG" ] ; then
311 log "Sorry, $CONFIG could not be read. Exiting. [$(date)]"
312 eerror "Sorry, $CONFIG could not be read. Exiting."
315 log "Sourcing $CONFIG"
320 start_seconds=$(cut -d . -f 1 /proc/uptime)
321 log "------------------------------------------------------------------------------"
322 log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
323 log "Executed grml-live command line:"
326 einfo "Logging actions to logfile $LOGFILE"
329 # on-the-fly configuration {{{
330 if [ -n "$MIRROR_DIRECTORY" ] ; then
331 if ! [ -d "$MIRROR_DIRECTORY/debian" ] ; then
332 log "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting. [$(date)]"
333 eerror "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting."
336 echo "$MIRROR_SOURCES" > /etc/grml/fai/apt/sources.list
337 if [ -n "$GRML_LIVE_SOURCES" ] ; then
338 echo "$GRML_LIVE_SOURCES" >> /etc/grml/fai/apt/sources.list
340 elif [ -n "$GRML_LIVE_SOURCES" ] ; then
341 echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
344 if [ -n "$FAI_DEBOOTSTRAP" ] ; then
345 sed -i "s#^FAI_DEBOOTSTRAP=.*#FAI_DEBOOTSTRAP=\"$FAI_DEBOOTSTRAP\"#" $NFSROOT_CONF
348 # does this suck? YES!
349 if [ -n "$SUITE" ] ; then
351 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
352 if [ -n "$file" ] ; then
353 sed -i "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF
354 DIST="\|\ etch\ \|\ stable\ \|\ lenny\ \|\ testing\ \|\ sid\ \|\ unstable\ "
355 sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" $file
359 sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list
360 # notice: activate grml-live pool only if we are building against unstable:
361 if grep -qe unstable -qe sid /etc/grml/fai/apt/sources.list ; then
362 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list || \
363 grep grml-stable /etc/grml/fai/apt/sources.list | \
364 sed 's/grml-stable/grml-live/' >> /etc/grml/fai/apt/sources.list
366 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list && \
367 sed -i 's/.*grml-live.*/# removed grml-live repository/' /etc/grml/fai/apt/sources.list
370 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
371 if [ -n "$file" ] ; then
372 sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file"
375 sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" $NFSROOT_CONF
379 [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
380 if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' $NFSROOT_CONF ; then
381 sed -i "s/--arch [a-z0-9]* /--arch $ARCH /" $NFSROOT_CONF
383 sed -i "s|FAI_DEBOOTSTRAP_OPTS=\"\(.*\)|FAI_DEBOOTSTRAP_OPTS=\"--arch $ARCH \1|" $NFSROOT_CONF
387 # CHROOT_OUTPUT - execute FAI {{{
388 [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
390 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
391 FAI_ACTION=softupdate
393 FAI_ACTION=dirinstall
396 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
397 if ! [ -r "$CHROOT_OUTPUT/etc/grml_version" ] ; then
398 log "Error: does not look like you have a working chroot. Updating/building not possible."
399 eerror "Error: does not look like you have a working chroot. Updating/building not possible. (Drop -u/-b option?)"
405 if [ -d "$CHROOT_OUTPUT/bin" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
406 log "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'"
407 ewarn "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'" ; eend 0
409 mkdir -p "$CHROOT_OUTPUT" || bailout 5 "Problem with creating $CHROOT_OUTPUT for FAI"
411 if [ -n "${MIRROR_DIRECTORY}" ] ; then
412 mkdir -p "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
413 mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
416 log "Executed FAI command line:"
417 log "BUILD_ONLY=$BUILD_ONLY fai $VERBOSE -C $GRML_FAI_CONFIG -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
418 BUILD_ONLY="$BUILD_ONLY" fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" -u \
419 "$HOSTNAME" $FAI_ACTION "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
420 RC="$PIPESTATUS" # notice: bash-only
422 if [ "$RC" != 0 ] ; then
423 log "Error while executing fai [exit code ${RC}]. Exiting."
424 eerror "Error while executing fai [exit code ${RC}]. Exiting." ; eend 1
427 log "Setting /etc/grml_version to $GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]"
428 echo "$GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]" > $CHROOT_OUTPUT/etc/grml_version
429 chmod 644 $CHROOT_OUTPUT/etc/grml_version
430 einfo "Rebuilding initramfs"
431 chroot $CHROOT_OUTPUT update-initramfs -u -t # make sure new /etc/grml_version reaches the initramfs
435 # Remove all FAI logs from chroot if class RELEASE is used:
436 if [ -f "$CHROOT_OUTPUT"/etc/grml_fai_release ] ; then
437 rm -rf "$CHROOT_OUTPUT"/var/log/fai/*
440 umount $CHROOT_OUTPUT/proc 2>/dev/null || /bin/true
441 umount $CHROOT_OUTPUT/sys 2>/dev/null || /bin/true
442 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
444 # notice: 'fai dirinstall' does not seem to exit appropriate, so:
446 CHECKLOG=/var/log/fai/$HOSTNAME/last
447 if [ -r "$CHECKLOG/software.log" ] ; then
448 # 1 errors during executing of commands
449 grep 'dpkg: error processing' $CHECKLOG/software.log >> $LOGFILE && ERROR=1
450 grep 'E: Method http has died unexpectedly!' $CHECKLOG/software.log >> $LOGFILE && ERROR=2
451 grep 'ERROR: chroot' $CHECKLOG/software.log >> $LOGFILE && ERROR=3
452 grep 'E: Failed to fetch' $CHECKLOG/software.log >> $LOGFILE && ERROR=4
453 grep 'Unable to write mmap - msync (28 No space left on device)' $CHECKLOG/software.log >> $LOGFILE && ERROR=5
456 if [ -r "$CHECKLOG/shell.log" ] ; then
457 grep 'FAILED with exit code' $CHECKLOG/shell.log >> $LOGFILE && ERROR=2
460 if [ -n "$ERROR" ] ; then
461 log "There was an error [${ERROR}] during execution of stage 'fai dirinstall' [$(date)]"
462 eerror "There was an error during execution of stage 'fai dirinstall'"
463 echo " Check out ${CHECKLOG}/ for details. [exit ${ERROR}]"
467 log "Finished execution of stage 'fai dirinstall' [$(date)]"
468 einfo "Finished execution of stage 'fai dirinstall'"
473 # BUILD_OUTPUT - execute arch specific stuff and squashfs {{{
474 [ -n "$BUILD_OUTPUT" ] || BUILD_OUTPUT="$OUTPUT/grml_cd"
475 mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for stage ARCH"
478 if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
479 if [ -d "$BUILD_OUTPUT"/boot -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
480 log "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'"
481 ewarn "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" ; eend 0
484 [ -d "$BUILD_OUTPUT"/boot/addons ] || mkdir -p "$BUILD_OUTPUT"/boot/addons
485 [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux
486 [ -d "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}" ] || mkdir -p "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"
488 cp /boot/memtest86+.bin "$BUILD_OUTPUT"/boot/addons/memtest
490 # if we don't have an initrd we a) can't boot and b) there was an error
491 # during build, so check for the file:
492 INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
493 if [ -n "$INITRD" ] ; then
494 cp $INITRD "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/initrd.gz
495 find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
497 log "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
498 eerror "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
502 KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
503 if [ -n "$KERNEL_IMAGE" ] ; then
504 cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/linux26
506 log "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
507 eerror "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
511 [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
512 if ! [ -d "${TEMPLATE_DIRECTORY}"/boot ] ; then
513 log "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting."
514 eerror "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting." ; eend 1
518 cp ${TEMPLATE_DIRECTORY}/boot/isolinux/* "$BUILD_OUTPUT"/boot/isolinux/
519 cp ${TEMPLATE_DIRECTORY}/boot/addons/* "$BUILD_OUTPUT"/boot/addons/
521 if ! [ -d "${BUILD_OUTPUT}/boot/grub" ] ; then
522 cp -a ${TEMPLATE_DIRECTORY}/boot/grub "$BUILD_OUTPUT"/boot/
525 if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
526 log "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
527 eerror "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting." ; eend 1
531 [ -d "$BUILD_OUTPUT"/GRML ] || mkdir "$BUILD_OUTPUT"/GRML
532 cp -a ${TEMPLATE_DIRECTORY}/GRML/* "$BUILD_OUTPUT"/GRML/
534 # adjust boot splash information:
535 RELEASE_INFO="$GRML_NAME $VERSION - Release Codename $RELEASENAME"
536 RELEASE_INFO="$(cut_string 68 "$RELEASE_INFO")"
537 RELEASE_INFO="$(extend_string_end 68 "$RELEASE_INFO")"
539 sed -i "s/%RELEASE_INFO%/$GRML_NAME $VERSION - $RELEASENAME/" "$BUILD_OUTPUT"/GRML/grml-version
540 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/GRML/grml-version
542 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
543 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
545 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
546 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
548 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
549 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
551 sed -i "s/%VERSION%/$VERSION/" "$BUILD_OUTPUT"/boot/grub/menu.lst
552 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/grub/menu.lst
554 # make sure the squashfs filename is set accordingly:
555 GRML_NAME_SQUASHFS="$GRML_NAME.squashfs"
556 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
557 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
559 GRML_NAME_SQUASHFS="$(cut_string 20 "$GRML_NAME_SQUASHFS")"
560 GRML_NAME_SQUASHFS="$(extend_string_end 20 "$GRML_NAME_SQUASHFS")"
561 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f4
563 # autostart for Windows:
564 if [ -d "${TEMPLATE_DIRECTORY}/windows/autostart/" ] ; then
565 cp ${TEMPLATE_DIRECTORY}/windows/autostart/* "$BUILD_OUTPUT"/
569 if [ -n "$WINDOWS_BINARIES" ] ; then
570 if [ -f "$BUILD_OUTPUT"/windows/putty.exe ] ; then
571 log "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'"
572 ewarn "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'" ; eend 0
574 if ! [ -d "$BUILD_OUTPUT"/windows ] ; then
575 mkdir "$BUILD_OUTPUT"/windows
576 ( cd "$BUILD_OUTPUT"/windows
577 for file in pageant plink pscp psftp putty puttygen ; do
578 wget -O ${file}.exe ${WINDOWS_BINARIES}/${file}.exe
579 md5sum ${file}.exe > ${file}.exe.md5
583 log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
584 einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
586 einfo "Finished execution of stage 'boot'" ; eend 0
589 elif [ "$ARCH" = powerpc ] ; then
590 ewarn 'Warning: formorer, it is your turn. :)'>&2
593 eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
596 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
597 log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
598 ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
600 [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
601 # make sure we don't leave (even an empty) base.tgz:
602 [ -f "$CHROOT_OUTPUT/base.tgz" ] && rm -f "$CHROOT_OUTPUT/base.tgz"
604 # make sure mksquashfs can handle the according option:
605 if [ -n "$SQUASHFS_ZLIB" ] ; then
606 mksquashfs --help 2>&1 | grep -q -- "$SQUASHFS_ZLIB" || SQUASHFS_ZLIB=''
609 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-nolzma" ; then
610 if ! mksquashfs --help 2>&1 | grep -q -- '-nolzma' ; then
611 ewarn "mksquashfs does NOT support the nolzma option, just using default zlib mode."
612 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-nolzma//g')"
617 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-lzma" ; then
618 if ! mksquashfs --help 2>&1 | grep -q -- '-lzma' ; then
619 ewarn "mksquashfs does NOT support the lzma option, falling back to zlib mode."
620 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-lzma//g')"
625 SQUASHFS_OUTPUT="$(mktemp -t grml-live.XXXXXX)"
626 log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/${GRML_NAME}.squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB"
627 if mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/"${GRML_NAME}".squashfs \
628 -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB 2>"${SQUASHFS_OUTPUT}" ; then
629 echo "${GRML_NAME}.squashfs" > $BUILD_OUTPUT/live/filesystem.module
630 log "Finished execution of stage 'squashfs' [$(date)]"
631 einfo "Finished execution of stage 'squashfs'" ; eend 0
632 rm -f "${SQUASHFS_OUTPUT}"
634 log "There was an error executing stage 'squashfs' [$(date)]:"
635 log "$(cat $SQUASHFS_OUTPUT)"
636 eerror "There was an error executing stage 'squashfs':" ; eend 1
637 cat "${SQUASHFS_OUTPUT}"
638 rm -f "${SQUASHFS_OUTPUT}"
643 # create md5sum file:
644 ( cd $BUILD_OUTPUT/GRML &&
645 find .. -type f -not -name md5sums -not -name isolinux.bin -exec md5sum {} \; > md5sums )
648 # ISO_OUTPUT - mkisofs {{{
649 [ -n "$ISO_OUTPUT" ] || ISO_OUTPUT="$OUTPUT/grml_isos"
650 [ -n "$ISO_NAME" ] || ISO_NAME="${GRML_NAME}_${VERSION}.iso"
652 if [ "$BOOT_METHOD" = "isolinux" ] ; then
653 BOOT_FILE="boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat"
654 elif [ "$BOOT_METHOD" = "grub" ] ; then
655 BOOT_FILE="boot/grub/stage2_eltorito"
658 if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
659 log "$ISO_OUTPUT exists already, skipping stage 'iso build'"
660 ewarn "$ISO_OUTPUT exists already, skipping stage 'iso build'" ; eend 0
662 mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
665 if cd "$BUILD_OUTPUT" ; then
666 log "mkisofs -V 'grml $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} ."
667 mkisofs -V "grml $VERSION" -publisher 'grml-live | grml.org' \
668 -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
670 -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
672 # generate md5sum of ISO if we are using class 'RELEASE':
673 case $CLASSES in *RELEASE*)
675 ( cd $ISO_OUTPUT && \
676 md5sum ${ISO_NAME} > ${ISO_NAME}.md5 && \
677 touch -r ${ISO_NAME} ${ISO_NAME}.md5 )
684 if [ "$RC" = 0 ] ; then
685 log "Finished execution of stage 'iso build' [$(date)]"
686 einfo "Finished execution of stage 'iso build'" ; eend 0
688 log "There was an error ($RC) executing stage 'iso build' [$(date)]"
689 eerror "There was an error executing stage 'iso build'" ; eend 1
696 [ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown"
697 einfo "Sucessfully finished execution of $PN [running ${SECONDS} seconds]" ; eend 0
698 log "Sucessfully finished execution of $PN [running ${SECONDS} seconds]"
702 ## END OF FILE #################################################################
703 # vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=3