From ee34c017120787518015d7028ddb447239533075 Mon Sep 17 00:00:00 2001 From: "Ward Nakchbandi (Cosmic Fusion)" <83735213+CosmicFusion@users.noreply.github.com> Date: Fri, 5 Jan 2024 21:44:48 +0300 Subject: [PATCH] Make sanity checks even stricter and fix efi path --- pikainstall/debian/changelog | 2 +- .../pika/pikainstall/pika-install-chroot.sh | 4 +- .../usr/lib/pika/pikainstall/pikainstall | 74 +++++++++---------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/pikainstall/debian/changelog b/pikainstall/debian/changelog index 84fe681..2e35f0f 100644 --- a/pikainstall/debian/changelog +++ b/pikainstall/debian/changelog @@ -1,4 +1,4 @@ -pikainstall (1.0.7-100pika1) pikauwu; urgency=medium +pikainstall (1.0.7-100pika2) pikauwu; urgency=medium * Initial release. diff --git a/pikainstall/usr/lib/pika/pikainstall/pika-install-chroot.sh b/pikainstall/usr/lib/pika/pikainstall/pika-install-chroot.sh index e51c47b..8c22f2f 100755 --- a/pikainstall/usr/lib/pika/pikainstall/pika-install-chroot.sh +++ b/pikainstall/usr/lib/pika/pikainstall/pika-install-chroot.sh @@ -29,8 +29,8 @@ chmod +x /var/albius-refind_linux.sh refind-install apt install -y /var/cache/apt/archives/pika-refind-theme*.deb /var/cache/apt/archives/booster*.deb # EFI workaround for MSI -mkdir -p /boot/EFI/BOOT -cp -vf /boot/EFI/refind/refind_x64.efi /boot/EFI/BOOT/BOOTX64.EFI +mkdir -p /boot/efi/EFI/BOOT +cp -vf /boot/efi/EFI/refind/refind_x64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI # Remove installer from installed system apt remove casper vanilla-installer -y || true apt autoremove -y || true diff --git a/pikainstall/usr/lib/pika/pikainstall/pikainstall b/pikainstall/usr/lib/pika/pikainstall/pikainstall index 6fd43cd..ef1c5bc 100755 --- a/pikainstall/usr/lib/pika/pikainstall/pikainstall +++ b/pikainstall/usr/lib/pika/pikainstall/pikainstall @@ -2,7 +2,7 @@ # import libs import argparse -import subprocess +import subprocess import os # Version @@ -81,10 +81,10 @@ root_part_encrypt = root_part_encrypt_command.stdout.readline().decode("utf-8"). root_uuid_encrypt_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-uuid'] + args.root, stdout=subprocess.PIPE, stderr=subprocess.PIPE) root_uuid_encrypt = root_uuid_encrypt_command.stdout.readline().decode("utf-8").strip() ## Print Root info -print("\nRoot UUID: {}".format(root_uuid)) +print("\nRoot UUID: {}".format(root_uuid)) if root_part_encrypt == "luks_none": - print("Root Encryption Partition: Root is not encrypted!") - print("Root Encryption UUID: Root is not encrypted!") + print("Root Encryption Partition: Root is not encrypted!") + print("Root Encryption UUID: Root is not encrypted!") else: print("Root Encryption Partition: {}".format(root_part_encrypt)) print("Root Encryption UUID: {}".format(root_uuid_encrypt)) @@ -114,16 +114,47 @@ if args.home is not None: print("\nHome UUID: {}".format(home_uuid)) if home_part_encrypt == "luks_none": print("Home Encryption Partition: Home is not encrypted!") - print("Home Encryption UUID: Home is not encrypted!") + print("Home Encryption UUID: Home is not encrypted!") else: print("Home Encryption Partition: {}".format(home_part_encrypt)) print("Home Encryption UUID: {}".format(home_uuid_encrypt)) ## Ask user for Home luks partition password for the key-filing process print("\nPlease enter the LUKS password for the device" + home_part_encrypt + " :") home_passwd = input("Warning: Do not enter this incorrectly or late installation will fail! ") - + # Checks +# Make sure mountpoints are not /dev prefixes +if args.root[0].startswith('/dev'): + print("Error: Root mount point is pointed a device, please use a mountpoint.") + exit(1) +if args.boot[0].startswith('/dev'): + print("Error: Boot mount point is pointed a device, please use a mountpoint.") + exit(1) +if args.efi[0].startswith('/dev'): + print("Error: EFI mount point is pointed a device, please use a mountpoint.") + exit(1) +if args.home is not None: + if args.home[0].startswith('/dev'): + print("Error: Home mount point is pointed a device, please use a mountpoint.") + exit(1) +# Make sure All mounts are in the correct place releative to chroot +if args.boot[0] == f"{args.root[0]}/boot": + print("Boot Partition Check: OK!") +else: + print(f"Error: Boot mount point is not in a correct place relative to chroot, please mount it in {args.root[0]}/boot and supply the new mountpoint!") + exit(1) +if args.efi[0] == f"{args.root[0]}/boot/efi": + print("EFI Partition Check: OK!") +else: + print(f"Error: EFI mount point is not in a correct place relative to chroot, please mount it in {args.root[0]}/boot/efi and supply the new mountpoint!") + exit(1) +if args.home is not None: + if args.home[0] == f"{args.root[0]}/home": + print("Home Partition Check: OK!") + else: + print(f"Error: Home mount point is not in a correct place relative to chroot, please mount it in {args.root[0]}/home and supply the new mountpoint!") + exit(1) # Make sure to avoid any mounts pointing at the same partition if root_uuid == boot_uuid: print("Error: Root and Boot are mounted on the same drive, please place boot on it's own partition.") @@ -144,37 +175,6 @@ elif args.home is not None: elif efi_uuid == home_uuid: print("Error: EFI and Home are mounted on the same drive, consider removing the -H/--home argument.") exit(1) -# Make sure mountpoints are not /dev prefixes -if args.root[0].startswith('/dev'): - print("Error: Root mount point is pointed a device, please use a mountpoint.") - exit(1) -if args.boot[0].startswith('/dev'): - print("Error: Boot mount point is pointed a device, please use a mountpoint.") - exit(1) -if args.efi[0].startswith('/dev'): - print("Error: EFI mount point is pointed a device, please use a mountpoint.") - exit(1) -if args.home is not None: - if args.home[0].startswith('/dev'): - print("Error: Home mount point is pointed a device, please use a mountpoint.") - exit(1) -# Make sure All mounts are releative to chroot -if args.boot[0].startswith(args.root[0]): - print("Boot Partition Check: OK!") -else: - print("Error: Boot mount point is not relative to chroot, please mount it some inside the chroot and supply the new mountpoint!") - exit(1) -if args.efi[0].startswith(args.root[0]): - print("EFI Partition Check: OK!") -else: - print("Error: EFI mount point is not relative to chroot, please mount it some inside the chroot and supply the new mountpoint!") - exit(1) -if args.home is not None: - if args.home[0].startswith(args.root[0]): - print("Home Partition Check: OK!") - else: - print("Error: Home mount point is not relative to chroot, please mount it some inside the chroot and supply the new mountpoint!") - exit(1) # With All Checks Clear and info gathered let's start installing