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 # Latest change: Sun Aug 17 13:19:16 CEST 2008 [mika]
8 ################################################################################
10 # read configuration files, set some misc variables {{{
18 GRML_LIVE_VERSION='0.9'
21 ISO_DATE="$(date +%Y-%m-%d)"
23 # usage information {{{
27 $PN - build process script for generating a (grml based) Linux Live-ISO
29 Usage: $PN [-a <architecture>] [-c <classe[s]>] [-g <grml_name>] \\
30 [-i <iso_name> ] [-o <output_directory>] [-s <suite>] \\
31 [-t <template_directory>] [-s <suite>] \\
32 [-v <version_number>] [-bFVhu]
37 $PN -c GRMLBASE,GRML_SMALL,I386 -o /grml/
38 $PN -c GRMLBASE,GRML_MEDIUM,I386 -o /dev/shm/grml
39 $PN -c GRMLBASE,GRML_SMALL,I386 -g grml-small -v 1.0
40 $PN -c GRMLBASE,GRML_FULL,I386 -i grml_0.0-1.iso -v 0.0-1
41 $PN -c GRMLBASE,GRML_FULL,I386 -s sid -V -r 'grml-live rocks'
43 More details: man grml-live
44 /usr/share/doc/grml-live/grml-live.html
46 Please send your bug reports, feedback,.. to the grml-team.
51 # make sure it's possible to get usage information without being
52 # root or actually executing the script
53 if [ "$1" = '-h' -o "$1" = '--help' ] ; then
55 [ "$(id -u 2>/dev/null)" != 0 ] && echo "Please notice that this script requires root permissions."
60 # we need root permissions for the build-process:
61 if [ "$(id -u 2>/dev/null)" != 0 ] ; then
62 echo "Error: please run this script with uid 0 (root)." >&2
66 if [ -r /var/run/fai/FAI_INSTALLATION_IN_PROGRESS ] ; then
67 echo "/usr/sbin/fai already running or was aborted before.">&2
68 echo "You may remove /var/run/fai/FAI_INSTALLATION_IN_PROGRESS and try again.">&2
73 if [ -r /var/run/fai/fai_softupdate_is_running ] ; then
74 echo "/usr/sbin/fai softupdate already running or was aborted before.">&2
75 echo "You may remove /var/run/fai/fai_softupdate_is_running and try again.">&2
79 # make sure they are not set by default
86 if [ -r /etc/grml/lsb-functions ] ; then
87 . /etc/grml/lsb-functions
89 einfo() { echo " [*] $*" ;}
90 eerror() { echo " [!] $*">&2 ;}
91 ewarn() { echo " [x] $*" ;}
95 # source main configuration file:
96 LIVE_CONF=/etc/grml/grml-live.conf
103 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
104 rm -f /var/run/fai/fai_softupdate_is_running \
105 /var/run/fai/FAI_INSTALLATION_IN_PROGRESS
106 [ -n "$1" ] && EXIT="$1" || EXIT="1"
107 [ -n "$2" ] && eerror "$2">&2
108 log "------------------------------------------------------------------------------"
111 # trap bailout 1 2 3 6 9 14 15
112 trap bailout 1 2 3 15
115 # check for important variables {{{
116 [ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG=/etc/grml/fai
117 [ -n "$HOSTNAME" ] || HOSTNAME=grml
118 [ -n "$USERNAME" ] || USERNAME=grml
119 [ -n "$CLASSES" ] || CLASSES="GRML,I386"
120 [ -n "$BOOT_METHOD" ] || BOOT_METHOD='isolinux'
121 [ -n "$OUTPUT" ] || bailout 1 "${PN}: \$OUTPUT not specified. Please adjust $LIVE_CONF. Exiting."
123 [ -n "$VERSION" ] || VERSION="0.0.1"
124 [ -n "$RELEASENAME" ] || RELEASENAME="grml-live rocks"
125 [ -n "$GRML_NAME" ] || GRML_NAME='grml'
128 if [ -z "$LOGFILE" ] ; then
129 LOGFILE=/var/log/grml-live.log
132 chown root:adm $LOGFILE
135 NFSROOT_CONF=/etc/grml/fai/make-fai-nfsroot.conf
139 # some important functions {{{
142 # usage: log "string to log"
143 log() { echo "$*" >> $LOGFILE ; }
145 # cut string at character number int = $1
146 # usage: cut_string 5 "1234567890" will output "12345"
148 [ -n "$2" ] || return 1
149 echo "$2" | head -c "$1"; echo -ne "\n"
152 # prepend int = $1 spaces before string = $2
153 # usage: extend_string_begin 5 "123" will output " 123"
154 extend_string_begin() {
155 [ -n "$2" ] || return 1
156 local COUNT="$(echo $2 | wc -c)"
157 local FILL="$(expr $COUNT - $1)"
158 while [ "$FILL" -gt 1 ] ; do
160 local FILL=$(expr $FILL - 1)
162 while [ "$FILL" -lt 1 ] ; do
164 local FILL=$(expr $FILL + 1)
166 echo "$2" | head -c "$1"; echo -ne "\n"
169 # append int = $1 spaces to string = $2
170 # usage: extend_string_begin 5 "123" will output "123 "
171 extend_string_end() {
172 [ -n "$2" ] || return 1
173 echo -n "$2" | head -c "$1"
174 local COUNT="$(echo $2 | wc -c)"
175 local FILL="$(expr $COUNT - $1)"
176 while [ "$FILL" -gt 1 ] ; do
178 local FILL=$(expr $FILL - 1)
180 while [ "$FILL" -lt 1 ] ; do
182 local FILL=$(expr $FILL + 1)
188 # read local (non-packaged) configuration {{{
189 LOCAL_CONFIG=/etc/grml/grml-live.local
190 if [ -r "$LOCAL_CONFIG" ] ; then
191 log "Sourcing $LOCAL_CONFIG"
194 log "No $LOCAL_CONFIG found, not sourcing it"
199 # command line parsing {{{
200 while getopts "a:C:c:g:i:o:r:s:t:v:bFhuVz" opt; do
204 c) CLASSES="$OPTARG" ;;
205 C) CONFIG="$OPTARG" ;;
206 g) GRML_NAME="$OPTARG" ;;
207 i) ISO_NAME="$OPTARG" ;;
209 CHROOT_OUTPUT="$OUTPUT/grml_chroot"
210 BUILD_OUTPUT="$OUTPUT/grml_cd"
211 ISO_OUTPUT="$OUTPUT/grml_isos"
213 r) RELEASENAME="$OPTARG" ;;
214 s) SUITE="$OPTARG" ;;
215 t) TEMPLATE_DIRECTORY="$OPTARG";;
216 v) VERSION="$OPTARG" ;;
218 h) usage ; bailout 0 ;;
221 z) SQUASHFS_ZLIB="-nolzma" ;;
222 ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
225 shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter
228 # some misc checks before executing FAI {{{
229 [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in $LIVE_CONF or
230 specify it on the command line using the -c option."
231 [ -n "$OUTPUT" ] || bailout 1 "Error: \$OUTPUT unset, please set it in $LIVE_CONF or
232 specify it on the command line using the -o option."
234 # trim characters that are known to cause problems inside $GRML_NAME;
235 # for example isolinux does not like '-' inside the directory name
236 [ -n "$GRML_NAME" ] && export SHORT_GRML_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')"
239 # clean/zero grml-live logfile {{{
240 if [ -n "$ZERO_LOGFILE" ] ; then
245 # clean/zero/remove old FAI directory {{{
246 if [ -n "$ZERO_FAI_LOGFILE" ] ; then
247 if [ -d /var/log/fai/"$HOSTNAME" ] ; then
248 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last)"
249 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-dirinstall)"
250 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-softupdate)"
251 rm -f /var/log/fai/"$HOSTNAME"/last \
252 /var/log/fai/"$HOSTNAME"/last-dirinstall \
253 /var/log/fai/"$HOSTNAME"/last-softupdate
258 # ask user whether the setup is ok {{{
259 if [ -z "$FORCE" ] ; then
261 echo "${PN} [${GRML_LIVE_VERSION}]: check your configuration (or use -F to force execution):"
263 echo " FAI classes: $CLASSES"
264 [ -r "$LOCAL_CONFIG" ] && echo " local config: /etc/grml/grml-live.local"
265 [ -n "$CONFIG" ] && echo " configuration: $CONFIG"
266 echo " main directory: $OUTPUT"
267 [ -n "$CHROOT_OUTPUT" ] && echo " chroot target: $CHROOT_OUTPUT"
268 [ -n "$BUILD_OUTPUT" ] && echo " build target: $BUILD_OUTPUT"
269 [ -n "$ISO_OUTPUT" ] && echo " ISO target: $ISO_OUTPUT"
270 [ -n "$GRML_NAME" ] && echo " grml name: $GRML_NAME"
271 [ -n "$RELEASENAME" ] && echo " release name: $RELEASENAME"
272 [ -n "$VERSION" ] && echo " grml version: $VERSION"
273 [ -n "$SUITE" ] && echo " Debian suite: $SUITE"
274 [ -n "$ARCH" ] && echo " Architecture: $ARCH"
275 [ -n "$BOOT_METHOD" ] && echo " Boot method: $BOOT_METHOD"
276 [ -n "$TEMPLATE_DIRECTORY" ] && echo " Template files: $TEMPLATE_DIRECTORY"
277 [ -n "$FAI_ARGS" ] && echo " additional arguments for FAI: $FAI_ARGS"
278 [ -n "$LOGFILE" ] && echo " Logging to file: $LOGFILE"
279 [ -n "$SQUASHFS_ZLIB" ] && echo " Using ZLIB (instead of LZMA) compression."
280 [ -n "$SQUASHFS_OPTIONS" ] && echo " Using SQUASHFS_OPTIONS ${SQUASHFS_OPTIONS}"
281 [ -n "$VERBOSE" ] && echo " Using VERBOSE mode."
282 [ -n "$UPDATE" ] && echo " Executing UPDATE instead of fresh installation."
283 [ -n "$BUILD_ONLY" ] && echo " Executing BUILD_ONLY instead of fresh installation or UPDATE."
285 echo -n "Is this ok for you? [y/N] "
287 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
288 bailout 1 "Exiting as requested."
293 if [ -n "$CONFIG" ] ; then
294 if ! [ -f "$CONFIG" ] ; then
295 log "Sorry, $CONFIG could not be read. Exiting. [$(date)]"
296 eerror "Sorry, $CONFIG could not be read. Exiting."
299 log "Sourcing $CONFIG"
304 start_seconds=$(cut -d . -f 1 /proc/uptime)
305 log "------------------------------------------------------------------------------"
306 log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
307 log "Executed grml-live command line:"
310 einfo "Logging actions to logfile $LOGFILE"
313 # on-the-fly configuration {{{
314 if [ -n "$MIRROR_DIRECTORY" ] ; then
315 if ! [ -d "$MIRROR_DIRECTORY/debian" ] ; then
316 log "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting. [$(date)]"
317 eerror "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting."
320 echo "$MIRROR_SOURCES" > /etc/grml/fai/apt/sources.list
321 if [ -n "$GRML_LIVE_SOURCES" ] ; then
322 echo "$GRML_LIVE_SOURCES" >> /etc/grml/fai/apt/sources.list
324 elif [ -n "$GRML_LIVE_SOURCES" ] ; then
325 echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
328 if [ -n "$FAI_DEBOOTSTRAP" ] ; then
329 sed -i "s#^FAI_DEBOOTSTRAP=.*#FAI_DEBOOTSTRAP=\"$FAI_DEBOOTSTRAP\"#" $NFSROOT_CONF
332 # does this suck? YES!
333 if [ -n "$SUITE" ] ; then
335 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
336 if [ -n "$file" ] ; then
337 sed -i "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF
338 DIST="\|\ etch\ \|\ stable\ \|\ lenny\ \|\ testing\ \|\ sid\ \|\ unstable\ "
339 sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" $file
343 sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list
344 # notice: activate grml-live pool only if we are building against unstable:
345 if grep -qe unstable -qe sid /etc/grml/fai/apt/sources.list ; then
346 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list || \
347 grep grml-stable /etc/grml/fai/apt/sources.list | \
348 sed 's/grml-stable/grml-live/' >> /etc/grml/fai/apt/sources.list
350 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list && \
351 sed -i 's/.*grml-live.*/# removed grml-live repository/' /etc/grml/fai/apt/sources.list
354 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
355 if [ -n "$file" ] ; then
356 sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file"
359 sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" $NFSROOT_CONF
363 [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
364 if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' $NFSROOT_CONF ; then
365 sed -i "s/--arch [a-z0-9]* /--arch $ARCH /" $NFSROOT_CONF
367 sed -i "s|FAI_DEBOOTSTRAP_OPTS=\"\(.*\)|FAI_DEBOOTSTRAP_OPTS=\"--arch $ARCH \1|" $NFSROOT_CONF
371 # CHROOT_OUTPUT - execute FAI {{{
372 [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
374 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
375 FAI_ACTION=softupdate
377 FAI_ACTION=dirinstall
380 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
381 if ! [ -r "$CHROOT_OUTPUT/etc/grml_version" ] ; then
382 log "Error: does not look like you have a working chroot. Updating/building not possible."
383 eerror "Error: does not look like you have a working chroot. Updating/building not possible. (Drop -u/-b option?)"
389 if [ -d "$CHROOT_OUTPUT/bin" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
390 log "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'"
391 ewarn "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'" ; eend 0
393 mkdir -p "$CHROOT_OUTPUT" || bailout 5 "Problem with creating $CHROOT_OUTPUT for FAI"
395 if [ -n "${MIRROR_DIRECTORY}" ] ; then
396 mkdir -p "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
397 mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
400 log "Executed FAI command line:"
401 log "BUILD_ONLY=$BUILD_ONLY fai $VERBOSE -C $GRML_FAI_CONFIG -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
402 BUILD_ONLY="$BUILD_ONLY" fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" -u \
403 "$HOSTNAME" $FAI_ACTION "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
404 RC="$PIPESTATUS" # notice: bash-only
406 if [ "$RC" != 0 ] ; then
407 log "Error while executing fai [exit code ${RC}]. Exiting."
408 eerror "Error while executing fai [exit code ${RC}]. Exiting." ; eend 1
411 log "Setting /etc/grml_version to $GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]"
412 echo "$GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]" > $CHROOT_OUTPUT/etc/grml_version
413 chmod 644 $CHROOT_OUTPUT/etc/grml_version
416 # Remove all FAI logs from chroot if class RELEASE is used:
417 if [ -f "$CHROOT_OUTPUT"/etc/grml_fai_release ] ; then
418 rm -rf "$CHROOT_OUTPUT"/var/log/fai/*
421 umount $CHROOT_OUTPUT/proc 2>/dev/null || /bin/true
422 umount $CHROOT_OUTPUT/sys 2>/dev/null || /bin/true
423 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
425 # notice: 'fai dirinstall' does not seem to exit appropriate, so:
427 CHECKLOG=/var/log/fai/$HOSTNAME/last
428 if [ -r "$CHECKLOG/software.log" ] ; then
429 # 1 errors during executing of commands
430 grep 'dpkg: error processing' $CHECKLOG/software.log >> $LOGFILE && ERROR=1
431 grep 'E: Method http has died unexpectedly!' $CHECKLOG/software.log >> $LOGFILE && ERROR=2
432 grep 'ERROR: chroot' $CHECKLOG/software.log >> $LOGFILE && ERROR=3
433 grep 'E: Failed to fetch' $CHECKLOG/software.log >> $LOGFILE && ERROR=4
434 grep 'Unable to write mmap - msync (28 No space left on device)' $CHECKLOG/software.log >> $LOGFILE && ERROR=5
437 if [ -r "$CHECKLOG/shell.log" ] ; then
438 grep 'FAILED with exit code' $CHECKLOG/shell.log >> $LOGFILE && ERROR=2
441 if [ -n "$ERROR" ] ; then
442 log "There was an error [${ERROR}] during execution of stage 'fai dirinstall' [$(date)]"
443 eerror "There was an error during execution of stage 'fai dirinstall'"
444 echo " Check out ${CHECKLOG}/ for details. [exit ${ERROR}]"
448 log "Finished execution of stage 'fai dirinstall' [$(date)]"
449 einfo "Finished execution of stage 'fai dirinstall'"
454 # BUILD_OUTPUT - execute arch specific stuff and squashfs {{{
455 [ -n "$BUILD_OUTPUT" ] || BUILD_OUTPUT="$OUTPUT/grml_cd"
456 mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for stage ARCH"
459 if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
460 if [ -d "$BUILD_OUTPUT"/boot -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
461 log "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'"
462 ewarn "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" ; eend 0
465 [ -d "$BUILD_OUTPUT"/boot/addons ] || mkdir -p "$BUILD_OUTPUT"/boot/addons
466 [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux
467 [ -d "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}" ] || mkdir -p "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"
469 cp /boot/memtest86+.bin "$BUILD_OUTPUT"/boot/addons/memtest
471 # if we don't have an initrd we a) can't boot and b) there was an error
472 # during build, so check for the file:
473 INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
474 if [ -n "$INITRD" ] ; then
475 cp $INITRD "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/initrd.gz
476 find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
478 log "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
479 eerror "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
483 KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
484 if [ -n "$KERNEL_IMAGE" ] ; then
485 cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/linux26
487 log "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
488 eerror "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
492 [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
493 if ! [ -d "${TEMPLATE_DIRECTORY}"/boot ] ; then
494 log "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting."
495 eerror "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting." ; eend 1
499 cp ${TEMPLATE_DIRECTORY}/boot/isolinux/* "$BUILD_OUTPUT"/boot/isolinux/
500 cp ${TEMPLATE_DIRECTORY}/boot/addons/* "$BUILD_OUTPUT"/boot/addons/
502 if ! [ -d "${BUILD_OUTPUT}/boot/grub" ] ; then
503 cp -a ${TEMPLATE_DIRECTORY}/boot/grub "$BUILD_OUTPUT"/boot/
506 if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
507 log "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
508 eerror "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting." ; eend 1
512 [ -d "$BUILD_OUTPUT"/GRML ] || mkdir "$BUILD_OUTPUT"/GRML
513 cp -a ${TEMPLATE_DIRECTORY}/GRML/* "$BUILD_OUTPUT"/GRML/
515 # adjust boot splash information:
516 RELEASE_INFO="$GRML_NAME $VERSION - Release Codename $RELEASENAME"
517 RELEASE_INFO="$(cut_string 68 "$RELEASE_INFO")"
518 RELEASE_INFO="$(extend_string_end 68 "$RELEASE_INFO")"
520 sed -i "s/%RELEASE_INFO%/$GRML_NAME $VERSION - $RELEASENAME/" "$BUILD_OUTPUT"/GRML/grml-version
521 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/GRML/grml-version
523 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
524 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
526 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
527 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
529 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
530 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
532 sed -i "s/%VERSION%/$VERSION/" "$BUILD_OUTPUT"/boot/grub/menu.lst
533 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/grub/menu.lst
535 # make sure the squashfs filename is set accordingly:
536 GRML_NAME_SQUASHFS="$GRML_NAME.squashfs"
537 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
538 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
540 GRML_NAME_SQUASHFS="$(cut_string 20 "$GRML_NAME_SQUASHFS")"
541 GRML_NAME_SQUASHFS="$(extend_string_end 20 "$GRML_NAME_SQUASHFS")"
542 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f4
544 # autostart for Windows:
545 if [ -d "${TEMPLATE_DIRECTORY}/windows/autostart/" ] ; then
546 cp ${TEMPLATE_DIRECTORY}/windows/autostart/* "$BUILD_OUTPUT"/
550 if [ -n "$WINDOWS_BINARIES" ] ; then
551 if [ -f "$BUILD_OUTPUT"/windows/putty.exe ] ; then
552 log "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'"
553 ewarn "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'" ; eend 0
555 if ! [ -d "$BUILD_OUTPUT"/windows ] ; then
556 mkdir "$BUILD_OUTPUT"/windows
557 ( cd "$BUILD_OUTPUT"/windows
558 for file in pageant plink pscp psftp putty puttygen ; do
559 wget -O ${file}.exe ${WINDOWS_BINARIES}/${file}.exe
560 md5sum ${file}.exe > ${file}.exe.md5
564 log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
565 einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
567 einfo "Finished execution of stage 'boot'" ; eend 0
570 elif [ "$ARCH" = powerpc ] ; then
571 ewarn 'Warning: formorer, it is your turn. :)'>&2
574 eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
577 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
578 log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
579 ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
581 [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
582 # make sure we don't leave (even an empty) base.tgz:
583 [ -f "$CHROOT_OUTPUT/base.tgz" ] && rm -f "$CHROOT_OUTPUT/base.tgz"
585 # make sure mksquashfs can handle the according option:
586 if [ -n "$SQUASHFS_ZLIB" ] ; then
587 mksquashfs --help 2>&1 | grep -q -- "$SQUASHFS_ZLIB" || SQUASHFS_ZLIB=''
591 if mksquashfs --help 2>&1 | grep -q -- -no-progress ; then
592 log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/${GRML_NAME}.squashfs -noappend -no-progress $SQUASHFS_OPTIONS $SQUASHFS_ZLIB"
593 mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/"${GRML_NAME}".squashfs -noappend -no-progress $SQUASHFS_OPTIONS $SQUASHFS_ZLIB
595 log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/${GRML_NAME}.squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB"
596 mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/"${GRML_NAME}".squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB
599 echo "${GRML_NAME}.squashfs" > $BUILD_OUTPUT/live/filesystem.module
600 log "Finished execution of stage 'squashfs' [$(date)]"
601 einfo "Finished execution of stage 'squashfs'" ; eend 0
604 # create md5sum file:
605 ( cd $BUILD_OUTPUT/GRML &&
606 find .. -type f -not -name md5sums -not -name isolinux.bin -exec md5sum {} \; > md5sums )
609 # ISO_OUTPUT - mkisofs {{{
610 [ -n "$ISO_OUTPUT" ] || ISO_OUTPUT="$OUTPUT/grml_isos"
611 [ -n "$ISO_NAME" ] || ISO_NAME="${GRML_NAME}_${VERSION}.iso"
613 if [ "$BOOT_METHOD" = "isolinux" ] ; then
614 BOOT_FILE="boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat"
615 elif [ "$BOOT_METHOD" = "grub" ] ; then
616 BOOT_FILE="boot/grub/stage2_eltorito"
619 if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
620 log "$ISO_OUTPUT exists already, skipping stage 'iso build'"
621 ewarn "$ISO_OUTPUT exists already, skipping stage 'iso build'" ; eend 0
623 mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
626 if cd "$BUILD_OUTPUT" ; then
627 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} ."
628 mkisofs -V "grml $VERSION" -publisher 'grml-live | grml.org' \
629 -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
631 -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
633 # generate md5sum of ISO if we are using class 'RELEASE':
634 case $CLASSES in *RELEASE*)
636 ( cd $ISO_OUTPUT && \
637 md5sum ${ISO_NAME} > ${ISO_NAME}.md5 && \
638 touch -r ${ISO_NAME} ${ISO_NAME}.md5 )
645 if [ "$RC" = 0 ] ; then
646 log "Finished execution of stage 'iso build' [$(date)]"
647 einfo "Finished execution of stage 'iso build'" ; eend 0
649 log "There was an error ($RC) executing stage 'iso build' [$(date)]"
650 eerror "There was an error executing stage 'iso build'" ; eend 1
657 [ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown"
658 einfo "Sucessfully finished execution of $PN [running ${SECONDS} seconds]" ; eend 0
659 log "Sucessfully finished execution of $PN [running ${SECONDS} seconds]"
663 ## END OF FILE #################################################################
664 # vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=3