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 --- mklive.sh.in | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'mklive.sh.in') 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