From 93f41feaa01f3f39f7aa3a2a3faccef82ef32516 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Wed, 14 Feb 2024 20:00:19 +0530 Subject: [PATCH 01/10] feat: add default locales --- blend-inst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/blend-inst b/blend-inst index d41c1fa..4987682 100755 --- a/blend-inst +++ b/blend-inst @@ -10,6 +10,7 @@ import os import sys import json +import yaml import signal import subprocess @@ -322,6 +323,16 @@ def inst_users(config): # Akshara def inst_akshara(config): + exec_chroot( + ['rm', '-f', '/etc/locale.gen']) + for locale in ['en_US.UTF-8', 'de_DE.UTF-8', 'fr_FR.UTF-8', 'es_ES.UTF-8', 'zh_CN.UTF-8', 'ja_JP.UTF-8', 'ru_RU.UTF-8', 'ar_EG.UTF-8']: + exec_chroot( + ['bash', '-c', f'echo "{locale}" >> /etc/locale.gen']) + exec_chroot( + ['locale-gen']) + exec_chroot( + ['bash', '-c', f'echo "LANG=en_US.UTF-8" >> /etc/locale.gen']) + system_config = { 'repo': 'https://pkg-repo.blendos.co', 'impl': 'http://github.com/blend-os/tracks/raw/main', @@ -340,7 +351,7 @@ def inst_akshara(config): ] if testing == False: - with open('/system.yaml', 'w') as system_config_file: + with open('/mnt/system.yaml', 'w') as system_config_file: yaml.dump(system_config, system_config_file) else: print(system_config) From 8add221ca0b182ef5601f82ba256535df8e3d345 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sun, 18 Feb 2024 11:24:20 +0530 Subject: [PATCH 02/10] feat: remove jade-gui-postinst --- blend-inst | 2 -- 1 file changed, 2 deletions(-) diff --git a/blend-inst b/blend-inst index 4987682..b79420f 100755 --- a/blend-inst +++ b/blend-inst @@ -243,8 +243,6 @@ def inst_setup_base(config): exec_chroot(['pacman', '-Sy', '--noconfirm', 'linux-zen', 'xorriso']) # Remove jade-gui exec_chroot(['pacman', '-Rn', '--noconfirm', 'jade-gui']) - # Install jade-gui-postinst - exec_chroot(['pacman', '-S', '--noconfirm', 'jade-gui-postinst']) def inst_bootloader(config): From 844a3f851b7beb4bdd92424052c3f0ba7a1aa207 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sun, 18 Feb 2024 13:19:41 +0530 Subject: [PATCH 03/10] fix: locales --- blend-inst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/blend-inst b/blend-inst index b79420f..88a54c9 100755 --- a/blend-inst +++ b/blend-inst @@ -325,11 +325,9 @@ def inst_akshara(config): ['rm', '-f', '/etc/locale.gen']) for locale in ['en_US.UTF-8', 'de_DE.UTF-8', 'fr_FR.UTF-8', 'es_ES.UTF-8', 'zh_CN.UTF-8', 'ja_JP.UTF-8', 'ru_RU.UTF-8', 'ar_EG.UTF-8']: exec_chroot( - ['bash', '-c', f'echo "{locale}" >> /etc/locale.gen']) + ['bash', '-c', f'echo "{locale} UTF-8" >> /etc/locale.gen']) exec_chroot( ['locale-gen']) - exec_chroot( - ['bash', '-c', f'echo "LANG=en_US.UTF-8" >> /etc/locale.gen']) system_config = { 'repo': 'https://pkg-repo.blendos.co', From f413571bceacb7aba7a7710e9aba388edbc11e48 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sat, 8 Jun 2024 05:08:17 +0000 Subject: [PATCH 04/10] feat: implement encryption for automatic partitioning --- blend-inst | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/blend-inst b/blend-inst index 88a54c9..b7f027d 100755 --- a/blend-inst +++ b/blend-inst @@ -32,12 +32,15 @@ def preexec(): signal.signal(signal.SIGQUIT, signal.SIG_IGN) -def exec(cmd): +def exec(cmd, input=None): if testing: - print(' '.join(cmd)) + if input != None: + print(' '.join(cmd), '<--', input) + else: + print(' '.join(cmd)) else: - subprocess.call(cmd, shell=False, stdout=sys.stdout, - stderr=sys.stderr, preexec_fn=preexec) + subprocess.run(cmd, shell=False, stdout=sys.stdout, + stderr=sys.stderr, preexec_fn=preexec, input=input.encode()).returncode def exec_chroot(cmd): @@ -134,6 +137,7 @@ def inst_partition(config): mode = config['partition']['mode'] efi = config['partition']['efi'] partitions = config['partition']['partitions'] + password = config['partition']['password'] # Delete partition table exec(['dd', 'if=/dev/zero', f'of={device}', 'bs=512', 'count=1']) @@ -162,10 +166,15 @@ def inst_partition(config): exec(['mkfs.vfat', '-F32', f'{device}p1']) else: exec(['mkfs.ext4', f'{device}p1']) + root_partition = f'{device}p2' + if password != '': + exec(['cryptsetup', '-q', 'luksFormat', root_partition], input=f'{password}\n') + exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') + root_partition = '/dev/mapper/new_root' # Format root partition - exec(['mkfs.ext4', f'{device}p2']) + exec(['mkfs.ext4', root_partition]) # Mount partitions - mount(f'{device}p2', '/mnt') + mount(root_partition, '/mnt') if efi: mkdir('/mnt/boot/efi') mount(f'{device}p1', '/mnt/boot/efi') @@ -178,10 +187,15 @@ def inst_partition(config): exec(['mkfs.vfat', '-F32', f'{device}1']) else: exec(['mkfs.ext4', f'{device}1']) + root_partition = f'{device}2' + if password != '': + exec(['cryptsetup', '-q', 'luksFormat', root_partition], input=f'{password}\n') + exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') + root_partition = '/dev/mapper/new_root' # Format root partition - exec(['mkfs.ext4', f'{device}2']) + exec(['mkfs.ext4', root_partition]) # Mount partitions - mount(f'{device}2', '/mnt') + mount(root_partition, '/mnt') if efi: mkdir('/mnt/boot/efi') mount(f'{device}1', '/mnt/boot/efi') From 0ad9676196c89c1a2a5a88f0643d15b28318f781 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sat, 8 Jun 2024 06:31:18 +0000 Subject: [PATCH 05/10] feat: add encryption and akshara hooks --- blend-inst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/blend-inst b/blend-inst index b7f027d..940e91e 100755 --- a/blend-inst +++ b/blend-inst @@ -253,6 +253,14 @@ def inst_setup_base(config): # Refresh package lists, pacman-key --init exec_chroot(['pacman-key', '--init']) exec_chroot(['pacman-key', '--populate', 'archlinux']) + # Add akshara and encrypt hooks + exec_chroot('bash', '-c', 'echo "MODULES=()" > /etc/mkinitcpio.conf') + exec_chroot('bash', '-c', 'echo "BINARIES=()" >> /etc/mkinitcpio.conf') + exec_chroot('bash', '-c', 'echo "FILES=()" >> /etc/mkinitcpio.conf') + if config['partition']['password'] == '': + exec_chroot('bash', '-c', 'echo "HOOKS=(base udev akshara autodetect keyboard keymap modconf block filesystems fsck)" >> /etc/mkinitcpio.conf') + else: + exec_chroot('bash', '-c', 'echo "HOOKS=(base udev akshara autodetect keyboard keymap consolefont modconf block encrypt filesystems fsck)" >> /etc/mkinitcpio.conf') # Install linux-zen exec_chroot(['pacman', '-Sy', '--noconfirm', 'linux-zen', 'xorriso']) # Remove jade-gui From f863382d07da66e37cc920f6bdbb5c16149cd929 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sat, 8 Jun 2024 07:21:30 +0000 Subject: [PATCH 06/10] feat: add null check for input --- blend-inst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blend-inst b/blend-inst index 940e91e..1b44c5d 100755 --- a/blend-inst +++ b/blend-inst @@ -39,8 +39,12 @@ def exec(cmd, input=None): else: print(' '.join(cmd)) else: - subprocess.run(cmd, shell=False, stdout=sys.stdout, - stderr=sys.stderr, preexec_fn=preexec, input=input.encode()).returncode + if input != None: + subprocess.run(cmd, shell=False, stdout=sys.stdout, + stderr=sys.stderr, preexec_fn=preexec, input=input.encode()).returncode + else: + subprocess.run(cmd, shell=False, stdout=sys.stdout, + stderr=sys.stderr, preexec_fn=preexec).returncode def exec_chroot(cmd): From c7c6375657c87f14b9893de95d6ccc20f530931d Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sat, 8 Jun 2024 08:35:30 +0000 Subject: [PATCH 07/10] feat: fix typo --- blend-inst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/blend-inst b/blend-inst index 1b44c5d..2da618d 100755 --- a/blend-inst +++ b/blend-inst @@ -144,7 +144,7 @@ def inst_partition(config): password = config['partition']['password'] # Delete partition table - exec(['dd', 'if=/dev/zero', f'of={device}', 'bs=512', 'count=1']) + exec(['wipefs', '-a', f'of={device}', 'bs=512', 'count=1']) exec(['sync']) if mode == 'Auto': @@ -169,14 +169,14 @@ def inst_partition(config): if efi: exec(['mkfs.vfat', '-F32', f'{device}p1']) else: - exec(['mkfs.ext4', f'{device}p1']) + exec(['mkfs.ext4', '-F', f'{device}p1']) root_partition = f'{device}p2' if password != '': exec(['cryptsetup', '-q', 'luksFormat', root_partition], input=f'{password}\n') exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') root_partition = '/dev/mapper/new_root' # Format root partition - exec(['mkfs.ext4', root_partition]) + exec(['mkfs.ext4', '-F', root_partition]) # Mount partitions mount(root_partition, '/mnt') if efi: @@ -190,14 +190,14 @@ def inst_partition(config): if efi: exec(['mkfs.vfat', '-F32', f'{device}1']) else: - exec(['mkfs.ext4', f'{device}1']) + exec(['mkfs.ext4', '-F', f'{device}1']) root_partition = f'{device}2' if password != '': exec(['cryptsetup', '-q', 'luksFormat', root_partition], input=f'{password}\n') exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') root_partition = '/dev/mapper/new_root' # Format root partition - exec(['mkfs.ext4', root_partition]) + exec(['mkfs.ext4', '-F', root_partition]) # Mount partitions mount(root_partition, '/mnt') if efi: @@ -258,13 +258,13 @@ def inst_setup_base(config): exec_chroot(['pacman-key', '--init']) exec_chroot(['pacman-key', '--populate', 'archlinux']) # Add akshara and encrypt hooks - exec_chroot('bash', '-c', 'echo "MODULES=()" > /etc/mkinitcpio.conf') - exec_chroot('bash', '-c', 'echo "BINARIES=()" >> /etc/mkinitcpio.conf') - exec_chroot('bash', '-c', 'echo "FILES=()" >> /etc/mkinitcpio.conf') + exec_chroot(['bash', '-c', 'echo "MODULES=()" > /etc/mkinitcpio.conf']) + exec_chroot(['bash', '-c', 'echo "BINARIES=()" >> /etc/mkinitcpio.conf']) + exec_chroot(['bash', '-c', 'echo "FILES=()" >> /etc/mkinitcpio.conf']) if config['partition']['password'] == '': - exec_chroot('bash', '-c', 'echo "HOOKS=(base udev akshara autodetect keyboard keymap modconf block filesystems fsck)" >> /etc/mkinitcpio.conf') + exec_chroot(['bash', '-c', 'echo "HOOKS=(base udev akshara autodetect keyboard keymap modconf block filesystems fsck)" >> /etc/mkinitcpio.conf']) else: - exec_chroot('bash', '-c', 'echo "HOOKS=(base udev akshara autodetect keyboard keymap consolefont modconf block encrypt filesystems fsck)" >> /etc/mkinitcpio.conf') + exec_chroot(['bash', '-c', 'echo "HOOKS=(base udev akshara autodetect keyboard keymap consolefont modconf block encrypt filesystems fsck)" >> /etc/mkinitcpio.conf']) # Install linux-zen exec_chroot(['pacman', '-Sy', '--noconfirm', 'linux-zen', 'xorriso']) # Remove jade-gui From 296d8886c52434f569bd47a8105112e62f5bbdc2 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sat, 8 Jun 2024 17:02:04 +0000 Subject: [PATCH 08/10] feat: pass UUID as kernel param --- blend-inst | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/blend-inst b/blend-inst index 2da618d..d6d330b 100755 --- a/blend-inst +++ b/blend-inst @@ -143,11 +143,11 @@ def inst_partition(config): partitions = config['partition']['partitions'] password = config['partition']['password'] - # Delete partition table - exec(['wipefs', '-a', f'of={device}', 'bs=512', 'count=1']) - exec(['sync']) - if mode == 'Auto': + # Delete partition table + exec(['wipefs', '-a', device]) + exec(['sync']) + if efi: # Create GPT label exec(['parted', '-s', device, 'mklabel', 'gpt']) @@ -164,6 +164,8 @@ def inst_partition(config): exec(['parted', '-s', device, 'mkpart', 'primary', 'ext4', '700MB', '100%']) + global orig_main_partition + if 'nvme' in device or 'mmcblk' in device: # Format EFI/boot partition if efi: @@ -171,6 +173,7 @@ def inst_partition(config): else: exec(['mkfs.ext4', '-F', f'{device}p1']) root_partition = f'{device}p2' + orig_main_partition = root_partition if password != '': exec(['cryptsetup', '-q', 'luksFormat', root_partition], input=f'{password}\n') exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') @@ -192,6 +195,7 @@ def inst_partition(config): else: exec(['mkfs.ext4', '-F', f'{device}1']) root_partition = f'{device}2' + orig_main_partition = root_partition if password != '': exec(['cryptsetup', '-q', 'luksFormat', root_partition], input=f'{password}\n') exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') @@ -274,18 +278,20 @@ def inst_setup_base(config): def inst_bootloader(config): # Install bootloader if 'NVIDIA' in subprocess.check_output(['lspci']).decode('utf-8'): - exec_chroot(['pacman', '-S', '--noconfirm', 'nvidia-dkms']) exec_chroot( - ['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} vt.global_cursor_default=0 nvidia_drm.modeset=1 splash"\' >> /etc/default/grub']) + ['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} nvidia_drm.modeset=1 splash"\' >> /etc/default/grub']) mkdir('/mnt/etc/udev/rules.d') exec_chroot(['ln', '-s', '/dev/null', '/etc/udev/rules.d/61-gdm.rules']) else: exec_chroot( - ['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} vt.global_cursor_default=0 splash"\' >> /etc/default/grub']) + ['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} splash"\' >> /etc/default/grub']) if config['partition']['mode'] == 'Auto': + if config['partition']['password'] != '': + exec_chroot( + ['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} cryptdevice=UUID=' + subprocess.check_output(['blkid', '-s', 'UUID', '-o', 'value', orig_main_partition]).decode('UTF-8').strip() + ':root root=/dev/mapper/root"\' >> /etc/default/grub']) exec_chroot( - ['bash', '-c', 'echo -e \'\\nGRUB_TIMEOUT=0\' >> /etc/default/grub']) + ['bash', '-c', 'echo -e \'\\nGRUB_TIMEOUT=3\' >> /etc/default/grub']) if config['bootloader']['type'] == 'grub-efi': exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory={config["bootloader"]["location"]}', '--bootloader-id=blend', '--removable']) From 29cfb63d20d1387fd28641944c37f1a3b63a8613 Mon Sep 17 00:00:00 2001 From: Rudra Saraswat Date: Sat, 8 Jun 2024 19:34:48 +0000 Subject: [PATCH 09/10] feat: fix FDE on UEFI systems --- blend-inst | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/blend-inst b/blend-inst index d6d330b..514de7a 100755 --- a/blend-inst +++ b/blend-inst @@ -115,10 +115,7 @@ def format_and_mount(config, mountpoint, filesystem, blockdevice): if mountpoint == 'System': mountpoint = '/mnt/' elif mountpoint == 'Boot': - if efi: - mountpoint = '/mnt/boot/efi/' - else: - mountpoint = '/mnt/boot/' + mountpoint = '/mnt/boot/' elif mountpoint == 'User': mountpoint = '/mnt/home/' else: @@ -158,11 +155,11 @@ def inst_partition(config): exec(['parted', '-s', device, 'mklabel', 'msdos']) # Create boot partition exec(['parted', '-s', device, 'mkpart', - 'primary', 'ext4', '1MIB', '600MIB']) + 'primary', 'ext4', '1MIB', '1400MIB']) # Create root partition exec(['parted', '-s', device, 'mkpart', - 'primary', 'ext4', '700MB', '100%']) + 'primary', 'ext4', '1500MB', '100%']) global orig_main_partition @@ -182,12 +179,8 @@ def inst_partition(config): exec(['mkfs.ext4', '-F', root_partition]) # Mount partitions mount(root_partition, '/mnt') - if efi: - mkdir('/mnt/boot/efi') - mount(f'{device}p1', '/mnt/boot/efi') - else: - mkdir('/mnt/boot') - mount(f'{device}p1', '/mnt/boot') + mkdir('/mnt/boot') + mount(f'{device}p1', '/mnt/boot') else: # Format EFI/boot partition if efi: @@ -204,12 +197,8 @@ def inst_partition(config): exec(['mkfs.ext4', '-F', root_partition]) # Mount partitions mount(root_partition, '/mnt') - if efi: - mkdir('/mnt/boot/efi') - mount(f'{device}1', '/mnt/boot/efi') - else: - mkdir('/mnt/boot') - mount(f'{device}1', '/mnt/boot') + mkdir('/mnt/boot') + mount(f'{device}1', '/mnt/boot') else: partitions.sort(key=lambda x: len(x[1])) for p in partitions: @@ -222,7 +211,7 @@ def inst_partition(config): print( "Invalid manual partitioning configuration. There must be a 'System' partition.") sys.exit(1) - if '/mnt/boot/' not in mountpoints and '/mnt/boot/efi/' not in mountpoints: + if '/mnt/boot/' not in mountpoints: print() print( "Invalid manual partitioning configuration. There must be a 'Boot' partition.") @@ -293,9 +282,9 @@ def inst_bootloader(config): exec_chroot( ['bash', '-c', 'echo -e \'\\nGRUB_TIMEOUT=3\' >> /etc/default/grub']) if config['bootloader']['type'] == 'grub-efi': - exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory={config["bootloader"]["location"]}', + exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory=/boot', '--bootloader-id=blend', '--removable']) - exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory={config["bootloader"]["location"]}', + exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory=/boot', '--bootloader-id=blend']) else: exec_chroot(['grub-install', '--target=i386-pc', From a030f9147a6510b3a58879b3fc41b4e69a078f03 Mon Sep 17 00:00:00 2001 From: askiiart Date: Tue, 1 Oct 2024 11:54:01 -0500 Subject: [PATCH 10/10] switch default to btrfs, switch to consistent units, fix wasted space on EFI systems --- blend-inst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blend-inst b/blend-inst index 514de7a..f054018 100755 --- a/blend-inst +++ b/blend-inst @@ -149,17 +149,17 @@ def inst_partition(config): # Create GPT label exec(['parted', '-s', device, 'mklabel', 'gpt']) # Create EFI partition - exec(['parted', '-s', device, 'mkpart', 'fat32', '0', '500']) + exec(['parted', '-s', device, 'mkpart', 'fat32', '0%', '512MiB']) else: # Create msdos label exec(['parted', '-s', device, 'mklabel', 'msdos']) # Create boot partition exec(['parted', '-s', device, 'mkpart', - 'primary', 'ext4', '1MIB', '1400MIB']) + 'primary', 'ext4', '0%', '512MiB']) # Create root partition exec(['parted', '-s', device, 'mkpart', - 'primary', 'ext4', '1500MB', '100%']) + 'primary', 'btrfs', '513MiB', '100%']) global orig_main_partition @@ -176,7 +176,7 @@ def inst_partition(config): exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') root_partition = '/dev/mapper/new_root' # Format root partition - exec(['mkfs.ext4', '-F', root_partition]) + exec(['mkfs.btrfs', '-F', root_partition]) # Mount partitions mount(root_partition, '/mnt') mkdir('/mnt/boot') @@ -194,7 +194,7 @@ def inst_partition(config): exec(['cryptsetup', 'open', root_partition, 'new_root', '-'], input=f'{password}\n') root_partition = '/dev/mapper/new_root' # Format root partition - exec(['mkfs.ext4', '-F', root_partition]) + exec(['mkfs.btrfs', '-F', root_partition]) # Mount partitions mount(root_partition, '/mnt') mkdir('/mnt/boot')