From 1fe6d9c2a3f6b9b88931600b48aa88f0c4aef340 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Fri, 18 Mar 2022 12:32:00 +0100 Subject: [PATCH] start adding offline iso --- etc/archboot/presets/x86_64-offline | 8 +++++ etc/archboot/x86_64-offline.conf | 31 +++++++++++++++++++ usr/bin/archboot-update-installer.sh | 11 +++++-- usr/lib/archboot/container_functions | 2 +- usr/lib/initcpio/install/archboot_base | 2 +- usr/lib/initcpio/install/archboot_base_common | 2 +- .../install/archboot_installer_offline | 22 +++++++++++++ 7 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 etc/archboot/presets/x86_64-offline create mode 100644 etc/archboot/x86_64-offline.conf create mode 100644 usr/lib/initcpio/install/archboot_installer_offline diff --git a/etc/archboot/presets/x86_64-offline b/etc/archboot/presets/x86_64-offline new file mode 100644 index 000000000..1fb4ca0ab --- /dev/null +++ b/etc/archboot/presets/x86_64-offline @@ -0,0 +1,8 @@ +# vim:set ft=sh: +# Created by Tobias Powalowski + +# mkinitcpio config file, defaulted to stock config file +MKINITCPIO_CONFIG="/etc/archboot/x86_64-offline.conf" + +# kernel version, defaulted to build for runtime kernel +ALL_kver="/boot/vmlinuz-linux" diff --git a/etc/archboot/x86_64-offline.conf b/etc/archboot/x86_64-offline.conf new file mode 100644 index 000000000..ceb156b15 --- /dev/null +++ b/etc/archboot/x86_64-offline.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_installer_latest 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/usr/bin/archboot-update-installer.sh b/usr/bin/archboot-update-installer.sh index 31fe62e20..289e4b9ff 100755 --- a/usr/bin/archboot-update-installer.sh +++ b/usr/bin/archboot-update-installer.sh @@ -11,8 +11,8 @@ _INSTALLER_SOURCE="https://gitlab.archlinux.org/tpowa/archboot/-/raw/master" kver() { # get kernel version from installed kernel - [[ "${_RUNNING_ARCH}" == "x86_64" ]] && VMLINUZ="${_W_DIR}/boot/vmlinuz-linux" - [[ "${_RUNNING_ARCH}" == "aarch64" ]] && VMLINUZ="${_W_DIR}/boot/Image" + [[ "${_RUNNING_ARCH}" == "x86_64" ]] && VMLINUZ="/vmlinuz-linux" + [[ "${_RUNNING_ARCH}" == "aarch64" ]] && VMLINUZ="/Image" if [[ -f "${VMLINUZ}" ]]; then offset=$(hexdump -s 526 -n 2 -e '"%0d"' "${VMLINUZ}") read -r _HWKVER _ < <(dd if="${VMLINUZ}" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null) @@ -103,8 +103,13 @@ if [[ "${_L_COMPLETE}" == "1" || "${_L_INSTALL_COMPLETE}" == "1" ]]; then echo " This will need some time ..." # create container without package cache [[ "${_L_COMPLETE}" == "1" ]] && ("archboot-${_RUNNING_ARCH}-create-container.sh" "${_W_DIR}" -cc -cp >/dev/tty7 2>&1 || exit 1) + # Switch offline mode # create container with package cache - [[ "${_L_INSTALL_COMPLETE}" == "1" ]] && ("archboot-${_RUNNING_ARCH}-create-container.sh" "${_W_DIR}" -cc >/dev/tty7 2>&1 || exit 1) + if [[ -e /var/cache/pacman/pkg/archboot.db ]]; then + [[ "${_L_INSTALL_COMPLETE}" == "1" ]] && ("archboot-${_RUNNING_ARCH}-create-container.sh" "${_W_DIR}" -cc --install-source=file:///var/cache/pacman/pkg >/dev/tty7 2>&1 || exit 1) + else + [[ "${_L_INSTALL_COMPLETE}" == "1" ]] && ("archboot-${_RUNNING_ARCH}-create-container.sh" "${_W_DIR}" -cc >/dev/tty7 2>&1 || exit 1) + fi # generate initrd in container, remove archboot packages from cache, not needed in normal install, umount tmp before generating initrd echo "Step 3/8: Moving kernel from ${_W_DIR} to / ..." if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then diff --git a/usr/lib/archboot/container_functions b/usr/lib/archboot/container_functions index 92b8400bc..28e924e49 100644 --- a/usr/lib/archboot/container_functions +++ b/usr/lib/archboot/container_functions @@ -118,7 +118,7 @@ _change_pacman_conf() { # umount special filesystems _umount_special() { - echo "Umount special filesystems in to ${1} ..." + echo "Umount special filesystems in ${1} ..." umount -R "${1}/proc" umount -R "${1}/sys" umount -R "${1}/dev" diff --git a/usr/lib/initcpio/install/archboot_base b/usr/lib/initcpio/install/archboot_base index ab72cc8a5..d09763aee 100644 --- a/usr/lib/initcpio/install/archboot_base +++ b/usr/lib/initcpio/install/archboot_base @@ -6,7 +6,7 @@ build () map add_binary getent head id cksum tail test tr uptime w who which whoami xargs \ swapon uniq cut seq snarf fdisk sfdisk cfdisk parted free less \ chgrp chown df dialog dmesg egrep fgrep stty sync tar bsdcpio hdparm \ - mktemp chroot dirname expr bzip2 su cpio gzip top sdparm tput \ + chroot dirname expr bzip2 su cpio gzip top sdparm tput \ ifconfig ln losetup mkfifo mknod readlink lzmadec lzop xz last wall mesg utmpdump \ xzdec switch_root pivot_root chcpu ctrlaltdel gdisk sgdisk cgdisk fixparts findmnt \ lsblk swaplabel cal chrt col colcrt colrm column fallocate flock getopt \ diff --git a/usr/lib/initcpio/install/archboot_base_common b/usr/lib/initcpio/install/archboot_base_common index 820e4bd7d..0be995b6b 100644 --- a/usr/lib/initcpio/install/archboot_base_common +++ b/usr/lib/initcpio/install/archboot_base_common @@ -16,7 +16,7 @@ build () map add_binary init agetty basename mount umount clear env printf gawk tty bash partprobe cp dir du ls mv rm sed grep \ kill killall more ps pwd rmdir true cat mkdir echo false sleep kmod pidof touch chmod \ find wc wget uname bsdtar yes awk halt shutdown reboot poweroff insmod modprobe sh dd hexdump \ - sort zstd nano date tee + sort zstd nano date tee mktemp ### add nano files add_full_dir /usr/share/nano diff --git a/usr/lib/initcpio/install/archboot_installer_offline b/usr/lib/initcpio/install/archboot_installer_offline new file mode 100644 index 000000000..9d069c452 --- /dev/null +++ b/usr/lib/initcpio/install/archboot_installer_offline @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Created by Tobias Powalowski + +build () +{ + source /etc/archboot/defaults + # only include cachedir on booted archboot or container + for i in "${_ISO_HOME_SOURCE}"/"${_DIR}"/*;do + [[ ! -L "${i}" ]] && add_file "$i" "/var/cache/pacman/pkg/$(basename $i)" + done + # fix symlinks + add_symlink "/var/cache/pacman/pkg/archboot.db" "/var/cache/pacman/pkg/archboot.db.tar.gz" + add_symlink "/var/cache/pacman/pkg/archboot.files" "/var/cache/pacman/pkg/archboot.files.tar.gz" +} + +help () +{ +cat<