Add stricter sanity checks

This commit is contained in:
Ward Nakchbandi (Cosmic Fusion) 2024-01-04 15:31:19 +03:00 committed by GitHub
parent e57305113d
commit fe98fea2bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import subprocess
import os
# Version
version="1.0.6"
version="1.0.7"
dist="PikaOS 3"
image="/cdrom/casper/filesystem.squashfs"
@ -123,7 +123,8 @@ if args.home is not None:
home_passwd = input("Warning: Do not enter this incorrectly or late installation will fail! ")
# Make sure to avoid any mounts pointing at the partition
# Checks
# 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.")
exit(1)
@ -143,6 +144,37 @@ 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.startswith('/dev'):
print("Error: Root mount point is pointed a device, please use a mountpoint.")
exit(1)
if args.boot.startswith('/dev'):
print("Error: Boot mount point is pointed a device, please use a mountpoint.")
exit(1)
if args.efi.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.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 boot.startswith(args.root):
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 efi.startswith(args.root):
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 boot.startswith(args.root):
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