6 Revize bd8b819ec5 ... 95bd021cb2

Autor SHA1 Zpráva Datum
  Naz 95bd021cb2 🔄ci: update xbps before use před 4 dny
  Naz a6be063ed1 Merge pull request #1 from void-linux/master před 4 dny
  Iris Lightshard 906652a494 don't uninstall initramfs packages if they were manually installed by -p před 2 měsíci
  Michael Aldridge baac93706d dracut/autoinstaller: Manipulate /etc/rc.conf less před 3 měsíci
  Michael Aldridge 9d681c609d dracut/autoinstaller: Replace inscrutable awk with inscrutable jq před 3 měsíci
  Michael Aldridge df8a44e1ef dracut/autoinstaller: Handle UEFI systems před 3 měsíci

+ 2 - 1
.github/workflows/gen-images.yml

@@ -13,7 +13,8 @@ jobs:
     steps:
     steps:
       - name: Install required packages
       - name: Install required packages
         run: |
         run: |
-          xbps-install -Syu
+          xbps-install -Syu xbps
+          xbps-install -yu
           xbps-install -y git bash make cdrtools qemu-user-static liblz4 squashfs-tools xorriso xmlto python3 python3-Markdown
           xbps-install -y git bash make cdrtools qemu-user-static liblz4 squashfs-tools xorriso xmlto python3 python3-Markdown
 
 
       - name: Clone void-mklive repository
       - name: Clone void-mklive repository

+ 10 - 8
dracut/autoinstaller/autoinstall.cfg

@@ -4,18 +4,14 @@
 # ===
 # ===
 # Disk Configuration
 # Disk Configuration
 # ===
 # ===
+# disk_expr: jq expression to select the disk from the output of `lsblk --json`
+# default: .blockdevices[0].name
+#disk_expr=".blockdevices[0].name"
+
 # disk: the disk to install to
 # disk: the disk to install to
 # default: the first disk that isn't the installer
 # default: the first disk that isn't the installer
 #disk=/dev/hda
 #disk=/dev/hda
 
 
-# bootpartitionsize: controls how large the boot partition will be
-# default: 500M
-#bootpartitionsize=500M
-
-# swapsize: how large should the swap partition be
-# default: equal to the installed physical memory
-#swapsize=
-
 # ===
 # ===
 # XBPS Configuration
 # XBPS Configuration
 # ===
 # ===
@@ -54,6 +50,12 @@
 # default: en_US.UTF-8
 # default: en_US.UTF-8
 #libclocale=en.US.UTF-8
 #libclocale=en.US.UTF-8
 
 
+# hostname_expr: Expression to derive the hostname from the output of
+# `ip --json -r a`.  The default finds all interfaces that are up and
+# possess a global address, and then picks the first one.
+# hostname_expr: [.[]|select(.operstate=="UP").addr_info.[]|select(.scope=="global").local].[0]
+#hostname_expr='[.[]|select(.operstate=="UP").addr_info.[]|select(.scope=="global").local].[0]'
+
 # hostname: static hostname for the system
 # hostname: static hostname for the system
 # default: derived from DNS
 # default: derived from DNS
 #hostname=VoidLinux
 #hostname=VoidLinux

+ 57 - 36
dracut/autoinstaller/install.sh

@@ -39,28 +39,44 @@ VAI_get_address() {
 
 
 VAI_partition_disk() {
 VAI_partition_disk() {
     # Paritition Disk
     # Paritition Disk
-    sfdisk "${disk}" <<EOF
-,$bootpartitionsize
-,${swapsize}K
-;
+
+    if [ -d /sys/firmware/efi ] ; then
+        VAI_info_msg "Partitioning Disk for UEFI Boot"
+        sfdisk "${disk}" <<EOF
+label: gpt
+,100M,U,
+,,L,
+EOF
+    else
+        VAI_info_msg "Partitioning Disk for BIOS Boot"
+        sfdisk "${disk}" <<EOF
+label: dos
+,,L,*
 EOF
 EOF
+    fi
 }
 }
 
 
 VAI_format_disk() {
 VAI_format_disk() {
     # Make Filesystems
     # Make Filesystems
-    mkfs.ext4 -F "${disk}1"
-    mkfs.ext4 -F "${disk}3"
-    if [ "${swapsize}" -ne 0 ] ; then
-        mkswap -f "${disk}2"
+    if [ -d /sys/firmware/efi ] ; then
+        mkfs.vfat -F32 "${disk}1"
+        mkfs.ext4 -F "${disk}2"
+    else
+        mkfs.ext4 -F "${disk}1"
     fi
     fi
 }
 }
 
 
 VAI_mount_target() {
 VAI_mount_target() {
     # Mount targetfs
     # Mount targetfs
     mkdir -p "${target}"
     mkdir -p "${target}"
-    mount "${disk}3" "${target}"
-    mkdir "${target}/boot"
-    mount "${disk}1" "${target}/boot"
+
+    if [ -d /sys/firmware/efi ] ; then
+        mount "${disk}2" "${target}"
+        mkdir -p "${target}/boot/efi"
+        mount "${disk}1" "${target}/boot/efi"
+    else
+        mount "${disk}1" "${target}"
+    fi
 }
 }
 
 
 VAI_install_xbps_keys() {
 VAI_install_xbps_keys() {
@@ -70,7 +86,12 @@ VAI_install_xbps_keys() {
 
 
 VAI_install_base_system() {
 VAI_install_base_system() {
     # Install a base system
     # Install a base system
-    XBPS_ARCH="${XBPS_ARCH}" xbps-install -Sy -R "${xbpsrepository}" -r /mnt base-system grub
+    _grub="grub"
+    if [ -d /sys/firmware/efi ] ; then
+        _grub="${_grub} grub-x86_64-efi"
+    fi
+
+    XBPS_ARCH="${XBPS_ARCH}" xbps-install -Sy -R "${xbpsrepository}" -r /mnt base-system ${_grub}
 
 
     # Install additional packages
     # Install additional packages
     if [  -n "${pkgs}" ] ; then
     if [  -n "${pkgs}" ] ; then
@@ -80,6 +101,11 @@ VAI_install_base_system() {
 }
 }
 
 
 VAI_prepare_chroot() {
 VAI_prepare_chroot() {
+    # Mount efivars if this is an EFI system
+    if [ -d /sys/firmware/efi ] ; then
+        mount -t efivarfs none /sys/firmware/efi/efivars
+    fi
+
     # Mount dev, bind, proc, etc into chroot
     # Mount dev, bind, proc, etc into chroot
     mount -t proc proc "${target}/proc"
     mount -t proc proc "${target}/proc"
     mount --rbind /sys "${target}/sys"
     mount --rbind /sys "${target}/sys"
@@ -103,14 +129,12 @@ VAI_configure_hostname() {
 }
 }
 
 
 VAI_configure_rc_conf() {
 VAI_configure_rc_conf() {
-    # Set the value of various tokens
-    sed -i "s:Europe/Madrid:${timezone}:" "${target}/etc/rc.conf"
-    sed -i "s:\"es\":\"${keymap}\":" "${target}/etc/rc.conf"
-
-    # Activate various tokens
-    sed -i "s:#HARDWARECLOCK:HARDWARECLOCK:" "${target}/etc/rc.conf"
-    sed -i "s:#TIMEZONE:TIMEZONE:" "${target}/etc/rc.conf"
-    sed -i "s:#KEYMAP:KEYMAP:" "${target}/etc/rc.conf"
+    if [ "${keymap}" != "us" ] ; then
+        sed -i "s:\"es\":\"${keymap}\":" "${target}/etc/rc.conf"
+        sed -i "s:#KEYMAP:KEYMAP:" "${target}/etc/rc.conf"
+    fi
+
+    ln -s "/usr/share/zoneinfo/${timezone}" "${target}/etc/localtime"
 }
 }
 
 
 VAI_add_user() {
 VAI_add_user() {
@@ -128,7 +152,7 @@ VAI_configure_grub() {
     echo "hostonly=yes" > "${target}/etc/dracut.conf.d/hostonly.conf"
     echo "hostonly=yes" > "${target}/etc/dracut.conf.d/hostonly.conf"
 
 
     # Choose the newest kernel
     # Choose the newest kernel
-    kernel_version="$(chroot "${target}" xbps-query linux | awk -F "[-_]" '/pkgver/ {print $2}')"
+    kernel_version="$(xbps-uhelper -r ${target} version linux | sed 's/_.*//')"
 
 
     # Install grub
     # Install grub
     chroot "${target}" grub-install "${disk}"
     chroot "${target}" grub-install "${disk}"
@@ -141,14 +165,13 @@ VAI_configure_grub() {
 VAI_configure_fstab() {
 VAI_configure_fstab() {
     # Grab UUIDs
     # Grab UUIDs
     uuid1="$(blkid -s UUID -o value "${disk}1")"
     uuid1="$(blkid -s UUID -o value "${disk}1")"
-    uuid2="$(blkid -s UUID -o value "${disk}2")"
-    uuid3="$(blkid -s UUID -o value "${disk}3")"
-
-    # Installl UUIDs into /etc/fstab
-    echo "UUID=$uuid3 / ext4 defaults,errors=remount-ro 0 1" >> "${target}/etc/fstab"
-    echo "UUID=$uuid1 /boot ext4 defaults 0 2" >> "${target}/etc/fstab"
-    if [ "${swapsize}" -ne 0 ] ; then
-        echo "UUID=$uuid2 swap swap defaults 0 0" >> "${target}/etc/fstab"
+    if [ -d /sys/firmware/efi ] ; then
+        uuid2="$(blkid -s UUID -o value "${disk}2")"
+        echo "UUID=$uuid1 /boot/efi vfat defaults 0 0" >> "${target}/etc/fstab"
+        echo "UUID=$uuid2 / ext4 defaults,errors=remount-ro 0 1" >> "${target}/etc/fstab"
+
+    else
+        echo "UUID=$uuid1 / ext4 defaults,errors=remount-ro 0 1" >> "${target}/etc/fstab"
     fi
     fi
 }
 }
 
 
@@ -195,11 +218,10 @@ VAI_end_action() {
 
 
 VAI_configure_autoinstall() {
 VAI_configure_autoinstall() {
     # -------------------------- Setup defaults ---------------------------
     # -------------------------- Setup defaults ---------------------------
-    bootpartitionsize="500M"
-    disk="$(lsblk -ipo NAME,TYPE,MOUNTPOINT | awk '{if ($2=="disk") {disks[$1]=0; last=$1} if ($3=="/") {disks[last]++}} END {for (a in disks) {if(disks[a] == 0){print a; break}}}')"
-    hostname="$(ip -4 -o -r a | awk -F'[ ./]' '{x=$7} END {print x}')"
-    # XXX: Set a manual swapsize here if the default doesn't fit your use case
-    swapsize="$(awk -F"\n" '/MemTotal/ {split($0, b, " "); print b[2] }' /proc/meminfo)";
+    disk_expr=".blockdevices[0].name"
+    disk="/dev/$(lsblk --json | jq -r "$disk_expr")"
+    hostname_expr='[.[]|select(.operstate=="UP").addr_info.[]|select(.scope=="global").local].[0]'
+    hostname="$(ip --json -r a | jq -r "$hostname_expr")"
     target="/mnt"
     target="/mnt"
     timezone="America/Chicago"
     timezone="America/Chicago"
     keymap="us"
     keymap="us"
@@ -256,7 +278,7 @@ VAI_main() {
     VAI_print_step "Configuring installer"
     VAI_print_step "Configuring installer"
     VAI_configure_autoinstall
     VAI_configure_autoinstall
 
 
-    VAI_print_step "Configuring disk using scheme 'Atomic'"
+    VAI_print_step "Configuring disk"
     VAI_partition_disk
     VAI_partition_disk
     VAI_format_disk
     VAI_format_disk
 
 
@@ -307,4 +329,3 @@ if getargbool 0 auto  ; then
     # Very important to release this before returning to dracut code
     # Very important to release this before returning to dracut code
     set +e
     set +e
 fi
 fi
-

+ 1 - 1
dracut/autoinstaller/module-setup.sh

@@ -11,7 +11,6 @@ depends() {
 }
 }
 
 
 install() {
 install() {
-    inst /usr/bin/awk
     inst /usr/bin/chmod
     inst /usr/bin/chmod
     inst /usr/bin/chroot
     inst /usr/bin/chroot
     inst /usr/bin/clear
     inst /usr/bin/clear
@@ -21,6 +20,7 @@ install() {
     inst /usr/bin/dhclient-script
     inst /usr/bin/dhclient-script
     inst /usr/bin/halt
     inst /usr/bin/halt
     inst /usr/bin/install
     inst /usr/bin/install
+    inst /usr/bin/jq
     inst /usr/bin/lsblk
     inst /usr/bin/lsblk
     inst /usr/bin/mkdir
     inst /usr/bin/mkdir
     inst /usr/bin/mkfs.ext4
     inst /usr/bin/mkfs.ext4

+ 14 - 6
mklive.sh

@@ -31,7 +31,7 @@ umask 022
 REQUIRED_PKGS=(base-files libgcc dash coreutils sed tar gawk squashfs-tools xorriso)
 REQUIRED_PKGS=(base-files libgcc dash coreutils sed tar gawk squashfs-tools xorriso)
 TARGET_PKGS=(base-files)
 TARGET_PKGS=(base-files)
 INITRAMFS_PKGS=(binutils xz device-mapper dhclient dracut-network openresolv)
 INITRAMFS_PKGS=(binutils xz device-mapper dhclient dracut-network openresolv)
-PACKAGE_LIST=()
+PACKAGE_LIST=(jq)
 IGNORE_PKGS=()
 IGNORE_PKGS=()
 PLATFORMS=()
 PLATFORMS=()
 readonly PROGNAME="$(basename "$0")"
 readonly PROGNAME="$(basename "$0")"
@@ -227,13 +227,21 @@ generate_initramfs() {
 	esac
 	esac
 }
 }
 
 
+array_contains() {
+    local -n arr="$1"
+    local val="$2"
+    printf '%s\0' "${arr[@]}" | grep -Fxqz "$val"
+}
+
 cleanup_rootfs() {
 cleanup_rootfs() {
     for f in "${INITRAMFS_PKGS[@]}"; do
     for f in "${INITRAMFS_PKGS[@]}"; do
-        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
+        if ! array_contains PACKAGE_LIST $f; then
+            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
         fi
         fi
     done
     done
     rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01vmklive
     rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01vmklive

+ 1 - 1
mknet.sh

@@ -170,7 +170,7 @@ else
     info_msg "Selecting u-boot bootloader"
     info_msg "Selecting u-boot bootloader"
     bootloader_pkg=uboot-mkimage
     bootloader_pkg=uboot-mkimage
 fi
 fi
-run_cmd_target "xbps-install $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -Sy ${KERNELPKG-linux} dracut binutils dracut-network dialog ${INITRAMFS_COMPRESSION-xz} ${bootloader_pkg}"
+run_cmd_target "xbps-install $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -Sy ${KERNELPKG-linux} dracut binutils dracut-network dialog jq ${INITRAMFS_COMPRESSION-xz} ${bootloader_pkg}"
 run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a"
 run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a"
 
 
 # Dracut needs to know the kernel version that will be using this
 # Dracut needs to know the kernel version that will be using this