diff --git a/srcpkgs/vmklive/files/dracut-module.sh b/srcpkgs/vmklive/files/dracut-module.sh new file mode 100644 index 00000000000..34d51202338 --- /dev/null +++ b/srcpkgs/vmklive/files/dracut-module.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +check() { + return 255 +} + +depends() { + echo dmsquash-live +} + +install() { + inst chmod + inst_hook pre-pivot 01 "$moddir/vmklive-adduser.sh" +} diff --git a/srcpkgs/vmklive/files/dracut-vmklive-adduser.sh b/srcpkgs/vmklive/files/dracut-vmklive-adduser.sh new file mode 100644 index 00000000000..03277af5872 --- /dev/null +++ b/srcpkgs/vmklive/files/dracut-vmklive-adduser.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +USERNAME=$(getarg live.user) +[ -z "$USERNAME" ] && USERNAME=anon + +# Create /etc/default/live.conf to store USER. +echo "USERNAME=$USERNAME" >> ${NEWROOT}/etc/default/live.conf +chmod 644 ${NEWROOT}/etc/default/live.conf + +# Create new user and remove password. We'll use autologin by default. +chroot ${NEWROOT} useradd -c $USERNAME -m $USERNAME -G audio,video,wheel -s /bin/bash +chroot ${NEWROOT} passwd -d $USERNAME 2>&1 >/dev/null + +# Enable sudo permission by default. +if [ -f ${NEWROOT}/etc/sudoers ]; then + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${NEWROOT}/etc/sudoers +fi + +# Enable autologin for getty(1). +if [ -f ${NEWROOT}/lib/systemd/system/getty@.service ]; then + rm -f "${NEWROOT}/etc/systemd/system/getty.target.wants/getty@tty1.service" + sed -e "s|/sbin/agetty|/sbin/live-getty|g" \ + "${NEWROOT}/lib/systemd/system/getty@.service" > \ + "${NEWROOT}/etc/systemd/system/getty.target.wants/getty@tty1.service" +fi + +# Create /sbin/live-getty. +cat > ${NEWROOT}/sbin/live-getty <<_EOF +#!/bin/sh + +if [ -x /sbin/agetty ]; then + _getty=/sbin/agetty +elif [ -x /sbin/getty ]; then + _getty=/sbin/getty +fi + +exec \${_getty} -n -l /sbin/live-autologin \$* +_EOF +chmod 755 ${NEWROOT}/sbin/live-getty + +# Create /sbin/live-autologin. +cat > ${NEWROOT}/sbin/live-autologin <<_EOF +#!/bin/sh + +. /etc/default/live.conf +exec /bin/login -f \$USERNAME +_EOF +chmod 755 ${NEWROOT}/sbin/live-autologin diff --git a/srcpkgs/vmklive/files/mklive.sh.in b/srcpkgs/vmklive/files/mklive.sh.in old mode 100755 new mode 100644 index 7038d8b5072..fbbd4fe5c31 --- a/srcpkgs/vmklive/files/mklive.sh.in +++ b/srcpkgs/vmklive/files/mklive.sh.in @@ -53,7 +53,7 @@ write_etc_motd() { cat >> "$ROOTFS/etc/motd" <<_EOF ############################################################################### - Autogenerated by vmklive @@MKLIVE_VERSION@@. + Autogenerated by vmklive @@MKLIVE_VERSION@@ ------------------------------------------------------------------------------- Welcome to the Void Linux Live system, you have been autologged in. @@ -112,18 +112,12 @@ MENU COLOR sel * #ffffffff #FF5255FF * LABEL linux MENU LABEL Boot Void GNU/Linux ${kver} ($(uname -m)) -KERNEL /casper/vmlinuz -INITRD /casper/initrd.lz -APPEND boot=casper keymap=${KEYMAP:-us} locale=${LOCALE:-en_US.UTF-8} ro - -LABEL linuxtoram -MENU LABEL Boot Void GNU/Linux ${kver} (RAM) ($(uname -m)) -KERNEL /casper/vmlinuz -INITRD /casper/initrd.lz -APPEND boot=casper toram keymap=${KEYMAP:-us} locale=${LOCALE:-en_US.UTF-8} ro - +KERNEL vmlinuz +APPEND initrd=initrd.lz root=live:CDLABEL=VoidLinux-live-$(uname -m)-${kver} \ + rootfstype=auto ro liveimg rd.luks=0 rd.md=0 rd.dm=0 \ + vconsole.keymap=${KEYMAP} vconsole.unicode=1 locale.LANG=${LOCALE} LABEL c -MENU LABEL Boot first HD found by the BIOS +MENU LABEL Boot first HD found by BIOS LOCALBOOT 0x80 _EOF } @@ -145,7 +139,7 @@ SPLASH_IMAGE=/usr/share/void-artwork/splash.png KEYMAP=us # Default locale to use. -LOCALE=en_US.UTF-8 +LOCALE=en_US # Path to XBPS utilities. #XBPS_BIN_CMD=xbps-bin @@ -162,11 +156,12 @@ _EOF usage() { cat <<_EOF -Usage: $(basename $0) [options] +Usage: $(basename $0) [options] Options: -C file Path to configuration file (defaults to ~/.mklive.conf) -c (gzip|bzip2|xz) Compression type for the squashfs/initramfs image. + -k version Kernel version to use. -o outfile Output file name for the ISO image. -r rootdir Rootfs directory. -s splash Splash image file for isolinux. @@ -178,10 +173,11 @@ _EOF # # main() # -while getopts "C:c:o:r:s:v:" opt; do +while getopts "C:c:k:o:r:s:v:" opt; do case $opt in C) CONFIG_FILE="$OPTARG";; c) COMPRESSTYPE="$OPTARG";; + k) KERNELVERSION="$OPTARG";; o) OUTPUT_FILE="$OPTARG";; r) ROOTDIR="$OPTARG";; s) SPLASH_IMAGE="$OPTARG";; @@ -190,18 +186,8 @@ while getopts "C:c:o:r:s:v:" opt; do done shift $(($OPTIND - 1)) -KERNELVERSION="$1" if [ -z "$KERNELVERSION" ]; then - usage -fi - -# Check that specific kernel version contains the unionfs module. -if [ ! -r "/boot/config-${KERNELVERSION}" ]; then - echo "Missing /boot/config-${KERNELVERSION} file, exiting..." - exit 1 -elif ! grep -Eq "^CONFIG_UNION_FS=(y|m)$" /boot/config-${KERNELVERSION}; then - echo "kernel ${KERNELVERSION} does not contain unionfs support, exiting..." - exit 1 + KERNELVERSION="$(uname -r)" fi # Set defaults @@ -214,7 +200,7 @@ fi LOGFILE="$(mktemp -t vmklive-XXXXXXXXXX.log)" if [ -z "$ISO_VOLUME" ]; then - ISO_VOLUME="Void Linux Live $(uname -m) ${KERNELVERSION}" + ISO_VOLUME="VoidLinux-live-$(uname -m)-${KERNELVERSION}" fi if [ -z "$SYSLINUX_DATADIR" ]; then SYSLINUX_DATADIR=/usr/share/syslinux @@ -250,7 +236,7 @@ else fi BUILDDIR=$(mktemp --tmpdir=$HOME -d) || exit 1 BUILDDIR=$(readlink -f $BUILDDIR) -ROOTFS="$BUILDDIR/casper/rootfs" +ROOTFS="$BUILDDIR/rootfs" ISOLINUX_DIR="$BUILDDIR/isolinux" ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg" @@ -279,6 +265,7 @@ fi # mount_pseudofs mkdir -p "$ROOTFS/tmp" +mkdir -p "$ISOLINUX_DIR" XBPS_ARGS="-r $ROOTFS -y" if [ -n "$REPOSITORY_CACHE" ]; then @@ -326,33 +313,20 @@ write_etc_motd # Create the initramfs with XZ compression. # info_msg "[3/9] Creating initramfs image ($COMPRESSTYPE)..." -mkinitramfs -c ${COMPRESSTYPE} \ - -o "$BUILDDIR/casper/initrd.lz" ${KERNELVERSION} \ - 2>/dev/null || error_out -mkdir -p "$ROOTFS"/cow +dracut --add "dmsquash-live vmklive" --${COMPRESSTYPE} \ + "${ISOLINUX_DIR}/initrd.lz" ${KERNELVERSION} 2>/dev/null || error_out # # Copy the linux image to the target directory. # info_msg "[4/9] Copying kernel image/modules..." -cp -f /boot/vmlinuz-${KERNELVERSION} "$BUILDDIR/casper/vmlinuz" || error_out $? +cp -f /boot/vmlinuz-${KERNELVERSION} "${ISOLINUX_DIR}/vmlinuz" || error_out $? mkdir -p "$ROOTFS/lib/modules" cp -a /lib/modules/${KERNELVERSION} "$ROOTFS/lib/modules" || error_out $? -# XXX: install lsblk and blkid from util-linux. -install -Dm755 /usr/bin/lsblk "$ROOTFS/usr/bin/lsblk" || error_out $? -install -Dm755 /usr/sbin/blkid "$ROOTFS/sbin/blkid" || error_out $? - -# -# Copy required xbps-casper files for autologin. -# -install -Dm644 /etc/casper.conf "$ROOTFS/etc/casper.conf" || error_out $? -install -Dm755 /sbin/casper-getty "$ROOTFS/sbin/casper-getty" || error_out $? -install -Dm755 /sbin/casper-login "$ROOTFS/sbin/casper-login" || error_out $? - # Generate a sane xbps.conf for the rootfs. rm -f $ROOTFS/etc/xbps/xbps.conf -echo "# xbps.conf generated by vmklive-@@MKLIVE_VERSION@@" \ +echo "# xbps.conf generated by vmklive-0.8.5" \ > $ROOTFS/etc/xbps/xbps.conf echo "TransactionFrequencyFlush = 0" \ >> $ROOTFS/etc/xbps/xbps.conf @@ -412,16 +386,10 @@ done # umount_pseudofs -# Save a few MBs from /usr/share. -for d in info man examples doc; do - [ -d "$ROOTFS/usr/share/${d}" ] && rm -rf "$ROOTFS/usr/share/${d}" -done - # # Copy required isolinux files in the target rootfs. # info_msg "[5/9] Copying isolinux files..." -mkdir -p "$ISOLINUX_DIR" cp -f $SYSLINUX_DATADIR/isolinux.bin "$ISOLINUX_DIR" cp -f $SYSLINUX_DATADIR/vesamenu.c32 "$ISOLINUX_DIR" write_default_isolinux_conf ${KERNELVERSION} @@ -433,17 +401,25 @@ fi # Prepare the squashed rootfs image. # info_msg "[6/9] Creating squashfs image ($COMPRESSTYPE) from rootfs..." -mksquashfs "$ROOTFS" "$BUILDDIR/casper/filesystem.squashfs" \ - -root-becomes / -comp ${COMPRESSTYPE} \ - 2>&1 | cat >> $LOGFILE || error_out -chmod 444 "$BUILDDIR/casper/filesystem.squashfs" || error_out $? +# Find out required size for the rootfs and create an ext3fs image off it. +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 2>&1 | cat >>$LOGFILE || error_out $? +mkdir -p "$BUILDDIR/tmp-rootfs" +mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" 2>&1 | cat >>$LOGFILE || error_out $? +mount -o loop "$BUILDDIR/tmp/LiveOS/ext3fs.img" "$BUILDDIR/tmp-rootfs" || error_out $? +cd $BUILDDIR +cp -a rootfs/* tmp-rootfs/ +umount -f "$BUILDDIR/tmp-rootfs" +mkdir -p "$BUILDDIR/LiveOS" -if [ -n "$ROOTDIR" ]; then - umount_pseudofs yes -else - info_msg "[7/9] Removing rootfs directory..." - rm -rf "$ROOTFS" || error_out $? -fi +mksquashfs "$BUILDDIR/tmp" "$BUILDDIR/LiveOS/squashfs.img" \ + -comp ${COMPRESSTYPE} 2>&1 | cat >> $LOGFILE || error_out +chmod 444 "$BUILDDIR/LiveOS/squashfs.img" || error_out $? + +info_msg "[7/9] Removing rootfs directory..." +rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp" || error_out $? # # Prepare the ISO image. diff --git a/srcpkgs/vmklive/template b/srcpkgs/vmklive/template index a6d1063395f..f30b819e275 100644 --- a/srcpkgs/vmklive/template +++ b/srcpkgs/vmklive/template @@ -1,19 +1,17 @@ # Template file for 'vmklive' pkgname=vmklive -version=0.8.5 -fulldepends="initramfs-tools xbps-casper>=0.25.1.236 cdrtools squashfs-tools syslinux" -short_desc="Void GNU/Linux live image maker" +version=0.9.0 +replaces="xbps-mklive>=0 vanilla-mklive>=0" +noextract=yes +noarch=yes +fulldepends="dracut>=018_2 cdrtools squashfs-tools syslinux" +short_desc="Void Linux live image maker" maintainer="Juan RP " license="Public domain" homepage="http://code.google.com/p/xbps" long_desc=" - $pkgname is a simple shell script to build a bootable live image, - with xbps binary packages." - -replaces="xbps-mklive>=0 vanilla-mklive>=0" -noextract=yes -noarch=yes - + $pkgname is a simple shell script to build a bootable live image + for void linux." do_build() { sed "s|@@MKLIVE_VERSION@@|${version}|g" \ @@ -22,4 +20,9 @@ do_build() { do_install() { vinstall ${pkgname}.sh 755 usr/sbin vmklive + # Install dracut module. + vinstall ${FILESDIR}/dracut-module.sh 755 \ + usr/lib/dracut/modules.d/01vmklive module-setup.sh + vinstall ${FILESDIR}/dracut-vmklive-adduser.sh 755 \ + usr/lib/dracut/modules.d/01vmklive vmklive-adduser.sh }