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
This commit is contained in:
parent
ec5a92c270
commit
77ff6c34c9
@ -10,7 +10,7 @@ This repository contains utilities for Void Linux:
|
|||||||
|
|
||||||
#### Dependencies
|
#### Dependencies
|
||||||
|
|
||||||
* xbps>=0.35
|
* xbps>=0.45
|
||||||
* parted (for mkimage)
|
* parted (for mkimage)
|
||||||
* qemu-user-static binaries (for mkrootfs)
|
* qemu-user-static binaries (for mkrootfs)
|
||||||
|
|
||||||
|
32
mklive.sh.in
32
mklive.sh.in
@ -39,7 +39,19 @@ die() {
|
|||||||
info_msg "ERROR: $@"
|
info_msg "ERROR: $@"
|
||||||
error_out 1
|
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() {
|
error_out() {
|
||||||
|
umount_pseudofs
|
||||||
[ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR"
|
[ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR"
|
||||||
exit ${1:=0}
|
exit ${1:=0}
|
||||||
}
|
}
|
||||||
@ -94,24 +106,25 @@ install_prereqs() {
|
|||||||
|
|
||||||
install_packages() {
|
install_packages() {
|
||||||
copy_void_conf $ROOTFS
|
copy_void_conf $ROOTFS
|
||||||
# Check that all pkgs are reachable.
|
|
||||||
XBPS_ARCH=$BASE_ARCH ${XBPS_INSTALL_CMD} -r $ROOTFS \
|
XBPS_ARCH=$BASE_ARCH ${XBPS_INSTALL_CMD} -r $ROOTFS \
|
||||||
$XBPS_REPOSITORY $XBPS_CACHEDIR -yn ${PACKAGE_LIST} ${INITRAMFS_PKGS}
|
$XBPS_REPOSITORY $XBPS_CACHEDIR -yn ${PACKAGE_LIST} ${INITRAMFS_PKGS}
|
||||||
[ $? -ne 0 ] && die "Missing required binary packages, exiting..."
|
[ $? -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}
|
$XBPS_REPOSITORY $XBPS_CACHEDIR -y ${PACKAGE_LIST} ${INITRAMFS_PKGS}
|
||||||
[ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST"
|
[ $? -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.
|
# Enable choosen UTF-8 locale and generate it into the target rootfs.
|
||||||
if [ -f $ROOTFS/etc/default/libc-locales ]; then
|
if [ -f $ROOTFS/etc/default/libc-locales ]; then
|
||||||
sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i $ROOTFS/etc/default/libc-locales
|
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
|
fi
|
||||||
|
chroot $ROOTFS env -i xbps-reconfigure -a
|
||||||
|
|
||||||
if [ -x installer.sh ]; then
|
if [ -x installer.sh ]; then
|
||||||
install -Dm755 installer.sh $ROOTFS/usr/sbin/void-installer
|
install -Dm755 installer.sh $ROOTFS/usr/sbin/void-installer
|
||||||
@ -131,7 +144,7 @@ generate_initramfs() {
|
|||||||
else
|
else
|
||||||
_args="--omit systemd"
|
_args="--omit systemd"
|
||||||
fi
|
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
|
--add-drivers "ahci" --force-add "vmklive" ${_args} "/boot/initrd" $KERNELVERSION
|
||||||
[ $? -ne 0 ] && die "Failed to generate the initramfs"
|
[ $? -ne 0 ] && die "Failed to generate the initramfs"
|
||||||
|
|
||||||
@ -213,6 +226,8 @@ generate_grub_efi_boot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
generate_squashfs() {
|
generate_squashfs() {
|
||||||
|
umount_pseudofs
|
||||||
|
|
||||||
# Find out required size for the rootfs and create an ext3fs image off it.
|
# Find out required size for the rootfs and create an ext3fs image off it.
|
||||||
ROOTFS_SIZE=$(du -sm "$ROOTFS"|awk '{print $1}')
|
ROOTFS_SIZE=$(du -sm "$ROOTFS"|awk '{print $1}')
|
||||||
if [ -z "$ROOTFS_FREESIZE" ]; then
|
if [ -z "$ROOTFS_FREESIZE" ]; then
|
||||||
@ -231,6 +246,7 @@ generate_squashfs() {
|
|||||||
$VOIDHOSTDIR/usr/bin/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"
|
-comp ${SQUASHFS_COMPRESSION} || die "Failed to generate squashfs image"
|
||||||
chmod 444 "$IMAGEDIR/LiveOS/squashfs.img"
|
chmod 444 "$IMAGEDIR/LiveOS/squashfs.img"
|
||||||
|
|
||||||
# Remove rootfs and temporary dirs, we don't need them anymore.
|
# Remove rootfs and temporary dirs, we don't need them anymore.
|
||||||
rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp"
|
rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user