about summary refs log tree commit diff
path: root/mklive.sh.in
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-10-09 15:24:32 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-10-09 15:43:55 +0200
commit44722b79e2f31c0c51bd2fc8c8d43c0009d79529 (patch)
tree5fc9fce8937199de06e2c22ad781e59fa654dfd2 /mklive.sh.in
parenta25ced5c198fff963ba7b7e9b613059e756374c0 (diff)
parentcb2510b3791091fb54681cee451eb7ec24e0b266 (diff)
downloadhrmpf-44722b79e2f31c0c51bd2fc8c8d43c0009d79529.tar.gz
hrmpf-44722b79e2f31c0c51bd2fc8c8d43c0009d79529.tar.xz
hrmpf-44722b79e2f31c0c51bd2fc8c8d43c0009d79529.zip
Merge remote-tracking branch 'origin/master'
* origin/master: (136 commits)
  dracut/services: don't autostart dmeventd, lvmetad and mdadm.
  mklive: fix guessing linux kernel pkgname.
  fix set_keymap rc.conf
  installer.sh: fix static IP settings in menu_install
  build-arm-images: PLATFORM can be overrided now.
  build-rootfs: build musl rootfs too; PLATFORMS can be overrided now.
  build-x86-images: added lxqt image.
  dracut/dm-autologin: autostart lxqt if available.
  mkrootfs: add dockstar support
  mklive: install GRUB EFI loader as EFI/BOOT/BOOTX64.EFI.
  build-x86-images: add gnome-keyring to cinnamon/mate/xfce images.
  build-x86-images: add firefox now it's available for musl.
  build-arm-images: respect musl targets.
  mkimage: consistently redirect std{err,out} to /dev/null with dd(1).
  build-arm-images: disable cubietruck for now; does not boot.
  build-arm-images: build all ARM images for glibc and musl.
  mkrootfs: get rid of pixz; fix rpi target arch.
  mkrootfs: set cachedir to $PWD/xbps-cachedir-<arch>; misc tweaks for musl.
  mkrootfs: update for musl support.
  build-x86-images: do not build the kde image; does not work yet.
  ...
Diffstat (limited to 'mklive.sh.in')
-rw-r--r--mklive.sh.in235
1 files changed, 122 insertions, 113 deletions
diff --git a/mklive.sh.in b/mklive.sh.in
index d794dfc..86b7f9d 100644
--- a/mklive.sh.in
+++ b/mklive.sh.in
@@ -1,9 +1,9 @@
-#!/bin/bash
+#!/bin/sh
 #
 # vim: set ts=4 sw=4 et:
 #
 #-
-# Copyright (c) 2009-2014 Juan Romero Pardines.
+# Copyright (c) 2009-2015 Juan Romero Pardines.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -26,27 +26,39 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #-
-set -E
-trap "echo; error_out $LINENO $?" INT TERM HUP ERR
+trap "error_out $LINENO $?" INT TERM 0
 
-readonly REQUIRED_PKGS="base-files syslinux grub-x86_64-efi squashfs-tools xorriso memtest86+"
+readonly REQUIRED_PKGS="base-files libgcc dash coreutils sed tar gawk syslinux grub-x86_64-efi squashfs-tools xorriso memtest86+"
+readonly INITRAMFS_PKGS="binutils xz device-mapper"
 readonly PROGNAME=$(basename $0)
 
 info_msg() {
     printf "\033[1m$@\n\033[m"
 }
-
+die() {
+    info_msg "ERROR: $@"
+    error_out 1
+}
+mount_pseudofs() {
+    for f in sys dev proc; do
+        mkdir -p $ROOTFS/$f
+        mount --bind /$f $ROOTFS/$f
+    done
+}
+umount_pseudofs() {
+    umount -f $ROOTFS/sys >/dev/null 2>&1
+    umount -f $ROOTFS/dev >/dev/null 2>&1
+    umount -f $ROOTFS/proc >/dev/null 2>&1
+}
 error_out() {
-    info_msg "There was an error in line $1 ... cleaning up $BUILDDIR, exiting."
-
-    [ -d "$BUILDDIR" ] && rm -rf "$BUILDDIR"
-
-    exit 1
+    umount_pseudofs
+    [ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR"
+    exit ${1:=0}
 }
 
 usage() {
     cat <<_EOF
-Usage: $(basename $0) [options]
+Usage: $PROGNAME [options]
 
 Options:
  -a <xbps-arch>     Set XBPS_ARCH (do not use it unless you know what it is)
@@ -63,8 +75,9 @@ Options:
 
  -C "cmdline args"  Add additional kernel command line arguments.
  -T "title"         Modify the bootloader title.
+ -K                 Do not remove builddir.
 
-The $(basename $0) script generates a live image of the Void Linux distribution.
+The $PROGNAME script generates a live image of the Void Linux distribution.
 This ISO image can be written to a CD/DVD-ROM or any USB stick.
 _EOF
     exit 1
@@ -74,40 +87,44 @@ copy_void_keys() {
     mkdir -p "$1"/var/db/xbps/keys
     cp keys/*.plist "$1"/var/db/xbps/keys
 }
+
 copy_void_conf() {
-    install -Dm644 data/void-vpkgs.conf "$1"/etc/xbps/virtualpkg.d/void.conf
+    install -Dm644 data/void-vpkgs.conf "$1"/usr/share/xbps.d/void-virtualpkgs.conf
+}
+
+copy_dracut_files() {
+    mkdir -p $1/usr/lib/dracut/modules.d/01vmklive
+    cp dracut/* $1/usr/lib/dracut/modules.d/01vmklive/
 }
 
 install_prereqs() {
     copy_void_conf $VOIDHOSTDIR
-    $XBPS_INSTALL_CMD -r $VOIDHOSTDIR $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${REQUIRED_PKGS} >> $LOGFILE 2>&1
-    if [ $? -ne 0 ]; then
-        info_msg "Failed to install required software, exiting..."
-        error_out
-    fi
+    $XBPS_INSTALL_CMD -r $VOIDHOSTDIR $XBPS_REPOSITORY \
+        $XBPS_HOST_CACHEDIR -y ${REQUIRED_PKGS}
+    [ $? -ne 0 ] && die "Failed to install required software, exiting..."
 }
 
 install_packages() {
-    if [ -n "$BASE_ARCH" ]; then
-        export XBPS_ARCH="$BASE_ARCH"
-    fi
     copy_void_conf $ROOTFS
-    # Check that all pkgs are reachable.
-    ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -yn ${PACKAGE_LIST} >>$LOGFILE 2>&1
-    if [ $? -ne 0 ]; then
-        info_msg "Missing required binary packages, exiting..."
-        error_out
-    fi
 
-    ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} >>$LOGFILE 2>&1
-    ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR  -yu >>$LOGFILE 2>&1
-    ${XBPS_REMOVE_CMD} -r $ROOTFS $XBPS_CACHEDIR -o >>$LOGFILE 2>&1
+    XBPS_ARCH=$BASE_ARCH ${XBPS_INSTALL_CMD} -r $ROOTFS \
+        $XBPS_REPOSITORY $XBPS_CACHEDIR -yn ${PACKAGE_LIST} ${INITRAMFS_PKGS}
+    [ $? -ne 0 ] && die "Missing required binary packages, exiting..."
+
+    mount_pseudofs
+
+    LANG=C XBPS_ARCH=$BASE_ARCH ${XBPS_INSTALL_CMD} -U -r $ROOTFS \
+        $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} ${INITRAMFS_PKGS}
+    [ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST"
+
+    xbps-reconfigure -r $ROOTFS -f base-files >/dev/null 2>&1
+    chroot $ROOTFS env -i xbps-reconfigure -f base-files
 
     # Enable choosen UTF-8 locale and generate it into the target rootfs.
     if [ -f $ROOTFS/etc/default/libc-locales ]; then
         sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i $ROOTFS/etc/default/libc-locales
-        xbps-uchroot $ROOTFS xbps-reconfigure -f glibc-locales >>$LOGFILE 2>&1
     fi
+    chroot $ROOTFS env -i xbps-reconfigure -a
 
     if [ -x installer.sh ]; then
         install -Dm755 installer.sh $ROOTFS/usr/sbin/void-installer
@@ -116,33 +133,36 @@ install_packages() {
     fi
     # Cleanup and remove useless stuff.
     rm -rf $ROOTFS/var/cache/* $ROOTFS/run/* $ROOTFS/var/run/*
-
-    unset XBPS_ARCH
-}
-
-copy_dracut_files() {
-    mkdir -p $1/usr/lib/dracut/modules.d/01vmklive
-    cp dracut/*.sh $1/usr/lib/dracut/modules.d/01vmklive/
 }
 
 generate_initramfs() {
-    # Install required pkgs in a temporary rootdir to create
-    # the initramfs and to copy required files.
-    copy_dracut_files $VOIDHOSTDIR
-    copy_void_conf $VOIDHOSTDIR
-    $XBPS_INSTALL_CMD -r $VOIDHOSTDIR $XBPS_REPOSITORY $XBPS_CACHEDIR -y base-system xz lz4 >>$LOGFILE 2>&1
+    local _args
 
+    copy_dracut_files $ROOTFS
     if [ "$BASE_SYSTEM_PKG" = "base-system-systemd" ]; then
         _args="--add systemd"
     else
         _args="--omit systemd"
     fi
-    xbps-uchroot $VOIDHOSTDIR /usr/bin/dracut --${INITRAMFS_COMPRESSION} \
-        --force-add "vmklive" ${_args} "/boot/initrd" $KERNELVERSION >>$LOGFILE 2>&1
+    chroot $ROOTFS env -i /usr/bin/dracut -N --${INITRAMFS_COMPRESSION} \
+        --add-drivers "ahci" --force-add "vmklive" ${_args} "/boot/initrd" $KERNELVERSION
+    [ $? -ne 0 ] && die "Failed to generate the initramfs"
 
-    mv $VOIDHOSTDIR/boot/initrd $BOOT_DIR
-    cp $VOIDHOSTDIR/boot/vmlinuz-$KERNELVERSION $BOOT_DIR/vmlinuz
-    cp $VOIDHOSTDIR/boot/memtest86+ $BOOT_DIR
+    mv $ROOTFS/boot/initrd $BOOT_DIR
+    cp $ROOTFS/boot/vmlinuz-$KERNELVERSION $BOOT_DIR/vmlinuz
+    cp $ROOTFS/boot/memtest86+ $BOOT_DIR
+}
+
+cleanup_rootfs() {
+    for f in ${INITRAMFS_PKGS}; do
+        revdeps=$(xbps-query -r $ROOTFS -X $f)
+        if [ -n "$revdeps" ]; then
+            xbps-pkgdb -r $ROOTFS -m auto $f
+        else
+            xbps-remove -r $ROOTFS -Ry ${f} >/dev/null 2>&1
+        fi
+    done
+    rm -r $ROOTFS/usr/lib/dracut/modules.d/01vmklive
 }
 
 generate_isolinux_boot() {
@@ -158,7 +178,7 @@ generate_isolinux_boot() {
     sed -i  -e "s|@@SPLASHIMAGE@@|$(basename ${SPLASH_IMAGE})|" \
         -e "s|@@KERNVER@@|${KERNELVERSION}|" \
         -e "s|@@KEYMAP@@|${KEYMAP}|" \
-        -e "s|@@ARCH@@|$(uname -m)|" \
+        -e "s|@@ARCH@@|$BASE_ARCH|" \
         -e "s|@@LOCALE@@|${LOCALE}|" \
         -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
         -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
@@ -171,34 +191,44 @@ generate_grub_efi_boot() {
     sed -i  -e "s|@@SPLASHIMAGE@@|$(basename ${SPLASH_IMAGE})|" \
         -e "s|@@KERNVER@@|${KERNELVERSION}|" \
         -e "s|@@KEYMAP@@|${KEYMAP}|" \
-        -e "s|@@ARCH@@|$(uname -m)|" \
+        -e "s|@@ARCH@@|$BASE_ARCH|" \
         -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
         -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
         -e "s|@@LOCALE@@|${LOCALE}|" $GRUB_DIR/grub_void.cfg
+    mkdir -p $GRUB_DIR/fonts
+    cp -f $GRUB_DATADIR/unicode.pf2 $GRUB_DIR/fonts
 
-    modprobe -q loop
+    modprobe -q loop || :
 
     # Create EFI vfat image.
-    dd if=/dev/zero of=$GRUB_DIR/efiboot.img bs=1024 count=4096  >>$LOGFILE 2>&1
-    mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >>$LOGFILE 2>&1
+    dd if=/dev/zero of=$GRUB_DIR/efiboot.img bs=1024 count=4096  >/dev/null 2>&1
+    mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >/dev/null 2>&1
 
     GRUB_EFI_TMPDIR="$(mktemp --tmpdir=$HOME -d)"
     LOOP_DEVICE="$(losetup --show --find ${GRUB_DIR}/efiboot.img)"
-    mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >>$LOGFILE 2>&1
+    mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1
 
     cp -a $IMAGEDIR/boot $VOIDHOSTDIR
-    xbps-uchroot $VOIDHOSTDIR grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi" \
+    xbps-uchroot $VOIDHOSTDIR grub-mkstandalone -- \
+        --directory="/usr/lib/grub/x86_64-efi" \
         --format="x86_64-efi" \
         --compression="xz" --output="/tmp/bootx64.efi" \
-        "boot/grub/grub.cfg" >>$LOGFILE 2>&1
-    mkdir -p ${GRUB_EFI_TMPDIR}/EFI/boot
-    cp -f $VOIDHOSTDIR/tmp/bootx64.efi ${GRUB_EFI_TMPDIR}/EFI/boot/
+        "boot/grub/grub.cfg"
+    if [ $? -ne 0 ]; then
+        umount "$GRUB_EFI_TMPDIR"
+        losetup --detach "${LOOP_DEVICE}"
+        die "Failed to generate EFI loader"
+    fi
+    mkdir -p ${GRUB_EFI_TMPDIR}/EFI/BOOT
+    cp -f $VOIDHOSTDIR/tmp/bootx64.efi ${GRUB_EFI_TMPDIR}/EFI/BOOT/BOOTX64.EFI
     umount "$GRUB_EFI_TMPDIR"
     losetup --detach "${LOOP_DEVICE}"
     rm -rf $GRUB_EFI_TMPDIR
 }
 
 generate_squashfs() {
+    umount_pseudofs
+
     # Find out required size for the rootfs and create an ext3fs image off it.
     ROOTFS_SIZE=$(du -sm "$ROOTFS"|awk '{print $1}')
     if [ -z "$ROOTFS_FREESIZE" ]; then
@@ -206,23 +236,24 @@ generate_squashfs() {
     fi
     mkdir -p "$BUILDDIR/tmp/LiveOS"
     dd if=/dev/zero of="$BUILDDIR/tmp/LiveOS/ext3fs.img" \
-        bs="$((ROOTFS_SIZE+ROOTFS_FREESIZE))M" count=1 >>$LOGFILE 2>&1
+        bs="$((ROOTFS_SIZE+ROOTFS_FREESIZE))M" count=1 >/dev/null 2>&1
     mkdir -p "$BUILDDIR/tmp-rootfs"
-    mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" >>$LOGFILE 2>&1
+    mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" >/dev/null 2>&1
     mount -o loop "$BUILDDIR/tmp/LiveOS/ext3fs.img" "$BUILDDIR/tmp-rootfs"
     cp -a $ROOTFS/* $BUILDDIR/tmp-rootfs/
     umount -f "$BUILDDIR/tmp-rootfs"
     mkdir -p "$IMAGEDIR/LiveOS"
 
-    mksquashfs "$BUILDDIR/tmp" "$IMAGEDIR/LiveOS/squashfs.img" \
-        -comp ${SQUASHFS_COMPRESSION} >>$LOGFILE 2>&1
+    $VOIDHOSTDIR/usr/bin/mksquashfs "$BUILDDIR/tmp" "$IMAGEDIR/LiveOS/squashfs.img" \
+        -comp ${SQUASHFS_COMPRESSION} || die "Failed to generate squashfs image"
     chmod 444 "$IMAGEDIR/LiveOS/squashfs.img"
+
     # Remove rootfs and temporary dirs, we don't need them anymore.
     rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp"
 }
 
 generate_iso_image() {
-    xorriso -as mkisofs \
+    $VOIDHOSTDIR/usr/bin/xorriso -as mkisofs \
         -iso-level 3 -rock -joliet \
         -max-iso9660-filenames -omit-period \
         -omit-version-number -relaxed-filenames -allow-lowercase \
@@ -232,18 +263,20 @@ generate_iso_image() {
         -no-emul-boot -boot-load-size 4 -boot-info-table \
         -eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \
         -isohybrid-mbr $SYSLINUX_DATADIR/isohdpfx.bin \
-        -output "$CURDIR/$OUTPUT_FILE" "$IMAGEDIR" >>$LOGFILE 2>&1
+        -output "$CURDIR/$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image"
 }
 
+XBPS_REPOSITORY=
 #
 # main()
 #
-while getopts "a:b:r:c:C:T:k:l:i:s:S:o:p:h" opt; do
+while getopts "a:b:r:c:C:T:Kk:l:i:s:S:o:p:h" opt; do
     case $opt in
         a) BASE_ARCH="$OPTARG";;
         b) BASE_SYSTEM_PKG="$OPTARG";;
-        r) XBPS_REPOSITORY+="--repository=$OPTARG ";;
+        r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG ";;
         c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
+        K) readonly KEEP_BUILDDIR=1;;
         k) KEYMAP="$OPTARG";;
         l) LOCALE="$OPTARG";;
         i) INITRAMFS_COMPRESSION="$OPTARG";;
@@ -256,10 +289,14 @@ while getopts "a:b:r:c:C:T:k:l:i:s:S:o:p:h" opt; do
         h) usage;;
     esac
 done
-shift $(($OPTIND - 1))
+shift $((OPTIND - 1))
+
+ARCH=$(uname -m)
 
 # Set defaults
-: ${XBPS_CACHEDIR:=--cachedir=/var/cache/xbps}
+: ${BASE_ARCH:=$(uname -m)}
+: ${XBPS_CACHEDIR:=-c $(pwd -P)/xbps-cachedir-${BASE_ARCH}}
+: ${XBPS_HOST_CACHEDIR:=-c $(pwd -P)/xbps-cachedir-${ARCH}}
 : ${KEYMAP:=us}
 : ${LOCALE:=en_US.UTF-8}
 : ${INITRAMFS_COMPRESSION:=xz}
@@ -270,12 +307,9 @@ shift $(($OPTIND - 1))
 # Required packages in the image for a working system.
 PACKAGE_LIST="$BASE_SYSTEM_PKG $PACKAGE_LIST"
 
-LOGFILE="$(mktemp -t vmklive-XXXXXXXXXX.log)"
-
 # Check for root permissions.
 if [ "$(id -u)" -ne 0 ]; then
-    echo "Must be run as root, exiting..."
-    exit 1
+    die "Must be run as root, exiting..."
 fi
 
 readonly CURDIR="$PWD"
@@ -295,8 +329,9 @@ ISOLINUX_DIR="$BOOT_DIR/isolinux"
 GRUB_DIR="$BOOT_DIR/grub"
 ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg"
 
-: ${XBPS_REPOSITORY:=--repository=http://repo.voidlinux.eu/current}
+: ${XBPS_REPOSITORY:=--repository=http://repo.voidlinux.eu/current --repository=http://muslrepo.voidlinux.eu/current}
 : ${SYSLINUX_DATADIR:=$VOIDHOSTDIR/usr/share/syslinux}
+: ${GRUB_DATADIR:=$VOIDHOSTDIR/usr/share/grub}
 : ${SPLASH_IMAGE:=data/splash.png}
 : ${XBPS_INSTALL_CMD:=xbps-install}
 : ${XBPS_REMOVE_CMD:=xbps-remove}
@@ -307,28 +342,21 @@ ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg"
 
 mkdir -p $ROOTFS $VOIDHOSTDIR $ISOLINUX_DIR $GRUB_DIR
 
-info_msg "Redirecting stdout/stderr to $LOGFILE ..."
-info_msg "[1/9] Synchronizing XBPS repository data..."
-# Sync index for remote repos first.
+info_msg "[1/8] Synchronizing XBPS repository data..."
 copy_void_keys $ROOTFS
-$XBPS_INSTALL_CMD -r $ROOTFS ${XBPS_REPOSITORY} -S
-cp -a $ROOTFS/* $VOIDHOSTDIR
+copy_void_keys $VOIDHOSTDIR
+XBPS_ARCH=$BASE_ARCH $XBPS_INSTALL_CMD -r $ROOTFS ${XBPS_REPOSITORY} -S
+$XBPS_INSTALL_CMD -r $VOIDHOSTDIR $XBPS_REPOSITORY -S
 
-_linux_series=$($XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -x linux)
-KERNELVERSION=$($XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -p pkgver ${_linux_series})
-KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion $KERNELVERSION)
+_linux_series=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -x linux|head -1)
+_kver=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -p pkgver ${_linux_series})
+KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion ${_kver})
 
-: ${OUTPUT_FILE="hrmpf-$(uname -m)-${KERNELVERSION}-$(date +%Y%m%d).iso"}
+: ${OUTPUT_FILE="hrmpf-${BASE_ARCH}-${KERNELVERSION}-$(date +%Y%m%d).iso"}
 
-#
-# Install required packages to generate the image.
-#
 info_msg "[2/9] Installing software to generate the image: ${REQUIRED_PKGS} ..."
 install_prereqs
 
-#
-# Install live system and specified packages.
-#
 mkdir -p "$ROOTFS"/etc
 [ -s data/motd ] && cp data/motd $ROOTFS/etc
 [ -s data/issue ] && cp data/issue $ROOTFS/etc
@@ -336,42 +364,23 @@ mkdir -p "$ROOTFS"/etc
 info_msg "[3/9] Installing void pkgs into the rootfs: ${PACKAGE_LIST} ..."
 install_packages
 
-export PATH=$VOIDHOSTDIR/usr/bin:$VOIDHOSTDIR/usr/sbin:$PATH
-export LD_LIBRARY_PATH=$VOIDHOSTDIR/usr/lib
-#
-# Generate the initramfs.
-#
 info_msg "[4/9] Generating initramfs image ($INITRAMFS_COMPRESSION)..."
 generate_initramfs
 
-#
-# Generate the isolinux boot.
-#
 info_msg "[5/9] Generating isolinux support for PC-BIOS systems..."
 generate_isolinux_boot
 
-#
-# Generate the GRUB EFI boot.
-#
 info_msg "[6/9] Generating GRUB support for EFI systems..."
 generate_grub_efi_boot
 
-#
-# Generate the squashfs image from rootfs.
-#
-info_msg "[7/9] Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..."
+info_msg "[7/9] Cleaning up rootfs..."
+cleanup_rootfs
+
+info_msg "[8/9] Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..."
 generate_squashfs
 
-#
-# Generate the ISO image.
-#
-info_msg "[8/9] Generating ISO image..."
+info_msg "[9/9] Generating ISO image..."
 generate_iso_image
 
-info_msg "[9/9] Removing build directory..."
-rm -rf "$BUILDDIR"
-
 hsize=$(du -sh "$CURDIR/$OUTPUT_FILE"|awk '{print $1}')
 info_msg "Created $(readlink -f $CURDIR/$OUTPUT_FILE) ($hsize) successfully."
-
-exit 0