Fix and repair

This commit is contained in:
Ward from fusion-voyager-3 2024-01-24 19:43:51 +03:00
parent b2a878ae6d
commit 13c5d4be7a
2 changed files with 39 additions and 18 deletions

View File

@ -1,4 +1,4 @@
pikainstall (1.1.1-100pika1) pikauwu; urgency=medium pikainstall (1.1.2-100pika1) pikauwu; urgency=medium
* Initial release. * Initial release.

View File

@ -5,6 +5,27 @@ import argparse
import subprocess import subprocess
import os import os
# Version
version="1.1.2"
dist="PikaOS 3"
image="/cdrom/casper/filesystem.squashfs"
# Print Program info
print("pikainstall " + version + ": PikaOS terminal installer! for " + dist + ".")
### text files
_REFIND_SETUP_FILE = """#!/usr/bin/bash
touch /boot/refind_linux.conf
echo '"'Boot with standard options'"' '"'nvidia-drm.modeset=1 root=UUID={ROOT_PART_UUID} quiet splash ---'"' > /boot/refind_linux.conf
echo '"'Boot with logging'"' '"'nvidia-drm.modeset=1 root=UUID={ROOT_PART_UUID} ---'"' >> /boot/refind_linux.conf
echo '"'Boot with safe graphics'"' '"'nvidia-drm.modeset=1 root=UUID={ROOT_PART_UUID} nomodeset ---'"' >> /boot/refind_linux.conf
"""#! /bin/python3
# import libs
import argparse
import subprocess
import os
# Version # Version
version="1.1.1" version="1.1.1"
dist="PikaOS 3" dist="PikaOS 3"
@ -69,16 +90,18 @@ parser.add_argument("-t", "--timezone", help="Choose what timezone to use.", met
args = parser.parse_args() args = parser.parse_args()
# Print all command-line arguments. # Print all command-line arguments.
print("\nParsed arguments: {}".format(args))
CHROOT_PATH = listToString(args.root[0])
# Get root info # Get root info
## Root UUID ## Root UUID
root_uuid_command= subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid'] + args.root, stdout=subprocess.PIPE, stderr=subprocess.PIPE) root_uuid_command= subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid', CHROOT_PATH], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
root_uuid = root_uuid_command.stdout.readline().decode("utf-8").strip() root_uuid = root_uuid_command.stdout.readline().decode("utf-8").strip()
## Root Encryption Partition ## Root Encryption Partition
root_part_encrypt_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-part'] + args.root, stdout=subprocess.PIPE, stderr=subprocess.PIPE) root_part_encrypt_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-part', CHROOT_PATH], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
root_part_encrypt = root_part_encrypt_command.stdout.readline().decode("utf-8").strip() root_part_encrypt = root_part_encrypt_command.stdout.readline().decode("utf-8").strip()
## Root Encryption UUID ## Root Encryption UUID
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_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-uuid', CHROOT_PATH], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
root_uuid_encrypt = root_uuid_encrypt_command.stdout.readline().decode("utf-8").strip() root_uuid_encrypt = root_uuid_encrypt_command.stdout.readline().decode("utf-8").strip()
## Print Root info ## Print Root info
print("\nRoot UUID: {}".format(root_uuid)) print("\nRoot UUID: {}".format(root_uuid))
@ -90,28 +113,28 @@ else:
print("Root Encryption UUID: {}".format(root_uuid_encrypt)) print("Root Encryption UUID: {}".format(root_uuid_encrypt))
# Get Boot info # Get Boot info
## Boot UUID ## Boot UUID
boot_uuid_command= subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid'] + args.root[0] + "/boot" , stdout=subprocess.PIPE, stderr=subprocess.PIPE) boot_uuid_command= subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid', CHROOT_PATH + "/boot"] , stdout=subprocess.PIPE, stderr=subprocess.PIPE)
## Print Boot ## Print Boot
boot_uuid = boot_uuid_command.stdout.readline().decode("utf-8").strip() boot_uuid = boot_uuid_command.stdout.readline().decode("utf-8").strip()
print("\nBoot UUID: {}".format(boot_uuid)) print("\nBoot UUID: {}".format(boot_uuid))
# Get EFI info # Get EFI info
## EFI UUID ## EFI UUID
efi_uuid_command= subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid'] + args.root[0] + "/boot/efi", stdout=subprocess.PIPE, stderr=subprocess.PIPE) efi_uuid_command= subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid', CHROOT_PATH + "/boot/efi"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
efi_uuid = efi_uuid_command.stdout.readline().decode("utf-8").strip() efi_uuid = efi_uuid_command.stdout.readline().decode("utf-8").strip()
## Print EFI Info ## Print EFI Info
print("\nEFI UUID: {}".format(efi_uuid)) print("\nEFI UUID: {}".format(efi_uuid))
## Home UUID ## Home UUID
home_uuid_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid'] + args.root[0] + "/home", stdout=subprocess.PIPE, stderr=subprocess.PIPE) home_uuid_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'uuid', CHROOT_PATH + "/home"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
home_uuid = home_uuid_command.stdout.readline().decode("utf-8").strip() home_uuid = home_uuid_command.stdout.readline().decode("utf-8").strip()
# Get Home info is exists # Get Home info is exists
if root_uuid != home_uuid: if root_uuid != home_uuid:
## Home Encryption Partition ## Home Encryption Partition
home_part_encrypt_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-part'] + args.root[0] + "/home", stdout=subprocess.PIPE, stderr=subprocess.PIPE) home_part_encrypt_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-part', CHROOT_PATH + "/home"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
home_part_encrypt = home_part_encrypt_command.stdout.readline().decode("utf-8").strip() home_part_encrypt = home_part_encrypt_command.stdout.readline().decode("utf-8").strip()
## Home Encryption UUID ## Home Encryption UUID
home_uuid_encrypt_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-uuid'] + args.root[0] + "/home", stdout=subprocess.PIPE, stderr=subprocess.PIPE) home_uuid_encrypt_command = subprocess.Popen(['/usr/lib/pika/pikainstall/partition-helper.sh', 'encrypt-uuid', CHROOT_PATH + "/home"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
home_uuid_encrypt = home_uuid_encrypt_command.stdout.readline().decode("utf-8").strip() home_uuid_encrypt = home_uuid_encrypt_command.stdout.readline().decode("utf-8").strip()
print("\nHome UUID: {}".format(home_uuid)) print("\nHome UUID: {}".format(home_uuid))
if home_part_encrypt == "luks_none": if home_part_encrypt == "luks_none":
@ -130,7 +153,7 @@ if root_uuid != home_uuid:
# Checks # Checks
# Make sure mountpoints are not /dev prefixes # Make sure mountpoints are not /dev prefixes
if args.root[0].startswith('/dev'): if CHROOT_PATH.startswith('/dev'):
print("Error: mountpoint is pointed a device, please use a mountpoint.") print("Error: mountpoint is pointed a device, please use a mountpoint.")
exit(1) exit(1)
# Make sure to have all mounts pointing at the same partition # Make sure to have all mounts pointing at the same partition
@ -155,22 +178,20 @@ elif root_uuid != home_uuid:
# With All Checks Clear and info gathered let's start installing # With All Checks Clear and info gathered let's start installing
## extract the squashfs image to root from casper ## extract the squashfs image to root from casper
squashfs_cmd = ['unsquashfs', '-f', '-d', listToString(args.root[0]), image] squashfs_cmd = ['unsquashfs', '-f', '-d', CHROOT_PATH, image]
subprocess.run(squashfs_cmd) subprocess.run(squashfs_cmd)
subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-image.txt']) subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-image.txt'])
## Enable bls_boot on boot partiton ## Enable bls_boot on boot partiton
boot_flag_cmd = ['/usr/lib/pika/pikainstall/partition-helper.sh', 'flag', listToString(args.root[0] + "/boot" ), 'bls_boot', 'on'] boot_flag_cmd = ['/usr/lib/pika/pikainstall/partition-helper.sh', 'flag', CHROOT_PATH, '/boot', 'bls_boot', 'on']
subprocess.run(boot_flag_cmd) subprocess.run(boot_flag_cmd)
subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-flag1.txt']) subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-flag1.txt'])
## Enable esp on EFI partiton ## Enable esp on EFI partiton
efi_flag_cmd = ['/usr/lib/pika/pikainstall/partition-helper.sh', 'flag', listToString(args.root[0] + "/boot/efi"), 'esp', 'on'] efi_flag_cmd = ['/usr/lib/pika/pikainstall/partition-helper.sh', 'flag', CHROOT_PATH, '/boot/efi', 'esp', 'on']
subprocess.run(efi_flag_cmd) subprocess.run(efi_flag_cmd)
subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-flag2.txt']) subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-flag2.txt'])
CHROOT_PATH = listToString(args.root[0])
# Write crypttab script if system has encryption # Write crypttab script if system has encryption
if root_part_encrypt != "luks_none": if root_part_encrypt != "luks_none":
subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-crypt.txt']) subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-crypt.txt'])
@ -185,7 +206,7 @@ if root_part_encrypt != "luks_none":
file.write(albius_crypttab_root_file) file.write(albius_crypttab_root_file)
# Write crypttab script if system has encryption # Write crypttab script if system has encryption
if args.root[0] + "/home" is not None: if CHROOT_PATH + "/home" is not None:
if home_part_encrypt != "luks_none": if home_part_encrypt != "luks_none":
subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-crypt.txt']) subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-crypt.txt'])
CRYPTTAB_FILE_PATH = '/var/albius-crypttab.sh' CRYPTTAB_FILE_PATH = '/var/albius-crypttab.sh'
@ -229,7 +250,7 @@ with open(CHROOT_REFIND_FILE_PATH, "w") as file:
## Run pika-install-script ## Run pika-install-script
subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-post.txt']) subprocess.run(['touch', '/tmp/pika-installer-gtk4-status-post.txt'])
bind_dev_cmd = ['/usr/lib/pika/pikainstall/pika-install-host.sh', listToString(args.root[0])] bind_dev_cmd = ['/usr/lib/pika/pikainstall/pika-install-host.sh', listToString(CHROOT_PATH)]
subprocess.run(bind_dev_cmd) subprocess.run(bind_dev_cmd)
print("System installed!") print("System installed!")