From 644890069cad4977f9d9cfa15703d74906560cc6 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 5 Nov 2014 09:45:29 +0100 Subject: mklive: install vpkg conf file to the system virtualpkg directory instead. --- mklive.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 8700075..8e4cd43 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -75,7 +75,7 @@ copy_void_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/virtualpkg.d/void.conf } install_prereqs() { -- cgit 1.4.1 From 8f2cc01d1825ad92f7d5467987029e182e4fcd04 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 3 Dec 2014 14:13:42 +0100 Subject: mklive: force reconfiguration of util-linux to make sure uuidd is created. --- mklive.sh.in | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 8e4cd43..9059407 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -108,6 +108,8 @@ install_packages() { sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i $ROOTFS/etc/default/libc-locales xbps-uchroot $ROOTFS xbps-reconfigure -f glibc-locales >>$LOGFILE 2>&1 fi + # reconfigure util-linux just to be safe + xbps-uchroot $ROOTFS xbps-reconfigure -f util-linux >>$LOGFILE 2>&1 if [ -x installer.sh ]; then install -Dm755 installer.sh $ROOTFS/usr/sbin/void-installer -- cgit 1.4.1 From f5af7c32bdb27a66864214b6cf983fb91b17f088 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 5 Dec 2014 12:45:43 +0100 Subject: mklive.sh: dont error out if loop module cannot be loaded. --- mklive.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 9059407..c1ee998 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -177,7 +177,7 @@ generate_grub_efi_boot() { -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \ -e "s|@@LOCALE@@|${LOCALE}|" $GRUB_DIR/grub_void.cfg - 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 -- cgit 1.4.1 From 4ab914cdf7cc7a42b9880d72b16417020839c280 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 17 Dec 2014 18:26:28 +0100 Subject: mklive: multiple improvements and fixes. - Does not need bash anymore, a POSIX shell is enough. - Avoid installing base-system twice to generate the initramfs. - Reconfigure some pkgs in the rootfs... otherwise some system users won't be created. - Added -K opt to not remove builddir. --- README.md | 1 - mklive.sh.in | 163 ++++++++++++++++++++++++++--------------------------------- 2 files changed, 72 insertions(+), 92 deletions(-) (limited to 'mklive.sh.in') diff --git a/README.md b/README.md index 89e4ea7..598f596 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ This repository contains utilities for Void Linux: #### Dependencies * xbps>=0.35 - * GNU bash * parted (for mkimage) * qemu-user-static binaries (for mkrootfs) diff --git a/mklive.sh.in b/mklive.sh.in index c1ee998..14d7c68 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # vim: set ts=4 sw=4 et: # @@ -26,27 +26,27 @@ # (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" +readonly REQUIRED_PKGS="base-files dash coreutils sed tar gawk syslinux grub-x86_64-efi squashfs-tools xorriso" +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 +} error_out() { - info_msg "There was an error in line $1 ... cleaning up $BUILDDIR, exiting." - - [ -d "$BUILDDIR" ] && rm -rf "$BUILDDIR" - - exit 1 + [ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR" + exit ${1:=0} } usage() { cat <<_EOF -Usage: $(basename $0) [options] +Usage: $PROGNAME [options] Options: -a Set XBPS_ARCH (do not use it unless you know what it is) @@ -63,8 +63,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,17 +75,20 @@ 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"/usr/share/xbps/virtualpkg.d/void.conf } +copy_dracut_files() { + mkdir -p $1/usr/lib/dracut/modules.d/01vmklive + cp dracut/*.sh $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_CACHEDIR -y ${REQUIRED_PKGS} + [ $? -ne 0 ] && die "Failed to install required software, exiting..." } install_packages() { @@ -93,23 +97,19 @@ install_packages() { 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 -yn ${PACKAGE_LIST} ${INITRAMFS_PKGS} + [ $? -ne 0 ] && die "Missing required binary packages, exiting..." - ${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_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} ${INITRAMFS_PKGS} + [ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST" # 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 + xbps-reconfigure -r $ROOTFS -f glibc-locales || die "Failed to reconfigure glibc-locales" + # reconfigure util-linux just to be safe + xbps-reconfigure -r $ROOTFS -f util-linux || die "Failed to reconfigure util-linux" fi - # reconfigure util-linux just to be safe - xbps-uchroot $ROOTFS xbps-reconfigure -f util-linux >>$LOGFILE 2>&1 if [ -x installer.sh ]; then install -Dm755 installer.sh $ROOTFS/usr/sbin/void-installer @@ -122,28 +122,26 @@ install_packages() { 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 - + 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 + xbps-uchroot $ROOTFS env -i /usr/bin/dracut --${INITRAMFS_COMPRESSION} \ + --force-add "vmklive" ${_args} "/boot/initrd" $KERNELVERSION + [ $? -ne 0 ] && die "Failed to generate the initramfs" + + mv $ROOTFS/boot/initrd $BOOT_DIR + cp $ROOTFS/boot/vmlinuz-$KERNELVERSION $BOOT_DIR/vmlinuz +} - mv $VOIDHOSTDIR/boot/initrd $BOOT_DIR - cp $VOIDHOSTDIR/boot/vmlinuz-$KERNELVERSION $BOOT_DIR/vmlinuz +cleanup_rootfs() { + for f in ${INITRAMFS_PKGS}; do + xbps-remove -r $ROOTFS -Ry ${f} || die "Failed to remove $f from rootfs" + done + rm -r $ROOTFS/usr/lib/dracut/modules.d/01vmklive } generate_isolinux_boot() { @@ -176,22 +174,30 @@ generate_grub_efi_boot() { -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 || : # 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 + "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/ umount "$GRUB_EFI_TMPDIR" @@ -207,16 +213,16 @@ 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 + -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" @@ -233,18 +239,19 @@ 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" } # # 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 ";; c) XBPS_CACHEDIR="--cachedir=$OPTARG";; + K) readonly KEEP_BUILDDIR=1;; k) KEYMAP="$OPTARG";; l) LOCALE="$OPTARG";; i) INITRAMFS_COMPRESSION="$OPTARG";; @@ -257,7 +264,7 @@ 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)) # Set defaults : ${XBPS_CACHEDIR:=--cachedir=/var/cache/xbps} @@ -271,12 +278,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" @@ -298,6 +302,7 @@ ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg" : ${XBPS_REPOSITORY:=--repository=http://repo.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} @@ -308,9 +313,7 @@ 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 @@ -321,15 +324,9 @@ KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion $KERNELVERSION) : ${OUTPUT_FILE="void-live-$(uname -m)-${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 @@ -337,42 +334,26 @@ 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. -# +export PATH=$VOIDHOSTDIR/usr/bin:$VOIDHOSTDIR/usr/sbin:$ROOTFS/usr/bin:$ROOTFS/usr/sbin:$PATH +export LD_LIBRARY_PATH=$ROOTFS/usr/lib + 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 -- cgit 1.4.1 From 7f49ee579c84b4ef2fa4bf7e704e686fe1e3d9be Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 17 Dec 2014 18:54:43 +0100 Subject: mklive: only remove unnecessary pkgs if don't have revdeps. ... otherwise switch them to automatic installation mode. --- mklive.sh.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 14d7c68..09c6f6b 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -139,7 +139,12 @@ generate_initramfs() { cleanup_rootfs() { for f in ${INITRAMFS_PKGS}; do - xbps-remove -r $ROOTFS -Ry ${f} || die "Failed to remove $f from rootfs" + 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 } -- cgit 1.4.1 From 653f1d2ad9c2865a9435b1aa9bff8cb1c68c4957 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 29 Dec 2014 09:50:29 +0100 Subject: mklive: misc fixes to generate successful musl images. --- mklive.sh.in | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 09c6f6b..2294faa 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -92,9 +92,6 @@ install_prereqs() { } 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} ${INITRAMFS_PKGS} @@ -118,11 +115,11 @@ install_packages() { fi # Cleanup and remove useless stuff. rm -rf $ROOTFS/var/cache/* $ROOTFS/run/* $ROOTFS/var/run/* - - unset XBPS_ARCH } generate_initramfs() { + local _args + copy_dracut_files $ROOTFS if [ "$BASE_SYSTEM_PKG" = "base-system-systemd" ]; then _args="--add systemd" @@ -254,7 +251,7 @@ 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="--repository=$OPTARG";; c) XBPS_CACHEDIR="--cachedir=$OPTARG";; K) readonly KEEP_BUILDDIR=1;; k) KEYMAP="$OPTARG";; @@ -318,6 +315,10 @@ ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg" mkdir -p $ROOTFS $VOIDHOSTDIR $ISOLINUX_DIR $GRUB_DIR +if [ -n "$BASE_ARCH" ]; then + export XBPS_ARCH="$BASE_ARCH" +fi + info_msg "[1/8] Synchronizing XBPS repository data..." copy_void_keys $ROOTFS $XBPS_INSTALL_CMD -r $ROOTFS ${XBPS_REPOSITORY} -S @@ -340,7 +341,7 @@ info_msg "[3/9] Installing void pkgs into the rootfs: ${PACKAGE_LIST} ..." install_packages export PATH=$VOIDHOSTDIR/usr/bin:$VOIDHOSTDIR/usr/sbin:$ROOTFS/usr/bin:$ROOTFS/usr/sbin:$PATH -export LD_LIBRARY_PATH=$ROOTFS/usr/lib +export LD_LIBRARY_PATH=$ROOTFS/usr/lib:$VOIDHOSTDIR/usr/lib info_msg "[4/9] Generating initramfs image ($INITRAMFS_COMPRESSION)..." generate_initramfs -- cgit 1.4.1 From 8134257155f517f218c797375cf70357b934c034 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 29 Dec 2014 11:26:55 +0100 Subject: mklive: more fixes for musl images. - Reconfigure util-linux only if it's installed in rootdir. - dracut: force add the ahci kernel module and build a non hostonly image. --- mklive.sh.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 2294faa..38cf04b 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -104,8 +104,10 @@ install_packages() { if [ -f $ROOTFS/etc/default/libc-locales ]; then sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i $ROOTFS/etc/default/libc-locales xbps-reconfigure -r $ROOTFS -f glibc-locales || die "Failed to reconfigure glibc-locales" + fi + if xbps-query -r $ROOTFS util-linux >/dev/null 2>&1; then # reconfigure util-linux just to be safe - xbps-reconfigure -r $ROOTFS -f util-linux || die "Failed to reconfigure util-linux" + xbps-reconfigure -r $ROOTFS -f util-linux fi if [ -x installer.sh ]; then @@ -126,8 +128,8 @@ generate_initramfs() { else _args="--omit systemd" fi - xbps-uchroot $ROOTFS env -i /usr/bin/dracut --${INITRAMFS_COMPRESSION} \ - --force-add "vmklive" ${_args} "/boot/initrd" $KERNELVERSION + xbps-uchroot $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 $ROOTFS/boot/initrd $BOOT_DIR -- cgit 1.4.1 From da528e772f3662a8a0dc316ccc05202ae2918c26 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 5 Jan 2015 17:55:52 +0100 Subject: mklive: declare vpkgs unversioned and update path for xbps>=0.43. --- data/void-vpkgs.conf | 6 +++--- mklive.sh.in | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'mklive.sh.in') diff --git a/data/void-vpkgs.conf b/data/void-vpkgs.conf index 75b56ac..9d3b98c 100644 --- a/data/void-vpkgs.conf +++ b/data/void-vpkgs.conf @@ -4,6 +4,6 @@ # - libressl-openssl as default openssl(1) # - openbsd-man as default man(1) # -virtualpkg=awk-0_1:gawk -virtualpkg=openssl-1.0_1:libressl-openssl -virtualpkg=man-0_1:openbsd-man +virtualpkg=awk:gawk +virtualpkg=openssl:libressl-openssl +virtualpkg=man:openbsd-man diff --git a/mklive.sh.in b/mklive.sh.in index 38cf04b..2a9d70a 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -77,7 +77,7 @@ copy_void_keys() { } copy_void_conf() { - install -Dm644 data/void-vpkgs.conf "$1"/usr/share/xbps/virtualpkg.d/void.conf + install -Dm644 data/void-vpkgs.conf "$1"/usr/share/xbps.d/void-virtualpkgs.conf } copy_dracut_files() { -- cgit 1.4.1 From 690ffec05cb2889f33b773db7a4268769360a24c Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 31 Jan 2015 10:00:05 +0100 Subject: mklive: unbreak setting multiple repos via -r (close #17) --- mklive.sh.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 2a9d70a..dcd1e75 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -3,7 +3,7 @@ # 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 @@ -246,6 +246,7 @@ generate_iso_image() { -output "$CURDIR/$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image" } +XBPS_REPOSITORY= # # main() # @@ -253,7 +254,7 @@ 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";; -- cgit 1.4.1 From a7ed58c4fb2140c0c3306d3dcc45e5a03c764315 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 11 Feb 2015 08:34:35 +0100 Subject: mklive: force C locale to install base pkgs to silence dracut. --- mklive.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index dcd1e75..01131b9 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -97,7 +97,7 @@ install_packages() { ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -yn ${PACKAGE_LIST} ${INITRAMFS_PKGS} [ $? -ne 0 ] && die "Missing required binary packages, exiting..." - ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} ${INITRAMFS_PKGS} + LANG=C ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} ${INITRAMFS_PKGS} [ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST" # Enable choosen UTF-8 locale and generate it into the target rootfs. -- cgit 1.4.1 From 69bcb88aa1d5771a463b524f7f6385ad3575a7dc Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 21 Feb 2015 18:25:14 +0100 Subject: mklive: add libgcc to required pkgs; glibc's pthread_cancel needs it :/ --- mklive.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 01131b9..95c39e4 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -28,7 +28,7 @@ #- trap "error_out $LINENO $?" INT TERM 0 -readonly REQUIRED_PKGS="base-files dash coreutils sed tar gawk syslinux grub-x86_64-efi squashfs-tools xorriso" +readonly REQUIRED_PKGS="base-files libgcc dash coreutils sed tar gawk syslinux grub-x86_64-efi squashfs-tools xorriso" readonly INITRAMFS_PKGS="binutils xz device-mapper" readonly PROGNAME=$(basename $0) -- cgit 1.4.1 From 8ee6fd344b50b647af72e3fa92238cdacbf34122 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 7 Apr 2015 10:23:19 +0200 Subject: mklive: reconfigure base-files for the kvm group. --- mklive.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 95c39e4..882a0ae 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -107,7 +107,7 @@ install_packages() { fi if xbps-query -r $ROOTFS util-linux >/dev/null 2>&1; then # reconfigure util-linux just to be safe - xbps-reconfigure -r $ROOTFS -f util-linux + xbps-reconfigure -r $ROOTFS -f base-files util-linux fi if [ -x installer.sh ]; then -- cgit 1.4.1 From bc72a0b4cff83518b3d2a790f29ad84c2ba30e7f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 15 Apr 2015 07:30:18 +0200 Subject: mklive: use $BASE_ARCH if set for the image filename. --- mklive.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 882a0ae..60e9248 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -331,7 +331,7 @@ _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) -: ${OUTPUT_FILE="void-live-$(uname -m)-${KERNELVERSION}-$(date +%Y%m%d).iso"} +: ${OUTPUT_FILE="void-live-${BASE_ARCH:=$(uname -m)}-${KERNELVERSION}-$(date +%Y%m%d).iso"} info_msg "[2/9] Installing software to generate the image: ${REQUIRED_PKGS} ..." install_prereqs -- cgit 1.4.1 From 929175a025254315fd0773d1af23943233616db8 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Sat, 2 May 2015 01:01:17 +0200 Subject: Support for MEMDISK The .iso can now be booted using Grub (memdisk from Syslinux package): linux16 /memdisk initrd16 /path/to/iso As well as from Syslinux: LINUX memdisk INITRD path/to/iso --- dracut/59-mtd.rules | 8 ++++++++ dracut/61-mtd.rules | 20 ++++++++++++++++++++ dracut/module-setup.sh | 7 +++++++ dracut/mtd.sh | 7 +++++++ mklive.sh.in | 2 +- 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 dracut/59-mtd.rules create mode 100644 dracut/61-mtd.rules create mode 100755 dracut/mtd.sh (limited to 'mklive.sh.in') diff --git a/dracut/59-mtd.rules b/dracut/59-mtd.rules new file mode 100644 index 0000000..d81a6ad --- /dev/null +++ b/dracut/59-mtd.rules @@ -0,0 +1,8 @@ +SUBSYSTEM!="block", GOTO="ps_end" +ACTION!="add|change", GOTO="ps_end" +# Also don't process disks that are slated to be a multipath device +ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="ps_end" + +KERNEL=="mtdblock[0-9]*", IMPORT BLKID + +LABEL="ps_end" diff --git a/dracut/61-mtd.rules b/dracut/61-mtd.rules new file mode 100644 index 0000000..0711d3a --- /dev/null +++ b/dracut/61-mtd.rules @@ -0,0 +1,20 @@ +SUBSYSTEM!="block", GOTO="pss_end" +ACTION!="add|change", GOTO="pss_end" +# Also don't process disks that are slated to be a multipath device +ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="pss_end" + +ACTION=="change", KERNEL=="dm-[0-9]*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", GOTO="do_pss" +KERNEL=="mtdblock*", GOTO="do_pss" + +GOTO="pss_end" + +LABEL="do_pss" +# by-path (parent device path) +ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT PATH_ID +ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}" +ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n" + +# by-label/by-uuid links (filesystem metadata) +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" +LABEL="pss_end" diff --git a/dracut/module-setup.sh b/dracut/module-setup.sh index 765f41f..c6d1661 100644 --- a/dracut/module-setup.sh +++ b/dracut/module-setup.sh @@ -14,6 +14,13 @@ install() { inst /usr/bin/chroot inst /usr/bin/chmod inst /usr/bin/sed + + inst /usr/bin/memdiskfind + instmods mtdblock phram + inst_rules "$moddir/59-mtd.rules" "$moddir/61-mtd.rules" + prepare_udev_rules 59-mtd.rules 61-mtd.rules + inst_hook pre-udev 01 "$moddir/mtd.sh" + inst_hook pre-pivot 01 "$moddir/adduser.sh" inst_hook pre-pivot 02 "$moddir/display-manager-autologin.sh" inst_hook pre-pivot 03 "$moddir/copy-initramfs.sh" diff --git a/dracut/mtd.sh b/dracut/mtd.sh new file mode 100755 index 0000000..1d94a4e --- /dev/null +++ b/dracut/mtd.sh @@ -0,0 +1,7 @@ +#!/bin/sh +MEMDISK=$(memdiskfind) +if [ "$MEMDISK" ]; then + modprobe phram phram=memdisk,$MEMDISK + modprobe mtdblock + printf 'KERNEL=="mtdblock0", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root /dev/mtdblock0"\n' >> /etc/udev/rules.d/99-live-squash.rules +fi diff --git a/mklive.sh.in b/mklive.sh.in index 60e9248..9523c0c 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -82,7 +82,7 @@ copy_void_conf() { copy_dracut_files() { mkdir -p $1/usr/lib/dracut/modules.d/01vmklive - cp dracut/*.sh $1/usr/lib/dracut/modules.d/01vmklive/ + cp dracut/* $1/usr/lib/dracut/modules.d/01vmklive/ } install_prereqs() { -- cgit 1.4.1 From af2fcf925a0ddd0f43cc6ede164369117cacd928 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 24 May 2015 08:35:56 +0200 Subject: mklive: force modesetting on musl for now. intel and radeon drivers are currently broken with musl (segmentation fault in OsLookupColor()). --- data/xorg-modesetting.conf | 4 ++++ mklive.sh.in | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 data/xorg-modesetting.conf (limited to 'mklive.sh.in') diff --git a/data/xorg-modesetting.conf b/data/xorg-modesetting.conf new file mode 100644 index 0000000..1d10c80 --- /dev/null +++ b/data/xorg-modesetting.conf @@ -0,0 +1,4 @@ +Section "Device" + Identifier "modesetting" + Driver "modesetting" +EndSection diff --git a/mklive.sh.in b/mklive.sh.in index 9523c0c..ca39200 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -115,6 +115,11 @@ install_packages() { else install -Dm755 /usr/sbin/void-installer $ROOTFS/usr/sbin/void-installer fi + case "$BASE_ARCH" in + *-musl) # XXX force modesetting with musl for now. + install -Dm644 data/xorg-modesetting.conf $ROOTFS/usr/share/X11/xorg.conf.d/99-modesetting.conf + ;; + esac # Cleanup and remove useless stuff. rm -rf $ROOTFS/var/cache/* $ROOTFS/run/* $ROOTFS/var/run/* } -- cgit 1.4.1 From 00dda59b0ba84253af985be91613b4b5c2d17670 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 27 May 2015 16:49:33 +0200 Subject: mklive: remove modesetting workaround for musl, intel(4) works again. --- build-x86-images.sh.in | 2 +- data/xorg-modesetting.conf | 4 ---- mklive.sh.in | 5 ----- 3 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 data/xorg-modesetting.conf (limited to 'mklive.sh.in') diff --git a/build-x86-images.sh.in b/build-x86-images.sh.in index 9168feb..8ec55c9 100644 --- a/build-x86-images.sh.in +++ b/build-x86-images.sh.in @@ -18,7 +18,7 @@ case "$ARCH" in esac readonly BASE_PKGS="dialog cryptsetup lvm2 mdadm $GRUB" -readonly X_PKGS="$BASE_PKGS xorg-minimal xorg-input-drivers xorg-video-drivers setxkbmap xauth font-misc-misc terminus-font cantarell-fonts gnome-themes-standard alsa-plugins-pulseaudio firefox" +readonly X_PKGS="$BASE_PKGS xorg-minimal xorg-input-drivers xorg-video-drivers setxkbmap xauth font-misc-misc terminus-font cantarell-fonts gnome-themes-standard alsa-plugins-pulseaudio" readonly E_PKGS="$X_PKGS lxdm enlightenment terminology econnman udisks2" readonly XFCE_PKGS="$X_PKGS lxdm xfce4 network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2" readonly MATE_PKGS="$X_PKGS lxdm mate mate-extra network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2" diff --git a/data/xorg-modesetting.conf b/data/xorg-modesetting.conf deleted file mode 100644 index 1d10c80..0000000 --- a/data/xorg-modesetting.conf +++ /dev/null @@ -1,4 +0,0 @@ -Section "Device" - Identifier "modesetting" - Driver "modesetting" -EndSection diff --git a/mklive.sh.in b/mklive.sh.in index ca39200..9523c0c 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -115,11 +115,6 @@ install_packages() { else install -Dm755 /usr/sbin/void-installer $ROOTFS/usr/sbin/void-installer fi - case "$BASE_ARCH" in - *-musl) # XXX force modesetting with musl for now. - install -Dm644 data/xorg-modesetting.conf $ROOTFS/usr/share/X11/xorg.conf.d/99-modesetting.conf - ;; - esac # Cleanup and remove useless stuff. rm -rf $ROOTFS/var/cache/* $ROOTFS/run/* $ROOTFS/var/run/* } -- cgit 1.4.1 From 8824220321e97af99643d2ad6a948ee5b5429deb Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 29 May 2015 09:21:11 +0200 Subject: mklive: misc changes to allow building images for musl. - The required host utilities (grub, squashfs-tools and xorriso) are now installed for the host os, this way we don't have to make tricks for dsos to work. - The cachedir is now by default set to $PWD/xbps-cachedir-$arch, this way packages for the host and the target don't conflict. - Due to the changes above it's now possible to build musl images without having musl-bootstrap installed, previously it was necessary. --- mklive.sh.in | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 9523c0c..7d3b67c 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -87,17 +87,20 @@ copy_dracut_files() { install_prereqs() { copy_void_conf $VOIDHOSTDIR - $XBPS_INSTALL_CMD -r $VOIDHOSTDIR $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${REQUIRED_PKGS} + $XBPS_INSTALL_CMD -r $VOIDHOSTDIR $XBPS_REPOSITORY \ + $XBPS_HOST_CACHEDIR -y ${REQUIRED_PKGS} [ $? -ne 0 ] && die "Failed to install required software, exiting..." } install_packages() { copy_void_conf $ROOTFS # Check that all pkgs are reachable. - ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -yn ${PACKAGE_LIST} ${INITRAMFS_PKGS} + 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..." - LANG=C ${XBPS_INSTALL_CMD} -r $ROOTFS $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} ${INITRAMFS_PKGS} + LANG=C XBPS_ARCH=$BASE_ARCH ${XBPS_INSTALL_CMD} -r $ROOTFS \ + $XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} ${INITRAMFS_PKGS} [ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST" # Enable choosen UTF-8 locale and generate it into the target rootfs. @@ -128,7 +131,7 @@ generate_initramfs() { else _args="--omit systemd" fi - xbps-uchroot $ROOTFS env -i /usr/bin/dracut -N --${INITRAMFS_COMPRESSION} \ + xbps-uchroot $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" @@ -192,7 +195,7 @@ generate_grub_efi_boot() { 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 \ + xbps-uchroot $VOIDHOSTDIR grub-mkstandalone -- \ --directory="/usr/lib/grub/x86_64-efi" \ --format="x86_64-efi" \ --compression="xz" --output="/tmp/bootx64.efi" \ @@ -225,7 +228,7 @@ generate_squashfs() { umount -f "$BUILDDIR/tmp-rootfs" mkdir -p "$IMAGEDIR/LiveOS" - mksquashfs "$BUILDDIR/tmp" "$IMAGEDIR/LiveOS/squashfs.img" \ + $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. @@ -233,7 +236,7 @@ generate_squashfs() { } 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 \ @@ -271,8 +274,12 @@ while getopts "a:b:r:c:C:T:Kk:l:i:s:S:o:p:h" opt; do done 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} @@ -305,7 +312,7 @@ 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} @@ -318,17 +325,14 @@ ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg" mkdir -p $ROOTFS $VOIDHOSTDIR $ISOLINUX_DIR $GRUB_DIR -if [ -n "$BASE_ARCH" ]; then - export XBPS_ARCH="$BASE_ARCH" -fi - 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}) +_linux_series=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -x linux) +KERNELVERSION=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -p pkgver ${_linux_series}) KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion $KERNELVERSION) : ${OUTPUT_FILE="void-live-${BASE_ARCH:=$(uname -m)}-${KERNELVERSION}-$(date +%Y%m%d).iso"} @@ -343,9 +347,6 @@ 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:$ROOTFS/usr/bin:$ROOTFS/usr/sbin:$PATH -export LD_LIBRARY_PATH=$ROOTFS/usr/lib:$VOIDHOSTDIR/usr/lib - info_msg "[4/9] Generating initramfs image ($INITRAMFS_COMPRESSION)..." generate_initramfs -- cgit 1.4.1 From 77ff6c34c90480c01b36b2b3c0c5145f398fb0e2 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 3 Jun 2015 14:28:38 +0200 Subject: mklive: require xbps>=0.45 for two phase installation. - The target pkgs are unpacked with -U, and then reconfiguration happens within the chroot, so that there's no need for host dependencies. - Use chroot where possible to make sure that euid==0, not xbps-uchroot. Close #32 and #33 --- README.md | 2 +- mklive.sh.in | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'mklive.sh.in') diff --git a/README.md b/README.md index 41a6a5e..7498034 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This repository contains utilities for Void Linux: #### Dependencies - * xbps>=0.35 + * xbps>=0.45 * parted (for mkimage) * qemu-user-static binaries (for mkrootfs) diff --git a/mklive.sh.in b/mklive.sh.in index 7d3b67c..d7efb09 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -39,7 +39,19 @@ 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() { + umount_pseudofs [ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR" exit ${1:=0} } @@ -94,24 +106,25 @@ install_prereqs() { install_packages() { copy_void_conf $ROOTFS - # Check that all pkgs are reachable. + 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..." - LANG=C XBPS_ARCH=$BASE_ARCH ${XBPS_INSTALL_CMD} -r $ROOTFS \ + 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-reconfigure -r $ROOTFS -f glibc-locales || die "Failed to reconfigure glibc-locales" - fi - if xbps-query -r $ROOTFS util-linux >/dev/null 2>&1; then - # reconfigure util-linux just to be safe - xbps-reconfigure -r $ROOTFS -f base-files util-linux fi + chroot $ROOTFS env -i xbps-reconfigure -a if [ -x installer.sh ]; then install -Dm755 installer.sh $ROOTFS/usr/sbin/void-installer @@ -131,7 +144,7 @@ generate_initramfs() { else _args="--omit systemd" fi - xbps-uchroot $ROOTFS env -- -i /usr/bin/dracut -N --${INITRAMFS_COMPRESSION} \ + 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" @@ -213,6 +226,8 @@ generate_grub_efi_boot() { } 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 @@ -231,6 +246,7 @@ generate_squashfs() { $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" } -- cgit 1.4.1 From 52c027ad0c9c4c35aaeae02a84244884df81c47a Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 4 Jun 2015 09:13:30 +0200 Subject: mklive: use $BASE_ARCH where it's required. --- mklive.sh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index d7efb09..8d3857d 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -177,7 +177,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}|" \ @@ -190,7 +190,7 @@ 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 @@ -351,7 +351,7 @@ _linux_series=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITOR KERNELVERSION=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -p pkgver ${_linux_series}) KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion $KERNELVERSION) -: ${OUTPUT_FILE="void-live-${BASE_ARCH:=$(uname -m)}-${KERNELVERSION}-$(date +%Y%m%d).iso"} +: ${OUTPUT_FILE="void-live-${BASE_ARCH}-${KERNELVERSION}-$(date +%Y%m%d).iso"} info_msg "[2/9] Installing software to generate the image: ${REQUIRED_PKGS} ..." install_prereqs -- cgit 1.4.1 From e514350f88c48f144fd2a76a3748fb35bd23b914 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 12 Jul 2015 08:48:08 +0200 Subject: mklive: install GRUB EFI loader as EFI/BOOT/BOOTX64.EFI. There are some EFI firmwares that expect the loader to be in that location and being uppercase, so that there more chances to make this boot on more systems. --- mklive.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index 8d3857d..a13969b 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -218,8 +218,8 @@ generate_grub_efi_boot() { 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/ + 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 -- cgit 1.4.1 From 0bdf5c6c361a55e609c2b141d47263278ac33e75 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 9 Oct 2015 09:04:47 +0200 Subject: mklive: fix guessing linux kernel pkgname. --- mklive.sh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mklive.sh.in') diff --git a/mklive.sh.in b/mklive.sh.in index a13969b..5070c65 100644 --- a/mklive.sh.in +++ b/mklive.sh.in @@ -347,9 +347,9 @@ 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_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r $ROOTFS ${XBPS_REPOSITORY:=-R} -x linux) -KERNELVERSION=$(XBPS_ARCH=$BASE_ARCH $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="void-live-${BASE_ARCH}-${KERNELVERSION}-$(date +%Y%m%d).iso"} -- cgit 1.4.1