3 # Purpose: build process script for generating a (grml based) Linux Live-ISO
4 # Authors: grml-team (grml.org),
5 # (c) Michael Prokop <mika@grml.org>,
6 # (c) Thorsten Glaser <tg@mirbsd.org>
7 # Bug-Reports: see http://grml.org/bugs/
8 # License: This file is licensed under the GPL v2 or any later version.
9 ################################################################################
11 # some misc and global stuff {{{
15 # define function getfilesize before "set -e"
16 if stat --help >/dev/null 2>&1; then
17 getfilesize='stat -c %s' # GNU stat
19 getfilesize='stat -f %z' # BSD stat
26 GRML_LIVE_VERSION='0.9.33-pre1'
29 SOURCES_LIST_FILE='/etc/grml/fai/apt/sources.list'
30 ADDONS_LIST_FILE='/boot/isolinux/addons_list.cfg'
33 # usage information {{{
37 $PN - build process script for generating a (grml based) Linux Live-ISO
39 Usage: $PN [options, see as follows]
41 -a <architecture> architecture; available values: i386 and amd64
42 -b build the ISO without updating the chroot via FAI
43 -B build the ISO without touching the chroot (skips cleanup)
44 -c <classe[s]> classes to be used for building the ISO via FAI
45 -C <configfile> configuration file for grml-live
46 -d <date> use specified date instead of build time as date of release
47 -F force execution without prompting
48 -g <grml_name> set the grml flavour name
49 -h display short usage information and exit
50 -i <iso_name> name of ISO
51 -I <src_directory> directory which provides files that should become
52 part of the chroot/ISO
53 -n skip generation of ISO
54 -o <output_directory> main output directory of the build process
56 -r <release_name> release name
57 -s <suite> Debian suite; values: etch, lenny, squeeze, sid
58 -t <template_directory> place of the templates
59 -u update existing chroot instead of rebuilding it from scratch
60 -v <version_number> specify version number of the release
61 -V increase verbosity in the build process
62 -z use ZLIB instead of LZMA compression (depends on
63 squashfs-tools version)
68 $PN -c GRMLBASE,GRML_MEDIUM,I386 -o /dev/shm/grml
69 $PN -c GRMLBASE,GRML_SMALL,REMOVE_DOCS,I386 -g grml-small -v 1.0
70 $PN -c GRMLBASE,GRML_FULL,I386 -i grml_0.0-1.iso -v 0.0-1
71 $PN -c GRMLBASE,GRML_FULL,I386 -s sid -V -r 'grml-live rocks'
73 More details: man grml-live + /usr/share/doc/grml-live/grml-live.html
74 http://grml.org/grml-live/
76 Please send your bug reports and feedback to the grml-team: http://grml.org/bugs/
80 # make sure it's possible to get usage information without being
81 # root or actually executing the script
82 if [ "$1" = '-h' -o "$1" = '--help' ] ; then
84 [ "$(id -u 2>/dev/null)" != 0 ] && echo "Please notice that this script requires root permissions."
89 # some runtime checks {{{
90 # we need root permissions for the build-process:
91 if [ "$(id -u 2>/dev/null)" != 0 ] ; then
92 echo "Error: please run this script with uid 0 (root)." >&2
96 if [ -r /var/run/fai/FAI_INSTALLATION_IN_PROGRESS ] ; then
97 echo "/usr/sbin/fai already running or was aborted before.">&2
98 echo "You may remove /var/run/fai/FAI_INSTALLATION_IN_PROGRESS and try again.">&2
103 if [ -r /var/run/fai/fai_softupdate_is_running ] ; then
104 echo "/usr/sbin/fai softupdate already running or was aborted before.">&2
105 echo "You may remove /var/run/fai/fai_softupdate_is_running and try again.">&2
110 # lsb-functions and configuration stuff {{{
111 # make sure they are not set by default
119 if [ -r /etc/grml/lsb-functions ] ; then
120 . /etc/grml/lsb-functions
122 einfo() { echo " [*] $*" ;}
123 eerror() { echo " [!] $*">&2 ;}
124 ewarn() { echo " [x] $*" ;}
128 # source main configuration file:
129 LIVE_CONF=/etc/grml/grml-live.conf
135 rm -f /var/run/fai/fai_softupdate_is_running \
136 /var/run/fai/FAI_INSTALLATION_IN_PROGRESS
137 [ -n "$SQUASHFS_STDERR" ] && rm -rf "$SQUASHFS_STDERR"
138 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
139 [ -n "$1" ] && EXIT="$1" || EXIT="1"
140 [ -n "$2" ] && eerror "$2">&2
141 log "------------------------------------------------------------------------------"
144 trap bailout 1 2 3 3 6 9 14 15
148 [ -n "$LOGFILE" ] || LOGFILE=/var/log/grml-live.log
150 chown root:adm $LOGFILE
154 # some important functions {{{
157 # usage: log "string to log"
158 log() { echo "$*" >> $LOGFILE ; }
160 # cut string at character number int = $1
161 # usage: cut_string 5 "1234567890" will output "12345"
163 [ -n "$2" ] || return 1
164 echo "$2" | head -c "$1"; echo -ne "\n"
167 # prepend int = $1 spaces before string = $2
168 # usage: extend_string_begin 5 "123" will output " 123"
169 extend_string_begin() {
170 [ -n "$2" ] || return 1
171 local COUNT="$(echo $2 | wc -c)"
172 local FILL="$(expr $COUNT - $1)"
173 while [ "$FILL" -gt 1 ] ; do
175 local FILL=$(expr $FILL - 1)
177 while [ "$FILL" -lt 1 ] ; do
179 local FILL=$(expr $FILL + 1)
181 echo "$2" | head -c "$1"; echo -ne "\n"
184 # append int = $1 spaces to string = $2
185 # usage: extend_string_begin 5 "123" will output "123 "
186 extend_string_end() {
187 [ -n "$2" ] || return 1
188 echo -n "$2" | head -c "$1"
189 local COUNT="$(echo $2 | wc -c)"
190 local FILL="$(expr $COUNT - $1)"
191 while [ "$FILL" -gt 1 ] ; do
193 local FILL=$(expr $FILL - 1)
195 while [ "$FILL" -lt 1 ] ; do
197 local FILL=$(expr $FILL + 1)
203 # read local (non-packaged) configuration {{{
204 LOCAL_CONFIG=/etc/grml/grml-live.local
205 if [ -r "$LOCAL_CONFIG" ] ; then
206 log "Sourcing $LOCAL_CONFIG"
209 log "No $LOCAL_CONFIG found, not sourcing it"
214 # command line parsing {{{
215 while getopts "a:C:c:d:g:i:I:o:r:s:t:v:bBFnquVz" opt; do
220 c) CLASSES="$OPTARG" ;;
221 C) CONFIG="$OPTARG" ;;
223 g) GRML_NAME="$OPTARG" ;;
224 i) ISO_NAME="$OPTARG" ;;
225 I) CHROOT_INSTALL="$OPTARG" ;;
227 o) OUTPUT="$OPTARG" ;;
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 # assume sane defaults (if not set already) {{{
244 [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)"
245 [ -n "$BOOT_METHOD" ] || BOOT_METHOD='isolinux'
246 [ -n "$BUILD_OUTPUT" ] || BUILD_OUTPUT="$OUTPUT/grml_cd"
247 [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
248 [ -n "$CLASSES" ] || CLASSES="GRMLBASE,GRML_MEDIUM,I386"
249 [ -n "$DATE" ] || DATE="$(date +%Y-%m-%d)"
250 [ -n "$DISTRI_INFO" ] || DISTRI_INFO='Grml - Live Linux for system administrators '
251 [ -n "$DISTRI_NAME" ] || DISTRI_NAME="grml"
252 [ -n "$DISTRI_SPLASH" ] || DISTRI_SPLASH='grml.png'
253 [ -n "$FORCE_ISO_REBUILD" ] || FORCE_ISO_REBUILD="false"
254 [ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG='/etc/grml/fai'
255 [ -n "$GRML_NAME" ] || GRML_NAME='grml'
256 [ -n "$HOSTNAME" ] || HOSTNAME='grml'
257 [ -n "$ISO_OUTPUT" ] || ISO_OUTPUT="$OUTPUT/grml_isos"
258 [ -n "$NFSROOT_CONF" ] || NFSROOT_CONF='/etc/grml/fai/make-fai-nfsroot.conf'
259 [ -n "$OUTPUT" ] || OUTPUT='/grml/grml-live'
260 [ -n "$RELEASENAME" ] || RELEASENAME='grml-live rocks'
261 [ -n "$SQUASHFS_EXCLUDES_FILE " ] || SQUASHFS_EXCLUDES_FILE='/etc/grml/fai/squashfs-excludes'
262 [ -n "$SUITE" ] || SUITE='lenny'
263 [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
264 [ -n "$USERNAME" ] || USERNAME='grml'
265 [ -n "$VERSION" ] || VERSION='0.0.1'
266 [ -n "$WINDOWS_BINARIES" ] || WINDOWS_BINARIES='http://the.earth.li/~sgtatham/putty/latest/x86/'
269 # some misc checks before executing FAI {{{
270 [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in $LIVE_CONF or
271 specify it on the command line using the -c option."
272 [ -n "$OUTPUT" ] || bailout 1 "Error: \$OUTPUT unset, please set it in $LIVE_CONF or
273 specify it on the command line using the -o option."
275 # set subdirectories according to $OUTPUT:
276 CHROOT_OUTPUT="$OUTPUT/grml_chroot"
277 BUILD_OUTPUT="$OUTPUT/grml_cd"
278 ISO_OUTPUT="$OUTPUT/grml_isos"
280 # trim characters that are known to cause problems inside $GRML_NAME;
281 # for example isolinux does not like '-' inside the directory name
282 [ -n "$GRML_NAME" ] && export SHORT_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')"
284 # export variables to have them available in fai scripts:
285 [ -n "$GRML_NAME" ] && export GRML_NAME="$GRML_NAME"
286 [ -n "$RELEASENAME" ] && export RELEASENAME="$RELEASENAME"
289 # clean/zero grml-live logfile {{{
290 if [ -n "$ZERO_LOGFILE" ] ; then
295 # clean/zero/remove old FAI directory {{{
296 if [ -n "$ZERO_FAI_LOGFILE" ] ; then
297 if [ -d /var/log/fai/"$HOSTNAME" ] ; then
298 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last)"
299 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-dirinstall)"
300 rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last-softupdate)"
301 rm -f /var/log/fai/"$HOSTNAME"/last \
302 /var/log/fai/"$HOSTNAME"/last-dirinstall \
303 /var/log/fai/"$HOSTNAME"/last-softupdate
308 # ask user whether the setup is ok {{{
309 if [ -z "$FORCE" ] ; then
311 echo "${PN} [${GRML_LIVE_VERSION}]: check your configuration (or use -F to force execution):"
313 echo " FAI classes: $CLASSES"
314 [ -r "$LOCAL_CONFIG" ] && echo " local config: /etc/grml/grml-live.local"
315 [ -n "$CONFIG" ] && echo " configuration: $CONFIG"
316 echo " main directory: $OUTPUT"
317 [ -n "$CHROOT_OUTPUT" ] && echo " chroot target: $CHROOT_OUTPUT"
318 [ -n "$BUILD_OUTPUT" ] && echo " build target: $BUILD_OUTPUT"
319 [ -n "$ISO_OUTPUT" ] && echo " ISO target: $ISO_OUTPUT"
320 [ -n "$GRML_NAME" ] && echo " grml name: $GRML_NAME"
321 [ -n "$RELEASENAME" ] && echo " release name: $RELEASENAME"
322 [ -n "$DATE" ] && echo " build date: $DATE"
323 [ -n "$VERSION" ] && echo " grml version: $VERSION"
324 [ -n "$SUITE" ] && echo " Debian suite: $SUITE"
325 [ -n "$ARCH" ] && echo " Architecture: $ARCH"
326 [ -n "$BOOT_METHOD" ] && echo " Boot method: $BOOT_METHOD"
327 [ -n "$TEMPLATE_DIRECTORY" ] && echo " Template files: $TEMPLATE_DIRECTORY"
328 [ -n "$CHROOT_INSTALL" ] && echo " Install files from directory to chroot: $CHROOT_INSTALL"
329 [ -n "$FAI_ARGS" ] && echo " additional arguments for FAI: $FAI_ARGS"
330 [ -n "$LOGFILE" ] && echo " Logging to file: $LOGFILE"
331 [ -n "$SQUASHFS_ZLIB" ] && echo " Using ZLIB (instead of LZMA) compression."
332 [ -n "$SQUASHFS_OPTIONS" ] && echo " Using SQUASHFS_OPTIONS ${SQUASHFS_OPTIONS}"
333 [ -n "$VERBOSE" ] && echo " Using VERBOSE mode."
334 [ -n "$UPDATE" ] && echo " Executing UPDATE instead of fresh installation."
335 [ -n "$SKIP_MKSQUASHFS" ] && echo " Skipping creation of SQUASHFS file."
336 [ -n "$SKIP_MKISOFS" ] && echo " Skipping creation of ISO file."
337 [ -n "$BUILD_ONLY" ] && echo " Executing BUILD_ONLY instead of fresh installation or UPDATE."
338 [ -n "$BUILD_DIRTY" ] && echo " Executing BUILD_DIRTY to leave chroot untouched."
340 echo -n "Is this ok for you? [y/N] "
342 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
343 bailout 1 "Exiting as requested."
348 if [ -n "$CONFIG" ] ; then
349 if ! [ -f "$CONFIG" ] ; then
350 log "Error: $CONFIG could not be read. Exiting. [$(date)]"
351 eerror "Error: $CONFIG could not be read. Exiting." ; eend 1
354 log "Sourcing $CONFIG"
359 start_seconds=$(cut -d . -f 1 /proc/uptime)
360 log "------------------------------------------------------------------------------"
361 log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
362 log "Executed grml-live command line:"
365 einfo "Logging actions to logfile $LOGFILE"
368 # on-the-fly configuration {{{
369 if [ -n "$MIRROR_DIRECTORY" ] ; then
370 if ! [ -d "$MIRROR_DIRECTORY/debian" ] ; then
371 log "Error: $MIRROR_DIRECTORY/debian does not seem to exist. Exiting. [$(date)]"
372 eerror "Error: $MIRROR_DIRECTORY/debian does not seem to exist. Exiting." ; eend 1
375 cat > "$SOURCES_LIST_FILE" << EOF
376 # NOTE: This file is *NOT* meant for manual customisation! This file is
377 # modified by grml-live and any changes might be overriden.
378 # You might consider using GRML_LIVE_SOURCES in /etc/grml/grml-live.conf*
379 # and using /etc/grml/fai/files/etc/apt instead!'
381 echo "$MIRROR_SOURCES" >> "$SOURCES_LIST_FILE"
382 if [ -n "$GRML_LIVE_SOURCES" ] ; then
383 echo "$GRML_LIVE_SOURCES" >> "$SOURCES_LIST_FILE"
385 elif [ -n "$GRML_LIVE_SOURCES" ] ; then
386 cat > "$SOURCES_LIST_FILE" << EOF
387 # NOTE: This file is *NOT* meant for manual customisation! This file is
388 # modified by grml-live and any changes might be overriden.
389 # You might consider using GRML_LIVE_SOURCES in /etc/grml/grml-live.conf*
390 # and using /etc/grml/fai/files/etc/apt instead!'
392 echo "$GRML_LIVE_SOURCES" >> "$SOURCES_LIST_FILE"
395 if [ -n "$FAI_DEBOOTSTRAP" ] ; then
396 sed "s#^FAI_DEBOOTSTRAP=.*#FAI_DEBOOTSTRAP=\"$FAI_DEBOOTSTRAP\"#" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
399 # does this suck? YES!
400 # /usr/share/debootstrap/scripts/unstable does not exist, instead use 'sid':
402 unstable) SUITE='sid' ;;
403 # make sure that we *NEVER* write any broken suite name to sources.list,
404 # otherwise we won't be able to adjust it one next (correct) execution
411 *) echo "Sorry, $SUITE is not a valid Debian suite, exiting.">&2; bailout 1 ;;
414 DIST=" etch\| stable\| lenny\| squeeze\| testing\| sid\| unstable"
415 sed "s/\(^deb .\+\)\([ \t]*\)\($DIST\)\([ \t]*\)\(main \)/\1 \2$SUITE\4\5/" "$SOURCES_LIST_FILE" | sponge "$SOURCES_LIST_FILE"
416 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
417 if [ -n "$file" ] ; then
418 sed "s/^SUITE=.*/SUITE=\"$SUITE\"/" $file | sponge $file
419 sed "s/\(^deb .\+\)\([ \t]*\)\($DIST\)\([ \t]*\)\(main \)/\1 \2$SUITE\4\5/" "$file" | sponge "$file"
423 # notice: activate grml-live pool only if we are building against unstable:
424 if grep -qe unstable -qe sid "$SOURCES_LIST_FILE" ; then
425 grep -q 'grml-live.*main' "$SOURCES_LIST_FILE" || \
426 grep grml-stable "$SOURCES_LIST_FILE" | \
427 sed 's/grml-stable/grml-live/' >> "$SOURCES_LIST_FILE"
429 grep -q 'grml-live.*main' "$SOURCES_LIST_FILE" && \
430 sed 's/.*grml-live.*/# removed grml-live repository/' "$SOURCES_LIST_FILE" | sponge "$SOURCES_LIST_FILE"
433 for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" "$NFSROOT_CONF" ; do
434 if [ -n "$file" ] ; then
435 sed "s|^FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file" | sponge "$file"
439 # validate whether the specified architecture class matches the
440 # architecture (option), otherwise installation of kernel will fail
441 if echo $CLASSES | grep -qi i386 ; then
442 if ! [[ "$ARCH" == "i386" ]] ; then
443 log "Error: You specified the I386 class but are trying to build something else (AMD64?)."
444 eerror "Error: You specified the I386 class but are trying to build something else (AMD64?)."
445 eerror "Tip: Either invoke grml-live with '-i i386' or adjust the architecture class. Exiting."
449 elif echo $CLASSES | grep -qi amd64 ; then
450 if ! [[ "$ARCH" == "amd64" ]] ; then
451 log "Error: You specified the AMD64 class but are trying to build something else (I386?)."
452 eerror "Error: You specified the AMD64 class but are trying to build something else (I386?)."
453 eerror "Tip: Either invoke grml-live with '-i amd64' or adjust the architecture class. Exiting."
459 if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' "$NFSROOT_CONF" ; then
460 sed "s/--arch [a-z0-9]* /--arch $ARCH /" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
462 sed "s|^FAI_DEBOOTSTRAP_OPTS=\"\(.*\)|FAI_DEBOOTSTRAP_OPTS=\"--arch $ARCH \1|" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
466 # CHROOT_OUTPUT - execute FAI {{{
467 if [ -n "$BUILD_DIRTY" ]; then
468 log "Skipping stage 'fai' as requested via option -B"
469 ewarn "Skipping stage 'fai' as requested via option -B" ; eend 0
471 [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot"
473 # provide inform fai about the ISO we build
474 [ -d "$CHROOT_OUTPUT/etc/" ] || mkdir -p "$CHROOT_OUTPUT/etc/"
475 echo '# This file has been generated by grml-live.' > "$CHROOT_OUTPUT/etc/grml_live_version"
476 [ -n "$GRML_LIVE_VERSION" ] && echo "GRML_LIVE_VERSION=$GRML_LIVE_VERSION" >> "$CHROOT_OUTPUT/etc/grml_live_version"
477 [ -n "$SUITE" ] && echo "SUITE=$SUITE" >> "$CHROOT_OUTPUT/etc/grml_live_version"
479 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
480 FAI_ACTION=softupdate
482 FAI_ACTION=dirinstall
485 if [ -n "$UPDATE" -o -n "$BUILD_ONLY" ] ; then
486 if ! [ -r "$CHROOT_OUTPUT/etc/debian_version" ] ; then
487 log "Error: does not look like you have a working chroot. Updating/building not possible."
488 eerror "Error: does not look like you have a working chroot. Updating/building not possible. (Drop -u/-b option?)"
494 if [ -d "$CHROOT_OUTPUT/bin" -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
495 log "Skiping stage 'fai dirinstall' as $CHROOT_OUTPUT exists already."
496 ewarn "Skiping stage 'fai dirinstall' as $CHROOT_OUTPUT exists already." ; eend 0
498 mkdir -p "$CHROOT_OUTPUT" || bailout 5 "Problem with creating $CHROOT_OUTPUT for FAI"
500 if [ -n "${MIRROR_DIRECTORY}" ] ; then
501 mkdir -p "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
502 mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
505 log "Executed FAI command line:"
506 log "BUILD_ONLY=$BUILD_ONLY fai $VERBOSE -C $GRML_FAI_CONFIG -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
507 BUILD_ONLY="$BUILD_ONLY" fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" -u \
508 "$HOSTNAME" $FAI_ACTION "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
509 RC="$PIPESTATUS" # notice: bash-only
511 FORCE_ISO_REBUILD=true
513 if [ "$RC" != 0 ] ; then
514 log "Error: critical error while executing fai [exit code ${RC}]. Exiting."
515 eerror "Error: critical error while executing fai [exit code ${RC}]. Exiting." ; eend 1
518 log "Setting /etc/grml_version to $GRML_NAME $VERSION Release Codename $RELEASENAME [$DATE]"
519 echo "$GRML_NAME $VERSION Release Codename $RELEASENAME [$DATE]" > $CHROOT_OUTPUT/etc/grml_version
520 chmod 644 $CHROOT_OUTPUT/etc/grml_version
521 einfo "Rebuilding initramfs"
522 # make sure new /etc/grml_version reaches the initramfs:
523 # chroot $CHROOT_OUTPUT update-initramfs -u -t => might break when using kernel-package :(
524 chroot $CHROOT_OUTPUT update-initramfs -u -k all
528 # Remove all FAI logs from chroot if class RELEASE is used:
529 if [ -f "$CHROOT_OUTPUT"/etc/grml_fai_release ] ; then
530 rm -rf "$CHROOT_OUTPUT"/var/log/fai/*
533 # make sure we don't leave any mounts - FAI doesn't remove them always
534 umount $CHROOT_OUTPUT/proc 2>/dev/null || /bin/true
535 umount $CHROOT_OUTPUT/sys 2>/dev/null || /bin/true
536 umount $CHROOT_OUTPUT/dev/pts 2>/dev/null || /bin/true
537 umount $CHROOT_OUTPUT/dev 2>/dev/null || /bin/true
539 [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
541 # notice: 'fai dirinstall' does not seem to exit appropriate, so:
543 CHECKLOG=/var/log/fai/$HOSTNAME/last
544 if [ -r "$CHECKLOG/software.log" ] ; then
545 # 1 errors during executing of commands
546 grep 'dpkg: error processing' $CHECKLOG/software.log >> $LOGFILE && ERROR=1
547 grep 'E: Method http has died unexpectedly!' $CHECKLOG/software.log >> $LOGFILE && ERROR=2
548 grep 'ERROR: chroot' $CHECKLOG/software.log >> $LOGFILE && ERROR=3
549 grep 'E: Failed to fetch' $CHECKLOG/software.log >> $LOGFILE && ERROR=4
550 grep 'Unable to write mmap - msync (28 No space left on device)' $CHECKLOG/software.log >> $LOGFILE && ERROR=5
553 if [ -r "$CHECKLOG/shell.log" ] ; then
554 grep 'FAILED with exit code' $CHECKLOG/shell.log >> $LOGFILE && ERROR=2
558 if [ -r "$CHECKLOG/package_errors.log" ] && grep -q '[a-z]' "$CHECKLOG/package_errors.log" ; then
559 ewarn "The following packages were requested for installation but could not be processed:"
560 cat $CHECKLOG/package_errors.log
564 if [ -n "$ERROR" ] ; then
565 log "Error: there was a critical error [${ERROR}] during execution of stage 'fai dirinstall' [$(date)]"
566 eerror "Error: there was a critical error during execution of stage 'fai dirinstall'"
567 eerror "Note: check out ${CHECKLOG}/ for details. [exit ${ERROR}]"
571 log "Finished execution of stage 'fai dirinstall' [$(date)]"
572 einfo "Finished execution of stage 'fai dirinstall'"
575 einfo "Find FAI build logs at $(readlink -f /var/log/fai/$HOSTNAME/last)"
576 log "Find FAI build logs at $(readlink -f /var/log/fai/$HOSTNAME/last)"
582 # BUILD_OUTPUT - execute arch specific stuff and squashfs {{{
583 [ -n "$BUILD_OUTPUT" ] || BUILD_OUTPUT="$OUTPUT/grml_cd"
584 mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for stage ARCH"
587 if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
588 if [ -d "$BUILD_OUTPUT"/boot/isolinux -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then
589 log "Skipping stage 'boot' as $BUILD_OUTPUT/boot/isolinux exists already."
590 ewarn "Skipping stage 'boot' as $BUILD_OUTPUT/boot/isolinux exists already." ; eend 0
593 [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux
594 [ -d "$BUILD_OUTPUT"/boot/"${SHORT_NAME}" ] || mkdir -p "$BUILD_OUTPUT"/boot/"${SHORT_NAME}"
596 if [ -z "$NO_ADDONS" ] ; then
597 [ -d "$BUILD_OUTPUT"/boot/addons ] || mkdir -p "$BUILD_OUTPUT"/boot/addons
598 if [ -r "$TEMPLATE_DIRECTORY"/boot/addons/memtest ] ; then
599 log "Installing $TEMPLATE_DIRECTORY/boot/addons/memtest"
600 cp "$TEMPLATE_DIRECTORY"/boot/addons/memtest "$BUILD_OUTPUT"/boot/addons/memtest
601 elif [ -r /boot/memtest86+.bin ] ; then
602 log "Installing /boot/memtest86+.bin"
603 cp /boot/memtest86+.bin "$BUILD_OUTPUT"/boot/addons/memtest
605 ewarn "No memtest binary found, skipping."
606 log "No memtest binary found, skipping."
611 # if we don't have an initrd we a) can't boot and b) there was an error
612 # during build, so check for the file:
613 INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
614 if [ -n "$INITRD" ] ; then
615 cp $INITRD "$BUILD_OUTPUT"/boot/"${SHORT_NAME}"/initrd.gz
616 find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
618 log "Error: No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
619 eerror "Error: No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
623 KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
624 if [ -n "$KERNEL_IMAGE" ] ; then
625 cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/"${SHORT_NAME}"/linux26
627 log "Error: No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
628 eerror "Error: No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
632 [ -n "$TEMPLATE_DIRECTORY" ] || TEMPLATE_DIRECTORY='/usr/share/grml-live/templates'
633 if ! [ -d "${TEMPLATE_DIRECTORY}"/boot ] ; then
634 log "Error: ${TEMPLATE_DIRECTORY}/boot does not exist. Exiting."
635 eerror "Error: ${TEMPLATE_DIRECTORY}/boot does not exist. Exiting." ; eend 1
639 # *always* copy files to output directory so the variables
640 # get adjusted according to the build
641 cp ${TEMPLATE_DIRECTORY}/boot/isolinux/* "$BUILD_OUTPUT"/boot/isolinux/
643 if [ -n "$NO_ADDONS" ] ; then
644 log "Skipping installation boot addons requested via \$NO_ADDONS."
645 einfo "Skipping installation boot addons requested via \$NO_ADDONS."
648 if ! [ -d /usr/share/grml-live/templates/boot/addons/bsd4grml ] ; then
649 ewarn "Boot addons not found, skipping therefore. (Consider installing package grml-live-addons)" ; eend 0
651 # copy only files so we can handle bsd4grml on its own
652 for file in ${TEMPLATE_DIRECTORY}/boot/addons/* ; do
653 test -f $file && cp $file "$BUILD_OUTPUT"/boot/addons/
656 if [ -z "$NO_ADDONS_BSD4GRML" ] ; then
657 cp -a ${TEMPLATE_DIRECTORY}/boot/addons/bsd4grml "$BUILD_OUTPUT"/boot/addons/
662 if ! [ -d "${BUILD_OUTPUT}/boot/grub" ] ; then
663 cp -a ${TEMPLATE_DIRECTORY}/boot/grub "$BUILD_OUTPUT"/boot/
665 # make sure we have recent template files available, otherwise updating
666 # the strings like $GRML_NAME and $VERSION might be out of date
667 cp ${TEMPLATE_DIRECTORY}/boot/grub/* "$BUILD_OUTPUT"/boot/grub/
669 if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
670 log "Error: ${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
671 eerror "Error: ${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting." ; eend 1
675 [ -d "$BUILD_OUTPUT"/GRML ] || mkdir "$BUILD_OUTPUT"/GRML
676 cp -a ${TEMPLATE_DIRECTORY}/GRML/* "$BUILD_OUTPUT"/GRML/
678 # adjust boot splash information:
679 RELEASE_INFO="$GRML_NAME $VERSION - Release Codename $RELEASENAME"
680 RELEASE_INFO="$(cut_string 68 "$RELEASE_INFO")"
681 RELEASE_INFO="$(extend_string_end 68 "$RELEASE_INFO")"
683 sed -i "s/%RELEASE_INFO%/$GRML_NAME $VERSION - $RELEASENAME/" "$BUILD_OUTPUT"/GRML/grml-version
684 sed -i "s/%DATE%/$DATE/" "$BUILD_OUTPUT"/GRML/grml-version
686 # make sure the squashfs filename is set accordingly:
687 SQUASHFS_NAME="$GRML_NAME.squashfs"
689 # adjust all variables in the templates with the according distribution information
690 for file in "${BUILD_OUTPUT}"/boot/isolinux/*.cfg "${BUILD_OUTPUT}"/boot/isolinux/*.msg \
691 "${BUILD_OUTPUT}"/boot/grub/* ; do
692 sed -i "s/%ARCH%/$ARCH/g" "${file}"
693 sed -i "s/%DATE%/$DATE/g" "${file}"
694 sed -i "s/%DISTRI_INFO%/$DISTRI_INFO/g" "${file}"
695 sed -i "s/%DISTRI_NAME%/$DISTRI_NAME/g" "${file}"
696 sed -i "s/%DISTRI_SPLASH%/$DISTRI_SPLASH/g" "${file}"
697 sed -i "s/%GRML_NAME%/$GRML_NAME/g" "${file}"
698 sed -i "s/%SQUASHFS_NAME%/$SQUASHFS_NAME/g" "${file}"
699 sed -i "s/%RELEASE_INFO%/$RELEASE_INFO/g" "${file}"
700 sed -i "s/%SHORT_NAME%/$SHORT_NAME/g" "${file}"
701 sed -i "s/%VERSION%/$VERSION/g" "${file}"
704 # adjust bootsplash accordingly but make sure the string has the according lenght
705 SQUASHFS_NAME="$(cut_string 20 "$SQUASHFS_NAME")"
706 SQUASHFS_NAME="$(extend_string_end 20 "$SQUASHFS_NAME")"
707 sed -i "s/%SQUASHFS_NAME%/$SQUASHFS_NAME/" "$BUILD_OUTPUT"/boot/isolinux/f4
708 sed -i "s/%SQUASHFS_NAME%/$SQUASHFS_NAME/" "$BUILD_OUTPUT"/boot/isolinux/f5
710 # generate addon list
711 rm "${BUILD_OUTPUT}/${ADDONS_LIST_FILE}"
712 for name in $(ls "${BUILD_OUTPUT}"/boot/isolinux/addon_*.cfg) ; do
713 include_name=$(basename "$name")
714 echo "include $include_name" >> "${BUILD_OUTPUT}/${ADDONS_LIST_FILE}"
717 if ! [ -r "${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg" ] || [ "$DISTRI_NAME" = "grml" ] ; then
718 log "including grmlmain.cfg in ${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
719 echo "include grmlmain.cfg" > "${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
720 echo "include default.cfg" > "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
721 echo "include menuoptions.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
722 echo "include grml.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
723 echo "include options.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
724 if [ ! -n "$NO_ADDONS" ] ; then
725 echo "include addons.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
727 echo "include isoprompt.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
728 echo "include hd.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
729 echo "include hidden.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/grmlmain.cfg"
730 else # assume we are building a custom distribution:
731 log "File ${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg found, using it."
732 einfo "File ${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg found, using it."
733 if grep -q "^include ${DISTRI_NAME}.cfg" "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" ; then
734 log "include for ${DISTRI_NAME}.cfg already present, nothing to do."
736 einfo "include for ${DISTRI_NAME}.cfg already present, nothing to do."
740 log "including ${DISTRI_NAME}.cfg in ${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
741 echo "include ${DISTRI_NAME}.cfg" > "${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
742 [ -n "$NO_ADDONS" ] || echo "include addons.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/distri.cfg"
746 # use old style console based isolinux method only if requested:
747 if [[ "${ISOLINUX_METHOD}" == "console" ]] ; then
748 log 'Using console based isolinux method as requested via $ISOLINUX_METHOD.'
749 einfo 'Using console based isolinux method as requested via $ISOLINUX_METHOD.'
750 if grep -q '^include console.cfg' "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" ; then
751 einfo "include for console.cfg already foud, nothing to do."
754 log "including console.cfg in ${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg"
755 einfo "including console.cfg in ${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg"
756 echo "include console.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg"
760 log 'Using graphical boot menu.'
761 if grep -q '^include vesamenu.cfg' "${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg" ; then
762 log "include for vesamenu.cfg already foud, nothing to do."
764 log "including vesamenu.cfg in ${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg"
765 echo "include vesamenu.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg"
769 # jump back to grub from bsd4grml (/boot/grub/stage2):
772 if [ -e "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.6 ]; then
773 if [ -e "$BUILD_OUTPUT"/boot/grub/core.img ]; then
779 for file in "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.6 \
780 "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.cfg \
781 "$BUILD_OUTPUT"/boot/isolinux/*.cfg \
782 "$BUILD_OUTPUT"/boot/grub/grub.cfg \
783 "$BUILD_OUTPUT"/boot/grub/menu.lst ; do
784 if [ -e "$file" ] ; then
785 sed -i -e "s!%GRUB_VERSION%!$GRUB_VERSION!g" \
786 -e "s!%GRUB_LEGACY%!$GRUB_LEGACY!g" "$file"
790 sed -i "s/%RELEASE_INFO%/$GRML_NAME $VERSION - $RELEASENAME/" "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.6
793 if [ -e "$BUILD_OUTPUT"/boot/grub/$GRUB_LEGACY ]; then
794 sed -i "s/%GRUB_LEGACY%/$GRUB_LEGACY/g" "$BUILD_OUTPUT"/boot/grub/menu.lst
795 sed -i "s/%GRUB_LEGACY%/$GRUB_LEGACY/g" "$BUILD_OUTPUT"/boot/grub/grub.cfg
797 sed -i "/%GRUB_LEGACY%/d" "$BUILD_OUTPUT"/boot/grub/menu.lst
798 sed -i "/%GRUB_LEGACY%/d" "$BUILD_OUTPUT"/boot/grub/grub.cfg
801 # autostart for Windows:
802 if [ -d "${TEMPLATE_DIRECTORY}/windows/autostart/" ] ; then
803 cp ${TEMPLATE_DIRECTORY}/windows/autostart/* "$BUILD_OUTPUT"/
807 if [ -n "$NO_WINDOWS_BINARIES" ] ; then
808 log "Skipping download of windows binaries as requested via \$NO_WINDOWS_BINARIES."
809 einfo "Skipping download of windows binaries as requested via \$NO_WINDOWS_BINARIES."
812 if [ -f "$BUILD_OUTPUT"/windows/putty.exe ] ; then
813 log "Skipping stage 'WINDOWS_BINARIES' as $BUILD_OUTPUT/windows exists already."
814 ewarn "Skipping stage 'WINDOWS_BINARIES' as $BUILD_OUTPUT/windows exists already." ; eend 0
816 if ! [ -d "$BUILD_OUTPUT"/windows ] ; then
817 mkdir "$BUILD_OUTPUT"/windows
818 ( cd "$BUILD_OUTPUT"/windows
819 for file in pageant plink pscp psftp putty puttygen ; do
820 wget -O ${file}.exe ${WINDOWS_BINARIES}/${file}.exe
821 md5sum ${file}.exe > ${file}.exe.md5
825 log "Finished execution of stage 'WINDOWS_BINARIES' [$(date)]"
826 einfo "Finished execution of stage 'WINDOWS_BINARIES'" ; eend 0
830 FORCE_ISO_REBUILD=true
831 einfo "Finished execution of stage 'boot'" ; eend 0
834 log 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!'
835 eerror 'Error: Unsupported ARCH, sorry. Want to support it? Contribute!' ; eend 1
839 # support installation of local files into the chroot/ISO
840 if [ -n "$CHROOT_INSTALL" ] ; then
841 if ! [ -d "$CHROOT_INSTALL" ] ; then
842 log "Configuration variable \$CHROOT_INSTALL is set but not a directory; ignoring"
843 ewarn "Configuration variable \$CHROOT_INSTALL is set but not a directory; ignoring"
845 log "Copying local files to chroot as requested via \$CHROOT_INSTALL"
846 einfo "Copying local files to chroot as requested via \$CHROOT_INSTALL"
847 rsync -avz --inplace "$CHROOT_INSTALL"/ "$CHROOT_OUTPUT/"
849 einfo "Make sure to run squashfs stage, otherwise your local files won't be part of the ISO."
850 FORCE_ISO_REBUILD=true
854 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$BUILD_DIRTY" ] ; then
855 log "Skipping stage 'squashfs' as $BUILD_OUTPUT/live exists already."
856 ewarn "Skipping stage 'squashfs' as $BUILD_OUTPUT/live exists already." ; eend 0
857 elif [ -n "$SKIP_MKSQUASHFS" ] ; then
858 log "Skipping stage 'squashfs' as requested via option -q"
859 ewarn "Skipping stage 'squashfs' as requested via option -q" ; eend 0
861 [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
862 # make sure we don't leave (even an empty) base.tgz:
863 [ -f "$CHROOT_OUTPUT/base.tgz" ] && rm -f "$CHROOT_OUTPUT/base.tgz"
865 # $SQUASHFS_BINARY is specified in the configuration:
866 if [ -n "$SQUASHFS_BINARY" ] ; then
867 if ! which "$SQUASHFS_BINARY" >/dev/null 2>&1 ; then
868 log "Error: specified mksquashfs binary ($SQUASHFS_BINARY) not found. Exiting."
869 eerror "Error: specified mksquashfs binary ($SQUASHFS_BINARY) not found. Exiting." ; eend 1
872 else # no $SQUASHFS_BINARY configured, let's find the according binary:
873 # Note: this is ALL for backward compability and yes: it's serious PITA.
874 # We'll definitely drop this once people build >2.6.28-grml* only and
875 # the squashfs-tools vs. squashfs-lzma-tools + zlib vs. lzma situation
878 # assume the safe default if mksquashfs-lzma isn't present:
879 if ! which mksquashfs-lzma >/dev/null 2>&1 ; then
880 SQUASHFS_BINARY='mksquashfs'
881 else # mksquashfs-lzma is available since squashfs-lzma-tools 4.0:
882 # if the user wants to use zlib then don't use mksquashfs-lzma:
883 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-nolzma" || [ -n "$SQUASHFS_ZLIB" ] ; then
884 SQUASHFS_BINARY='mksquashfs'
885 else # neither -nolzma nor -z and mksquashfs-lzma is available:
886 SQUASHFS_BINARY='mksquashfs-lzma'
888 # backwards compability: someone has squashfs-lzma-tools >=4 installed but
889 # 1) doesn't use -nolzma in $SQUASHFS_OPTIONS or the grml-live's -z option *and*
890 # 2) builds against kernel version <=2.6.28-grml[64]
891 if ls $CHROOT_OUTPUT/boot/vmlinuz* >/dev/null 2>&1 ; then
892 KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
894 case $KERNEL_IMAGE in
895 *vmlinuz-2.6.28-grml*|*vmlinuz-2.6.26-grml*|*vmlinuz-2.6.23-grml*)
896 log "You seem to be building a system with squashfs file format 3 using squashfs-lzma-tools >=4."
897 ewarn "You seem to be building a system with squashfs file format 3 using squashfs-lzma-tools >=4."
898 ewarn "|-> Consider installing squashfs-lzma-tools 3.3-1 for support of file format version 3."
899 ewarn "|-> Trying the mksquashfs binary instead of mksquashfs-lzma (though this might fail)."
900 ewarn "\`-> Visit http://grml.org/grml-live/#current_state for further details if building fails."
902 SQUASHFS_BINARY='mksquashfs'
907 # if we still want to use mksquashfs-lzma then let's choose
908 # blocksize 256k as this gives best result with regards to time + comopression
909 [[ "$SQUASHFS_BINARY" == "mksquashfs-lzma" ]] && SQUASHFS_OPTIONS="-b 256k -lzma"
915 # make sure mksquashfs can handle the according option:
916 if [ -n "$SQUASHFS_ZLIB" ] ; then
917 $SQUASHFS_BINARY --help 2>&1 | grep -q -- "$SQUASHFS_ZLIB" || SQUASHFS_ZLIB=''
920 # make sure to drop the -nolzma option if it's not available:
921 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-nolzma" ; then
922 if ! $SQUASHFS_BINARY --help 2>&1 | grep -q -- '-nolzma' ; then
923 log "The $SQUASHFS_BINARY binary does NOT support the nolzma option, dropping it and using default mode."
924 ewarn "The $SQUASHFS_BINARY binary does NOT support the nolzma option, dropping it and using default mode."
925 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-nolzma//g')"
930 # make sure to drop the -lzma option if it's not available:
931 if echo "$SQUASHFS_OPTIONS" | grep -q -- "-lzma" ; then
932 if ! $SQUASHFS_BINARY --help 2>&1 | grep -q -- '-lzma' ; then
933 log "The $SQUASHFS_BINARY binary does NOT support the lzma option, dropping it and using default mode."
934 ewarn "The $SQUASHFS_BINARY binary does NOT support the lzma option, dropping it and using default mode."
935 SQUASHFS_OPTIONS="$(echo $SQUASHFS_OPTIONS | sed 's/-lzma//g')"
940 # support exclusion of files via exclude-file:
941 if [ -n "$SQUASHFS_EXCLUDES_FILE" -a "$SQUASHFS_EXCLUDES_FILE" ] ; then
942 SQUASHFS_OPTIONS="$SQUASHFS_OPTIONS -ef $SQUASHFS_EXCLUDES_FILE"
945 # get rid of unnecessary files when building grml-small for final release:
946 if echo "$CLASSES" | grep -q GRML_SMALL ; then
947 SQUASHFS_OPTIONS="$SQUASHFS_OPTIONS -e initrd.img* vmlinuz*"
950 # check whether we have the according binary available:
951 if ! which $SQUASHFS_BINARY >/dev/null 2>&1 ; then
952 log "Error: mksquashfs binary (${SQUASHFS_BINARY}) could not be found. Exiting."
953 eerror "Error: mksquashfs binary (${SQUASHFS_BINARY}) could not be found. Exiting."
954 eerror "|-> Make sure to install either squashfs-tools and/or squashfs-lzma-tools."
955 eerror "\`-> Visit http://grml.org/grml-live/#current_state for further details."
961 SQUASHFS_STDERR="$(mktemp -t grml-live.XXXXXX)"
963 [ -n "$SQUASHFS_OPTIONS" ] && SQUASHFS_INFO_MSG="$SQUASHFS_OPTIONS"
964 [ -n "$SQUASHFS_ZLIB" ] && SQUASHFS_INFO_MSG="$SQUASHFS_INFO_MSG $SQUASHFS_ZLIB"
965 [ -n "$SQUASHFS_INFO_MSG" ] && SQUASHFS_INFO_MSG="using options: $SQUASHFS_INFO_MSG"
966 einfo "Squashfs build information: running binary $SQUASHFS_BINARY $SQUASHFS_INFO_MSG"
968 log "$SQUASHFS_BINARY $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/${GRML_NAME}.squashfs -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB"
970 if $SQUASHFS_BINARY $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/"${GRML_NAME}".squashfs \
971 -noappend $SQUASHFS_OPTIONS $SQUASHFS_ZLIB 2>"${SQUASHFS_STDERR}" ; then
972 echo "${GRML_NAME}.squashfs" > $BUILD_OUTPUT/live/filesystem.module
973 log "Finished execution of stage 'squashfs' [$(date)]"
974 einfo "Finished execution of stage 'squashfs'" ; eend 0
976 log "Error: there was a critical error executing stage 'squashfs' [$(date)]:"
977 log "$(cat $SQUASHFS_STDERR)"
978 eerror "Error: there was a critical error executing stage 'squashfs':" ; eend 1
979 cat "${SQUASHFS_STDERR}"
983 FORCE_ISO_REBUILD=true
986 # create md5sum file:
987 ( cd $BUILD_OUTPUT/GRML &&
988 find .. -type f -not -name md5sums -not -name isolinux.bin -exec md5sum {} \; > md5sums )
991 # ISO_OUTPUT - mkisofs {{{
992 [ -n "$ISO_OUTPUT" ] || ISO_OUTPUT="$OUTPUT/grml_isos"
993 [ -n "$ISO_NAME" ] || ISO_NAME="${GRML_NAME}_${VERSION}.iso"
995 if [ "$BOOT_METHOD" = "isolinux" ] ; then
996 BOOT_FILE="boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat"
997 elif [ "$BOOT_METHOD" = "grub" ] ; then
998 BOOT_FILE="boot/grub/stage2"
1001 if [ -f "${ISO_OUTPUT}/${ISO_NAME}" -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$BUILD_DIRTY" -a "$FORCE_ISO_REBUILD" = "false" ] ; then
1002 log "Skipping stage 'iso build' as $ISO_OUTPUT/${ISO_NAME} exists already."
1003 ewarn "Skipping stage 'iso build' as $ISO_OUTPUT/${ISO_NAME} exists already." ; eend 0
1004 elif [ -n "$SKIP_MKISOFS" ] ; then
1005 log "Skipping stage 'iso build' as requested via option -n"
1006 ewarn "Skipping stage 'iso build' as requested via option -n" ; eend 0
1008 mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
1010 if $FORCE_ISO_REBUILD && ! [ -f "${ISO_OUTPUT}/${ISO_NAME}" ] ; then
1011 log "Forcing rebuild of ISO because files on ISO have been modified."
1012 einfo "Forcing rebuild of ISO because files on ISO have been modified."
1015 # support mkisofs as well as genisoimage
1016 if which mkisofs >/dev/null 2>&1; then
1018 elif which genisoimage >/dev/null 2>&1; then
1019 MKISOFS='genisoimage'
1021 log "Error: neither mkisofs nor genisoimage available - can not create ISO."
1022 eerror "Error: neither mkisofs nor genisoimage available - can not create ISO." ; eend 1
1027 if cd "$BUILD_OUTPUT" ; then
1028 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} ."
1029 "$MKISOFS" -V "${GRML_NAME} ${VERSION}" -publisher 'grml-live | grml.org' \
1030 -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
1031 -b $BOOT_FILE -no-pad \
1032 -o "${ISO_OUTPUT}/${ISO_NAME}" . ; RC=$?
1034 # pad the output ISO to multiples of 256 KiB for partition table support
1035 siz=$($getfilesize "${ISO_OUTPUT}/${ISO_NAME}")
1036 cyls=$((siz / 512 / 32 / 16 + 1)) # C=$cyls H=16 S=32
1037 siz=$((cyls * 16 * 32 * 512)) # size after padding
1038 dd if=/dev/zero bs=1 count=1 seek=$((siz - 1)) \
1039 of="${ISO_OUTPUT}/${ISO_NAME}" 2>/dev/null
1041 # support disabling hybrid ISO image
1042 if [ "$HYBRID_METHOD" = "disable" ] ; then\
1043 log "Skipping creation of hybrid ISO file as requested via HYBRID_METHOD=disable"
1044 einfo "Skipping creation of hybrid ISO file as requested via HYBRID_METHOD=disable"
1046 # use isohybrid only on request
1047 elif [ "$HYBRID_METHOD" = "isohybrid" ] ; then
1048 if ! which isohybrid >/dev/null 2>&1 ; then
1049 bailout 12 "isohybrid binary not found - please install syslinux/syslinux-common"
1051 log "Creating hybrid ISO file with isohybrid method"
1052 einfo "Creating hybrid ISO file with isohybrid method"
1053 isohybrid "${ISO_OUTPUT}/${ISO_NAME}"
1056 # by default use our manifold boot method:
1058 if ! [ -r boot/grub/core.img ] ; then
1059 ewarn "boot/grub/core.img not found, not creating manifold boot ISO file"
1061 log "Creating hybrid ISO file with manifold method"
1062 einfo "Creating hybrid ISO file with manifold method"
1064 # 512 bytes: MBR, partition table, load GRUB 2
1065 echo 4 63 | mksh /usr/share/grml-live/scripts/bootgrub.mksh -A -M 4:0x96 -g $cyls:16:32
1066 # pad to a whole of 2048 bytes (one CD sector)
1067 dd if=/dev/zero bs=512 count=3 2>/dev/null
1068 # append GRUB 2 (must be <=30720 bytes)
1069 cat boot/grub/core.img
1070 ) | dd of="${ISO_OUTPUT}/${ISO_NAME}" conv=notrunc 2>/dev/null
1075 # generate md5sum and sha1sum of ISO if we are using class 'RELEASE':
1076 case $CLASSES in *RELEASE*)
1079 if cd $ISO_OUTPUT ; then
1080 md5sum ${ISO_NAME} > ${ISO_NAME}.md5 && \
1081 touch -r ${ISO_NAME} ${ISO_NAME}.md5
1082 sha1sum ${ISO_NAME} > ${ISO_NAME}.sha1 && \
1083 touch -r ${ISO_NAME} ${ISO_NAME}.sha1
1092 if [ "$RC" = 0 ] ; then
1093 log "Finished execution of stage 'iso build' [$(date)]"
1094 einfo "Finished execution of stage 'iso build'" ; eend 0
1096 log "Error: there was a critical error ($RC) executing stage 'iso build' [$(date)]"
1097 eerror "Error: there was a critical error executing stage 'iso build'" ; eend 1
1104 [ -n "$start_seconds" ] && SECONDS="$[$(cut -d . -f 1 /proc/uptime)-$start_seconds]" || SECONDS="unknown"
1105 einfo "Successfully finished execution of $PN [$(date) - running ${SECONDS} seconds]" ; eend 0
1106 log "Successfully finished execution of $PN [$(date) - running ${SECONDS} seconds]"
1110 ## END OF FILE #################################################################
1111 # vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=3