diff --git a/COPYING b/COPYING index f7117fd..426f41f 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ Simplified BSD: -# Copyright (c) 2009-2012 Juan Romero Pardines. +# Copyright (c) 2009-2013 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/Makefile b/Makefile index 2fc0b19..6f07ff0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ GITVER := $(shell git rev-parse HEAD) -VERSION = 0.10 +VERSION = 0.11 PREFIX ?= /usr/local SBINDIR ?= $(PREFIX)/sbin SHAREDIR ?= $(PREFIX)/share diff --git a/README b/README index e04a0cd..55c5445 100644 --- a/README +++ b/README @@ -9,12 +9,13 @@ ISOLINUX is used to boot from PC-BIOS systems, while GRUB is used to boot in EFI systems. Dependencies: - - xbps>=0.18 + + - xbps>=0.21 + - GNU bash - syslinux (to generate the PC-BIOS bootloader) - dosfstools (to generate the EFI bootloader) - xorriso (to generate the ISO image) - squashfs-tools (to generate the squashed rootfs) - - linux-user-chroot (to chroot and bind mount pseudofs) Usage: void-mklive [options] diff --git a/dracut/adduser.sh b/dracut/adduser.sh index e242529..f3aa323 100644 --- a/dracut/adduser.sh +++ b/dracut/adduser.sh @@ -20,6 +20,10 @@ if [ -f ${NEWROOT}/etc/sudoers ]; then echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${NEWROOT}/etc/sudoers fi +chroot ${NEWROOT} systemctl disable graphical.target +chroot ${NEWROOT} systemctl enable multi-user.target +touch ${NEWROOT}/etc/sysctl.conf + # Enable autologin for agetty(8). if [ -f ${NEWROOT}/usr/lib/systemd/system/getty@.service ]; then rm -f "${NEWROOT}/etc/systemd/system/getty.target.wants/getty@tty1.service" diff --git a/grub/grub_void.cfg.in b/grub/grub_void.cfg.in index 8a31263..69b1fad 100644 --- a/grub/grub_void.cfg.in +++ b/grub/grub_void.cfg.in @@ -28,7 +28,7 @@ if [ cpuid -l ]; then menuentry "Void GNU/Linux @@KERNVER@@ (@@ARCH@@)" { set gfxpayload="keep" linux (${voidlive})/boot/vmlinuz \ - root=live:CDLABEL=VOID_LIVE ro rootfstype=auto liveimg \ + root=live:CDLABEL=VOID_LIVE ro rootfstype=auto \ rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \ vconsole.keymap=@@KEYMAP@@ vconsole.unicode=1 locale.LANG=@@LOCALE@@ initrd (${voidlive})/boot/initrd.lz diff --git a/isolinux/isolinux.cfg.in b/isolinux/isolinux.cfg.in index 68bbaaa..a4d8ce9 100644 --- a/isolinux/isolinux.cfg.in +++ b/isolinux/isolinux.cfg.in @@ -23,7 +23,7 @@ MENU COLOR sel * #ffffffff #FF5255FF * LABEL linux MENU LABEL Boot Void GNU/Linux @@KERNVER@@ @@ARCH@@ KERNEL /boot/vmlinuz -APPEND initrd=/boot/initrd.lz root=live:CDLABEL=VOID_LIVE rootfstype=auto ro rd.liveimg rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.keymap=@@KEYMAP@@ vconsole.unicode=1 locale.LANG=@@LOCALE@@ +APPEND initrd=/boot/initrd.lz root=live:CDLABEL=VOID_LIVE rootfstype=auto ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.keymap=@@KEYMAP@@ vconsole.unicode=1 locale.LANG=@@LOCALE@@ LABEL c MENU LABEL Boot first HD found by BIOS LOCALBOOT 0x80 diff --git a/mklive.sh.in b/mklive.sh.in index 6df2f36..e3c78c7 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash #- -# Copyright (c) 2009-2012 Juan Romero Pardines. +# Copyright (c) 2009-2013 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -23,42 +23,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. #- -trap "echo; error_out $?" INT QUIT - -CHROOT_CMD="linux-user-chroot --unshare-ipc --unshare-pid --unshare-net \ ---mount-bind /dev /dev --mount-bind /sys /sys --mount-proc /proc" +set -E +trap "echo; error_out $LINENO $?" INT TERM HUP ERR info_msg() { printf "\033[1m$@\n\033[m" } error_out() { - info_msg "There was an error! cleaning up $BUILDDIR, exiting..." + info_msg "There was an error in line $1 ... cleaning up $BUILDDIR, exiting." + + umount_kernel_fs [ -d "$BUILDDIR" ] && rm -rf "$BUILDDIR" - #[ -f "$LOGFILE" ] && rm -f "$LOGFILE" exit 1 } +umount_kernel_fs() { + for f in sys/fs/cgroup/systemd sys/fs/cgroup dev/shm dev/pts dev proc sys run; do + umount -f $ROOTFS/kernel_temp/$f &>/dev/null + done +} + write_etc_motd() { cat >> "$ROOTFS/etc/motd" <<_EOF ############################################################################### -Autogenerated by void-mklive "0.10 3d7b51707195b6e765b4d1d59d70266ebe87ce1e" +Autogenerated by void-mklive "@@MKLIVE_VERSION@@" ------------------------------------------------------------------------------- Welcome to the Void Linux Live system, you have been autologged in. This user has full sudo(8) permissions without any password, be careful executing commands through sudo(8). -To play with package management use the xbps-* utilities. Please visit: - -http://code.google.com/p/xbps/ - -for more information and/or documentation about using the X Binary -Package System. If you think it is useful, please make a donation -to improve further development from the above URL, thanks. - To start the installation please type: $ sudo void-installer @@ -109,14 +106,14 @@ usage() Usage: $(basename $0) [options] Options: - -C file Path to configuration file (defaults to ~/.mklive.conf) - -c (gzip|bzip2|xz) ompression type for the squashfs/initramfs image. - -l "pkgname ..." Generate a local repository in the image with these packages. + -C file Path to configuration file (defaults to ~/.mklive.conf) + -c (gzip|bzip2|xz) Compression type for the squashfs/initramfs image. + -l "pkgname ..." Generate a local repository in the image with these packages. Packages must be delimited by blanks. - -r rootdir Use this directory to generate the image (if unset, + -r rootdir Use this directory to generate the image (if unset, current working directory will be used). - -o outfile Output file name for the ISO image. - -s splash Splash image file for isolinux. + -o outfile Output file name for the ISO image. + -s splash Splash image file for isolinux. _EOF exit 1 } @@ -132,16 +129,12 @@ install_packages() { error_out fi ${XBPS_INSTALL_CMD} ${XBPS_ARGS} ${PACKAGE_LIST} >>$LOGFILE 2>&1 - [ $? -ne 0 ] && error_out $? ${XBPS_INSTALL_CMD} ${XBPS_ARGS} -u >>$LOGFILE 2>&1 - [ $? -ne 0 ] && error_out $? ${XBPS_REMOVE_CMD} ${XBPS_ARGS} -o >>$LOGFILE 2>&1 - [ $? -ne 0 ] && error_out $? - ${XBPS_QUERY_CMD} -r "$ROOTFS" -l > \ - "${OUTPUT_FILE%.iso}"-package-list.txt || error_out + ${XBPS_QUERY_CMD} -r "$ROOTFS" -l > "${OUTPUT_FILE%.iso}"-package-list.txt # Reconfigure all pkgs again via linux-user-chroot. - $CHROOT_CMD $ROOTFS xbps-reconfigure -fa >>$LOGFILE 2>&1 + chroot $ROOTFS /usr/sbin/xbps-reconfigure -fa >>$LOGFILE 2>&1 } generate_initramfs() { @@ -151,23 +144,26 @@ generate_initramfs() { base-system void-mklive >>$LOGFILE 2>&1 # Install some required utilities from util-linux. - install -Dm755 $ROOTFS/kernel_temp/usr/sbin/agetty \ - "$ROOTFS/usr/sbin/agetty" || error_out $? - install -Dm755 $ROOTFS/kernel_temp/usr/bin/lsblk \ - "$ROOTFS/usr/bin/lsblk" || error_out $? + install -Dm755 $ROOTFS/kernel_temp/usr/bin/mount "$ROOTFS/usr/bin/mount" + install -Dm755 $ROOTFS/kernel_temp/usr/sbin/agetty "$ROOTFS/usr/sbin/agetty" + install -Dm755 $ROOTFS/kernel_temp/usr/bin/lsblk "$ROOTFS/usr/bin/lsblk" # Install stdbuf from coreutils, required by void-installer. - install -Dm755 $ROOTFS/kernel_temp/usr/bin/stdbuf \ - "$ROOTFS/usr/bin/stdbuf" || error_out $? + install -Dm755 $ROOTFS/kernel_temp/usr/bin/stdbuf "$ROOTFS/usr/bin/stdbuf" install -Dm755 $ROOTFS/kernel_temp/usr/libexec/coreutils/libstdbuf.so \ - "$ROOTFS/usr/libexec/coreutils/libstdbuf.so" || error_out $? + "$ROOTFS/usr/libexec/coreutils/libstdbuf.so" + + chroot $ROOTFS/kernel_temp /usr/bin/dracut --no-hostonly \ + --add " dmsquash-live vmklive " --${COMPRESSTYPE} \ + "/boot/initrd.lz" >>$LOGFILE 2>&1 + + umount_kernel_fs - $CHROOT_CMD $ROOTFS/kernel_temp dracut --no-hostonly \ - --add "dmsquash-live vmklive" --${COMPRESSTYPE} \ - "/boot/initrd.lz" 2>/dev/null || error_out mv $ROOTFS/kernel_temp/boot/initrd.lz $BOOT_DIR # We rely on pam now, so let's install the host login config. install -Dm644 $ROOTFS/kernel_temp/etc/pam.d/login \ - "$ROOTFS/etc/pam.d/login" || error_out $? + "$ROOTFS/etc/pam.d/login" + # Remove pam_motd.so; busybox login already prints it. + sed -e '/^.*pam_motd.so*/d' -i "$ROOTFS/etc/pam.d/login" } copy_kernel_and_modules() { @@ -176,33 +172,36 @@ copy_kernel_and_modules() { mkdir -p $ROOTFS/lib/modules cp -a $ROOTFS/kernel_temp/lib/modules/${KERNELVERSION} \ $ROOTFS/lib/modules + # remove temporary rootfs. rm -rf $ROOTFS/kernel_temp } generate_local_repository() { mkdir -p $ROOTFS/packages - pkgs=$($XBPS_INSTALL_CMD -s -r /tmp/blah -n ${LOCALREPO_PKGLIST}) + pkgs=$($XBPS_INSTALL_CMD -r /tmp/blah -n ${LOCALREPO_PKGLIST}) set -- ${pkgs} while [ $# -ne 0 ]; do - pkgn=$1; action=$2; ver=$3; repo=$4; binpkg=$5; arch=$6 - shift 6 - bpkg=$repo/$binpkg + pkg=$1; action=$2; arch=$3; repo=$4; + shift 4 + bpkg=${repo}/${pkg}.${arch}.xbps cp -f $bpkg $ROOTFS/packages done LD_LIBRARY_PATH="$ROOTFS/usr/lib" \ $ROOTFS/usr/sbin/$XBPS_RINDEX_CMD -a $ROOTFS/packages/*.xbps 2>&1 >>$LOGFILE - rm -f $ROOTFS/packages/index-files.plist } generate_isolinux_boot() { - cp -f $SYSLINUX_DATADIR/isolinux.bin "$ISOLINUX_DIR" || error_out $? - cp -f $SYSLINUX_DATADIR/vesamenu.c32 "$ISOLINUX_DIR" || error_out $? + cp -f $SYSLINUX_DATADIR/isolinux.bin "$ISOLINUX_DIR" + cp -f $SYSLINUX_DATADIR/ldlinux.c32 "$ISOLINUX_DIR" + cp -f $SYSLINUX_DATADIR/libcom32.c32 "$ISOLINUX_DIR" + cp -f $SYSLINUX_DATADIR/vesamenu.c32 "$ISOLINUX_DIR" + cp -f $SYSLINUX_DATADIR/libutil.c32 "$ISOLINUX_DIR" cp -f $MKLIVE_DATADIR/isolinux.cfg.in \ - "$ISOLINUX_DIR"/isolinux.cfg || error_out $? + "$ISOLINUX_DIR"/isolinux.cfg if [ -f "$SPLASH_IMAGE" ]; then - cp -f $SPLASH_IMAGE "$ISOLINUX_DIR" || error_out $? + cp -f $SPLASH_IMAGE "$ISOLINUX_DIR" fi sed -i -e "s|@@SPLASHIMAGE@@|$(basename $SPLASH_IMAGE)|" \ -e "s|@@KERNVER@@|${KERNELVERSION}|" \ @@ -212,38 +211,34 @@ generate_isolinux_boot() { } generate_grub_efi_boot() { - cp -f $MKLIVE_DATADIR/grub.cfg $GRUB_DIR || error_out $? - cp -f $MKLIVE_DATADIR/grub_void.cfg.in \ - $GRUB_DIR/grub_void.cfg || error_out $? + cp -f $MKLIVE_DATADIR/grub.cfg $GRUB_DIR + cp -f $MKLIVE_DATADIR/grub_void.cfg.in $GRUB_DIR/grub_void.cfg sed -i -e "s|@@SPLASHIMAGE@@|$(basename $SPLASH_IMAGE)|" \ -e "s|@@KERNVER@@|${KERNELVERSION}|" \ -e "s|@@KEYMAP@@|${KEYMAP}|" \ -e "s|@@ARCH@@|$(uname -m)|" \ -e "s|@@LOCALE@@|${LOCALE}|" $GRUB_DIR/grub_void.cfg - mkdir -p $GRUB_DIR/fonts $GRUB_DIR/locale || error_out $? - cp -f $GRUB_DATADIR/unicode.pf2 $GRUB_DIR/fonts || error_out $? - cp -f /boot/grub/locale/* $GRUB_DIR/locale || error_out $? + mkdir -p $GRUB_DIR/fonts $GRUB_DIR/locale + cp -f $GRUB_DATADIR/unicode.pf2 $GRUB_DIR/fonts + cp -f /boot/grub/locale/* $GRUB_DIR/locale # Create EFI vfat image. - dd if=/dev/zero of=$GRUB_DIR/efiboot.img bs=1024 count=4096 \ - >>$LOGFILE 2>&1 || error_out $? - mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" \ - >>$LOGFILE 2>&1 || error_out $? + 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 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 || error_out $? + mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >>$LOGFILE 2>&1 - mkdir -p "${GRUB_EFI_TMPDIR}/EFI/boot/" || error_out $? - cd "$BUILDDIR" || error_out $? + mkdir -p "${GRUB_EFI_TMPDIR}/EFI/boot/" + cd "$BUILDDIR" grub-mkstandalone --directory="/usr/lib/grub/x86_64-efi" \ --format="x86_64-efi" \ --compression="xz" --output="${GRUB_EFI_TMPDIR}/EFI/boot/bootx64.efi" \ - "boot/grub/grub.cfg" >>$LOGFILE 2>&1 || error_out $? - umount "$GRUB_EFI_TMPDIR" || error_out $? - losetup --detach "${LOOP_DEVICE}" || error_out $? - rm -rf $GRUB_EFI_TMPDIR || error_out $? + "boot/grub/grub.cfg" >>$LOGFILE 2>&1 + umount "$GRUB_EFI_TMPDIR" + losetup --detach "${LOOP_DEVICE}" + rm -rf $GRUB_EFI_TMPDIR } generate_squashfs() { @@ -251,23 +246,20 @@ generate_squashfs() { ROOTFS_SIZE=$(du -sk "$ROOTFS"|awk '{print $1}') mkdir -p "$BUILDDIR/tmp/LiveOS" dd if=/dev/zero of="$BUILDDIR/tmp/LiveOS/ext3fs.img" \ - bs="$((${ROOTFS_SIZE}+($ROOTFS_SIZE/6)))K" count=1 \ - >>$LOGFILE 2>&1 || error_out $? + bs="$((${ROOTFS_SIZE}+($ROOTFS_SIZE/6)))K" count=1 >>$LOGFILE 2>&1 mkdir -p "$BUILDDIR/tmp-rootfs" - mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" \ - >>$LOGFILE 2>&1 || error_out $? - mount -o loop "$BUILDDIR/tmp/LiveOS/ext3fs.img" \ - "$BUILDDIR/tmp-rootfs" || error_out $? + mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" >>$LOGFILE 2>&1 + mount -o loop "$BUILDDIR/tmp/LiveOS/ext3fs.img" "$BUILDDIR/tmp-rootfs" cd $BUILDDIR cp -a rootfs/* tmp-rootfs/ umount -f "$BUILDDIR/tmp-rootfs" mkdir -p "$BUILDDIR/LiveOS" mksquashfs "$BUILDDIR/tmp" "$BUILDDIR/LiveOS/squashfs.img" \ - -comp ${COMPRESSTYPE} >>$LOGFILE 2>&1 || error_out - chmod 444 "$BUILDDIR/LiveOS/squashfs.img" || error_out $? + -comp ${COMPRESSTYPE} >>$LOGFILE 2>&1 + chmod 444 "$BUILDDIR/LiveOS/squashfs.img" # Remove rootfs and temporary dirs, we don't need them anymore. - rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp" || error_out $? + rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp" } generate_iso_image() { @@ -280,8 +272,8 @@ generate_iso_image() { -eltorito-catalog boot/isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 -boot-info-table \ -eltorito-alt-boot --efi-boot boot/grub/efiboot.img -no-emul-boot \ - -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \ - -output "$OUTPUT_FILE" "$BUILDDIR" >>$LOGFILE 2>&1 || error_out $? + -isohybrid-mbr $SYSLINUX_DATADIR/isohdpfx.bin \ + -output "$OUTPUT_FILE" "$BUILDDIR" >>$LOGFILE 2>&1 } # @@ -290,12 +282,12 @@ generate_iso_image() { while getopts "C:c:l:o:r:s:h" opt; do case $opt in C) CONFIG_FILE="$OPTARG";; - c) COMPRESSTYPE="$OPTARG";; -l) LOCALREPO_PKGLIST="$OPTARG";; - o) OUTPUT_FILE="$OPTARG";; -r) ROOTDIR="$OPTARG";; - s) SPLASH_IMAGE="$OPTARG";; -h) usage;; + c) COMPRESSTYPE="$OPTARG";; + l) LOCALREPO_PKGLIST="$OPTARG";; + o) OUTPUT_FILE="$OPTARG";; + r) ROOTDIR="$OPTARG";; + s) SPLASH_IMAGE="$OPTARG";; + h) usage;; esac done shift $(($OPTIND - 1)) @@ -366,9 +358,9 @@ fi ISO_VOLUME="VOID_LIVE" if [ -n "$ROOTDIR" ]; then - BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d) || exit 1 + BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d) else - BUILDDIR=$(mktemp --tmpdir="$(pwd -P)" -d) || exit 1 + BUILDDIR=$(mktemp --tmpdir="$(pwd -P)" -d) fi BUILDDIR=$(readlink -f $BUILDDIR) ROOTFS="$BUILDDIR/rootfs" @@ -393,9 +385,9 @@ if [ -n "$REPOSITORY_CACHE" ]; then fi XBPS_VERSION=$($XBPS_QUERY_CMD -V|awk '{print $2}') case $XBPS_VERSION in -# XBPS >= 0.18 - [0-9].[1-9][8-9]*|[0-9].[2-9][0-9]*) ;; -*) echo "Your xbps utilities are too old ($XBPS_VERSION), 0.18 is required." && exit 1;; +# XBPS >= 0.21 + [0-9].[2-9][1-9]*) ;; + *) echo "Your xbps utilities are too old ($XBPS_VERSION), 0.21 is required."; exit 1;; esac KERNELVERSION=$($XBPS_QUERY_CMD -R --property version kernel) @@ -464,7 +456,7 @@ info_msg "[8/9] Generating ISO image..." generate_iso_image info_msg "[9/9] Removing build directory..." -rm -rf "$BUILDDIR" || error_out $? +rm -rf "$BUILDDIR" hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}') info_msg "Created $(readlink -f $OUTPUT_FILE) ($hsize) successfully."