diff --git a/Readme.md b/Readme.md index cba6913..5d3f324 100644 --- a/Readme.md +++ b/Readme.md @@ -45,6 +45,7 @@ For security purpose, Linuxloops will not install packages/binaries that are not |BlendOS |v4 |✓ (shim-signed AUR) |✓ | |[notes][BlendOS-notes]| |BlissOS |15 / 16 | | | | | |Brunch |Latest |✓ | |✓ (partially included) |[notes][Brunch-notes]| +|ChimeraOS |Stable |✓ |✓ (default) | | | |ChromeOS-Flex |Latest |✓ | | |[notes][ChromeOS-Flex-notes]| |Debian |Bookworm |✓ |✓ |✓ | | |Devuan |Daedalus |✓ |✓ | | | diff --git a/Readme/Virtual-machines.md b/Readme/Virtual-machines.md index f2b9336..a72cb71 100644 --- a/Readme/Virtual-machines.md +++ b/Readme/Virtual-machines.md @@ -12,7 +12,9 @@ Linuxloops disk images can be run in Virtual Machines by treating them as raw di ## QEMU -The boot mode needs to be set to EFI and disk images can natively be used as raw disks. +The boot mode needs to be set to EFI and disk images can natively be used as raw disks: + +qemu-system-x86_64 -drive file=/test.img -m 8192 -enable-kvm -machine type=pc,accel=kvm -M q35 -cpu host -smp 4,sockets=1,cores=4,threads=1 -bios /usr/share/ovmf/x64/OVMF.fd -vga virtio -display gtk,gl=on -audio driver=sdl,model=virtio ## VirtualBox diff --git a/linuxloops b/linuxloops index 0704423..a5e7486 100644 --- a/linuxloops +++ b/linuxloops @@ -31,7 +31,7 @@ Usage: sudo bash linuxloops -distro -env "${chrootdir}"/bootstrap/linuxloops/prepare_chroot <"${chrootdir}"/bootstrap/linuxloops/install_script < /usr/bin/frzr-release +chmod 0755 /usr/bin/frzr-release +curl -L https://github.com/ChimeraOS/frzr/raw/master/frzr-tweaks -o /usr/bin/frzr-tweaks +chmod 0755 /usr/bin/frzr-tweaks +curl -L https://github.com/ChimeraOS/frzr/raw/master/frzr-initramfs -o /usr/bin/frzr-initramfs +chmod 0755 /usr/bin/frzr-initramfs +curl -L https://github.com/ChimeraOS/frzr/raw/master/__frzr-deploy -o /usr/bin/frzr-deploy +sed -i 's@MOUNT_PATH=/frzr_root@MOUNT_PATH=/mnt@g' /usr/bin/frzr-deploy +chmod 0755 /usr/bin/frzr-deploy +frzr-deploy chimeraos/chimeraos:stable +btrfs subvolume snapshot /mnt/deployments/\$(ls /mnt/deployments/ | grep 'chimeraos-' | tail -1) /mnt/deployments/tmp +btrfs property set -fts /mnt/deployments/tmp ro false +mount -o subvol=deployments/tmp "${root_partition}" /mnt +mount -o subvol=home "${root_partition}" /mnt/home +mount -t proc none /mnt/proc +mount -t sysfs none /mnt/sys +mount -t devtmpfs none /mnt/dev +mount -t devpts none /mnt/dev/pts +mount -t tmpfs -o mode=1777 none /mnt/dev/shm +mount -t tmpfs none /mnt/run +mount -t tmpfs -o mode=1777 none /mnt/tmp +chroot /mnt <<'CHROOT_STEAM' +mkdir -p /var/lib/pacman +cp -r /usr/var/lib/pacman/local /var/lib/pacman/ +pacman -Syu --noconfirm xorg-server-xvfb +mkdir -p /home/gamer +chown 1000:1000 /home/gamer +sudo -Hu 'gamer' cp -rT /etc/skel /home/gamer +sudo -Hu 'gamer' xvfb-run steam -exitsteam +CHROOT_STEAM +umount /mnt/tmp +umount /mnt/run +umount /mnt/dev/shm +umount /mnt/dev/pts +umount /mnt/dev +umount /mnt/sys +umount /mnt/proc +umount /mnt/home +umount /mnt +btrfs subvolume delete /mnt/deployments/tmp +if [ "${install_type}" == "image" ]; then + mkdir /initramfs + cp /linuxloops/install_initramfs /initramfs/linuxloops + cd /initramfs + mkdir -p ./usr/local/bin ./usr/local/etc ./usr/local/lib + for i in \$(ldd /usr/bin/losetup | cut -d' ' -f3); do cp "\${i}" ./usr/local/lib/; done + cp -a /usr/bin/losetup ./usr/local/bin/ + echo 'alias losetup="LD_LIBRARY_PATH=/usr/local/lib /usr/local/lib/ld-linux-x86-64.so.2 /usr/local/bin/losetup"' >> ./usr/local/etc/profile + for i in \$(ldd /usr/bin/ntfs-3g | cut -d' ' -f3); do cp "\${i}" ./usr/local/lib/; done + cp -a /usr/bin/ntfs-3g ./usr/local/bin/ + echo 'alias ntfs-3g="LD_LIBRARY_PATH=/usr/local/lib /usr/local/lib/ld-linux-x86-64.so.2 /usr/local/bin/ntfs-3g"' >> ./usr/local/etc/profile + for i in \$(ldd /usr/bin/ntfsfix | cut -d' ' -f3); do cp "\${i}" ./usr/local/lib/; done + cp -a /usr/bin/ntfsfix ./usr/local/bin/ + echo 'alias ntfsfix="LD_LIBRARY_PATH=/usr/local/lib /usr/local/lib/ld-linux-x86-64.so.2 /usr/local/bin/ntfsfix"' >> ./usr/local/etc/profile + chmod 0755 ./linuxloops + find . | cpio -o -H newc > /mnt/boot/linuxloops.img + cd .. + rm -r /initramfs +fi +INSTALL_SCRIPT +chmod 0755 "${chrootdir}"/bootstrap/linuxloops/install_script + +initramfs_type="iso_init_chimera" +} + chroot_ChromeOS-Flex() { prepare_bootstrap=" @@ -8003,7 +8096,7 @@ cat >"${chrootdir}"/bootstrap/linuxloops/partition_script <"${chrootdir}"/bootstrap/linuxloops/setup_and_mount_rootfs <"${chrootdir}"/bootstrap/linuxloops/enter_chroot <"${chrootdir}"/bootstrap/linuxloops/install_settings <"${chrootdir}"/bootstrap/linuxloops/install_secureboot <"${chrootdir}"/bootstrap/linuxloops/install_fstab <> "${chrootdir}"/bootstrap/linuxloops/install_initramfs +add_linuxloops_recovery +add_linuxloops_udev_start +add_linuxloops_main +add_linuxloops_udev_end +cat >>"${chrootdir}"/bootstrap/linuxloops/install_initramfs <<'INITSCRIPT' +if [ -z "$linuxloops_init" ]; then + if [ -x /init ]; then + linuxloops_init="/init" + elif [ -x /sbin/init ]; then + linuxloops_init="/sbin/init" + else + echo "linuxloops: No init system found." > /dev/kmsg + recovery_shell + fi +fi + +echo "linuxloops: boot sequence finished." > /dev/kmsg + +subvol="$(cat /proc/cmdline | cut -d'/' -f2)" +echo ${subvol} > /test + +umount /run +umount /sys +umount /proc +umount /dev > /dev/null 2>&1 || umount -l /dev > /dev/null 2>&1 || echo "linuxloops: /dev was not properly unmounted" > /dev/kmsg + +rootflags="subvol=deployments/${subvol}" exec "$linuxloops_init" +INITSCRIPT +} + generate_install_initramfs() { -if [ "${initramfs_type}" == "initcpio" ] || [ "${initramfs_type}" == "initramfstools" ] || [ "${initramfs_type}" == "dracut" ] || [ "${initramfs_type}" == "nixos_config" ] || [ "${initramfs_type}" == "iso_init" ]; then +if [ "${initramfs_type}" == "initcpio" ] || [ "${initramfs_type}" == "initramfstools" ] || [ "${initramfs_type}" == "dracut" ] || [ "${initramfs_type}" == "nixos_config" ] || [ "${initramfs_type}" == "iso_init" ] || [ "${initramfs_type}" == "iso_init_chimera" ]; then generate_"${initramfs_type}" fi } generate_install_bootloader() { -if [ "${distro}" == "BlissOS" ] || [ "${distro}" == "Brunch" ] || [ "${distro}" == "ChromeOS-Flex" ] || [ "${distro}" == "NixOS" ] || [ "${distro}" == "Tails" ]; then return; fi +if [ "${distro}" == "BlissOS" ] || [ "${distro}" == "Brunch" ] || [ "${distro}" == "ChimeraOS" ] || [ "${distro}" == "ChromeOS-Flex" ] || [ "${distro}" == "NixOS" ] || [ "${distro}" == "Tails" ]; then return; fi cat >"${chrootdir}"/bootstrap/linuxloops/install_bootloader <"${chrootdir}"/bootstrap/linuxloops/install_userpw <"${chrootdir}"/bootstrap/linuxloops/exit_chroot < "${linuxloopsdir}"/"${distro}".iso.sha256sum.mod + if sha256sum -c "${linuxloopsdir}"/"${distro}".iso.sha256sum.mod; then echo "sha256sum verification succeeded" break else @@ -9770,6 +9910,46 @@ elif [ "${1}" == "lxc" ]; then fi rm -f "${linuxloopsdir}"/"${2}"-rootfs.tar.xz* "${linuxloopsdir}"/"${2}"-SHA256SUMS done +elif [ "${1}" == "rootfs-xz" ]; then + echo "Downloading ${distro} rootfs image from ${2}" + for i in 1 .. 3; do + if sudo -u ${SUDO_USER} curl --progress-bar --connect-timeout 60 --retry 10 --retry-delay 1 -L -C - -f "${2}" -o "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz; then + sudo -u ${SUDO_USER} curl --progress-bar --connect-timeout 60 --retry 10 --retry-delay 1 -L -C - -f ${rootfs_sha256sum} -o "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz.sha256sum + sudo -u ${SUDO_USER} sed "s@$(basename ${2})@${linuxloopsdir}/${distro}-rootfs.tar.xz@g" "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz.sha256sum > "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz.sha256sum.mod + if sha256sum -c "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz.sha256sum.mod; then + echo "sha256sum verification succeeded" + break + else + echo "sha256sum verification failed, retrying download..." + fi + fi + if [ "${i}" -eq 3 ]; then echo "Download of ${distro} rootfs from ${2} failed"; exit 1; fi + done + if [ -z "$(command -v gpg)" ]; then + echo "Warning: iso cannot be verified as gpg is not available." + skip_gpg=1 + elif [ -z "${rootfs_signature}" ] || [ -z "${master_key}" ]; then + echo "Warning: iso cannot be verified as no signature or master key provided." + skip_gpg=1 + else + echo "Importing master key" + sudo -u ${SUDO_USER} gpg --homedir "${linuxloopsdir}"/gnupg --keyserver hkps://keyserver.ubuntu.com --recv "${master_key}" + echo "Downloading rootfs signature" + sudo -u ${SUDO_USER} curl --progress-bar --connect-timeout 60 --retry 10 --retry-delay 1 -L -C - -f ${rootfs_signature} -o "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz.asc + echo "Verifying rootfs signature" + fi + if [ ${skip_gpg} -eq 1 ] || sudo -u ${SUDO_USER} gpg --homedir "${linuxloopsdir}"/gnupg --verify "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz.asc "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz"${gpg_check_extension}"; then + if tar xf "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz -C "${chrootdir}"/bootstrap; then + echo "${distro} rootfs successfylly extracted." + rm -f "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz.* + return 0 + else + echo "Failed to extract ${distro} rootfs, will not proceed." + fi + else + echo "rootfs signature verification failed, will not proceed." + fi + rm "${linuxloopsdir}"/"${distro}"-rootfs.tar.xz* fi losetup -d "${destination_device}" exit_with_error "Download of bootstrap image failed." @@ -9865,7 +10045,7 @@ else partition_path="${destination_device}"p fi efi_partition="${partition_path}"1 -if [ "${distro}" == "BlissOS" ]; then +if [ "${distro}" == "BlissOS" ] || [ "${distro}" == "ChimeraOS" ]; then root_partition="${partition_path}"2 else boot_partition="${partition_path}"2 @@ -9894,10 +10074,21 @@ config="menuentry '${distro}' --class '$(echo ${distro} | tr [:upper:] [:lower:] search --no-floppy --set=root --file \"\${img_path}\" loopback loop \"\${img_path}\" for bliss in (loop,2)/android-*; do set root=\$bliss; done - linux \$root/kernel rdinit=/linuxloops img_uuid=\${img_uuid} img_path=\${img_path} root=/dev/ram0 + linux \$root/vmlinuz-linux rdinit=/linuxloops img_uuid=\${img_uuid} img_path=\${img_path} root=/dev/ram0 initrd \$root/initrd.img (loop,2)/linuxloops.img } " +elif [ "${distro}" == "ChimeraOS" ]; then +config="menuentry '${distro}' --class '$(echo ${distro} | tr [:upper:] [:lower:])' {${remove_tpm} + img_path=\"${img_path}\" + img_uuid=\"${img_uuid}\" + search --no-floppy --set=root --file \"\${img_path}\" + loopback loop \"\${img_path}\" + for chimera in (loop,1)/chimeraos-*; do set root=\$chimera; done + linux \$root/vmlinuz-linux rdinit=/linuxloops img_uuid=\${img_uuid} img_path=\${img_path} root=/dev/loop0p2 rw quiet splash loglevel=3 rd.systemd.show_status=auto rd.udev.log_priority=3 ibt=off split_lock_detect=off iomem=relaxed nowatchdog + initrd \$root/amd-ucode.img \$root/intel-ucode.img \$root/initramfs-linux.img (loop,1)/linuxloops.img +} +" elif [ "${distro}" == "Brunch" ]; then config="submenu '${distro}' { menuentry '${distro}' --class '$(echo ${distro} | tr [:upper:] [:lower:])' {${remove_tpm} @@ -10045,7 +10236,7 @@ fi set_credentials() { -if [ "${distro}" == "BlissOS" ] || [ "${distro}" == "Brunch" ] || [ "${distro}" == "ChromeOS-Flex" ] || [ "${distro}" == "Tails" ]; then return; fi +if [ "${distro}" == "BlissOS" ] || [ "${distro}" == "Brunch" ] || [ "${distro}" == "ChimeraOS" ] || [ "${distro}" == "ChromeOS-Flex" ] || [ "${distro}" == "Tails" ]; then return; fi if [ "${declarative}" == "Yes" ] && [ ! -z "${username}" ] && [ ! -z "${userpass}" ]; then if echo "${username}" | grep -q '^[a-z][-a-z0-9]*\$'; then echo -e "Username contains unsupported characters.\n\n"; exit 1; fi if echo "${userpass}" | grep -q '[^a-zA-Z0-9!@#&$£%µ^+-\*/=~¨]'; then echo -e "Password contains unsupported characters.\n\n"; exit 1; fi @@ -10140,6 +10331,9 @@ case "${distro}" in 'Brunch') available_space_needed=7 ;; + 'ChimeraOS') + available_space_needed=3 + ;; 'ChromeOS-Flex') available_space_needed=7 ;; @@ -10201,7 +10395,11 @@ if [ "${install_type}" == "disk" ]; then destination=$(sudo -u ${SUDO_USER} zenity --height=480 --width=640 --title="LinuxLoops installer" --list --radiolist --text "Select the drive that you want to use for installation." --column "Select" --column "Device" --column "Size (in GB)" ${test} --ok-label="Next" 2>/dev/null) if [ -z "${destination}" ]; then exit 1; fi fullpath="${destination}" - install_size=$(sudo -u ${SUDO_USER} zenity --height=480 --width=640 --title="LinuxLoops installer" --scale --text "This device has $(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) )) GB available.\n How much would you like to allocate for ${distro} ?\n" --min-value=14 --max-value=$(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) )) --value=$(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) )) --step 1 --ok-label="Next" 2>/dev/null) + if [ $(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) - 14 )) -eq 0 ]; then + install_size=14 + else + install_size=$(sudo -u ${SUDO_USER} zenity --height=480 --width=640 --title="LinuxLoops installer" --scale --text "This device has $(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) )) GB available.\n How much would you like to allocate for ${distro} ?\n" --min-value=14 --max-value=$(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) )) --value=$(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) )) --step 1 --ok-label="Next" 2>/dev/null) + fi if [ -z "${install_size}" ]; then exit 1; fi if [ "${install_size}" -eq $(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024 / 1024) )) ]; then install_sizeMB=$(( ($(lsblk -drnbpf -o SIZE ${destination}) / 1024 /1024) )); else install_sizeMB=$((install_size*1024)); fi else @@ -10237,7 +10435,7 @@ else if [ -z "${install_size}" ]; then exit 1; fi install_sizeMB=$((install_size*1024)) fi -if [ "${distro}" != "BlissOS" ] && [ "${distro}" != "Brunch" ] && [ "${distro}" != "ChromeOS-Flex" ] && [ "${distro}" != "Tails" ]; then +if [ "${distro}" != "BlissOS" ] && [ "${distro}" != "Brunch" ] && [ "${distro}" != "ChimeraOS" ] && [ "${distro}" != "ChromeOS-Flex" ] && [ "${distro}" != "Tails" ]; then locale=$(sudo -u ${SUDO_USER} zenity --height=480 --width=640 --title="LinuxLoops installer" --list --radiolist --text "Please select your locale (language / formats)." --column "Select" --column "Locale" --column "Description" "${available_locales[@]}" --ok-label="Next" 2>/dev/null) if [ -z "${locale}" ]; then exit 1; fi keymap=$(sudo -u ${SUDO_USER} zenity --height=480 --width=640 --title="LinuxLoops installer" --list --radiolist --text "Please select your keyboard layout." --column "Select" --column "Keymap" --column "Description" "${available_keymaps[@]}" --ok-label="Next" 2>/dev/null) @@ -10348,7 +10546,7 @@ if [ ! -z "${swap_size}" ]; then if [ -z "${swap_size##*[!0-9]*}" ] || [ "${swap_size}" -lt 0 ]; then echo "Provided swap size is not a positive integer: ${swap_size}."; exit 1; fi if [ "${swap_size}" -gt 0 ] && [ $(( install_sizeMB - (swap_size * 1024) )) -lt $(( 12 * 1024 )) ]; then echo "At least 12 GB should be available for the main partition, please increase the image size or reduce the swap size."; exit 1; fi fi -if [ "${distro}" == "BlissOS" ] || [ "${distro}" == "Brunch" ] || [ "${distro}" == "ChromeOS-Flex" ] || [ "${distro}" == "Tails" ]; then +if [ "${distro}" == "BlissOS" ] || [ "${distro}" == "Brunch" ] || [ "${distro}" == "ChimeraOS" ] || [ "${distro}" == "ChromeOS-Flex" ] || [ "${distro}" == "Tails" ]; then if [ "${encryption}" == "Yes" ]; then echo -e "rootfs encryption is not supported with ${distro}.\n"; exit 1; fi if [ ! -z "${swap_size}" ] && [ "${swap_size}" -ne 0 ]; then echo -e "Swap cannot be enabled by design with ${distro}.\n"; exit 1; fi fi