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.5'
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,REMOVE_DOCS,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 rm -f /var/run/fai/fai_softupdate_is_running \
116 /var/run/fai/FAI_INSTALLATION_IN_PROGRESS
117 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
118 [ -n "$1" ] && EXIT="$1" || EXIT="1"
119 [ -n "$2" ] && eerror "$2">&2
120 log "------------------------------------------------------------------------------"
123 trap bailout 1 2 3 3 6 9 14 15
126 # check for important variables {{{
127 [ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG=/etc/grml/fai
128 [ -n "$HOSTNAME" ] || HOSTNAME=grml
129 [ -n "$USERNAME" ] || USERNAME=grml
130 [ -n "$CLASSES" ] || CLASSES="GRML,I386"
131 [ -n "$BOOT_METHOD" ] || BOOT_METHOD='isolinux'
132 [ -n "$OUTPUT" ] || bailout 1 "${PN}: \$OUTPUT not specified. Please adjust $LIVE_CONF. Exiting."
134 [ -n "$VERSION" ] || VERSION="0.0.1"
135 [ -n "$RELEASENAME" ] || RELEASENAME="grml-live rocks"
136 [ -n "$GRML_NAME" ] || GRML_NAME='grml'
139 if [ -z "$LOGFILE" ] ; then
140 LOGFILE=/var/log/grml-live.log
143 chown root:adm $LOGFILE
146 NFSROOT_CONF=/etc/grml/fai/make-fai-nfsroot.conf
150 # some important functions {{{
153 # usage: log "string to log"
154 log() { echo "$*" >> $LOGFILE ; }
156 # cut string at character number int = $1
157 # usage: cut_string 5 "1234567890" will output "12345"
159 [ -n "$2" ] || return 1
160 echo "$2" | head -c "$1"; echo -ne "\n"
163 # prepend int = $1 spaces before string = $2
164 # usage: extend_string_begin 5 "123" will output " 123"
165 extend_string_begin() {
166 [ -n "$2" ] || return 1
167 local COUNT="$(echo $2 | wc -c)"
168 local FILL="$(expr $COUNT - $1)"
169 while [ "$FILL" -gt 1 ] ; do
171 local FILL=$(expr $FILL - 1)
173 while [ "$FILL" -lt 1 ] ; do
175 local FILL=$(expr $FILL + 1)
177 echo "$2" | head -c "$1"; echo -ne "\n"
180 # append int = $1 spaces to string = $2
181 # usage: extend_string_begin 5 "123" will output "123 "
182 extend_string_end() {
183 [ -n "$2" ] || return 1
184 echo -n "$2" | head -c "$1"
185 local COUNT="$(echo $2 | wc -c)"
186 local FILL="$(expr $COUNT - $1)"
187 while [ "$FILL" -gt 1 ] ; do
189 local FILL=$(expr $FILL - 1)
191 while [ "$FILL" -lt 1 ] ; do
193 local FILL=$(expr $FILL + 1)
199 # read local (non-packaged) configuration {{{
200 LOCAL_CONFIG=/etc/grml/grml-live.local
201 if [ -r "$LOCAL_CONFIG" ] ; then
202 log "Sourcing $LOCAL_CONFIG"
205 log "No $LOCAL_CONFIG found, not sourcing it"
210 # command line parsing {{{
211 while getopts "a:C:c:g:i:o:r:s:t:v:bFuVz" opt; do
215 c) CLASSES="$OPTARG" ;;
216 C) CONFIG="$OPTARG" ;;
217 g) GRML_NAME="$OPTARG" ;;
218 i) ISO_NAME="$OPTARG" ;;
220 CHROOT_OUTPUT="$OUTPUT/grml_chroot"
221 BUILD_OUTPUT="$OUTPUT/grml_cd"
222 ISO_OUTPUT="$OUTPUT/grml_isos"
224 r) RELEASENAME="$OPTARG" ;;
225 s) SUITE="$OPTARG" ;;
226 t) TEMPLATE_DIRECTORY="$OPTARG";;
227 v) VERSION="$OPTARG" ;;
231 z) SQUASHFS_ZLIB="-nolzma" ;;
232 ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
235 shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter
238 # some misc checks before executing FAI {{{
239 [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in $LIVE_CONF or
240 specify it on the command line using the -c option."
241 [ -n "$OUTPUT" ] || bailout 1 "Error: \$OUTPUT unset, please set it in $LIVE_CONF or
242 specify it on the command line using the -o option."
244 # trim characters that are known to cause problems inside $GRML_NAME;
245 # for example isolinux does not like '-' inside the directory name
246 [ -n "$GRML_NAME" ] && export SHORT_GRML_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')"
248 # export variables to have them available in fai scripts:
249 [ -n "$GRML_NAME" ] && export GRML_NAME="$GRML_NAME"
250 [ -n "$RELEASENAME" ] && export RELEASENAME="$RELEASENAME"
253 # clean/zero grml-live logfile {{{
254 if [ -n "$ZERO_LOGFILE" ] ; then
259 # clean/zero/remove old FAI directory {{{
260 if [ -n "$ZERO_FAI_LOGFILE" ] ; then
261 if [ -d /var/log/fai/"$HOSTNAME" ] ; then
262 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last)"
263 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-dirinstall)"
264 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-softupdate)"
265 rm -f /var/log/fai/"$HOSTNAME"/last \
266 /var/log/fai/"$HOSTNAME"/last-dirinstall \
267 /var/log/fai/"$HOSTNAME"/last-softupdate
272 # ask user whether the setup is ok {{{
273 if [ -z "$FORCE" ] ; then
275 echo "${PN} [${GRML_LIVE_VERSION}]: check your configuration (or use -F to force execution):"
277 echo " FAI classes: $CLASSES"
278 [ -r "$LOCAL_CONFIG" ] && echo " local config: /etc/grml/grml-live.local"
279 [ -n "$CONFIG" ] && echo " configuration: $CONFIG"
280 echo " main directory: $OUTPUT"
281 [ -n "$CHROOT_OUTPUT" ] && echo " chroot target: $CHROOT_OUTPUT"
282 [ -n "$BUILD_OUTPUT" ] && echo " build target: $BUILD_OUTPUT"
283 [ -n "$ISO_OUTPUT" ] && echo " ISO target: $ISO_OUTPUT"
284 [ -n "$GRML_NAME" ] && echo " grml name: $GRML_NAME"
285 [ -n "$RELEASENAME" ] && echo " release name: $RELEASENAME"
286 [ -n "$VERSION" ] && echo " grml version: $VERSION"
287 [ -n "$SUITE" ] && echo " Debian suite: $SUITE"
288 [ -n "$ARCH" ] && echo " Architecture: $ARCH"
289 [ -n "$BOOT_METHOD" ] && echo " Boot method: $BOOT_METHOD"
290 [ -n "$TEMPLATE_DIRECTORY" ] && echo " Template files: $TEMPLATE_DIRECTORY"
291 [ -n "$FAI_ARGS" ] && echo " additional arguments for FAI: $FAI_ARGS"
292 [ -n "$LOGFILE" ] && echo " Logging to file: $LOGFILE"
293 [ -n "$SQUASHFS_ZLIB" ] && echo " Using ZLIB (instead of LZMA) compression."
294 [ -n "$SQUASHFS_OPTIONS" ] && echo " Using SQUASHFS_OPTIONS ${SQUASHFS_OPTIONS}"
295 [ -n "$VERBOSE" ] && echo " Using VERBOSE mode."
296 [ -n "$UPDATE" ] && echo " Executing UPDATE instead of fresh installation."
297 [ -n "$BUILD_ONLY" ] && echo " Executing BUILD_ONLY instead of fresh installation or UPDATE."
299 echo -n "Is this ok for you? [y/N] "
301 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
302 bailout 1 "Exiting as requested."
307 if [ -n "$CONFIG" ] ; then
308 if ! [ -f "$CONFIG" ] ; then
309 log "Sorry, $CONFIG could not be read. Exiting. [$(date)]"
310 eerror "Sorry, $CONFIG could not be read. Exiting."
313 log "Sourcing $CONFIG"
318 start_seconds=$(cut -d . -f 1 /proc/uptime)
319 log "------------------------------------------------------------------------------"
320 log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
321 log "Executed grml-live command line:"
324 einfo "Logging actions to logfile $LOGFILE"
327 # on-the-fly configuration {{{
328 if [ -n "$MIRROR_DIRECTORY" ] ; then
329 if ! [ -d "$MIRROR_DIRECTORY/debian" ] ; then
330 log "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting. [$(date)]"
331 eerror "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting."
334 echo "$MIRROR_SOURCES" > /etc/grml/fai/apt/sources.list
335 if [ -n "$GRML_LIVE_SOURCES" ] ; then
336 echo "$GRML_LIVE_SOURCES" >> /etc/grml/fai/apt/sources.list
338 elif [ -n "$GRML_LIVE_SOURCES" ] ; then
339 echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
342 if [ -n "$FAI_DEBOOTSTRAP" ] ; then
343 sed -i "s#^FAI_DEBOOTSTRAP=.*#FAI_DEBOOTSTRAP=\"$FAI_DEBOOTSTRAP\"#" $NFSROOT_CONF
346 # does this suck? YES!
347 if [ -n "$SUITE" ] ; then
349 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
350 if [ -n "$file" ] ; then
351 sed -i "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF
352 DIST="\|\ etch\ \|\ stable\ \|\ lenny\ \|\ testing\ \|\ sid\ \|\ unstable\ "
353 sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" $file
357 sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list
358 # notice: activate grml-live pool only if we are building against unstable:
359 if grep -qe unstable -qe sid /etc/grml/fai/apt/sources.list ; then
360 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list || \
361 grep grml-stable /etc/grml/fai/apt/sources.list | \
362 sed 's/grml-stable/grml-live/' >> /etc/grml/fai/apt/sources.list
364 grep -q 'grml-live.*main' /etc/grml/fai/apt/sources.list && \
365 sed -i 's/.*grml-live.*/# removed grml-live repository/' /etc/grml/fai/apt/sources.list
368 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
369 if [ -n "$file" ] ; then
370 sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file"
373 sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" $NFSROOT_CONF
377 [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
378 if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' $NFSROOT_CONF ; then
379 sed -i "s/--arch [a-z0-9]* /--arch $ARCH /" $NFSROOT_CONF
381 sed -i "s|FAI_DEBOOTSTRAP_OPTS=\"\(.*\)|FAI_DEBOOTSTRAP_OPTS=\"--arch $ARCH \1|" $NFSROOT_CONF
385 # CHROOT_OUTPUT - execute FAI {{{
386 [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
388 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
389 FAI_ACTION=softupdate
391 FAI_ACTION=dirinstall
394 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
395 if ! [ -r "$CHROOT_OUTPUT/etc/grml_version" ] ; then
396 log "Error: does not look like you have a working chroot. Updating/building not possible."
397 eerror "Error: does not look like you have a working chroot. Updating/building not possible. (Drop -u/-b option?)"
403 if [ -d "$CHROOT_OUTPUT/bin" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
404 log "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'"
405 ewarn "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'" ; eend 0
407 mkdir -p "$CHROOT_OUTPUT" || bailout 5 "Problem with creating $CHROOT_OUTPUT for FAI"
409 if [ -n "${MIRROR_DIRECTORY}" ] ; then
410 mkdir -p "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
411 mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
414 log "Executed FAI command line:"
415 log "BUILD_ONLY=$BUILD_ONLY fai $VERBOSE -C $GRML_FAI_CONFIG -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
416 BUILD_ONLY="$BUILD_ONLY" fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" -u \
417 "$HOSTNAME" $FAI_ACTION "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
418 RC="$PIPESTATUS" # notice: bash-only
420 if [ "$RC" != 0 ] ; then
421 log "Error while executing fai [exit code ${RC}]. Exiting."
422 eerror "Error while executing fai [exit code ${RC}]. Exiting." ; eend 1
425 log "Setting /etc/grml_version to $GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]"
426 echo "$GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]" > $CHROOT_OUTPUT/etc/grml_version
427 chmod 644 $CHROOT_OUTPUT/etc/grml_version
428 einfo "Rebuilding initramfs"
429 # make sure new /etc/grml_version reaches the initramfs:
430 chroot $CHROOT_OUTPUT update-initramfs -u -t
434 # Remove all FAI logs from chroot if class RELEASE is used:
435 if [ -f "$CHROOT_OUTPUT"/etc/grml_fai_release ] ; then
436 rm -rf "$CHROOT_OUTPUT"/var/log/fai/*
439 # make sure we don't leave any mounts - FAI doesn't remove them always
440 umount $CHROOT_OUTPUT/proc 2>/dev/null || /bin/true
441 umount $CHROOT_OUTPUT/sys 2>/dev/null || /bin/true
442 umount $CHROOT_OUTPUT/dev/pts 2>/dev/null || /bin/true
443 umount $CHROOT_OUTPUT/dev 2>/dev/null || /bin/true
445 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
447 # notice: 'fai dirinstall' does not seem to exit appropriate, so:
449 CHECKLOG=/var/log/fai/$HOSTNAME/last
450 if [ -r "$CHECKLOG/software.log" ] ; then
451 # 1 errors during executing of commands
452 grep 'dpkg: error processing' $CHECKLOG/software.log >> $LOGFILE && ERROR=1
453 grep 'E: Method http has died unexpectedly!' $CHECKLOG/software.log >> $LOGFILE && ERROR=2
454 grep 'ERROR: chroot' $CHECKLOG/software.log >> $LOGFILE && ERROR=3
455 grep 'E: Failed to fetch' $CHECKLOG/software.log >> $LOGFILE && ERROR=4
456 grep 'Unable to write mmap - msync (28 No space left on device)' $CHECKLOG/software.log >> $LOGFILE && ERROR=5
459 if [ -r "$CHECKLOG/shell.log" ] ; then
460 grep 'FAILED with exit code' $CHECKLOG/shell.log >> $LOGFILE && ERROR=2
463 if [ -n "$ERROR" ] ; then
464 log "There was an error [${ERROR}] during execution of stage 'fai dirinstall' [$(date)]"
465 eerror "There was an error during execution of stage 'fai dirinstall'"
466 echo " Check out ${CHECKLOG}/ for details. [exit ${ERROR}]"
470 log "Finished execution of stage 'fai dirinstall' [$(date)]"
471 einfo "Finished execution of stage 'fai dirinstall'"
476 # BUILD_OUTPUT - execute arch specific stuff and squashfs {{{
477 [ -n "$BUILD_OUTPUT" ] || BUILD_OUTPUT="$OUTPUT/grml_cd"
478 mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for stage ARCH"
481 if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
482 if [ -d "$BUILD_OUTPUT"/boot -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
483 log "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'"
484 ewarn "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" ; eend 0
487 [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux
488 [ -d "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}" ] || mkdir -p "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"
490 if [ -z "$NO_ADDONS" ] ; then
491 [ -d "$BUILD_OUTPUT"/boot/addons ] || mkdir -p "$BUILD_OUTPUT"/boot/addons
492 cp /boot/memtest86+.bin "$BUILD_OUTPUT"/boot/addons/memtest
495 # if we don't have an initrd we a) can't boot and b) there was an error
496 # during build, so check for the file:
497 INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
498 if [ -n "$INITRD" ] ; then
499 cp $INITRD "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/initrd.gz
500 find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
502 log "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
503 eerror "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
507 KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
508 if [ -n "$KERNEL_IMAGE" ] ; then
509 cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/"${SHORT_GRML_NAME}"/linux26
511 log "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
512 eerror "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
516 [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
517 if ! [ -d "${TEMPLATE_DIRECTORY}"/boot ] ; then
518 log "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting."
519 eerror "${TEMPLATE_DIRECTORY}/boot does not exist. Exiting." ; eend 1
523 cp ${TEMPLATE_DIRECTORY}/boot/isolinux/* "$BUILD_OUTPUT"/boot/isolinux/
525 if [ -z "$NO_ADDONS" ] ; then
526 cp ${TEMPLATE_DIRECTORY}/boot/addons/* "$BUILD_OUTPUT"/boot/addons/
529 if ! [ -d "${BUILD_OUTPUT}/boot/grub" ] ; then
530 cp -a ${TEMPLATE_DIRECTORY}/boot/grub "$BUILD_OUTPUT"/boot/
533 if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
534 log "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
535 eerror "${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting." ; eend 1
539 [ -d "$BUILD_OUTPUT"/GRML ] || mkdir "$BUILD_OUTPUT"/GRML
540 cp -a ${TEMPLATE_DIRECTORY}/GRML/* "$BUILD_OUTPUT"/GRML/
542 # adjust boot splash information:
543 RELEASE_INFO="$GRML_NAME $VERSION - Release Codename $RELEASENAME"
544 RELEASE_INFO="$(cut_string 68 "$RELEASE_INFO")"
545 RELEASE_INFO="$(extend_string_end 68 "$RELEASE_INFO")"
547 sed -i "s/%RELEASE_INFO%/$GRML_NAME $VERSION - $RELEASENAME/" "$BUILD_OUTPUT"/GRML/grml-version
548 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/GRML/grml-version
550 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
551 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot.msg
553 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
554 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
556 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
557 sed -i "s/%DATE%/$ISO_DATE/" "$BUILD_OUTPUT"/boot/isolinux/boot-beep.msg
559 sed -i "s/%VERSION%/$VERSION/" "$BUILD_OUTPUT"/boot/grub/menu.lst
560 sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/grub/menu.lst
562 # make sure the squashfs filename is set accordingly:
563 GRML_NAME_SQUASHFS="$GRML_NAME.squashfs"
564 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg
565 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/syslinux.cfg
567 GRML_NAME_SQUASHFS="$(cut_string 20 "$GRML_NAME_SQUASHFS")"
568 GRML_NAME_SQUASHFS="$(extend_string_end 20 "$GRML_NAME_SQUASHFS")"
569 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f4
571 # autostart for Windows:
572 if [ -d "${TEMPLATE_DIRECTORY}/windows/autostart/" ] ; then
573 cp ${TEMPLATE_DIRECTORY}/windows/autostart/* "$BUILD_OUTPUT"/
577 if [ -n "$WINDOWS_BINARIES" ] ; then
578 if [ -f "$BUILD_OUTPUT"/windows/putty.exe ] ; then
579 log "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'"
580 ewarn "$BUILD_OUTPUT/windows exists already, skipping stage 'WINDOWS_BINARIES'" ; eend 0
582 if ! [ -d "$BUILD_OUTPUT"/windows ] ; then
583 mkdir "$BUILD_OUTPUT"/windows
584 ( cd "$BUILD_OUTPUT"/windows
585 for file in pageant plink pscp psftp putty puttygen ; do
586 wget -O ${file}.exe ${WINDOWS_BINARIES}/${file}.exe
587 md5sum ${file}.exe > ${file}.exe.md5
591 log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
592 einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
594 einfo "Finished execution of stage 'boot'" ; eend 0
597 elif [ "$ARCH" = powerpc ] ; then
598 ewarn 'Warning: formorer, it is your turn. :)'>&2
601 eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
604 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
605 log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
606 ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
608 [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
609 # make sure we don't leave (even an empty) base.tgz:
610 [ -f "$CHROOT_OUTPUT/base.tgz" ] && rm -f "$CHROOT_OUTPUT/base.tgz"
612 # make sure mksquashfs can handle the according option:
613 if [ -n "$SQUASHFS_ZLIB" ] ; then
614 mksquashfs --help 2>&1 | grep -q -- "$SQUASHFS_ZLIB" || SQUASHFS_ZLIB=''
617 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-nolzma" ; then
618 if ! mksquashfs --help 2>&1 | grep -q -- '-nolzma' ; then
619 ewarn "mksquashfs does NOT support the nolzma option, just using default zlib mode."
620 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-nolzma//g')"
625 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-lzma" ; then
626 if ! mksquashfs --help 2>&1 | grep -q -- '-lzma' ; then
627 ewarn "mksquashfs does NOT support the lzma option, falling back to zlib mode."
628 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-lzma//g')"
633 # support exclusion of files via exclude-file:
634 if [ -n "$SQUASHFS_EXCLUDES_FILE" -a "$SQUASHFS_EXCLUDES_FILE" ] ; then
635 SQUASHFS_OPTIONS="$SQUASHFS_OPTIONS -ef $SQUASHFS_EXCLUDES_FILE"
638 # get rid of unnecessary files when building grml-small for final release:
639 if echo "$CLASSES" | grep -q GRML_SMALL ; then
640 SQUASHFS_OPTIONS="$SQUASHFS_OUTPUT -e initrd.img* vmlinuz*"
643 SQUASHFS_OUTPUT="$(mktemp -t grml-live.XXXXXX)"
644 log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/${GRML_NAME}.squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB"
645 if mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/"${GRML_NAME}".squashfs \
646 -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB 2>"${SQUASHFS_OUTPUT}" ; then
647 echo "${GRML_NAME}.squashfs" > $BUILD_OUTPUT/live/filesystem.module
648 log "Finished execution of stage 'squashfs' [$(date)]"
649 einfo "Finished execution of stage 'squashfs'" ; eend 0
650 rm -f "${SQUASHFS_OUTPUT}"
652 log "There was an error executing stage 'squashfs' [$(date)]:"
653 log "$(cat $SQUASHFS_OUTPUT)"
654 eerror "There was an error executing stage 'squashfs':" ; eend 1
655 cat "${SQUASHFS_OUTPUT}"
656 rm -f "${SQUASHFS_OUTPUT}"
661 # create md5sum file:
662 ( cd $BUILD_OUTPUT/GRML &&
663 find .. -type f -not -name md5sums -not -name isolinux.bin -exec md5sum {} \; > md5sums )
666 # ISO_OUTPUT - mkisofs {{{
667 [ -n "$ISO_OUTPUT" ] || ISO_OUTPUT="$OUTPUT/grml_isos"
668 [ -n "$ISO_NAME" ] || ISO_NAME="${GRML_NAME}_${VERSION}.iso"
670 if [ "$BOOT_METHOD" = "isolinux" ] ; then
671 BOOT_FILE="boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat"
672 elif [ "$BOOT_METHOD" = "grub" ] ; then
673 BOOT_FILE="boot/grub/stage2_eltorito"
676 if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
677 log "$ISO_OUTPUT exists already, skipping stage 'iso build'"
678 ewarn "$ISO_OUTPUT exists already, skipping stage 'iso build'" ; eend 0
680 mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
683 if cd "$BUILD_OUTPUT" ; then
684 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} ."
685 mkisofs -V "grml $VERSION" -publisher 'grml-live | grml.org' \
686 -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
688 -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
690 # generate md5sum of ISO if we are using class 'RELEASE':
691 case $CLASSES in *RELEASE*)
693 ( cd $ISO_OUTPUT && \
694 md5sum ${ISO_NAME} > ${ISO_NAME}.md5 && \
695 touch -r ${ISO_NAME} ${ISO_NAME}.md5 )
702 if [ "$RC" = 0 ] ; then
703 log "Finished execution of stage 'iso build' [$(date)]"
704 einfo "Finished execution of stage 'iso build'" ; eend 0
706 log "There was an error ($RC) executing stage 'iso build' [$(date)]"
707 eerror "There was an error executing stage 'iso build'" ; eend 1
714 [ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown"
715 einfo "Sucessfully finished execution of $PN [running ${SECONDS} seconds]" ; eend 0
716 log "Sucessfully finished execution of $PN [running ${SECONDS} seconds]"
720 ## END OF FILE #################################################################
721 # vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=3