From 3edb26914fe302a0ee2fca571357f006aa981ad7 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Sat, 15 Mar 2025 19:55:22 +0300 Subject: [PATCH] remove unused --- installer.sh | 1614 -------------------------------------------------- lib.sh | 338 ----------- mkiso.sh | 978 ------------------------------ mkmine.sh | 83 --- release.sh | 88 --- 5 files changed, 3101 deletions(-) delete mode 100755 installer.sh delete mode 100755 lib.sh delete mode 100755 mkiso.sh delete mode 100755 mkmine.sh delete mode 100755 release.sh diff --git a/installer.sh b/installer.sh deleted file mode 100755 index c41affc..0000000 --- a/installer.sh +++ /dev/null @@ -1,1614 +0,0 @@ -#!/bin/bash -#- -# Copyright (c) 2012-2015 Juan Romero Pardines . -# 2012 Dave Elusive . -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#- - -# Make sure we don't inherit these from env. -SOURCE_DONE= -HOSTNAME_DONE= -KEYBOARD_DONE= -LOCALE_DONE= -TIMEZONE_DONE= -ROOTPASSWORD_DONE= -USERLOGIN_DONE= -USERPASSWORD_DONE= -USERNAME_DONE= -USERGROUPS_DONE= -USERACCOUNT_DONE= -BOOTLOADER_DONE= -PARTITIONS_DONE= -NETWORK_DONE= -FILESYSTEMS_DONE= -MIRROR_DONE= - -TARGETDIR=/mnt/target -LOG=/dev/tty8 -CONF_FILE=/tmp/.void-installer.conf -if [ ! -f $CONF_FILE ]; then - touch -f $CONF_FILE -fi -ANSWER=$(mktemp -t vinstall-XXXXXXXX || exit 1) -TARGET_SERVICES=$(mktemp -t vinstall-sv-XXXXXXXX || exit 1) -TARGET_FSTAB=$(mktemp -t vinstall-fstab-XXXXXXXX || exit 1) - -trap "DIE" INT TERM QUIT - -# disable printk -if [ -w /proc/sys/kernel/printk ]; then - echo 0 >/proc/sys/kernel/printk -fi - -# Detect if this is an EFI system. -if [ -e /sys/firmware/efi/systab ]; then - EFI_SYSTEM=1 - EFI_FW_BITS=$(cat /sys/firmware/efi/fw_platform_size) - if [ $EFI_FW_BITS -eq 32 ]; then - EFI_TARGET=i386-efi - else - EFI_TARGET=x86_64-efi - fi -fi - -# dialog colors -BLACK="\Z0" -RED="\Z1" -GREEN="\Z2" -YELLOW="\Z3" -BLUE="\Z4" -MAGENTA="\Z5" -CYAN="\Z6" -WHITE="\Z7" -BOLD="\Zb" -REVERSE="\Zr" -UNDERLINE="\Zu" -RESET="\Zn" - -# Properties shared per widget. -MENULABEL="${BOLD}Use UP and DOWN keys to navigate \ -menus. Use TAB to switch between buttons and ENTER to select.${RESET}" -MENUSIZE="14 60 0" -INPUTSIZE="8 60" -MSGBOXSIZE="8 70" -YESNOSIZE="$INPUTSIZE" -WIDGET_SIZE="10 70" - -DIALOG() { - rm -f $ANSWER - dialog --colors --keep-tite --no-shadow --no-mouse \ - --backtitle "${BOLD}${WHITE}Void Linux installation -- https://www.voidlinux.org (@@MKLIVE_VERSION@@)${RESET}" \ - --cancel-label "Back" --aspect 20 "$@" 2>$ANSWER - return $? -} - -INFOBOX() { - # Note: dialog --infobox and --keep-tite don't work together - dialog --colors --no-shadow --no-mouse \ - --backtitle "${BOLD}${WHITE}Void Linux installation -- https://www.voidlinux.org (@@MKLIVE_VERSION@@)${RESET}" \ - --title "${TITLE}" --aspect 20 --infobox "$@" -} - -DIE() { - rval=$1 - [ -z "$rval" ] && rval=0 - clear - rm -f $ANSWER $TARGET_FSTAB $TARGET_SERVICES - # reenable printk - if [ -w /proc/sys/kernel/printk ]; then - echo 4 >/proc/sys/kernel/printk - fi - umount_filesystems - exit $rval -} - -set_option() { - if grep -Eq "^${1} .*" $CONF_FILE; then - sed -i -e "/^${1} .*/d" $CONF_FILE - fi - echo "${1} ${2}" >>$CONF_FILE -} - -get_option() { - grep -E "^${1} .*" $CONF_FILE | sed -e "s|^${1} ||" -} - -# ISO-639 language names for locales -iso639_language() { - case "$1" in - aa) echo "Afar" ;; - af) echo "Afrikaans" ;; - an) echo "Aragonese" ;; - ar) echo "Arabic" ;; - ast) echo "Asturian" ;; - be) echo "Belgian" ;; - bg) echo "Bulgarian" ;; - bhb) echo "Bhili" ;; - br) echo "Breton" ;; - bs) echo "Bosnian" ;; - ca) echo "Catalan" ;; - cs) echo "Czech" ;; - cy) echo "Welsh" ;; - da) echo "Danish" ;; - de) echo "German" ;; - el) echo "Greek" ;; - en) echo "English" ;; - es) echo "Spanish" ;; - et) echo "Estonian" ;; - eu) echo "Basque" ;; - fi) echo "Finnish" ;; - fo) echo "Faroese" ;; - fr) echo "French" ;; - ga) echo "Irish" ;; - gd) echo "Scottish Gaelic" ;; - gl) echo "Galician" ;; - gv) echo "Manx" ;; - he) echo "Hebrew" ;; - hr) echo "Croatian" ;; - hsb) echo "Upper Sorbian" ;; - hu) echo "Hungarian" ;; - id) echo "Indonesian" ;; - is) echo "Icelandic" ;; - it) echo "Italian" ;; - iw) echo "Hebrew" ;; - ja) echo "Japanese" ;; - ka) echo "Georgian" ;; - kk) echo "Kazakh" ;; - kl) echo "Kalaallisut" ;; - ko) echo "Korean" ;; - ku) echo "Kurdish" ;; - kw) echo "Cornish" ;; - lg) echo "Ganda" ;; - lt) echo "Lithuanian" ;; - lv) echo "Latvian" ;; - mg) echo "Malagasy" ;; - mi) echo "Maori" ;; - mk) echo "Macedonian" ;; - ms) echo "Malay" ;; - mt) echo "Maltese" ;; - nb) echo "Norwegian Bokmål" ;; - nl) echo "Dutch" ;; - nn) echo "Norwegian Nynorsk" ;; - oc) echo "Occitan" ;; - om) echo "Oromo" ;; - pl) echo "Polish" ;; - pt) echo "Portugese" ;; - ro) echo "Romanian" ;; - ru) echo "Russian" ;; - sk) echo "Slovak" ;; - sl) echo "Slovenian" ;; - so) echo "Somali" ;; - sq) echo "Albanian" ;; - st) echo "Southern Sotho" ;; - sv) echo "Swedish" ;; - tcy) echo "Tulu" ;; - tg) echo "Tajik" ;; - th) echo "Thai" ;; - tl) echo "Tagalog" ;; - tr) echo "Turkish" ;; - uk) echo "Ukrainian" ;; - uz) echo "Uzbek" ;; - wa) echo "Walloon" ;; - xh) echo "Xhosa" ;; - yi) echo "Yiddish" ;; - zh) echo "Chinese" ;; - zu) echo "Zulu" ;; - *) echo "$1" ;; - esac -} - -# ISO-3166 country codes for locales -iso3166_country() { - case "$1" in - AD) echo "Andorra" ;; - AE) echo "United Arab Emirates" ;; - AL) echo "Albania" ;; - AR) echo "Argentina" ;; - AT) echo "Austria" ;; - AU) echo "Australia" ;; - BA) echo "Bonsia and Herzegovina" ;; - BE) echo "Belgium" ;; - BG) echo "Bulgaria" ;; - BH) echo "Bahrain" ;; - BO) echo "Bolivia" ;; - BR) echo "Brazil" ;; - BW) echo "Botswana" ;; - BY) echo "Belarus" ;; - CA) echo "Canada" ;; - CH) echo "Switzerland" ;; - CL) echo "Chile" ;; - CN) echo "China" ;; - CO) echo "Colombia" ;; - CR) echo "Costa Rica" ;; - CY) echo "Cyprus" ;; - CZ) echo "Czech Republic" ;; - DE) echo "Germany" ;; - DJ) echo "Djibouti" ;; - DK) echo "Denmark" ;; - DO) echo "Dominican Republic" ;; - DZ) echo "Algeria" ;; - EC) echo "Ecuador" ;; - EE) echo "Estonia" ;; - EG) echo "Egypt" ;; - ES) echo "Spain" ;; - FI) echo "Finland" ;; - FO) echo "Faroe Islands" ;; - FR) echo "France" ;; - GB) echo "Great Britain" ;; - GE) echo "Georgia" ;; - GL) echo "Greenland" ;; - GR) echo "Greece" ;; - GT) echo "Guatemala" ;; - HK) echo "Hong Kong" ;; - HN) echo "Honduras" ;; - HR) echo "Croatia" ;; - HU) echo "Hungary" ;; - ID) echo "Indonesia" ;; - IE) echo "Ireland" ;; - IL) echo "Israel" ;; - IN) echo "India" ;; - IQ) echo "Iraq" ;; - IS) echo "Iceland" ;; - IT) echo "Italy" ;; - JO) echo "Jordan" ;; - JP) echo "Japan" ;; - KE) echo "Kenya" ;; - KR) echo "Korea, Republic of" ;; - KW) echo "Kuwait" ;; - KZ) echo "Kazakhstan" ;; - LB) echo "Lebanon" ;; - LT) echo "Lithuania" ;; - LU) echo "Luxembourg" ;; - LV) echo "Latvia" ;; - LY) echo "Libya" ;; - MA) echo "Morocco" ;; - MG) echo "Madagascar" ;; - MK) echo "Macedonia" ;; - MT) echo "Malta" ;; - MX) echo "Mexico" ;; - MY) echo "Malaysia" ;; - NI) echo "Nicaragua" ;; - NL) echo "Netherlands" ;; - NO) echo "Norway" ;; - NZ) echo "New Zealand" ;; - OM) echo "Oman" ;; - PA) echo "Panama" ;; - PE) echo "Peru" ;; - PH) echo "Philippines" ;; - PL) echo "Poland" ;; - PR) echo "Puerto Rico" ;; - PT) echo "Portugal" ;; - PY) echo "Paraguay" ;; - QA) echo "Qatar" ;; - RO) echo "Romania" ;; - RU) echo "Russian Federation" ;; - SA) echo "Saudi Arabia" ;; - SD) echo "Sudan" ;; - SE) echo "Sweden" ;; - SG) echo "Singapore" ;; - SI) echo "Slovenia" ;; - SK) echo "Slovakia" ;; - SO) echo "Somalia" ;; - SV) echo "El Salvador" ;; - SY) echo "Syria" ;; - TH) echo "Thailand" ;; - TJ) echo "Tajikistan" ;; - TN) echo "Tunisia" ;; - TR) echo "Turkey" ;; - TW) echo "Taiwan" ;; - UA) echo "Ukraine" ;; - UG) echo "Uganda" ;; - US) echo "United States of America" ;; - UY) echo "Uruguay" ;; - UZ) echo "Uzbekistan" ;; - VE) echo "Venezuela" ;; - YE) echo "Yemen" ;; - ZA) echo "South Africa" ;; - ZW) echo "Zimbabwe" ;; - *) echo "$1" ;; - esac -} - -show_disks() { - local dev size sectorsize gbytes - - # IDE - for dev in $(ls /sys/block|grep -E '^hd'); do - if [ "$(cat /sys/block/$dev/device/media)" = "disk" ]; then - # Find out nr sectors and bytes per sector; - echo "/dev/$dev" - size=$(cat /sys/block/$dev/size) - sectorsize=$(cat /sys/block/$dev/queue/hw_sector_size) - gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))" - echo "size:${gbytes}GB;sector_size:$sectorsize" - fi - done - # SATA/SCSI and Virtual disks (virtio) - for dev in $(ls /sys/block|grep -E '^([sv]|xv)d|mmcblk|nvme'); do - echo "/dev/$dev" - size=$(cat /sys/block/$dev/size) - sectorsize=$(cat /sys/block/$dev/queue/hw_sector_size) - gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))" - echo "size:${gbytes}GB;sector_size:$sectorsize" - done - # cciss(4) devices - for dev in $(ls /dev/cciss 2>/dev/null|grep -E 'c[0-9]d[0-9]$'); do - echo "/dev/cciss/$dev" - size=$(cat /sys/block/cciss\!$dev/size) - sectorsize=$(cat /sys/block/cciss\!$dev/queue/hw_sector_size) - gbytes="$(($size * $sectorsize / 1024 / 1024 / 1024))" - echo "size:${gbytes}GB;sector_size:$sectorsize" - done -} - -get_partfs() { - # Get fs type from configuration if available. This ensures - # that the user is shown the proper fs type if they install the system. - local part="$1" - local default="${2:-none}" - local fstype=$(grep "MOUNTPOINT ${part} " "$CONF_FILE"|awk '{print $3}') - echo "${fstype:-$default}" -} - -show_partitions() { - local dev fstype fssize p part - - set -- $(show_disks) - while [ $# -ne 0 ]; do - disk=$(basename $1) - shift 2 - # ATA/SCSI/SATA - for p in /sys/block/$disk/$disk*; do - if [ -d $p ]; then - part=$(basename $p) - fstype=$(lsblk -nfr /dev/$part|awk '{print $2}'|head -1) - [ "$fstype" = "iso9660" ] && continue - [ "$fstype" = "crypto_LUKS" ] && continue - [ "$fstype" = "LVM2_member" ] && continue - fssize=$(lsblk -nr /dev/$part|awk '{print $4}'|head -1) - echo "/dev/$part" - echo "size:${fssize:-unknown};fstype:$(get_partfs "/dev/$part")" - fi - done - done - # Device Mapper - for p in /dev/mapper/*; do - part=$(basename $p) - [ "${part}" = "live-rw" ] && continue - [ "${part}" = "live-base" ] && continue - [ "${part}" = "control" ] && continue - - fstype=$(lsblk -nfr $p|awk '{print $2}'|head -1) - fssize=$(lsblk -nr $p|awk '{print $4}'|head -1) - echo "${p}" - echo "size:${fssize:-unknown};fstype:$(get_partfs "$p")" - done - # Software raid (md) - for p in $(ls -d /dev/md* 2>/dev/null|grep '[0-9]'); do - part=$(basename $p) - if cat /proc/mdstat|grep -qw $part; then - fstype=$(lsblk -nfr /dev/$part|awk '{print $2}') - [ "$fstype" = "crypto_LUKS" ] && continue - [ "$fstype" = "LVM2_member" ] && continue - fssize=$(lsblk -nr /dev/$part|awk '{print $4}') - echo "$p" - echo "size:${fssize:-unknown};fstype:$(get_partfs "$p")" - fi - done - # cciss(4) devices - for part in $(ls /dev/cciss 2>/dev/null|grep -E 'c[0-9]d[0-9]p[0-9]+'); do - fstype=$(lsblk -nfr /dev/cciss/$part|awk '{print $2}') - [ "$fstype" = "crypto_LUKS" ] && continue - [ "$fstype" = "LVM2_member" ] && continue - fssize=$(lsblk -nr /dev/cciss/$part|awk '{print $4}') - echo "/dev/cciss/$part" - echo "size:${fssize:-unknown};fstype:$(get_partfs "/dev/cciss/$part")" - done - if [ -e /sbin/lvs ]; then - # LVM - lvs --noheadings|while read lvname vgname perms size; do - echo "/dev/mapper/${vgname}-${lvname}" - echo "size:${size};fstype:$(get_partfs "/dev/mapper/${vgname}-${lvname}" lvm)" - done - fi -} - -menu_filesystems() { - local dev fstype fssize mntpoint reformat - - while true; do - DIALOG --ok-label "Change" --cancel-label "Done" \ - --title " Select the partition to edit " --menu "$MENULABEL" \ - ${MENUSIZE} $(show_partitions) - [ $? -ne 0 ] && return - - dev=$(cat $ANSWER) - DIALOG --title " Select the filesystem type for $dev " \ - --menu "$MENULABEL" ${MENUSIZE} \ - "btrfs" "Oracle's Btrfs" \ - "ext2" "Linux ext2 (no journaling)" \ - "ext3" "Linux ext3 (journal)" \ - "ext4" "Linux ext4 (journal)" \ - "f2fs" "Flash-Friendly Filesystem" \ - "swap" "Linux swap" \ - "vfat" "FAT32" \ - "xfs" "SGI's XFS" - if [ $? -eq 0 ]; then - fstype=$(cat $ANSWER) - else - continue - fi - if [ "$fstype" != "swap" ]; then - DIALOG --inputbox "Please specify the mount point for $dev:" ${INPUTSIZE} - if [ $? -eq 0 ]; then - mntpoint=$(cat $ANSWER) - elif [ $? -eq 1 ]; then - continue - fi - else - mntpoint=swap - fi - DIALOG --yesno "Do you want to create a new filesystem on $dev?" ${YESNOSIZE} - if [ $? -eq 0 ]; then - reformat=1 - elif [ $? -eq 1 ]; then - reformat=0 - else - continue - fi - fssize=$(lsblk -nr $dev|awk '{print $4}') - set -- "$fstype" "$fssize" "$mntpoint" "$reformat" - if [ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ]; then - local bdev=$(basename $dev) - local ddev=$(basename $(dirname $dev)) - if [ "$ddev" != "dev" ]; then - sed -i -e "/^MOUNTPOINT \/dev\/${ddev}\/${bdev} .*/d" $CONF_FILE - else - sed -i -e "/^MOUNTPOINT \/dev\/${bdev} .*/d" $CONF_FILE - fi - echo "MOUNTPOINT $dev $1 $2 $3 $4" >>$CONF_FILE - fi - done - FILESYSTEMS_DONE=1 -} - -menu_partitions() { - DIALOG --title " Select the disk to partition " \ - --menu "$MENULABEL" ${MENUSIZE} $(show_disks) - if [ $? -eq 0 ]; then - local device=$(cat $ANSWER) - - DIALOG --title " Select the software for partitioning " \ - --menu "$MENULABEL" ${MENUSIZE} \ - "cfdisk" "Easy to use" \ - "fdisk" "More advanced" - if [ $? -eq 0 ]; then - local software=$(cat $ANSWER) - - DIALOG --title "Modify Partition Table on $device" --msgbox "\n -${BOLD}${software} will be executed in disk $device.${RESET}\n\n -For BIOS systems, MBR or GPT partition tables are supported. To use GPT\n -on PC BIOS systems, an empty partition of 1MB must be added at the first\n -2GB of the disk with the partition type \`BIOS Boot'.\n -${BOLD}NOTE: you don't need this on EFI systems.${RESET}\n\n -For EFI systems, GPT is mandatory and a FAT32 partition with at least 100MB\n -must be created with the partition type \`EFI System'. This will be used as\n -the EFI System Partition. This partition must have the mountpoint \`/boot/efi'.\n\n -At least 1 partition is required for the rootfs (/). For this partition,\n -at least 2GB is required, but more is recommended. The rootfs partition\n -should have the partition type \`Linux Filesystem'. For swap, RAM*2\n -should be enough and the partition type \`Linux swap' should be used.\n\n -${BOLD}WARNING: /usr is not supported as a separate partition.${RESET}\n -${RESET}\n" 23 80 - if [ $? -eq 0 ]; then - while true; do - clear; $software $device; PARTITIONS_DONE=1 - break - done - else - return - fi - fi - fi -} - -menu_keymap() { - local _keymaps="$(find /usr/share/kbd/keymaps/ -type f -iname "*.map.gz" -printf "%f\n" | sed 's|.map.gz||g' | sort)" - local _KEYMAPS= - - for f in ${_keymaps}; do - _KEYMAPS="${_KEYMAPS} ${f} -" - done - while true; do - DIALOG --title " Select your keymap " --menu "$MENULABEL" 14 70 14 ${_KEYMAPS} - if [ $? -eq 0 ]; then - set_option KEYMAP "$(cat $ANSWER)" - loadkeys "$(cat $ANSWER)" - KEYBOARD_DONE=1 - break - else - return - fi - done -} - -set_keymap() { - local KEYMAP=$(get_option KEYMAP) - - if [ -f /etc/vconsole.conf ]; then - sed -i -e "s|KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/vconsole.conf - else - sed -i -e "s|#\?KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/rc.conf - fi -} - -menu_locale() { - local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')" - local LOCALES ISO639 ISO3166 - local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1) - INFOBOX "Scanning locales ..." 4 60 - for f in ${_locales}; do - eval $(echo $f | awk 'BEGIN { FS="." } \ - { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }') - echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE - done - clear - # Sort by ISO-639 language names - LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g') - rm -f $TMPFILE - while true; do - (IFS="|"; DIALOG --title " Select your locale " --menu "$MENULABEL" 18 70 18 ${LOCALES}) - if [ $? -eq 0 ]; then - set_option LOCALE "$(cat $ANSWER)" - LOCALE_DONE=1 - break - else - return - fi - done -} - -set_locale() { - if [ -f $TARGETDIR/etc/default/libc-locales ]; then - local LOCALE="$(get_option LOCALE)" - : "${LOCALE:=C.UTF-8}" - sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf - # Uncomment locale from /etc/default/libc-locales and regenerate it. - sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales - echo "Running xbps-reconfigure -f glibc-locales ..." >$LOG - chroot $TARGETDIR xbps-reconfigure -f glibc-locales >$LOG 2>&1 - fi -} - -menu_timezone() { - local areas=(Africa America Antarctica Arctic Asia Atlantic Australia Europe Indian Pacific) - - local area locations location - while (IFS='|'; DIALOG ${area:+--default-item|"$area"} --title " Select area " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${areas[@]}")); do - area=$(cat $ANSWER) - read -a locations -d '\n' < <(find /usr/share/zoneinfo/$area -type f -printf '%P\n' | sort) - if (IFS='|'; DIALOG --title " Select location (${area}) " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${locations[@]//_/ }")); then - location=$(tr ' ' '_' < $ANSWER) - set_option TIMEZONE "$area/$location" - TIMEZONE_DONE=1 - return 0 - else - continue - fi - done - return 1 -} - -set_timezone() { - local TIMEZONE="$(get_option TIMEZONE)" - - ln -sf "/usr/share/zoneinfo/${TIMEZONE}" "${TARGETDIR}/etc/localtime" -} - -menu_hostname() { - while true; do - DIALOG --inputbox "Set the machine hostname:" ${INPUTSIZE} - if [ $? -eq 0 ]; then - set_option HOSTNAME "$(cat $ANSWER)" - HOSTNAME_DONE=1 - break - else - return - fi - done -} - -set_hostname() { - local hostname="$(get_option HOSTNAME)" - echo "${hostname:-void}" > $TARGETDIR/etc/hostname -} - -menu_rootpassword() { - local _firstpass _secondpass _again _desc - - while true; do - if [ -z "${_firstpass}" ]; then - _desc="Enter the root password" - else - _again=" again" - fi - DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE} - if [ $? -eq 0 ]; then - if [ -z "${_firstpass}" ]; then - _firstpass="$(cat $ANSWER)" - else - _secondpass="$(cat $ANSWER)" - fi - if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then - if [ "${_firstpass}" != "${_secondpass}" ]; then - INFOBOX "Passwords do not match! Please enter again." 6 60 - unset _firstpass _secondpass _again - sleep 2 && clear && continue - fi - set_option ROOTPASSWORD "${_firstpass}" - ROOTPASSWORD_DONE=1 - break - fi - else - return - fi - done -} - -set_rootpassword() { - echo "root:$(get_option ROOTPASSWORD)" | chroot $TARGETDIR chpasswd -c SHA512 -} - -menu_useraccount() { - local _firstpass _secondpass _desc _again - local _groups _status _group _checklist - local _preset _userlogin - - while true; do - _preset=$(get_option USERLOGIN) - [ -z "$_preset" ] && _preset="void" - DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset" - if [ $? -eq 0 ]; then - _userlogin="$(cat $ANSWER)" - # based on useradd(8) § Caveats - if [ "${#_userlogin}" -le 32 ] && [[ "${_userlogin}" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]]; then - set_option USERLOGIN "${_userlogin}" - USERLOGIN_DONE=1 - break - else - INFOBOX "Invalid login name! Please try again." 6 60 - unset _userlogin - sleep 2 && clear && continue - fi - else - return - fi - done - - while true; do - _preset=$(get_option USERNAME) - [ -z "$_preset" ] && _preset="Void User" - DIALOG --inputbox "Enter a display name for login '$(get_option USERLOGIN)' :" \ - ${INPUTSIZE} "$_preset" - if [ $? -eq 0 ]; then - set_option USERNAME "$(cat $ANSWER)" - USERNAME_DONE=1 - break - else - return - fi - done - - while true; do - if [ -z "${_firstpass}" ]; then - _desc="Enter the password for login '$(get_option USERLOGIN)'" - else - _again=" again" - fi - DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE} - if [ $? -eq 0 ]; then - if [ -z "${_firstpass}" ]; then - _firstpass="$(cat $ANSWER)" - else - _secondpass="$(cat $ANSWER)" - fi - if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then - if [ "${_firstpass}" != "${_secondpass}" ]; then - INFOBOX "Passwords do not match! Please enter again." 6 60 - unset _firstpass _secondpass _again - sleep 2 && clear && continue - fi - set_option USERPASSWORD "${_firstpass}" - USERPASSWORD_DONE=1 - break - fi - else - return - fi - done - - _groups="wheel,audio,video,floppy,cdrom,optical,kvm,users,xbuilder" - while true; do - _desc="Select group membership for login '$(get_option USERLOGIN)':" - for _group in $(cat /etc/group); do - _gid="$(echo ${_group} | cut -d: -f3)" - _group="$(echo ${_group} | cut -d: -f1)" - _status="$(echo ${_groups} | grep -w ${_group})" - if [ -z "${_status}" ]; then - _status=off - else - _status=on - fi - # ignore the groups of root, existing users, and package groups - if [[ "${_gid}" -ge 1000 || "${_group}" = "_"* || "${_group}" =~ ^(root|nogroup|chrony|dbus|lightdm|polkitd)$ ]]; then - continue - fi - if [ -z "${_checklist}" ]; then - _checklist="${_group} ${_group}:${_gid} ${_status}" - else - _checklist="${_checklist} ${_group} ${_group}:${_gid} ${_status}" - fi - done - DIALOG --no-tags --checklist "${_desc}" 20 60 18 ${_checklist} - if [ $? -eq 0 ]; then - set_option USERGROUPS $(cat $ANSWER | sed -e's| |,|g') - USERGROUPS_DONE=1 - break - else - return - fi - done -} - -set_useraccount() { - [ -z "$USERACCOUNT_DONE" ] && return - chroot $TARGETDIR useradd -m -G "$(get_option USERGROUPS)" \ - -c "$(get_option USERNAME)" "$(get_option USERLOGIN)" - echo "$(get_option USERLOGIN):$(get_option USERPASSWORD)" | \ - chroot $TARGETDIR chpasswd -c SHA512 -} - -menu_bootloader() { - while true; do - DIALOG --title " Select the disk to install the bootloader" \ - --menu "$MENULABEL" ${MENUSIZE} $(show_disks) none "Manage bootloader otherwise" - if [ $? -eq 0 ]; then - set_option BOOTLOADER "$(cat $ANSWER)" - BOOTLOADER_DONE=1 - break - else - return - fi - done - while true; do - DIALOG --yesno "Use a graphical terminal for the boot loader?" ${YESNOSIZE} - if [ $? -eq 0 ]; then - set_option TEXTCONSOLE 0 - break - elif [ $? -eq 1 ]; then - set_option TEXTCONSOLE 1 - break - else - return - fi - done -} - -set_bootloader() { - local dev=$(get_option BOOTLOADER) grub_args= - - if [ "$dev" = "none" ]; then return; fi - - # Check if it's an EFI system via efivars module. - if [ -n "$EFI_SYSTEM" ]; then - grub_args="--target=$EFI_TARGET --efi-directory=/boot/efi --bootloader-id=void_grub --recheck" - fi - echo "Running grub-install $grub_args $dev..." >$LOG - chroot $TARGETDIR grub-install $grub_args $dev >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to install GRUB to $dev!\nCheck $LOG for errors." ${MSGBOXSIZE} - DIE 1 - fi - echo "Running grub-mkconfig on $TARGETDIR..." >$LOG - chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ -failed to run grub-mkconfig!\nCheck $LOG for errors." ${MSGBOXSIZE} - DIE 1 - fi -} - -test_network() { - # Reset the global variable to ensure that network is accessible for this test. - NETWORK_DONE= - - rm -f otime && \ - xbps-uhelper fetch https://repo-default.voidlinux.org/current/otime >$LOG 2>&1 - local status=$? - rm -f otime - - if [ "$status" -eq 0 ]; then - DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE} - NETWORK_DONE=1 - return 1 - fi - if [ "$1" = "nm" ]; then - DIALOG --msgbox "Network Manager is enabled but network is inaccessible, please set it up externally with nmcli, nmtui, or the Network Manager tray applet." ${MSGBOXSIZE} - else - DIALOG --msgbox "Network is inaccessible, please set it up properly." ${MSGBOXSIZE} - fi -} - -configure_wifi() { - local dev="$1" ssid enc pass _wpasupconf=/etc/wpa_supplicant/wpa_supplicant.conf - - DIALOG --form "Wireless configuration for ${dev}\n(encryption type: wep or wpa)" 0 0 0 \ - "SSID:" 1 1 "" 1 16 30 0 \ - "Encryption:" 2 1 "" 2 16 4 3 \ - "Password:" 3 1 "" 3 16 63 0 || return 1 - readarray -t values <<<$(cat $ANSWER) - ssid="${values[0]}"; enc="${values[1]}"; pass="${values[2]}" - - if [ -z "$ssid" ]; then - DIALOG --msgbox "Invalid SSID." ${MSGBOXSIZE} - return 1 - elif [ -z "$enc" -o "$enc" != "wep" -a "$enc" != "wpa" ]; then - DIALOG --msgbox "Invalid encryption type (possible values: wep or wpa)." ${MSGBOXSIZE} - return 1 - elif [ -z "$pass" ]; then - DIALOG --msgbox "Invalid AP password." ${MSGBOXSIZE} - fi - - # reset the configuration to the default, if necessary - # otherwise backup the configuration - if [ -f ${_wpasupconf}.orig ]; then - cp -f ${_wpasupconf}.orig ${_wpasupconf} - else - cp -f ${_wpasupconf} ${_wpasupconf}.orig - fi - if [ "$enc" = "wep" ]; then - cat << EOF >> ${_wpasupconf} -network={ - ssid="$ssid" - wep_key0="$pass" - wep_tx_keyidx=0 - auth_alg=SHARED -} -EOF - else - wpa_passphrase "$ssid" "$pass" >> ${_wpasupconf} - fi - - sv restart wpa_supplicant - configure_net_dhcp $dev - return $? -} - -configure_net() { - local dev="$1" rval - - DIALOG --yesno "Do you want to use DHCP for $dev?" ${YESNOSIZE} - rval=$? - if [ $rval -eq 0 ]; then - configure_net_dhcp $dev - elif [ $rval -eq 1 ]; then - configure_net_static $dev - fi -} - -iface_setup() { - ip addr show dev $1 | grep -q -e 'inet ' -e 'inet6 ' - return $? -} - -configure_net_dhcp() { - local dev="$1" - - iface_setup $dev - if [ $? -eq 1 ]; then - sv restart dhcpcd 2>&1 | tee $LOG | \ - DIALOG --progressbox "Initializing $dev via DHCP..." ${WIDGET_SIZE} - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to run dhcpcd. See $LOG for details." ${MSGBOXSIZE} - return 1 - fi - export -f iface_setup - timeout 10s bash -c "while true; do iface_setup $dev; sleep 0.25; done" - if [ $? -eq 1 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} DHCP request failed for $dev. Check $LOG for errors." ${MSGBOXSIZE} - return 1 - fi - fi - test_network - if [ $? -eq 1 ]; then - set_option NETWORK "${dev} dhcp" - fi -} - -configure_net_static() { - local ip gw dns1 dns2 dev=$1 - - DIALOG --form "Static IP configuration for $dev:" 0 0 0 \ - "IP address:" 1 1 "192.168.0.2" 1 21 20 0 \ - "Gateway:" 2 1 "192.168.0.1" 2 21 20 0 \ - "DNS Primary" 3 1 "8.8.8.8" 3 21 20 0 \ - "DNS Secondary" 4 1 "8.8.4.4" 4 21 20 0 || return 1 - - set -- $(cat $ANSWER) - ip=$1; gw=$2; dns1=$3; dns2=$4 - echo "running: ip link set dev $dev up" >$LOG - ip link set dev $dev up >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to bring $dev interface." ${MSGBOXSIZE} - return 1 - fi - echo "running: ip addr add $ip dev $dev" >$LOG - ip addr add $ip dev $dev >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to set ip to the $dev interface." ${MSGBOXSIZE} - return 1 - fi - ip route add default via $gw >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to setup your gateway." ${MSGBOXSIZE} - return 1 - fi - echo "nameserver $dns1" >/etc/resolv.conf - echo "nameserver $dns2" >>/etc/resolv.conf - test_network - if [ $? -eq 1 ]; then - set_option NETWORK "${dev} static $ip $gw $dns1 $dns2" - fi -} - -menu_network() { - local dev addr f DEVICES - - if [ -e /var/service/NetworkManager ]; then - test_network nm - return - fi - - for f in $(ls /sys/class/net); do - [ "$f" = "lo" ] && continue - addr=$(cat /sys/class/net/$f/address) - DEVICES="$DEVICES $f $addr" - done - DIALOG --title " Select the network interface to configure " \ - --menu "$MENULABEL" ${MENUSIZE} ${DEVICES} - if [ $? -eq 0 ]; then - dev=$(cat $ANSWER) - if $(echo $dev|egrep -q "^wl.*" 2>/dev/null); then - configure_wifi $dev - else - configure_net $dev - fi - fi -} - -validate_useraccount() { - # don't check that USERNAME has been set because it can be empty - local USERLOGIN=$(get_option USERLOGIN) - local USERPASSWORD=$(get_option USERPASSWORD) - local USERGROUPS=$(get_option USERGROUPS) - - if [ -n "$USERLOGIN" ] && [ -n "$USERPASSWORD" ] && [ -n "$USERGROUPS" ]; then - USERACCOUNT_DONE=1 - fi -} - -validate_filesystems() { - local mnts dev size fstype mntpt mkfs rootfound fmt - local usrfound efi_system_partition - local bootdev=$(get_option BOOTLOADER) - - unset TARGETFS - mnts=$(grep -E '^MOUNTPOINT .*' $CONF_FILE) - set -- ${mnts} - while [ $# -ne 0 ]; do - fmt="" - dev=$2; fstype=$3; size=$4; mntpt="$5"; mkfs=$6 - shift 6 - - if [ "$mntpt" = "/" ]; then - rootfound=1 - elif [ "$mntpt" = "/usr" ]; then - usrfound=1 - elif [ "$fstype" = "vfat" -a "$mntpt" = "/boot/efi" ]; then - efi_system_partition=1 - fi - if [ "$mkfs" -eq 1 ]; then - fmt="NEW FILESYSTEM: " - fi - if [ -z "$TARGETFS" ]; then - TARGETFS="${fmt}$dev ($size) mounted on $mntpt as ${fstype}\n" - else - TARGETFS="${TARGETFS}${fmt}${dev} ($size) mounted on $mntpt as ${fstype}\n" - fi - done - if [ -z "$rootfound" ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -the mount point for the root filesystem (/) has not yet been configured." ${MSGBOXSIZE} - return 1 - elif [ -n "$usrfound" ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -/usr mount point has been configured but is not supported, please remove it to continue." ${MSGBOXSIZE} - return 1 - elif [ -n "$EFI_SYSTEM" -a "$bootdev" != "none" -a -z "$efi_system_partition" ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -The EFI System Partition has not yet been configured, please create it\n -as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE} - return 1 - fi - FILESYSTEMS_DONE=1 -} - -create_filesystems() { - local mnts dev mntpt fstype fspassno mkfs size rv uuid - - mnts=$(grep -E '^MOUNTPOINT .*' $CONF_FILE | sort -k 5) - set -- ${mnts} - while [ $# -ne 0 ]; do - dev=$2; fstype=$3; mntpt="$5"; mkfs=$6 - shift 6 - - # swap partitions - if [ "$fstype" = "swap" ]; then - swapoff $dev >/dev/null 2>&1 - if [ "$mkfs" -eq 1 ]; then - mkswap $dev >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to create swap on ${dev}!\ncheck $LOG for errors." ${MSGBOXSIZE} - DIE 1 - fi - fi - swapon $dev >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} - DIE 1 - fi - # Add entry for target fstab - uuid=$(blkid -o value -s UUID "$dev") - echo "UUID=$uuid none swap defaults 0 0" >>$TARGET_FSTAB - continue - fi - - if [ "$mkfs" -eq 1 ]; then - case "$fstype" in - btrfs) MKFS="mkfs.btrfs -f"; modprobe btrfs >$LOG 2>&1;; - ext2) MKFS="mke2fs -F"; modprobe ext2 >$LOG 2>&1;; - ext3) MKFS="mke2fs -F -j"; modprobe ext3 >$LOG 2>&1;; - ext4) MKFS="mke2fs -F -t ext4"; modprobe ext4 >$LOG 2>&1;; - f2fs) MKFS="mkfs.f2fs -f"; modprobe f2fs >$LOG 2>&1;; - vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;; - xfs) MKFS="mkfs.xfs -f -i sparse=0"; modprobe xfs >$LOG 2>&1;; - esac - TITLE="Check $LOG for details ..." - INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60 - echo "Running $MKFS $dev..." >$LOG - $MKFS $dev >$LOG 2>&1; rv=$? - if [ $rv -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to create filesystem $fstype on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} - DIE 1 - fi - fi - # Mount rootfs the first one. - [ "$mntpt" != "/" ] && continue - mkdir -p $TARGETDIR - echo "Mounting $dev on $mntpt ($fstype)..." >$LOG - mount -t $fstype $dev $TARGETDIR >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE} - DIE 1 - fi - # Add entry to target fstab - uuid=$(blkid -o value -s UUID "$dev") - if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then - fspassno=0 - else - fspassno=1 - fi - echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB - done - - # mount all filesystems in target rootfs - mnts=$(grep -E '^MOUNTPOINT .*' $CONF_FILE | sort -k 5) - set -- ${mnts} - while [ $# -ne 0 ]; do - dev=$2; fstype=$3; mntpt="$5" - shift 6 - [ "$mntpt" = "/" -o "$fstype" = "swap" ] && continue - mkdir -p ${TARGETDIR}${mntpt} - echo "Mounting $dev on $mntpt ($fstype)..." >$LOG - mount -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE} - DIE - fi - # Add entry to target fstab - uuid=$(blkid -o value -s UUID "$dev") - if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then - fspassno=0 - else - fspassno=2 - fi - echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB - done -} - -mount_filesystems() { - for f in sys proc dev; do - [ ! -d $TARGETDIR/$f ] && mkdir $TARGETDIR/$f - echo "Mounting $TARGETDIR/$f..." >$LOG - mount --rbind /$f $TARGETDIR/$f >$LOG 2>&1 - done -} - -umount_filesystems() { - local mnts="$(grep -E '^MOUNTPOINT .* swap .*$' $CONF_FILE | sort -r -k 5)" - set -- ${mnts} - while [ $# -ne 0 ]; do - local dev=$2; local fstype=$3 - shift 6 - if [ "$fstype" = "swap" ]; then - echo "Disabling swap space on $dev..." >$LOG - swapoff $dev >$LOG 2>&1 - continue - fi - done - echo "Unmounting $TARGETDIR..." >$LOG - umount -R $TARGETDIR >$LOG 2>&1 -} - -log_and_count() { - local progress whole tenth - while read line; do - echo "$line" >$LOG - copy_count=$((copy_count + 1)) - progress=$((1000 * copy_count / copy_total)) - if [ "$progress" != "$copy_progress" ]; then - whole=$((progress / 10)) - tenth=$((progress % 10)) - printf "Progress: %d.%d%% (%d of %d files)\n" $whole $tenth $copy_count $copy_total - copy_progress=$progress - fi - done -} - -copy_rootfs() { - local tar_in="--create --one-file-system --xattrs" - TITLE="Check $LOG for details ..." - INFOBOX "Counting files, please be patient ..." 4 60 - copy_total=$(tar ${tar_in} -v -f /dev/null / 2>/dev/null | wc -l) - export copy_total copy_count=0 copy_progress= - clear - tar ${tar_in} -f - / 2>/dev/null | \ - tar --extract --xattrs --xattrs-include='*' --preserve-permissions -v -f - -C $TARGETDIR | \ - log_and_count | \ - DIALOG --title "${TITLE}" \ - --progressbox "Copying live image to target rootfs." 5 60 - if [ $? -ne 0 ]; then - DIE 1 - fi - unset copy_total copy_count copy_percent -} - -install_packages() { - local _grub= _syspkg= - - if [ "$(get_option BOOTLOADER)" != none ]; then - if [ -n "$EFI_SYSTEM" ]; then - if [ $EFI_FW_BITS -eq 32 ]; then - _grub="grub-i386-efi" - else - _grub="grub-x86_64-efi" - fi - else - _grub="grub" - fi - fi - - _syspkg="base-system" - - mkdir -p $TARGETDIR/var/db/xbps/keys $TARGETDIR/usr/share - cp -a /usr/share/xbps.d $TARGETDIR/usr/share/ - cp /var/db/xbps/keys/*.plist $TARGETDIR/var/db/xbps/keys - if [ -n "$MIRROR_DONE" ]; then - mkdir -p $TARGETDIR/etc - cp -a /etc/xbps.d $TARGETDIR/etc - fi - mkdir -p $TARGETDIR/boot/grub - - _arch=$(xbps-uhelper arch) - - stdbuf -oL env XBPS_ARCH=${_arch} \ - xbps-install -r $TARGETDIR -SyU ${_syspkg} ${_grub} 2>&1 | \ - DIALOG --title "Installing base system packages..." \ - --programbox 24 80 - if [ $? -ne 0 ]; then - DIE 1 - fi - xbps-reconfigure -r $TARGETDIR -f base-files >/dev/null 2>&1 - stdbuf -oL chroot $TARGETDIR xbps-reconfigure -a 2>&1 | \ - DIALOG --title "Configuring base system packages..." --programbox 24 80 - if [ $? -ne 0 ]; then - DIE 1 - fi -} - -menu_services() { - local sv _status _checklist="" - # filter out services that probably shouldn't be messed with - local sv_ignore='^(agetty-(tty[1-9]|generic|serial|console)|udevd|sulogin)$' - find $TARGETDIR/etc/runit/runsvdir/default -mindepth 1 -maxdepth 1 -xtype d -printf '%f\n' | \ - grep -Ev "$sv_ignore" | sort -u > "$TARGET_SERVICES" - while true; do - while read -r sv; do - if [ -n "$sv" ]; then - if grep -qx "$sv" "$TARGET_SERVICES" 2>/dev/null; then - _status=on - else - _status=off - fi - _checklist+=" ${sv} ${sv} ${_status}" - fi - done < <(find $TARGETDIR/etc/sv -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | grep -Ev "$sv_ignore" | sort -u) - DIALOG --no-tags --checklist "Select services to enable:" 20 60 18 ${_checklist} - if [ $? -eq 0 ]; then - comm -13 "$TARGET_SERVICES" <(cat "$ANSWER" | tr ' ' '\n') | while read -r sv; do - enable_service "$sv" - done - comm -23 "$TARGET_SERVICES" <(cat "$ANSWER" | tr ' ' '\n') | while read -r sv; do - disable_service "$sv" - done - break - else - return - fi - done -} - -enable_service() { - ln -sf "/etc/sv/$1" "$TARGETDIR/etc/runit/runsvdir/default/$1" -} - -disable_service() { - rm -f "$TARGETDIR/etc/runit/runsvdir/default/$1" -} - -menu_install() { - ROOTPASSWORD_DONE="$(get_option ROOTPASSWORD)" - BOOTLOADER_DONE="$(get_option BOOTLOADER)" - - if [ -z "$ROOTPASSWORD_DONE" ]; then - DIALOG --msgbox "${BOLD}The root password has not been configured, \ -please do so before starting the installation.${RESET}" ${MSGBOXSIZE} - return 1 - elif [ -z "$BOOTLOADER_DONE" ]; then - DIALOG --msgbox "${BOLD}The disk to install the bootloader has not been \ -configured, please do so before starting the installation.${RESET}" ${MSGBOXSIZE} - return 1 - fi - - # Validate filesystems after making sure bootloader is done, - # so that specific checks can be made based on the selection - validate_filesystems || return 1 - - if [ -z "$FILESYSTEMS_DONE" ]; then - DIALOG --msgbox "${BOLD}Required filesystems were not configured, \ -please do so before starting the installation.${RESET}" ${MSGBOXSIZE} - return 1 - fi - - # Validate useraccount. All parameters must be set (name, password, login name, groups). - validate_useraccount - - if [ -z "$USERACCOUNT_DONE" ]; then - DIALOG --yesno "${BOLD}The user account is not set up properly.${RESET}\n\n -${BOLD}${RED}WARNING: no user will be created. You will only be able to login \ -with the root user in your new system.${RESET}\n\n -${BOLD}Do you want to continue?${RESET}" 10 60 || return - fi - - DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n -${BOLD}${TARGETFS}${RESET}\n -${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \ -filesystems.${RESET}\n\n -${BOLD}Do you want to continue?${RESET}" 20 80 || return - unset TARGETFS - - # Create and mount filesystems - create_filesystems - - SOURCE_DONE="$(get_option SOURCE)" - # If source not set use defaults. - if [ "$(get_option SOURCE)" = "local" -o -z "$SOURCE_DONE" ]; then - copy_rootfs - . /etc/default/live.conf - rm -f $TARGETDIR/etc/motd - rm -f $TARGETDIR/etc/issue - rm -f $TARGETDIR/usr/sbin/void-installer - # Remove modified sddm.conf to let sddm use the defaults. - rm -f $TARGETDIR/etc/sddm.conf - # Remove live user. - echo "Removing $USERNAME live user from targetdir ..." >$LOG - chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1 - rm -f $TARGETDIR/etc/sudoers.d/99-void-live - sed -i "s,GETTY_ARGS=\"--noclear -a $USERNAME\",GETTY_ARGS=\"--noclear\",g" $TARGETDIR/etc/sv/agetty-tty1/conf - TITLE="Check $LOG for details ..." - INFOBOX "Rebuilding initramfs for target ..." 4 60 - echo "Rebuilding initramfs for target ..." >$LOG - # mount required fs - mount_filesystems - chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1 - INFOBOX "Removing temporary packages from target ..." 4 60 - echo "Removing temporary packages from target ..." >$LOG - TO_REMOVE="dialog xtools-minimal xmirror" - # only remove espeakup and brltty if it wasn't enabled in the live environment - if ! [ -e "/var/service/espeakup" ]; then - TO_REMOVE+=" espeakup" - fi - if ! [ -e "/var/service/brltty" ]; then - TO_REMOVE+=" brltty" - fi - if [ "$(get_option BOOTLOADER)" = none ]; then - TO_REMOVE+=" grub-x86_64-efi grub-i386-efi grub" - fi - # uninstall separately to minimise errors - for pkg in $TO_REMOVE; do - xbps-remove -r $TARGETDIR -Ry "$pkg" >>$LOG 2>&1 - done - rmdir $TARGETDIR/mnt/target - else - # mount required fs - mount_filesystems - # network install, use packages. - install_packages - fi - - INFOBOX "Applying installer settings..." 4 60 - - # copy target fstab. - install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab - # Mount /tmp as tmpfs. - echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0" >> $TARGETDIR/etc/fstab - - - # set up keymap, locale, timezone, hostname, root passwd and user account. - set_keymap - set_locale - set_timezone - set_hostname - set_rootpassword - set_useraccount - - # Copy /etc/skel files for root. - cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root - - NETWORK_DONE="$(get_option NETWORK)" - # network settings for target - if [ -n "$NETWORK_DONE" ]; then - local net="$(get_option NETWORK)" - set -- ${net} - local _dev="$1" _type="$2" _ip="$3" _gw="$4" _dns1="$5" _dns2="$6" - if [ -z "$_type" ]; then - # network type empty??!!! - : - elif [ "$_type" = "dhcp" ]; then - if $(echo $_dev|egrep -q "^wl.*" 2>/dev/null); then - cp /etc/wpa_supplicant/wpa_supplicant.conf $TARGETDIR/etc/wpa_supplicant - enable_service wpa_supplicant - fi - enable_service dhcpcd - elif [ -n "$_dev" -a "$_type" = "static" ]; then - # static IP through dhcpcd. - mv $TARGETDIR/etc/dhcpcd.conf $TARGETDIR/etc/dhcpcd.conf.orig - echo "# Static IP configuration set by the void-installer for $_dev." \ - >$TARGETDIR/etc/dhcpcd.conf - echo "interface $_dev" >>$TARGETDIR/etc/dhcpcd.conf - echo "static ip_address=$_ip" >>$TARGETDIR/etc/dhcpcd.conf - echo "static routers=$_gw" >>$TARGETDIR/etc/dhcpcd.conf - echo "static domain_name_servers=$_dns1 $_dns2" >>$TARGETDIR/etc/dhcpcd.conf - enable_service dhcpcd - fi - fi - - if [ -d $TARGETDIR/etc/sudoers.d ]; then - USERLOGIN="$(get_option USERLOGIN)" - if [ -z "$(echo $(get_option USERGROUPS) | grep -w wheel)" -a -n "$USERLOGIN" ]; then - # enable sudo for primary user USERLOGIN who is not member of wheel - echo "# Enable sudo for login '$USERLOGIN'" > "$TARGETDIR/etc/sudoers.d/$USERLOGIN" - echo "$USERLOGIN ALL=(ALL:ALL) ALL" >> "$TARGETDIR/etc/sudoers.d/$USERLOGIN" - else - # enable the sudoers entry for members of group wheel - echo "%wheel ALL=(ALL:ALL) ALL" > "$TARGETDIR/etc/sudoers.d/wheel" - fi - unset USERLOGIN - fi - - # clean up polkit rule - it's only useful in live systems - rm -f $TARGETDIR/etc/polkit-1/rules.d/void-live.rules - - # enable text console for grub if chosen - if [ "$(get_option TEXTCONSOLE)" = "1" ]; then - sed -i $TARGETDIR/etc/default/grub \ - -e 's|#\(GRUB_TERMINAL_INPUT\).*|\1=console|' \ - -e 's|#\(GRUB_TERMINAL_OUTPUT\).*|\1=console|' - fi - - # install bootloader. - set_bootloader - - # menu for enabling services - menu_services - - sync && sync && sync - - # unmount all filesystems. - umount_filesystems - - # installed successfully. - DIALOG --yesno "${BOLD}Void Linux has been installed successfully!${RESET}\n -Do you want to reboot the system?" ${YESNOSIZE} - if [ $? -eq 0 ]; then - shutdown -r now - else - return - fi -} - -menu_source() { - local src= - - DIALOG --title " Select installation source " \ - --menu "$MENULABEL" 8 70 0 \ - "Local" "Packages from ISO image" \ - "Network" "Base system only, downloaded from official repository" - case "$(cat $ANSWER)" in - "Local") src="local";; - "Network") src="net"; - if [ -z "$NETWORK_DONE" ]; then - if test_network; then - menu_network - fi - fi;; - *) return 1;; - esac - SOURCE_DONE=1 - set_option SOURCE $src -} - -menu_mirror() { - xmirror 2>$LOG && MIRROR_DONE=1 -} - -menu() { - local AFTER_HOSTNAME - if [ -z "$DEFITEM" ]; then - DEFITEM="Keyboard" - fi - - if xbps-uhelper arch | grep -qe '-musl$'; then - AFTER_HOSTNAME="Timezone" - DIALOG --default-item $DEFITEM \ - --extra-button --extra-label "Settings" \ - --title " Void Linux installation menu " \ - --menu "$MENULABEL" 10 70 0 \ - "Keyboard" "Set system keyboard" \ - "Network" "Set up the network" \ - "Source" "Set source installation" \ - "Mirror" "Select XBPS mirror" \ - "Hostname" "Set system hostname" \ - "Timezone" "Set system time zone" \ - "RootPassword" "Set system root password" \ - "UserAccount" "Set primary user name and password" \ - "BootLoader" "Set disk to install bootloader" \ - "Partition" "Partition disk(s)" \ - "Filesystems" "Configure filesystems and mount points" \ - "Install" "Start installation with saved settings" \ - "Exit" "Exit installation" - else - AFTER_HOSTNAME="Locale" - DIALOG --default-item $DEFITEM \ - --extra-button --extra-label "Settings" \ - --title " Void Linux installation menu " \ - --menu "$MENULABEL" 10 70 0 \ - "Keyboard" "Set system keyboard" \ - "Network" "Set up the network" \ - "Source" "Set source installation" \ - "Mirror" "Select XBPS mirror" \ - "Hostname" "Set system hostname" \ - "Locale" "Set system locale" \ - "Timezone" "Set system time zone" \ - "RootPassword" "Set system root password" \ - "UserAccount" "Set primary user name and password" \ - "BootLoader" "Set disk to install bootloader" \ - "Partition" "Partition disk(s)" \ - "Filesystems" "Configure filesystems and mount points" \ - "Install" "Start installation with saved settings" \ - "Exit" "Exit installation" - fi - - if [ $? -eq 3 ]; then - # Show settings - cp $CONF_FILE /tmp/conf_hidden.$$; - sed -i "s/^ROOTPASSWORD .*/ROOTPASSWORD <-hidden->/" /tmp/conf_hidden.$$ - sed -i "s/^USERPASSWORD .*/USERPASSWORD <-hidden->/" /tmp/conf_hidden.$$ - DIALOG --title "Saved settings for installation" --textbox /tmp/conf_hidden.$$ 14 60 - rm /tmp/conf_hidden.$$ - return - fi - - case $(cat $ANSWER) in - "Keyboard") menu_keymap && [ -n "$KEYBOARD_DONE" ] && DEFITEM="Network";; - "Network") menu_network && [ -n "$NETWORK_DONE" ] && DEFITEM="Source";; - "Source") menu_source && [ -n "$SOURCE_DONE" ] && DEFITEM="Mirror";; - "Mirror") menu_mirror && [ -n "$MIRROR_DONE" ] && DEFITEM="Hostname";; - "Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="$AFTER_HOSTNAME";; - "Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";; - "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";; - "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";; - "UserAccount") menu_useraccount && [ -n "$USERLOGIN_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \ - && DEFITEM="BootLoader";; - "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";; - "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";; - "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";; - "Install") menu_install;; - "Exit") DIE;; - *) DIALOG --yesno "Abort Installation?" ${YESNOSIZE} && DIE - esac -} - -if ! command -v dialog >/dev/null; then - echo "ERROR: missing dialog command, exiting..." - exit 1 -fi - -if [ "$(id -u)" != "0" ]; then - echo "void-installer must run as root" 1>&2 - exit 1 -fi - -# -# main() -# -DIALOG --title "${BOLD}${RED} Enter the void ... ${RESET}" --msgbox "\n -Welcome to the Void Linux installation. A simple and minimal \ -Linux distribution made from scratch and built from the source package tree \ -available for XBPS, a new alternative binary package system.\n\n -The installation should be pretty straightforward. If you are in trouble \ -please join us at ${BOLD}#voidlinux${RESET} on ${BOLD}irc.libera.chat${RESET}.\n\n -${BOLD}https://www.voidlinux.org${RESET}\n\n" 16 80 - -while true; do - menu -done - -exit 0 -# vim: set ts=4 sw=4 et: diff --git a/lib.sh b/lib.sh deleted file mode 100755 index 96c3e33..0000000 --- a/lib.sh +++ /dev/null @@ -1,338 +0,0 @@ -#!/bin/sh - -# This contains the COMPLETE list of binaries that this script needs -# to function. The only exception is the QEMU binary since it is not -# known in advance which one wil be required. -readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe" -readonly HOSTARCH=$(xbps-uhelper arch) - -is_target_native() { - # Because checking whether the target is runnable is ugly, stuff - # it into a single function. That makes it easy to check anywhere. - local target_arch - - target_arch="$1" - # this will cover most - if [ "${target_arch%-musl}" = "${HOSTARCH%-musl}" ]; then - return 0 - fi - - case "$HOSTARCH" in - # ppc64le has no 32-bit variant, only runs its own stuff - ppc64le*) return 1 ;; - # x86_64 also runs i686 - x86_64*) test -z "${target_arch##*86*}" ;; - # aarch64 also runs armv* - aarch64*) test -z "${target_arch##armv*}" ;; - # bigendian ppc64 also runs ppc - ppc64*) test "${target_arch%-musl}" = "ppc" ;; - # anything else is just their own - *) return 1 ;; - esac - - return $? -} - -version() ( - set +u - [ -n "$PROGNAME" ] && printf "%s " "$PROGNAME" - echo "$(cat ./version) ${MKLIVE_REV:-"$(git -c safe.directory="$(pwd)" rev-parse --short HEAD 2> /dev/null)"}" -) - -info_msg() { - # This function handles the printing that is bold within all - # scripts. This is a convenience function so that the rather ugly - # looking ASCII escape codes live in only one place. - printf "\033[1m%s\n\033[m" "$@" -} - -die() { - # This function is registered in all the scripts to make sure that - # the important mounts get cleaned up and the $ROOTFS location is - # removed. - printf "FATAL: %s\n" "$@" - umount_pseudofs - [ -d "$ROOTFS" ] && rm -rf "$ROOTFS" - exit 1 -} - -check_tools() { - # All scripts within mklive declare the tools they will use in a - # variable called "REQTOOLS". This function checks that these - # tools are available and prints out the path to each tool that - # will be used. This can be useful to figure out what is broken - # if a different version of something is used than was expected. - for tool in $LIBTOOLS $REQTOOLS ; do - if ! which "$tool" > /dev/null ; then - die "Required tool $tool is not available on this system!" - fi - done - - info_msg "The following tools will be used:" - for tool in $LIBTOOLS $REQTOOLS ; do - which "$tool" - done -} - -mount_pseudofs() { - # This function ensures that the psuedofs mountpoints are present - # in the chroot. Strictly they are not necessary to have for many - # commands, but bind-mounts are cheap and it isn't too bad to just - # mount them all the time. - for f in dev proc sys; do - # In a naked chroot there is nothing to bind the mounts to, so - # we need to create directories for these first. - [ ! -d "$ROOTFS/$f" ] && mkdir -p "$ROOTFS/$f" - if ! mountpoint -q "$ROOTFS/$f" ; then - # It is VERY important that this only happen if the - # pseudofs isn't already mounted. If it already is then - # this is virtually impossible to troubleshoot because it - # looks like the subsequent umount just isn't working. - mount -r --rbind /$f "$ROOTFS/$f" --make-rslave - fi - done - if ! mountpoint -q "$ROOTFS/tmp" ; then - mkdir -p "$ROOTFS/tmp" - mount -o mode=0755,nosuid,nodev -t tmpfs tmpfs "$ROOTFS/tmp" - fi -} - -umount_pseudofs() { - # This function cleans up the mounts in the chroot. Failure to - # clean up these mounts will prevent the tmpdir from being - # deletable instead throwing the error "Device or Resource Busy". - # The '-f' option is passed to umount to account for the - # contingency where the psuedofs mounts are not present. - if [ -d "${ROOTFS}" ]; then - for f in dev proc sys; do - umount -R -f "$ROOTFS/$f" >/dev/null 2>&1 - done - fi - umount -f "$ROOTFS/tmp" >/dev/null 2>&1 -} - -run_cmd_target() { - info_msg "Running $* for target $XBPS_TARGET_ARCH ..." - if is_target_native "$XBPS_TARGET_ARCH"; then - # This is being run on the same architecture as the host, - # therefore we should set XBPS_ARCH. - if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then - die "Could not run command $*" - fi - else - # This is being run on a foriegn arch, therefore we should set - # XBPS_TARGET_ARCH. In this case XBPS will not attempt - # certain actions and will require reconfiguration later. - if ! eval XBPS_TARGET_ARCH="$XBPS_TARGET_ARCH" "$@" ; then - die "Could not run command $*" - fi - fi -} - -run_cmd() { - # This is a general purpose function to run commands that a user - # may wish to see. For example its useful to see the tar/xz - # pipeline to not need to delve into the scripts to see what - # options its set up with. - info_msg "Running $*" - eval "$@" -} - -run_cmd_chroot() { - # General purpose chroot function which makes sure the chroot is - # prepared. This function takes 2 arguments, the location to - # chroot to and the command to run. - - # This is an idempotent function, it is safe to call every time - # before entering the chroot. This has the advantage of making - # execution in the chroot appear as though it "Just Works(tm)". - register_binfmt - - # Before we step into the chroot we need to make sure the - # pseudo-filesystems are ready to go. Not all commands will need - # this, but its still a good idea to call it here anyway. - mount_pseudofs - - # With assurance that things will run now we can jump into the - # chroot and run stuff! - chroot "$1" sh -c "$2" -} - -cleanup_chroot() { - # This function cleans up the chroot shims that are used by QEMU - # to allow builds on alien platforms. It takes no arguments but - # expects the global $ROOTFS variable to be set. - - # Un-Mount the pseudofs mounts if they were mounted - umount_pseudofs -} - -register_binfmt() { - # This function sets up everything that is needed to be able to - # chroot into a ROOTFS and be able to run commands there. This - # really matters on platforms where the host architecture is - # different from the target, and you wouldn't be able to run - # things like xbps-reconfigure -a. This function is idempotent - # (You can run it multiple times without modifying state). This - # function takes no arguments, but does expect the global variable - # $XBPS_TARGET_ARCH to be set. - - # This select sets up the "magic" bytes in /proc that let the - # kernel select an alternate interpreter. More values for this - # map can be obtained from here: - # https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh - - # If the XBPS_TARGET_ARCH is unset but the PLATFORM is known, it - # may be possible to set the architecture from the static - # platforms map. - if [ -z "$XBPS_TARGET_ARCH" ] && [ ! -z "$PLATFORM" ] ; then - set_target_arch_from_platform - fi - - # In the special case where the build is native we can return - # without doing anything else - # This is only a basic check for identical archs, with more careful - # checks below for cases like ppc64 -> ppc and x86_64 -> i686. - _hostarch="${HOSTARCH%-musl}" - _targetarch="${XBPS_TARGET_ARCH%-musl}" - if [ "$_hostarch" = "$_targetarch" ] ; then - return - fi - - case "${_targetarch}" in - armv*) - # TODO: detect aarch64 hosts that run 32 bit ARM without qemu (some cannot) - if ( [ "${_targetarch}" = "armv6l" ] && [ "${_hostarch}" = "armv7l" ] ) ; then - return - fi - if [ "${_targetarch}" = "armv5tel" -a \ - \( "${_hostarch}" = "armv6l" -o "${_hostarch}" = "armv7l" \) ] ; then - return - fi - _cpu=arm - ;; - aarch64) - _cpu=aarch64 - ;; - ppc64le) - _cpu=ppc64le - ;; - ppc64) - _cpu=ppc64 - ;; - ppc) - if [ "$_hostarch" = "ppc64" ] ; then - return - fi - _cpu=ppc - ;; - mipsel) - if [ "$_hostarch" = "mips64el" ] ; then - return - fi - _cpu=mipsel - ;; - x86_64) - _cpu=x86_64 - ;; - i686) - if [ "$_hostarch" = "x86_64" ] ; then - return - fi - _cpu=i386 - ;; - riscv64) - _cpu=riscv64 - ;; - *) - die "Unknown target architecture!" - ;; - esac - - # For builds that do not match the host architecture, the correct - # qemu binary will be required. - QEMU_BIN="qemu-${_cpu}" - if ! $QEMU_BIN -version >/dev/null 2>&1; then - die "$QEMU_BIN binary is missing in your system, exiting." - fi - - # In order to use the binfmt system the binfmt_misc mountpoint - # must exist inside of proc - if ! mountpoint -q /proc/sys/fs/binfmt_misc ; then - modprobe -q binfmt_misc - mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc 2>/dev/null - fi - - # Only register if the map is incomplete - if [ ! -f /proc/sys/fs/binfmt_misc/qemu-$_cpu ] ; then - if ! command -v update-binfmts >/dev/null 2>&1; then - die "could not add binfmt: update-binfmts binary is missing in your system" - fi - update-binfmts --import "qemu-$_cpu" - fi -} - -set_target_arch_from_platform() { - # This function maintains a lookup from platform to target - # architecture. This is required for scripts that need to know - # the target architecture, but don't necessarily need to know it - # internally (i.e. only run_cmd_chroot). - case "$PLATFORM" in - rpi-aarch64*) XBPS_TARGET_ARCH="aarch64";; - rpi-armv7l*) XBPS_TARGET_ARCH="armv7l";; - rpi-armv6l*) XBPS_TARGET_ARCH="armv6l";; - i686*) XBPS_TARGET_ARCH="i686";; - x86_64*) XBPS_TARGET_ARCH="x86_64";; - GCP*) XBPS_TARGET_ARCH="x86_64";; - pinebookpro*) XBPS_TARGET_ARCH="aarch64";; - pinephone*) XBPS_TARGET_ARCH="aarch64";; - rock64*) XBPS_TARGET_ARCH="aarch64";; - rockpro64*) XBPS_TARGET_ARCH="aarch64";; - asahi*) XBPS_TARGET_ARCH="aarch64";; - *) die "$PROGNAME: Unable to compute target architecture from platform";; - esac - - if [ -z "${PLATFORM##*-musl}" ] ; then - XBPS_TARGET_ARCH="${XBPS_TARGET_ARCH}-musl" - fi -} - -set_dracut_args_from_platform() { - # In rare cases it is necessary to set platform specific dracut - # args. This is mostly the case on ARM platforms. - case "$PLATFORM" in - *) ;; - esac -} - -set_cachedir() { - # The package artifacts are cacheable, but they need to be isolated - # from the host cache. - : "${XBPS_CACHEDIR:=--cachedir=$PWD/xbps-cache/${XBPS_TARGET_ARCH}}" -} - -rk33xx_flash_uboot() { - local dir="$1" - local dev="$2" - dd if="${dir}/idbloader.img" of="${dev}" seek=64 conv=notrunc,fsync >/dev/null 2>&1 - dd if="${dir}/u-boot.itb" of="${dev}" seek=16384 conv=notrunc,fsync >/dev/null 2>&1 -} - -# These should all resolve even if they won't have the appropriate -# repodata files for the selected architecture. -: "${XBPS_REPOSITORY:=--repository=https://repo-default.voidlinux.org/current \ - --repository=https://repo-default.voidlinux.org/current/musl \ - --repository=https://repo-default.voidlinux.org/current/aarch64}" - -# This library is the authoritative source of the platform map, -# because of this we may need to get this information from the command -# line. This select allows us to get that information out. This -# fails silently if the toolname isn't known since this script is -# sourced. -case "${1:-}" in - platform2arch) - PLATFORM=$2 - set_target_arch_from_platform - echo "$XBPS_TARGET_ARCH" - ;; -esac diff --git a/mkiso.sh b/mkiso.sh deleted file mode 100755 index b8d0db8..0000000 --- a/mkiso.sh +++ /dev/null @@ -1,978 +0,0 @@ -#!/bin/bash - -readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe" -readonly HOSTARCH=$(xbps-uhelper arch) - -is_target_native() { - # Because checking whether the target is runnable is ugly, stuff - # it into a single function. That makes it easy to check anywhere. - local target_arch - - target_arch="$1" - # this will cover most - if [ "${target_arch%-musl}" = "${HOSTARCH%-musl}" ]; then - return 0 - fi - - case "$HOSTARCH" in - # ppc64le has no 32-bit variant, only runs its own stuff - ppc64le*) return 1 ;; - # x86_64 also runs i686 - x86_64*) test -z "${target_arch##*86*}" ;; - # aarch64 also runs armv* - aarch64*) test -z "${target_arch##armv*}" ;; - # bigendian ppc64 also runs ppc - ppc64*) test "${target_arch%-musl}" = "ppc" ;; - # anything else is just their own - *) return 1 ;; - esac - - return $? -} - -version() ( - set +u - [ -n "$PROGNAME" ] && printf "%s " "$PROGNAME" - echo "$(cat ./version) ${MKLIVE_REV:-"$(git -c safe.directory="$(pwd)" rev-parse --short HEAD 2> /dev/null)"}" -) - -info_msg() { - # This function handles the printing that is bold within all - # scripts. This is a convenience function so that the rather ugly - # looking ASCII escape codes live in only one place. - printf "\033[1m%s\n\033[m" "$@" -} - -die() { - # This function is registered in all the scripts to make sure that - # the important mounts get cleaned up and the $ROOTFS location is - # removed. - printf "FATAL: %s\n" "$@" - umount_pseudofs - [ -d "$ROOTFS" ] && rm -rf "$ROOTFS" - exit 1 -} - -check_tools() { - # All scripts within mklive declare the tools they will use in a - # variable called "REQTOOLS". This function checks that these - # tools are available and prints out the path to each tool that - # will be used. This can be useful to figure out what is broken - # if a different version of something is used than was expected. - for tool in $LIBTOOLS $REQTOOLS ; do - if ! which "$tool" > /dev/null ; then - die "Required tool $tool is not available on this system!" - fi - done - - info_msg "The following tools will be used:" - for tool in $LIBTOOLS $REQTOOLS ; do - which "$tool" - done -} - -mount_pseudofs() { - # This function ensures that the psuedofs mountpoints are present - # in the chroot. Strictly they are not necessary to have for many - # commands, but bind-mounts are cheap and it isn't too bad to just - # mount them all the time. - for f in dev proc sys; do - # In a naked chroot there is nothing to bind the mounts to, so - # we need to create directories for these first. - [ ! -d "$ROOTFS/$f" ] && mkdir -p "$ROOTFS/$f" - if ! mountpoint -q "$ROOTFS/$f" ; then - # It is VERY important that this only happen if the - # pseudofs isn't already mounted. If it already is then - # this is virtually impossible to troubleshoot because it - # looks like the subsequent umount just isn't working. - mount -r --rbind /$f "$ROOTFS/$f" --make-rslave - fi - done - if ! mountpoint -q "$ROOTFS/tmp" ; then - mkdir -p "$ROOTFS/tmp" - mount -o mode=0755,nosuid,nodev -t tmpfs tmpfs "$ROOTFS/tmp" - fi -} - -umount_pseudofs() { - # This function cleans up the mounts in the chroot. Failure to - # clean up these mounts will prevent the tmpdir from being - # deletable instead throwing the error "Device or Resource Busy". - # The '-f' option is passed to umount to account for the - # contingency where the psuedofs mounts are not present. - if [ -d "${ROOTFS}" ]; then - for f in dev proc sys; do - umount -R -f "$ROOTFS/$f" >/dev/null 2>&1 - done - fi - umount -f "$ROOTFS/tmp" >/dev/null 2>&1 -} - -run_cmd_target() { - info_msg "Running $* for target $XBPS_TARGET_ARCH ..." - if is_target_native "$XBPS_TARGET_ARCH"; then - # This is being run on the same architecture as the host, - # therefore we should set XBPS_ARCH. - if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then - die "Could not run command $*" - fi - else - # This is being run on a foriegn arch, therefore we should set - # XBPS_TARGET_ARCH. In this case XBPS will not attempt - # certain actions and will require reconfiguration later. - if ! eval XBPS_TARGET_ARCH="$XBPS_TARGET_ARCH" "$@" ; then - die "Could not run command $*" - fi - fi -} - -run_cmd() { - # This is a general purpose function to run commands that a user - # may wish to see. For example its useful to see the tar/xz - # pipeline to not need to delve into the scripts to see what - # options its set up with. - info_msg "Running $*" - eval "$@" -} - -run_cmd_chroot() { - # General purpose chroot function which makes sure the chroot is - # prepared. This function takes 2 arguments, the location to - # chroot to and the command to run. - - # This is an idempotent function, it is safe to call every time - # before entering the chroot. This has the advantage of making - # execution in the chroot appear as though it "Just Works(tm)". - register_binfmt - - # Before we step into the chroot we need to make sure the - # pseudo-filesystems are ready to go. Not all commands will need - # this, but its still a good idea to call it here anyway. - mount_pseudofs - - # With assurance that things will run now we can jump into the - # chroot and run stuff! - chroot "$1" sh -c "$2" -} - -cleanup_chroot() { - # This function cleans up the chroot shims that are used by QEMU - # to allow builds on alien platforms. It takes no arguments but - # expects the global $ROOTFS variable to be set. - - # Un-Mount the pseudofs mounts if they were mounted - umount_pseudofs -} - -register_binfmt() { - # This function sets up everything that is needed to be able to - # chroot into a ROOTFS and be able to run commands there. This - # really matters on platforms where the host architecture is - # different from the target, and you wouldn't be able to run - # things like xbps-reconfigure -a. This function is idempotent - # (You can run it multiple times without modifying state). This - # function takes no arguments, but does expect the global variable - # $XBPS_TARGET_ARCH to be set. - - # This select sets up the "magic" bytes in /proc that let the - # kernel select an alternate interpreter. More values for this - # map can be obtained from here: - # https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh - - # If the XBPS_TARGET_ARCH is unset but the PLATFORM is known, it - # may be possible to set the architecture from the static - # platforms map. - if [ -z "$XBPS_TARGET_ARCH" ] && [ ! -z "$PLATFORM" ] ; then - set_target_arch_from_platform - fi - - # In the special case where the build is native we can return - # without doing anything else - # This is only a basic check for identical archs, with more careful - # checks below for cases like ppc64 -> ppc and x86_64 -> i686. - _hostarch="${HOSTARCH%-musl}" - _targetarch="${XBPS_TARGET_ARCH%-musl}" - if [ "$_hostarch" = "$_targetarch" ] ; then - return - fi - - case "${_targetarch}" in - armv*) - # TODO: detect aarch64 hosts that run 32 bit ARM without qemu (some cannot) - if ( [ "${_targetarch}" = "armv6l" ] && [ "${_hostarch}" = "armv7l" ] ) ; then - return - fi - if [ "${_targetarch}" = "armv5tel" -a \ - \( "${_hostarch}" = "armv6l" -o "${_hostarch}" = "armv7l" \) ] ; then - return - fi - _cpu=arm - ;; - aarch64) - _cpu=aarch64 - ;; - ppc64le) - _cpu=ppc64le - ;; - ppc64) - _cpu=ppc64 - ;; - ppc) - if [ "$_hostarch" = "ppc64" ] ; then - return - fi - _cpu=ppc - ;; - mipsel) - if [ "$_hostarch" = "mips64el" ] ; then - return - fi - _cpu=mipsel - ;; - x86_64) - _cpu=x86_64 - ;; - i686) - if [ "$_hostarch" = "x86_64" ] ; then - return - fi - _cpu=i386 - ;; - riscv64) - _cpu=riscv64 - ;; - *) - die "Unknown target architecture!" - ;; - esac - - # For builds that do not match the host architecture, the correct - # qemu binary will be required. - QEMU_BIN="qemu-${_cpu}" - if ! $QEMU_BIN -version >/dev/null 2>&1; then - die "$QEMU_BIN binary is missing in your system, exiting." - fi - - # In order to use the binfmt system the binfmt_misc mountpoint - # must exist inside of proc - if ! mountpoint -q /proc/sys/fs/binfmt_misc ; then - modprobe -q binfmt_misc - mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc 2>/dev/null - fi - - # Only register if the map is incomplete - if [ ! -f /proc/sys/fs/binfmt_misc/qemu-$_cpu ] ; then - if ! command -v update-binfmts >/dev/null 2>&1; then - die "could not add binfmt: update-binfmts binary is missing in your system" - fi - update-binfmts --import "qemu-$_cpu" - fi -} - -set_target_arch_from_platform() { - # This function maintains a lookup from platform to target - # architecture. This is required for scripts that need to know - # the target architecture, but don't necessarily need to know it - # internally (i.e. only run_cmd_chroot). - case "$PLATFORM" in - rpi-aarch64*) XBPS_TARGET_ARCH="aarch64";; - rpi-armv7l*) XBPS_TARGET_ARCH="armv7l";; - rpi-armv6l*) XBPS_TARGET_ARCH="armv6l";; - i686*) XBPS_TARGET_ARCH="i686";; - x86_64*) XBPS_TARGET_ARCH="x86_64";; - GCP*) XBPS_TARGET_ARCH="x86_64";; - pinebookpro*) XBPS_TARGET_ARCH="aarch64";; - pinephone*) XBPS_TARGET_ARCH="aarch64";; - rock64*) XBPS_TARGET_ARCH="aarch64";; - rockpro64*) XBPS_TARGET_ARCH="aarch64";; - asahi*) XBPS_TARGET_ARCH="aarch64";; - *) die "$PROGNAME: Unable to compute target architecture from platform";; - esac - - if [ -z "${PLATFORM##*-musl}" ] ; then - XBPS_TARGET_ARCH="${XBPS_TARGET_ARCH}-musl" - fi -} - -set_dracut_args_from_platform() { - # In rare cases it is necessary to set platform specific dracut - # args. This is mostly the case on ARM platforms. - case "$PLATFORM" in - *) ;; - esac -} - -set_cachedir() { - # The package artifacts are cacheable, but they need to be isolated - # from the host cache. - : "${XBPS_CACHEDIR:=--cachedir=$PWD/xbps-cache/${XBPS_TARGET_ARCH}}" -} - -rk33xx_flash_uboot() { - local dir="$1" - local dev="$2" - dd if="${dir}/idbloader.img" of="${dev}" seek=64 conv=notrunc,fsync >/dev/null 2>&1 - dd if="${dir}/u-boot.itb" of="${dev}" seek=16384 conv=notrunc,fsync >/dev/null 2>&1 -} - -# These should all resolve even if they won't have the appropriate -# repodata files for the selected architecture. -: "${XBPS_REPOSITORY:=--repository=https://repo-default.voidlinux.org/current \ - --repository=https://repo-default.voidlinux.org/current/musl \ - --repository=https://repo-default.voidlinux.org/current/aarch64}" - -# This library is the authoritative source of the platform map, -# because of this we may need to get this information from the command -# line. This select allows us to get that information out. This -# fails silently if the toolname isn't known since this script is -# sourced. -case "${1:-}" in - platform2arch) - PLATFORM=$2 - set_target_arch_from_platform - echo "$XBPS_TARGET_ARCH" - ;; -esac - -umask 022 - -MOSVER="$(cat version)" -REQUIRED_PKGS=(base-files libgcc plymouth dash coreutils sed tar gawk squashfs-tools xorriso) -TARGET_PKGS=(base-files plymouth) -INITRAMFS_PKGS=(binutils xz device-mapper fbv dhclient dracut-network openresolv xsetroot) -PACKAGE_LIST=(bash openjdk21 xorg qt5 qt5-devel elogind plymouth) -IGNORE_PKGS=() -PLATFORMS=() -readonly PROGNAME="$(basename "$0")" -declare -a INCLUDE_DIRS=() - -# sudo ./mklive.sh -T minceraftOS -p openjdk21 live.autologin live.user=player live.shell=/bin/bash - -die() { - info_msg "ERROR: $*" - error_out 1 $LINENO -} - -print_step() { - CURRENT_STEP=$((CURRENT_STEP+1)) - info_msg "[${CURRENT_STEP}/${STEP_COUNT}] $*" -} - -mount_pseudofs() { - for f in sys dev proc; do - mkdir -p "$ROOTFS"/$f - mount --rbind /$f "$ROOTFS"/$f - done -} - -umount_pseudofs() { - for f in sys dev proc; do - if [ -d "$ROOTFS/$f" ] && ! umount -R -f "$ROOTFS/$f"; then - info_msg "ERROR: failed to unmount $ROOTFS/$f/" - return 1 - fi - done -} - -error_out() { - trap - INT TERM 0 - umount_pseudofs || exit "${1:-0}" - [ -d "$BUILDDIR" ] && [ -z "$KEEP_BUILDDIR" ] && rm -rf --one-file-system "$BUILDDIR" - exit "${1:-0}" -} - -copy_void_keys() { - mkdir -p "$1"/var/db/xbps/keys - cp keys/*.plist "$1"/var/db/xbps/keys -} - -copy_dracut_files() { - mkdir -p "$1"/usr/lib/dracut/modules.d/01vmklive - cp dracut/vmklive/* "$1"/usr/lib/dracut/modules.d/01vmklive/ -} - -copy_autoinstaller_files() { - mkdir -p "$1"/usr/lib/dracut/modules.d/01autoinstaller - cp dracut/autoinstaller/* "$1"/usr/lib/dracut/modules.d/01autoinstaller/ -} - -install_prereqs() { - XBPS_ARCH=$HOST_ARCH "$XBPS_INSTALL_CMD" -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} \ - -c "$XBPS_HOST_CACHEDIR" -y "${REQUIRED_PKGS[@]}" - [ $? -ne 0 ] && die "Failed to install required software, exiting..." -} - -install_target_pkgs() { - XBPS_ARCH=$TARGET_ARCH "$XBPS_INSTALL_CMD" -r "$VOIDTARGETDIR" ${XBPS_REPOSITORY} \ - -c "$XBPS_HOST_CACHEDIR" -y "${TARGET_PKGS[@]}" - [ $? -ne 0 ] && die "Failed to install required software, exiting..." -} - -post_install_packages() { - # Cleanup and remove useless stuff. - rm -rf "$ROOTFS"/var/cache/* "$ROOTFS"/run/* "$ROOTFS"/var/run/* - - # boot failure if disks have raid logical volumes and this isn't loaded - for f in "$ROOTFS/usr/lib/modules/$KERNELVERSION/kernel/drivers/md/dm-raid.ko".*; do - echo "dm-raid" > "$ROOTFS"/etc/modules-load.d/dm-raid.conf - break - done - - chroot "$ROOTFS" xbps-install -S plymouth - - mkdir -p /usr - mkdir -p /usr/share - mkdir -p /usr/share/plymouth - mkdir -p /usr/share/plymouth/themes - mkdir -p /usr/share/plymouth/themes/simple-image - cp data/simple-image.plymouth "$ROOTFS"/usr/share/plymouth/themes/simple-image - cp data/simple-image.script "$ROOTFS"/usr/share/plymouth/themes/simple-image - cp data/logo.png "$ROOTFS"/usr/share/plymouth/themes/simple-image - - mkdir -p /etc - mkdir -p /etc/plymouth - echo "[Daemon] -Theme=simple-image" > /etc/plymouth/plymouthd.conf - - chroot "$ROOTFS" env -i plymouth-set-default-theme -R "simple-image" -} - -install_packages() { - XBPS_ARCH=$TARGET_ARCH "${XBPS_INSTALL_CMD}" -r "$ROOTFS" \ - ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -yn "${PACKAGE_LIST[@]}" "${INITRAMFS_PKGS[@]}" - [ $? -ne 0 ] && die "Missing required binary packages, exiting..." - - mount_pseudofs - - LANG=C XBPS_TARGET_ARCH=$TARGET_ARCH "${XBPS_INSTALL_CMD}" -U -r "$ROOTFS" \ - ${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -y "${PACKAGE_LIST[@]}" "${INITRAMFS_PKGS[@]}" - [ $? -ne 0 ] && die "Failed to install ${PACKAGE_LIST[*]} ${INITRAMFS_PKGS[*]}" - - 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 - fi - - if XBPS_ARCH=$BASE_ARCH "$XBPS_QUERY_CMD" -r "$ROOTFS" dkms >/dev/null 2>&1; then - # dkms modules alphabetically before dkms can't configure - # if dkms hasn't configured beforehand to create /var/lib/dkms - chroot "$ROOTFS" env -i xbps-reconfigure dkms - fi - - chroot "$ROOTFS" env -i xbps-reconfigure -a - - if XBPS_ARCH=$BASE_ARCH "$XBPS_QUERY_CMD" -r "$ROOTFS" dash >/dev/null 2>&1; then - # bash configures alphabetically before dash, - # so if it's installed we should ensure it's /bin/sh - chroot "$ROOTFS" env -i xbps-alternatives -s dash - fi - - post_install_packages -} - -ignore_packages() { - mkdir -p "$ROOTFS"/etc/xbps.d - for pkg in "${IGNORE_PKGS[@]}"; do - echo "ignorepkg=$pkg" >> "$ROOTFS"/etc/xbps.d/mklive-ignore.conf - done -} - -enable_services() { - SERVICE_LIST="$*" - for service in $SERVICE_LIST; do - if ! [ -e $ROOTFS/etc/sv/$service ]; then - die "service $service not in /etc/sv" - fi - ln -sf /etc/sv/$service $ROOTFS/etc/runit/runsvdir/default/ - done - ln -sf /etc/sv/plymouthd $ROOTFS/etc/runit/runsvdir/default/ - ln -sf /etc/sv/elogind $ROOTFS/etc/runit/runsvdir/default/ -} - -change_shell() { - chroot "$ROOTFS" chsh -s "$ROOT_SHELL" root - [ $? -ne 0 ] && die "Failed to change the shell for root" -} - -copy_include_directories() { - for includedir in "${INCLUDE_DIRS[@]}"; do - info_msg "=> copying include directory '$includedir' ..." - find "$includedir" -mindepth 1 -maxdepth 1 -exec cp -rfpPv {} "$ROOTFS"/ \; - done -} - -generate_initramfs() { - local _args - - copy_dracut_files "$ROOTFS" - copy_autoinstaller_files "$ROOTFS" - chroot "$ROOTFS" env -i /usr/bin/dracut -N --"${INITRAMFS_COMPRESSION}" \ - --add-drivers "ahci" --force-add "vmklive autoinstaller" --omit systemd "/boot/initrd" $KERNELVERSION - [ $? -ne 0 ] && die "Failed to generate the initramfs" - - mv "$ROOTFS"/boot/initrd "$BOOT_DIR" - case "$TARGET_ARCH" in - i686*|x86_64*) cp "$ROOTFS/boot/vmlinuz-$KERNELVERSION" "$BOOT_DIR"/vmlinuz ;; - aarch64*) cp "$ROOTFS/boot/vmlinux-$KERNELVERSION" "$BOOT_DIR"/vmlinux ;; - esac -} - -cleanup_rootfs() { - 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 - fi - done - rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01vmklive - rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01autoinstaller -} - -generate_isolinux_boot() { - cp -f "$SYSLINUX_DATADIR"/isolinux.bin "$ISOLINUX_DIR" - cp -f "$SYSLINUX_DATADIR"/ldlinux.c32 "$ISOLINUX_DIR" - cp -f "$SYSLINUX_DATADIR"/libcom32.c32 "$ISOLINUX_DIR" - cp -f "$SYSLINUX_DATADIR"/vesamenu.c32 "$ISOLINUX_DIR" - cp -f "$SYSLINUX_DATADIR"/libutil.c32 "$ISOLINUX_DIR" - cp -f "$SYSLINUX_DATADIR"/chain.c32 "$ISOLINUX_DIR" - cp -f "$SYSLINUX_DATADIR"/reboot.c32 "$ISOLINUX_DIR" - cp -f "$SYSLINUX_DATADIR"/poweroff.c32 "$ISOLINUX_DIR" - cp -f isolinux/isolinux.cfg.in "$ISOLINUX_DIR"/isolinux.cfg - cp -f ${SPLASH_IMAGE} "$ISOLINUX_DIR" - - sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \ - -e "s|@@KERNVER@@|${KERNELVERSION}|" \ - -e "s|@@KEYMAP@@|${KEYMAP}|" \ - -e "s|@@ARCH@@|$TARGET_ARCH|" \ - -e "s|@@LOCALE@@|${LOCALE}|" \ - -e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \ - -e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \ - "$ISOLINUX_DIR"/isolinux.cfg - - # include memtest86+ - if [ -e "$VOIDTARGETDIR"/boot/memtest86+/memtest.bin ]; then - cp "$VOIDTARGETDIR"/boot/memtest86+/memtest.bin "$BOOT_DIR" - fi -} - -generate_grub_efi_boot() { - cp -f grub/grub.cfg "$GRUB_DIR" - cp -f "${SPLASH_IMAGE}" "$ISOLINUX_DIR" - cp -f grub/grub_void.cfg.pre "$GRUB_DIR"/grub_void.cfg - - case "$TARGET_ARCH" in - i686*|x86_64*) KERNEL_IMG=vmlinuz; WANT_MEMTEST=yes ;; - aarch64*) KERNEL_IMG=vmlinux; WANT_MEMTEST=no ;; - esac - - write_entry() { - local entrytitle="$1" id="$2" cmdline="$3" dtb="$4" hotkey="$5" - cat << EOF >> "$GRUB_DIR"/grub_void.cfg -menuentry "${entrytitle}" --id "${id}" ${hotkey:+--hotkey $hotkey} { - set gfxpayload="keep" - linux (\${voidlive})/boot/${KERNEL_IMG} \\ - root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \\ - rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \\ - vconsole.unicode=1 vconsole.keymap=${KEYMAP} locale.LANG=${LOCALE} ${cmdline} - initrd (\${voidlive})/boot/initrd -EOF - if [ -n "${dtb}" ]; then - printf ' devicetree (${voidlive})/boot/dtbs/%s\n' "${dtb}" >> "$GRUB_DIR"/grub_void.cfg - fi - printf '}\n' >> "$GRUB_DIR"/grub_void.cfg - } - - write_entries() { - local title_sfx="$1" id_sfx="$2" cmdline="$3" dtb="$4" - - ENTRY_TITLE="${BOOT_TITLE}" - - write_entry "${ENTRY_TITLE}" "linux${id_sfx}" \ - "$BOOT_CMDLINE $cmdline live.autologin live.user=player live.shell=/bin/bash quiet splash" "$dtb" - } - - write_entries - - # for platform in "${PLATFORMS[@]}"; do - # ( - # . "platforms/${platform}.sh" - - # if [ -n "$PLATFORM_DTB" ]; then - # mkdir -p "${BOOT_DIR}/dtbs/${PLATFORM_DTB%/*}" - # cp "${ROOTFS}/boot/dtbs/dtbs-${KERNVER}"*/"${PLATFORM_DTB}" "${BOOT_DIR}/dtbs/${PLATFORM_DTB}" - # fi - - # printf 'submenu "%s" --id platform-%s {\n' \ - # "${BOOT_TITLE} for ${PLATFORM_NAME:-$platform} >" "${platform}" >> "$GRUB_DIR"/grub_void.cfg - # write_entries "for ${PLATFORM_NAME:-$platform} " "-$platform" "$PLATFORM_CMDLINE" "${PLATFORM_DTB}" - # printf '}\n' >> "$GRUB_DIR"/grub_void.cfg - # ) - # done - - cat grub/grub_void.cfg.post >> "$GRUB_DIR"/grub_void.cfg - - cat grub/grub_void.cfg - - sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" "$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. - truncate -s 32M "$GRUB_DIR"/efiboot.img >/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="$BUILDDIR" -dt grub-efi.XXXXX)" - LOOP_DEVICE="$(losetup --show --find "${GRUB_DIR}"/efiboot.img)" - mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1 - - build_grub_image() { - local GRUB_ARCH="$1" EFI_ARCH="$2" - xbps-uchroot "$VOIDTARGETDIR" grub-mkstandalone -- \ - --directory="/usr/lib/grub/${GRUB_ARCH}-efi" \ - --format="${GRUB_ARCH}-efi" \ - --output="/tmp/boot${EFI_ARCH,,}.efi" \ - "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 "$VOIDTARGETDIR/tmp/boot${EFI_ARCH,,}.efi" "${GRUB_EFI_TMPDIR}/EFI/BOOT/BOOT${EFI_ARCH^^}.EFI" - } - - cp -a "$IMAGEDIR"/boot "$VOIDTARGETDIR" - - case "$TARGET_ARCH" in - i686*|x86_64*) - # XXX: why are both built on both arches? - build_grub_image i386 ia32 - build_grub_image x86_64 x64 - # include memtest86+ - if [ -e "$VOIDTARGETDIR"/boot/memtest86+/memtest.efi ]; then - cp "$VOIDTARGETDIR"/boot/memtest86+/memtest.efi "$BOOT_DIR" - fi - ;; - aarch64*) - build_grub_image arm64 aa64 - ;; - esac - umount "$GRUB_EFI_TMPDIR" - losetup --detach "${LOOP_DEVICE}" - rm -rf "$GRUB_EFI_TMPDIR" -} - -generate_squashfs() { - umount_pseudofs || exit 1 - - # Find out required size for the rootfs and create an ext3fs image off it. - ROOTFS_SIZE=$(du --apparent-size -sm "$ROOTFS"|awk '{print $1}') - mkdir -p "$BUILDDIR/tmp/LiveOS" - truncate -s "$((ROOTFS_SIZE+ROOTFS_SIZE))M" \ - "$BUILDDIR"/tmp/LiveOS/ext3fs.img >/dev/null 2>&1 - mkdir -p "$BUILDDIR/tmp-rootfs" - 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" - - "$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" -} - -generate_iso_image() { - local bootloader n - XORRISO_ARGS=( - -iso-level 3 -rock -joliet -joliet-long -max-iso9660-filenames -omit-period - -omit-version-number -relaxed-filenames -allow-lowercase - -volid VOID_LIVE - ) - - if [ "$IMAGE_TYPE" = hybrid ]; then - XORRISO_ARGS+=(-isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin) - fi - - n=1 - for bootloader in "${BOOTLOADERS[@]}"; do - if (( n > 1 )); then - XORRISO_ARGS+=(-eltorito-alt-boot) - fi - - case "${bootloader}" in - grub) - XORRISO_ARGS+=( - -e boot/grub/efiboot.img -no-emul-boot - -isohybrid-gpt-basdat -isohybrid-apm-hfsplus - ) - ;; - syslinux) - XORRISO_ARGS+=( - -eltorito-boot boot/isolinux/isolinux.bin - -eltorito-catalog boot/isolinux/boot.cat - -no-emul-boot -boot-load-size 4 -boot-info-table - ) - ;; - esac - - n=$(( n + 1 )) - done - - XORRISO_ARGS+=( - -output "$OUTPUT_FILE" "$IMAGEDIR" - ) - - "$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs "${XORRISO_ARGS[@]}" || die "Failed to generate ISO image" -} - -# -# main() -# -while getopts "a:b:r:c:C:T:Kk:l:i:I:S:e:s:o:p:g:v:P:Vh" opt; do - case $opt in - a) TARGET_ARCH="$OPTARG";; - b) BASE_SYSTEM_PKG="$OPTARG";; - r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";; - c) XBPS_CACHEDIR="$OPTARG";; - g) IGNORE_PKGS+=($OPTARG) ;; - K) readonly KEEP_BUILDDIR=1;; - k) KEYMAP="$OPTARG";; - l) LOCALE="$OPTARG";; - i) INITRAMFS_COMPRESSION="$OPTARG";; - I) INCLUDE_DIRS+=("$OPTARG");; - S) SERVICE_LIST="$SERVICE_LIST $OPTARG";; - e) ROOT_SHELL="$OPTARG";; - s) SQUASHFS_COMPRESSION="$OPTARG";; - o) OUTPUT_FILE="$OPTARG";; - p) PACKAGE_LIST+=($OPTARG);; - P) PLATFORMS+=($OPTARG) ;; - C) BOOT_CMDLINE="$OPTARG";; - T) BOOT_TITLE="$OPTARG";; - v) LINUX_VERSION="$OPTARG";; - esac -done -shift $((OPTIND - 1)) -XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=https://repo-default.voidlinux.org/current --repository=https://repo-default.voidlinux.org/current/musl --repository=https://repo-default.voidlinux.org/current/aarch64" - -# Configure dracut to use overlayfs for the writable overlay. -BOOT_CMDLINE="$BOOT_CMDLINE rd.live.overlay.overlayfs=1 " - -HOST_ARCH=$(xbps-uhelper arch) - -# Set defaults -: ${TARGET_ARCH:=$(xbps-uhelper arch 2>/dev/null || uname -m)} -: ${XBPS_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${TARGET_ARCH}} -: ${XBPS_HOST_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${HOST_ARCH}} -: ${KEYMAP:=us} -: ${LOCALE:=en_US.UTF-8} -: ${INITRAMFS_COMPRESSION:=xz} -: ${SQUASHFS_COMPRESSION:=xz} -: ${BASE_SYSTEM_PKG:=base-system} -: ${BOOT_TITLE:="MinceraftOS"} -: ${LINUX_VERSION:=linux} - -XBPS_TARGET_ARCH="$TARGET_ARCH" register_binfmt - -case "$TARGET_ARCH" in - x86_64*|i686*) - BOOTLOADERS=(syslinux grub) - IMAGE_TYPE='hybrid' - TARGET_PKGS+=(syslinux grub-i386-efi grub-x86_64-efi memtest86+) - PLATFORMS=() # arm only - ;; - aarch64*) - BOOTLOADERS=(grub) - IMAGE_TYPE='efi' - TARGET_PKGS+=(grub-arm64-efi) - for platform in "${PLATFORMS[@]}"; do - if [ -r "platforms/${platform}.sh" ]; then - . "platforms/${platform}.sh" - else - die "unknown platform: ${platform}" - fi - PACKAGE_LIST+=("${PLATFORM_PKGS[@]}") - unset PLATFORM_PKGS PLATFORM_CMDLINE PLATFORM_DTB - done - - ;; - *) >&2 echo "architecture $TARGET_ARCH not supported by mklive.sh"; exit 1;; -esac - -# Required packages in the image for a working system. -PACKAGE_LIST+=("$BASE_SYSTEM_PKG") - -# Check for root permissions. -if [ "$(id -u)" -ne 0 ]; then - die "Must be run as root, exiting..." -fi - -trap 'error_out $? $LINENO' INT TERM 0 - -BUILDDIR="./build" -rm -rf $BUILDDIR -IMAGEDIR="$BUILDDIR/image" -ROOTFS="$IMAGEDIR/rootfs" -VOIDHOSTDIR="$BUILDDIR/void-host" -VOIDTARGETDIR="$BUILDDIR/void-target" -BOOT_DIR="$IMAGEDIR/boot" -ISOLINUX_DIR="$BOOT_DIR/isolinux" -GRUB_DIR="$BOOT_DIR/grub" -ROOT_SHELL="/bin/bash" -CURRENT_STEP=0 -STEP_COUNT=10 -[ "${IMAGE_TYPE}" = hybrid ] && STEP_COUNT=$((STEP_COUNT+1)) -[ "${#INCLUDE_DIRS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1)) -[ "${#IGNORE_PKGS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1)) -[ -n "$ROOT_SHELL" ] && STEP_COUNT=$((STEP_COUNT+1)) - -: ${SYSLINUX_DATADIR:="$VOIDTARGETDIR"/usr/lib/syslinux} -: ${GRUB_DATADIR:="$VOIDTARGETDIR"/usr/share/grub} -: ${SPLASH_IMAGE:=data/splash.png} -: ${XBPS_INSTALL_CMD:=xbps-install} -: ${XBPS_REMOVE_CMD:=xbps-remove} -: ${XBPS_QUERY_CMD:=xbps-query} -: ${XBPS_RINDEX_CMD:=xbps-rindex} -: ${XBPS_UHELPER_CMD:=xbps-uhelper} -: ${XBPS_RECONFIGURE_CMD:=xbps-reconfigure} - -mkdir -p "$ROOTFS" "$VOIDHOSTDIR" "$VOIDTARGETDIR" "$GRUB_DIR" "$ISOLINUX_DIR" - -print_step "Synchronizing XBPS repository data..." -copy_void_keys "$ROOTFS" -XBPS_ARCH=$TARGET_ARCH $XBPS_INSTALL_CMD -r "$ROOTFS" ${XBPS_REPOSITORY} -Sy -copy_void_keys "$VOIDHOSTDIR" -XBPS_ARCH=$HOST_ARCH $XBPS_INSTALL_CMD -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} -Sy -copy_void_keys "$VOIDTARGETDIR" -XBPS_ARCH=$TARGET_ARCH $XBPS_INSTALL_CMD -r "$VOIDTARGETDIR" ${XBPS_REPOSITORY} -Sy - -# Get linux version for ISO -# If linux version option specified use -shopt -s extglob -case "$LINUX_VERSION" in - linux+([0-9.])) - IGNORE_PKGS+=(linux) - PACKAGE_LIST+=("$LINUX_VERSION" linux-base) - ;; - linux-@(mainline|lts)) - IGNORE_PKGS+=(linux) - PACKAGE_LIST+=("$LINUX_VERSION") - LINUX_VERSION="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x "$LINUX_VERSION" | grep 'linux[0-9._]\+')" - ;; - linux-asahi) - IGNORE_PKGS+=(linux) - PACKAGE_LIST+=(linux-asahi linux-base) - ;; - linux) - PACKAGE_LIST+=(linux) - LINUX_VERSION="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x linux | grep 'linux[0-9._]\+')" - ;; - *) - die "-v option must be in format linux or linux-" - ;; -esac -shopt -u extglob - -_kver="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -p pkgver $LINUX_VERSION)" -KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion ${_kver}) - -if [ "$LINUX_VERSION" = linux-asahi ]; then - KERNELVERSION="${KERNELVERSION%%_*}-asahi_${KERNELVERSION##*_}" -fi - -if [ "$?" -ne "0" ]; then - die "Failed to find kernel package version" -fi - -mkdir -p output - -: ${OUTPUT_FILE="output/minceraftOS-$MOSVER-$(date '+%Y-%m-%d_%H:%M:%S').iso"} - -print_step "Installing software to generate the image: ${REQUIRED_PKGS[*]} ..." -install_prereqs "${REQUIRED_PKGS[@]}" - -print_step "Installing software to generate the image: ${TARGET_PKGS[*]} ..." -install_target_pkgs "${TARGET_PKGS[@]}" - -mkdir -p "$ROOTFS"/etc -[ -s data/motd ] && cp data/motd "$ROOTFS"/etc -[ -s data/issue ] && cp data/issue "$ROOTFS"/etc -# cp -r data/minceraft "$ROOTFS"/etc - -if [ "${#IGNORE_PKGS[@]}" -gt 0 ]; then - print_step "Ignoring packages in the rootfs: ${IGNORE_PKGS[*]} ..." - ignore_packages -fi - -print_step "Installing void pkgs into the rootfs: ${PACKAGE_LIST[*]} ..." -install_packages - -: ${DEFAULT_SERVICE_LIST:=agetty-tty1 agetty-tty2 agetty-tty3 agetty-tty4 agetty-tty5 agetty-tty6 udevd} -print_step "Enabling services: ${SERVICE_LIST} ..." -enable_services ${DEFAULT_SERVICE_LIST} ${SERVICE_LIST} - -if [ -n "$ROOT_SHELL" ]; then - print_step "Changing the root shell ..." - change_shell -fi - -if [ "${#INCLUDE_DIRS[@]}" -gt 0 ];then - print_step "Copying directory structures into the rootfs ..." - copy_include_directories -fi - -print_step "Generating initramfs image ($INITRAMFS_COMPRESSION)..." -generate_initramfs - -if [ "$IMAGE_TYPE" = hybrid ]; then - print_step "Generating isolinux support for PC-BIOS systems..." - generate_isolinux_boot -fi - -print_step "Generating GRUB support for EFI systems..." -generate_grub_efi_boot - -mkdir -p "$ROOTFS"/home -mkdir -p "$ROOTFS"/home/player -cp data/xinitrc "$ROOTFS"/home/player/.xinitrc -cp data/bash_profile "$ROOTFS"/home/player/.bash_profile -cp -r data/mine "$ROOTFS"/home/player/mine -touch "$ROOTFS"/home/player/.Xauthority -cp data/bash_profile "$ROOTFS"/home/player/.profile -cp data/bash_profile "$ROOTFS"/etc/profile -chmod 777 "$ROOTFS"/home/player -R - -mkdir -p "$ROOTFS"/usr -mkdir -p "$ROOTFS"/usr/share -mkdir -p "$ROOTFS"/usr/share/icons/ -mkdir -p "$ROOTFS"/usr/share/icons/default -cp -r data/cursors "$ROOTFS"/usr/share/icons/default/cursors -cp data/index.theme "$ROOTFS"/usr/share/icons/default/index.theme -chmod -R 755 "$ROOTFS"/usr/share/icons/default/cursors - -cat "$ROOTFS"/etc -cat "$ROOTFS"/etc/X11 - -print_step "Cleaning up rootfs..." -cleanup_rootfs - -print_step "Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..." -generate_squashfs - -print_step "Generating ISO image..." -generate_iso_image - -hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}') -info_msg "Created $(readlink -f "$OUTPUT_FILE") ($hsize) successfully." diff --git a/mkmine.sh b/mkmine.sh deleted file mode 100755 index b293bf0..0000000 --- a/mkmine.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -start_path="$(pwd)" - -function wrap_pwd { - local was_path="$(pwd)" - cd $start_path - $@ - cd $was_path -} - -function build_ultimmc { - echo "Build UltimMC" - if [ -f ultimmc/build/UltimMC ]; then - return - fi - mkdir -p ultimmc/build - cd ultimmc/build - export JAVA_HOME=/usr/lib/jvm/openjdk8 - cmake \ - -DCMAKE_C_COMPILER=/usr/bin/gcc \ - -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ - -DCMAKE_BUILD_TYPE=Release \ - -DLauncher_NOTIFICATION_URL:STRING=https://files.multimc.org/notifications.json \ - -DCMAKE_INSTALL_PREFIX:PATH=../ \ - -DLauncher_UPDATER_BASE=https://files.multimc.org/update/ \ - -DLauncher_PASTE_EE_API_KEY:STRING=utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ \ - -DLauncher_ANALYTICS_ID:STRING=UA-87731965-2 \ - -DLauncher_LAYOUT=lin-nodeps \ - -DLauncher_BUILD_PLATFORM=lin64 \ - -DLauncher_BUG_TRACKER_URL=https://github.com/UltimMC/Launcher/issues \ - -DLauncher_EMBED_SECRETS=On \ - .. - make -} - -function start_launcher { - echo "Launcher is starting..." - cd data/mine - ./UltimMC -l default -} - -function build_mods { - echo "Mods are building..." - cd mods - ./build-all.sh -} - -function copy_mine_data { - echo "Minceraft data is copying..." - cp mine-data/ultimmc.cfg data/mine - cp mine-data/run_mine.sh data/mine - cp mine-data/accounts.json data/mine - cp -r mine-data/translations data/mine - cp -r mine-data/themes data/mine - cp -r mine-data/libraries data/mine - cp -r mine-data/injectors data/mine - cp -r mine-data/icons data/mine - mkdir -p data/mine/instances - mkdir -p data/mine/instances/default - cp mine-data/mmc-pack.json data/mine/instances/default - cp mine-data/instance.cfg data/mine/instances/default - mkdir -p data/mine/instances/default/.minecraft - cp mine-data/options.txt data/mine/instances/default/.minecraft -} - -function create_mine_dir { - echo "Create minceraft launcher directory..." - mkdir data/mine || return - wrap_pwd copy_mine_data - wrap_pwd build_mods - rm -rf data/mine/instances/default/.minecraft/mods - cp -r mods/build data/mine/instances/default/.minecraft/mods - wrap_pwd build_ultimmc - cp -a ultimmc/build/. data/mine - chmod 777 data/mine -R - wrap_pwd start_launcher - wrap_pwd copy_mine_data -} - -rm -rf data/mine -create_mine_dir -echo "Minceraft is ready to play!" diff --git a/release.sh b/release.sh deleted file mode 100755 index f10b418..0000000 --- a/release.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -set -e - -usage() { - echo "release.sh start [-l LIVE_ARCHS] [-f LIVE_VARIANTS] [-a ROOTFS_ARCHS]" - echo " [-p PLATFORMS] [-i SBC_IMGS] [-d DATE] [-r REPOSITORY] -- [gh args...]" - echo "release.sh dl [run id] -- [gh args...]" - echo "release.sh sign DATE SHASUMFILE" - exit 1 -} - -check_programs() { - for prog; do - if ! type $prog &>/dev/null; then - echo "missing program: $prog" - exit 1 - fi - done -} - -start_build() { - check_programs gh - ARGS=() - while getopts "a:d:f:i:l:p:r:" opt; do - case $opt in - a) ARGS+=(-f rootfs="$OPTARG") ;; - d) ARGS+=(-f datecode="$OPTARG") ;; - f) ARGS+=(-f live_flavors="$OPTARG") ;; - i) ARGS+=(-f sbc_imgs="$OPTARG") ;; - l) ARGS+=(-f live_archs="$OPTARG") ;; - p) ARGS+=(-f platformfs="$OPTARG") ;; - r) ARGS+=(-f mirror="$OPTARG") ;; - ?) usage;; - esac - done - shift $((OPTIND - 1)) - gh workflow run gen-images.yml "${ARGS[@]}" "$@" -} - -# this assumes that the latest successful build is the one to download -# wish it could be better but alas: -# https://github.com/cli/cli/issues/4001 -download_build() { - local run - check_programs gh - if [ -n "$1" ] && [ "$1" != "--" ]; then - run="$1" - shift - else - run="$(gh run list -s success -w gen-images.yml --json databaseId -q '.[].databaseId' "$@" | sort -r | head -1)" - fi - if [ -n "$1" ] && [ "$1" != "--" ]; then - usage - elif [ "$1" == "--" ]; then - shift - fi - echo "Downloading artifacts from run ${run} [this may take a while] ..." - gh run download "$run" -p 'void-live*' "$@" - echo "Done." -} - -sign_build() { - check_programs pwgen minisign - DATECODE="$1" - SUMFILE="$2" - mkdir -p release - - echo "Creating key..." - pwgen -cny 25 1 > "release/void-release-$DATECODE.key" - minisign -G -p "release/void-release-$DATECODE.pub" \ - -s "release/void-release-$DATECODE.sec" \ - -c "This key is only valid for images with date $DATECODE." \ - < <(cat "release/void-release-$DATECODE.key" "release/void-release-$DATECODE.key") - - echo "Signing $SUMFILE..." - minisign -S -x "${SUMFILE//txt/sig}" -s "release/void-release-$DATECODE.sec" \ - -c "This key is only valid for images with date $DATECODE." \ - -t "This key is only valid for images with date $DATECODE." \ - -m "$SUMFILE" < "release/void-release-$DATECODE.key" -} - -case "$1" in - st*) shift; start_build "$@" ;; - d*) shift; download_build "$@" ;; - si*) shift; sign_build "$@" ;; - *) usage ;; -esac