From d43b0d4989f4254126f3b8441306cb2fd4c0008a Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Mon, 12 Sep 2022 22:00:21 +0200 Subject: [PATCH] start riscv64 support, rename fix_aarch64_network to fix_network --- etc/archboot/defaults | 4 ++ etc/archboot/presets/riscv64 | 9 +++ etc/archboot/presets/riscv64-latest | 9 +++ etc/archboot/presets/riscv64-local | 9 +++ etc/archboot/riscv64-latest.conf | 31 +++++++++++ etc/archboot/riscv64-local.conf | 30 ++++++++++ etc/archboot/riscv64-update_installer.conf | 41 ++++++++++++++ etc/archboot/riscv64.conf | 38 +++++++++++++ .../archboot-aarch64-pacman-chroot-tarball.sh | 4 +- .../archboot-riscv64-pacman-chroot-tarball.sh | 55 +++++++++++++++++++ usr/lib/archboot/common.sh | 2 +- usr/lib/archboot/server.sh | 2 +- 12 files changed, 230 insertions(+), 4 deletions(-) create mode 100644 etc/archboot/presets/riscv64 create mode 100644 etc/archboot/presets/riscv64-latest create mode 100644 etc/archboot/presets/riscv64-local create mode 100644 etc/archboot/riscv64-latest.conf create mode 100644 etc/archboot/riscv64-local.conf create mode 100644 etc/archboot/riscv64-update_installer.conf create mode 100644 etc/archboot/riscv64.conf create mode 100755 usr/bin/archboot-riscv64-pacman-chroot-tarball.sh diff --git a/etc/archboot/defaults b/etc/archboot/defaults index 69bc70eb9..83c137c75 100644 --- a/etc/archboot/defaults +++ b/etc/archboot/defaults @@ -50,10 +50,14 @@ _SERVER_SOURCE_DIR="${_SERVER_PUBLIC}/src/iso" _PACMAN_AARCH64="pacman-aarch64-chroot" _PACMAN_AARCH64_CHROOT="${_PACMAN_AARCH64}-latest.tar.zst" _SERVER_PACMAN_AARCH64="${_SERVER_PUBLIC}/src/${_PACMAN_AARCH64}" +_PACMAN_RISCV64="pacman-RISCV64-chroot" +_PACMAN_RISCV64_CHROOT="${_PACMAN_RISCV64}-latest.tar.zst" +_SERVER_PACMAN_RISCV64="${_SERVER_PUBLIC}/src/${_PACMAN_RISCV64}" # public download paths _ARCHBOOT_PUBLIC="https://pkgbuild.com/~tpowa/archboot" _ARCHBOOT_SOURCE="${_ARCHBOOT_PUBLIC}/src/iso" _ARCHBOOT_AARCH64_CHROOT_PUBLIC="${_ARCHBOOT_PUBLIC}/src/${_PACMAN_AARCH64}" +_ARCHBOOT_RISCV64_CHROOT_PUBLIC="${_ARCHBOOT_PUBLIC}/src/${_PACMAN_RISCV64}" # local user and group _USER="tobias" _GROUP="users" diff --git a/etc/archboot/presets/riscv64 b/etc/archboot/presets/riscv64 new file mode 100644 index 000000000..3a9963ed9 --- /dev/null +++ b/etc/archboot/presets/riscv64 @@ -0,0 +1,9 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# mkinitcpio config file, defaulted to stock config file +MKINITCPIO_CONFIG="/etc/archboot/riscv64.conf" + +# kernel version, defaulted to build for runtime kernel +ALL_kver="/boot/vmlinuz-linux" + diff --git a/etc/archboot/presets/riscv64-latest b/etc/archboot/presets/riscv64-latest new file mode 100644 index 000000000..4cf33c728 --- /dev/null +++ b/etc/archboot/presets/riscv64-latest @@ -0,0 +1,9 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# mkinitcpio config file, defaulted to stock config file +MKINITCPIO_CONFIG="/etc/archboot/riscv64-latest.conf" + +# kernel version, defaulted to build for runtime kernel +ALL_kver="/boot/vmlinuz-linux" + diff --git a/etc/archboot/presets/riscv64-local b/etc/archboot/presets/riscv64-local new file mode 100644 index 000000000..76d8b0399 --- /dev/null +++ b/etc/archboot/presets/riscv64-local @@ -0,0 +1,9 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# mkinitcpio config file, defaulted to stock config file +MKINITCPIO_CONFIG="/etc/archboot/riscv64-local.conf" + +# kernel version, defaulted to build for runtime kernel +ALL_kver="/boot/vmlinuz-linux" + diff --git a/etc/archboot/riscv64-latest.conf b/etc/archboot/riscv64-latest.conf new file mode 100644 index 000000000..cabfc1cf8 --- /dev/null +++ b/etc/archboot/riscv64-latest.conf @@ -0,0 +1,31 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# For more information on how using mkinitcpio please refer to the main config file +# or check the wiki. +MODULES=() +BINARIES=() +FILES=() + +# SETUP +# +# Please change the hooks only if you know what you are doing. +HOOKS=(udev keyboard archboot_base_common archboot_base_latest archboot_installer_common \ +archboot_net_common archboot_remote archboot_kexec archboot_licenses) + +# COMPRESSION +# Use this to compress the initramfs image. By default, gzip compression +# is used. Use 'cat' to create an uncompressed image. +COMPRESSION="zstd" +#COMPRESSION="gzip" +#COMPRESSION="bzip2" +#COMPRESSION="lzma" +#COMPRESSION="xz" +#COMPRESSION="lzop" +#COMPRESSION="lz4" + +# COMPRESSION_OPTIONS +# Additional options for the compressor +COMPRESSION_OPTIONS=(-19) +MODULES_DECOMPRESS="no" + diff --git a/etc/archboot/riscv64-local.conf b/etc/archboot/riscv64-local.conf new file mode 100644 index 000000000..f3bea3e71 --- /dev/null +++ b/etc/archboot/riscv64-local.conf @@ -0,0 +1,30 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# For more information on how using mkinitcpio please refer to the main config file +# or check the wiki. +MODULES=() +BINARIES=() +FILES=() + +# SETUP +# +# Please change the hooks only if you know what you are doing. +HOOKS=(udev keyboard archboot_base_common archboot_base_latest \ +archboot_installer_common archboot_net_common archboot_remote archboot_kexec archboot_licenses archboot_cache) + +# COMPRESSION +# Use this to compress the initramfs image. By default, gzip compression +# is used. Use 'cat' to create an uncompressed image. +COMPRESSION="zstd" +#COMPRESSION="gzip" +#COMPRESSION="bzip2" +#COMPRESSION="lzma" +#COMPRESSION="xz" +#COMPRESSION="lzop" +#COMPRESSION="lz4" + +# COMPRESSION_OPTIONS +# Additional options for the compressor +COMPRESSION_OPTIONS=(-19) +MODULES_DECOMPRESS="no" diff --git a/etc/archboot/riscv64-update_installer.conf b/etc/archboot/riscv64-update_installer.conf new file mode 100644 index 000000000..ceb17e824 --- /dev/null +++ b/etc/archboot/riscv64-update_installer.conf @@ -0,0 +1,41 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# For more information on how using mkinitcpio please refer to the main config file +# or check the wiki. +MODULES=() +BINARIES=() +FILES=() + +# SETUP +# +# Please change the hooks only if you know what you are doing. +HOOKS=(archboot_cache archboot_cache_cleanup archboot_base archboot_base_cleanup \ +archboot_firmware archboot_firmware_cleanup archboot_base_common archboot_base_common_cleanup \ +archboot_filesystems archboot_filesystems_cleanup archboot_net archboot_net_cleanup \ +block dmraid lvm2 encrypt btrfs keyboard archboot_acpi archboot_kms udev \ +archboot_devicemapper archboot_hypervisor archboot_net_common archboot_platform archboot_wireless \ +archboot_wireless_staging archboot_installer_common archboot_installer archboot_installer_cleanup \ +archboot_tz archboot_keymap archboot_motd archboot_hwdetect archboot_mdadm mdadm_udev \ +archboot_lvm2 archboot_remote archboot_kexec archboot_grub archboot_efibootmgr archboot_pciutils \ +archboot_usbutils archboot_smartmontools archboot_licenses archboot_netctl \ +archboot_fsarchiver archboot_vim archboot_wipe archboot_testdisk archboot_ddrescue \ +archboot_nmap archboot_tcpdump archboot_dnsmasq \ +archboot_usb_modeswitch archboot_secure_boot archboot_efivar archboot_lshw) + +# COMPRESSION +# Use this to compress the initramfs image. By default, gzip compression +# is used. Use 'cat' to create an uncompressed image. +COMPRESSION="zstd" +#COMPRESSION="gzip" +#COMPRESSION="bzip2" +#COMPRESSION="lzma" +#COMPRESSION="xz" +#COMPRESSION="lzop" +#COMPRESSION="lz4" + +# COMPRESSION_OPTIONS +# Additional options for the compressor +#COMPRESSION_OPTIONS=() +MODULES_DECOMPRESS="no" + diff --git a/etc/archboot/riscv64.conf b/etc/archboot/riscv64.conf new file mode 100644 index 000000000..c2a8a53be --- /dev/null +++ b/etc/archboot/riscv64.conf @@ -0,0 +1,38 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# For more information on how using mkinitcpio please refer to the main config file +# or check the wiki. +MODULES=() +BINARIES=() +FILES=() + +# SETUP +# +# Please change the hooks only if you know what you are doing. +HOOKS=(archboot_kms udev archboot_base_common archboot_base archboot_installer_common \ +archboot_installer archboot_tz archboot_keymap archboot_acpi archboot_motd archboot_hwdetect \ +block archboot_net_common archboot_net keyboard dmraid archboot_devicemapper archboot_mdadm \ +mdadm_udev lvm2 archboot_lvm2 encrypt btrfs archboot_filesystems archboot_remote \ +archboot_kexec archboot_grub archboot_efibootmgr archboot_pciutils archboot_usbutils \ +archboot_smartmontools archboot_licenses archboot_wireless archboot_wireless_staging \ +archboot_netctl archboot_fsarchiver archboot_vim archboot_wipe archboot_testdisk \ +archboot_ddrescue archboot_nmap archboot_tcpdump archboot_dnsmasq \ +archboot_platform archboot_hypervisor archboot_usb_modeswitch archboot_secure_boot \ +archboot_efivar archboot_lshw archboot_firmware) + +# COMPRESSION +# Use this to compress the initramfs image. By default, gzip compression +# is used. Use 'cat' to create an uncompressed image. +COMPRESSION="zstd" +#COMPRESSION="gzip" +#COMPRESSION="bzip2" +#COMPRESSION="lzma" +#COMPRESSION="xz" +#COMPRESSION="lzop" +#COMPRESSION="lz4" + +# COMPRESSION_OPTIONS +# Additional options for the compressor +COMPRESSION_OPTIONS=(-19) +MODULES_DECOMPRESS="no" diff --git a/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh b/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh index fcc11dfc7..5fb148edc 100755 --- a/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh +++ b/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh @@ -31,13 +31,13 @@ bsdtar -xf ArchLinuxARM-aarch64-latest.tar.gz -C "${1}" echo "Removing installation tarball ..." rm ArchLinuxARM-aarch64-latest.tar.gz _generate_keyring "${1}" || exit 1 -_fix_aarch64_network "${1}" +_fix_network "${1}" # update container to latest packages echo "Installing pacman to container ..." mkdir -p "${1}/${_PACMAN_AARCH64}/var/lib/pacman" systemd-nspawn -D "${1}" pacman --root "/${_PACMAN_AARCH64}" -Sy awk pacman --ignore systemd-resolvconf --noconfirm >/dev/null 2>&1 _generate_keyring "${1}/${_PACMAN_AARCH64}" || exit 1 -_fix_aarch64_network "${1}/${_PACMAN_AARCH64}" +_fix_network "${1}/${_PACMAN_AARCH64}" _CLEANUP_CONTAINER="1" _clean_container "${1}/${_PACMAN_AARCH64}" 2>/dev/null _CLEANUP_CACHE="1" _clean_cache "${1}/${_PACMAN_AARCH64}" 2>/dev/null echo "Generating tarball ..." diff --git a/usr/bin/archboot-riscv64-pacman-chroot-tarball.sh b/usr/bin/archboot-riscv64-pacman-chroot-tarball.sh new file mode 100755 index 000000000..01038d235 --- /dev/null +++ b/usr/bin/archboot-riscv64-pacman-chroot-tarball.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# created by Tobias Powalowski +_ARCH="riscv64" +. /etc/archboot/defaults +. /usr/lib/archboot/common.sh +. /usr/lib/archboot/container.sh +_RISCV64_VERSION="archriscv-20220727" +_LATEST_RISCV64="https://archriscv.felixc.at/images/${_RISCV64_VERSION}.tar.zst" +_KEYRING="archlinux" + +_usage () { + echo "CREATE RISCV64 PACMAN CHROOT" + echo "-----------------------------" + echo "This will create an riscv64 pacman chroot tarball on x86_64" + echo "Usage: ${_BASENAME} " + exit 0 +} + +[[ -z "${1}" ]] && _usage + +_root_check +_x86_64_check + +echo "Starting container creation ..." +# remove old files +[[ -f ${_PACMAN_RISCV64_CHROOT} ]] && rm ${_PACMAN_RISCV64_CHROOT}{,.sig} 2>/dev/null +echo "Create directory ${1} ..." +mkdir -p "${1}"/"${_PACMAN_RISCV64}" +echo "Downloading archlinux riscv64 ..." +! [[ -f ${_RISCV64_VERSION}.tar.zst ]] && wget "${_LATEST_RISCV64}" >/dev/null 2>&1 +bsdtar -xf ${_RISCV64_VERSION}.tar.zst -C "${1}" +echo "Removing installation tarball ..." +rm ${_RISCV64_VERSION}.tar.zst +_generate_keyring "${1}" || exit 1 +_fix_network "${1}" +# update container to latest packages +echo "Installing pacman to container ..." +mkdir -p "${1}/${_PACMAN_RISCV64}/var/lib/pacman" +systemd-nspawn -D "${1}" pacman --root "/${_PACMAN_RISCV64}" -Sy awk pacman --ignore systemd-resolvconf --noconfirm >/dev/null 2>&1 +_generate_keyring "${1}/${_PACMAN_RISCV64}" || exit 1 +_fix_network "${1}/${_PACMAN_RISCV64}" +_CLEANUP_CONTAINER="1" _clean_container "${1}/${_PACMAN_RISCV64}" 2>/dev/null +_CLEANUP_CACHE="1" _clean_cache "${1}/${_PACMAN_RISCV64}" 2>/dev/null +echo "Generating tarball ..." +tar -acf ${_PACMAN_RISCV64_CHROOT} -C "${1}"/"${_PACMAN_RISCV64}" . >/dev/null 2>&1 || exit 1 +echo "Removing ${1} ..." +rm -r "${1}" +echo "Finished container tarball." +echo "Sign tarball ..." +#shellcheck disable=SC2086 +sudo -u "${_USER}" gpg ${_GPG} ${_PACMAN_RISCV64_CHROOT} || exit 1 +chown "${_USER}":"${_GROUP}" ${_PACMAN_RISCV64_CHROOT}{,.sig} || exit 1 +echo "Uploading tarball to ${_SERVER}:${_SERVER_PACMAN_RISCV64} ..." +sudo -u "${_USER}" scp ${_PACMAN_RISCV64_CHROOT}{,.sig} ${_SERVER}:${_SERVER_PACMAN_RISCV64} || exit 1 +echo "Finished." diff --git a/usr/lib/archboot/common.sh b/usr/lib/archboot/common.sh index ad4b7f0ea..44a74b7e4 100644 --- a/usr/lib/archboot/common.sh +++ b/usr/lib/archboot/common.sh @@ -93,7 +93,7 @@ _x86_64_pacman_restore() { fi } -_fix_aarch64_network() { +_fix_network() { echo "Fix network settings in ${1} ..." # enable parallel downloads sed -i -e 's:^#ParallelDownloads:ParallelDownloads:g' "${1}"/etc/pacman.conf diff --git a/usr/lib/archboot/server.sh b/usr/lib/archboot/server.sh index c53db8e73..51b1b2219 100644 --- a/usr/lib/archboot/server.sh +++ b/usr/lib/archboot/server.sh @@ -19,7 +19,7 @@ _update_aarch64_pacman_chroot() { # update container to latest packages echo "Update container to latest packages..." systemd-nspawn -D "${_PACMAN_AARCH64}" pacman -Syu --noconfirm >/dev/null 2>&1 || exit 1 - _fix_aarch64_network "${_PACMAN_AARCH64}" + _fix_network "${_PACMAN_AARCH64}" _CLEANUP_CONTAINER="1" _clean_container "${_PACMAN_AARCH64}" >/dev/null 2>&1 _CLEANUP_CACHE="1" _clean_cache "${_PACMAN_AARCH64}" >/dev/null 2>&1 echo "Generating tarball ..."