export LANG=C
export LC_ALL=C
+# avoid leaking into chroots
+unset TMPDIR
+
# define function getfilesize before "set -e"
if stat --help >/dev/null 2>&1; then
getfilesize='stat -c %s' # GNU stat
-q skip mksquashfs
-Q skip netboot package build
-r <release_name> release name
- -s <suite> Debian suite; values: etch, lenny, squeeze, sid
+ -s <suite> Debian suite/release, like: stable, testing, unstable
-t <template_directory> place of the templates
-u update existing chroot instead of rebuilding it from scratch
-U <username> arrange output to be owned by specified username
$PN
$PN -c GRMLBASE,GRML_FULL,AMD64 -o /dev/shm/grml
$PN -c GRMLBASE,GRML_FULL,AMD64 -i grml_0.0-1.iso -v 0.0-1
- $PN -c GRMLBASE,GRML_FULL,AMD64 -s sid -V -r 'grml-live rocks'
+ $PN -c GRMLBASE,GRML_FULL,AMD64 -s stable -V -r 'grml-ftw'
More details: man grml-live + /usr/share/doc/grml-live/grml-live.html
http://grml.org/grml-live/
# source main configuration file:
LIVE_CONF=/etc/grml/grml-live.conf
-. $LIVE_CONF
+if ! [ -r "$LIVE_CONF" ] ; then
+ ewarn "Configuration file $LIVE_CONF can not be read, ignoring"
+else
+ einfo "Sourcing configuration file $LIVE_CONF"
+ . $LIVE_CONF
+ eend $?
+fi
# }}}
# umount all directories {{{
umount $CHROOT_OUTPUT/dev/pts 2>/dev/null || /bin/true
umount $CHROOT_OUTPUT/dev 2>/dev/null || /bin/true
+ if [ -n "$EXTRACT_ISO_NAME" ] ; then
+ umount "$EXTRACT_ISO_NAME" 2>/dev/null || /bin/true
+ fi
+
# certain FAI versions sadly leave a ramdisk behind, so better safe than sorry
if [ -x /usr/lib/fai/mkramdisk ] ; then
/usr/lib/fai/mkramdisk -u "$(readlink -f ${CHROOT_OUTPUT}/var/lib/dpkg)" >/dev/null 2>&1 || /bin/true
U) CHOWN_USER="$OPTARG" ;;
V) VERBOSE="-v" ;;
z) SQUASHFS_ZLIB=1 ;;
- ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
+ ?) echo "invalid option -$OPTARG" >&2; usage; bailout 1 ;;
esac
done
shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter
+
+if [ -n "$1" ] ; then
+ echo "Error: unknown argument '$1' in options. Exiting to avoid possible data loss." >&2
+ bailout 1
+fi
# }}}
# read local (non-packaged) configuration {{{
echo -n "Is this ok for you? [y/N] "
read a
if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
- bailout 1 "Exiting as requested."
+ CLEAN_ARTIFACTS=0
+ echo "Exiting as requested."
+ exit 0
fi
echo
fi
eend 1
bailout 1
fi
- unsquashfs -d "${CHROOT_OUTPUT}" "${mountpoint}"/live/*/*.squashfs ; rc=$?
+
+ if ls "${mountpoint}"/live/*/*.squashfs 2>/dev/null | grep -q . ; then # ISOs >=2011.12
+ log "Using ${mountpoint}/live/*/*.squashfs for unsquashfs"
+ unsquashfs -d "${CHROOT_OUTPUT}" "${mountpoint}"/live/*/*.squashfs ; rc=$?
+ elif ls "${mountpoint}"/live/*.squashfs 2>/dev/null | grep -q . ; then # ISOs before 2011.12
+ log "Using ${mountpoint}/live/*.squashfs for unsquashfs"
+ unsquashfs -d "${CHROOT_OUTPUT}" "${mountpoint}"/live/*.squashfs ; rc=$?
+ else
+ log "Error: Could not find any *.squashfs files on the ISO"
+ eerror "Error: Could not find any *.squashfs files on the ISO"
+ eend 1
+ bailout 1
+ fi
+
umount "$mountpoint"
rmdir "$mountpoint"
if [ "$rc" != 0 ]; then
# validate whether the specified architecture class matches the
# architecture (option), otherwise installation of kernel will fail
-if echo $CLASSES | grep -qi i386 ; then
+if echo $CLASSES | grep -qw I386 ; then
if ! [[ "$ARCH" == "i386" ]] ; then
log "Error: You specified the I386 class but are trying to build something else (AMD64?)."
eerror "Error: You specified the I386 class but are trying to build something else (AMD64?)."
# generate nfsroot configuration for FAI on the fly
if [ -z "$FAI_DEBOOTSTRAP" ] ; then
- FAI_DEBOOTSTRAP="$SUITE http://cdn.debian.net/debian"
+ FAI_DEBOOTSTRAP="$SUITE http://http.debian.net/debian"
fi
if [ -z "$FAI_DEBOOTSTRAP_OPTS" ] ; then
-u "$HOSTNAME" "$FAI_ACTION" "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
RC="$PIPESTATUS" # notice: bash-only
+ if [ "$RC" != 0 ] ; then
+ log "Error: critical error while executing fai [exit code ${RC}]. Exiting."
+ eerror "Error: critical error while executing fai [exit code ${RC}]. Exiting." ; eend 1
+ bailout 1
+ fi
+
# provide inform fai about the ISO we build, needs to be provided
# *after* FAI stage, otherwise FAI skips the debootstrap stage if
# there is not BASEFILE (as it checks for presence of /etc) :(
FORCE_ISO_REBUILD=true
- if [ "$RC" != 0 ] ; then
- log "Error: critical error while executing fai [exit code ${RC}]. Exiting."
- eerror "Error: critical error while executing fai [exit code ${RC}]. Exiting." ; eend 1
- bailout 1
- fi
-
# move fai logs into grml_logs directory
mkdir -p "$LOG_OUTPUT"/fai/
cp -r "$CHROOT_OUTPUT"/var/log/fai/"$HOSTNAME"/last/* "$LOG_OUTPUT"/fai/
echo "source /boot/grub/footer.cfg" >> "${BUILD_OUTPUT}"/boot/grub/loopback.cfg
# copy grub files from target
- cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.mod "${BUILD_OUTPUT}"/boot/grub/
- cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.o "${BUILD_OUTPUT}"/boot/grub/
- cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.lst "${BUILD_OUTPUT}"/boot/grub/
+ mkdir -p "${BUILD_OUTPUT}"/boot/grub/i386-pc/
+ cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.mod "${BUILD_OUTPUT}"/boot/grub/i386-pc/
+ cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.o "${BUILD_OUTPUT}"/boot/grub/i386-pc/
+ cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/*-pc/*.lst "${BUILD_OUTPUT}"/boot/grub/i386-pc/
cp -a "${CHROOT_OUTPUT}"/usr/share/grub/ascii.pf2 "${BUILD_OUTPUT}"/boot/grub/
cp -a "${CHROOT_OUTPUT}"/boot/grub/core.img "${BUILD_OUTPUT}"/boot/grub/
cp -a "${CHROOT_OUTPUT}"/boot/grub/grub.img "${BUILD_OUTPUT}"/boot/grub/
+ # copy modules for UEFI grub
+ mkdir -p "${BUILD_OUTPUT}"/boot/grub/x86_64-efi/
+ cp -a "${CHROOT_OUTPUT}"/usr/lib/grub/x86_64-efi/*.{mod,lst} "${BUILD_OUTPUT}"/boot/grub/x86_64-efi/
+
if ! [ -d "${TEMPLATE_DIRECTORY}"/GRML ] ; then
log "Error: ${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting."
eerror "Error: ${TEMPLATE_DIRECTORY}/GRML does not exist. Exiting." ; eend 1
# create md5sum file:
if [ -z "$BOOTSTRAP_ONLY" ] ; then
( cd $BUILD_OUTPUT/GRML/"${GRML_NAME}" &&
- find .. -type f -not -name md5sums -not -name isolinux.bin -exec md5sum {} \; > md5sums )
+ find ../.. -type f -not -name md5sums -not -name isolinux.bin -exec md5sum {} \; > md5sums )
fi
# }}}
# (hidden NTFS, IIRC), as the partition type is sometimes needed
# to get the BIOS even look at the partition created by isohybrid
if isohybrid --help | grep -q -- --uefi ; then
- log "Detected uefi support for isohybrid, enabling"
- einfo "Detected uefi support for isohybrid, enabling"
- ISOHYBRID_OPTIONS=--uefi
+ if echo $CLASSES | grep -qw I386 ; then
+ log "Detected uefi support for isohybrid but 32bit systems do not support it, ignoring."
+ einfo "Detected uefi support for isohybrid but 32bit systems do not support it, ignoring."
+ else
+ log "Detected uefi support for isohybrid, enabling"
+ einfo "Detected uefi support for isohybrid, enabling"
+ ISOHYBRID_OPTIONS=--uefi
+ fi
fi
log "isohybrid $ISOHYBRID_OPTIONS ${ISO_OUTPUT}/${ISO_NAME}"
mkdir -p "$NETBOOT"
- if ! [ -r "${CHROOT}/usr/lib/syslinux/pxelinux.0" ] ; then
+ if ! [ -r "${CHROOT_OUTPUT}/usr/lib/syslinux/pxelinux.0" ] ; then
ewarn "File /usr/lib/syslinux/pxelinux.0 not found in build chroot." ; eend 0
eindent
einfo "Install syslinux[-common] package in chroot to get a netboot package."