Compare commits
No commits in common. "a030f9147a6510b3a58879b3fc41b4e69a078f03" and "0e1ced3229d099101bd531ef0d2ad435235becab" have entirely different histories.
a030f9147a
...
0e1ced3229
1 changed files with 43 additions and 71 deletions
114
blend-inst
114
blend-inst
|
@ -10,7 +10,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import yaml
|
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
@ -32,19 +31,12 @@ def preexec():
|
||||||
signal.signal(signal.SIGQUIT, signal.SIG_IGN)
|
signal.signal(signal.SIGQUIT, signal.SIG_IGN)
|
||||||
|
|
||||||
|
|
||||||
def exec(cmd, input=None):
|
def exec(cmd):
|
||||||
if testing:
|
if testing:
|
||||||
if input != None:
|
print(' '.join(cmd))
|
||||||
print(' '.join(cmd), '<--', input)
|
|
||||||
else:
|
|
||||||
print(' '.join(cmd))
|
|
||||||
else:
|
else:
|
||||||
if input != None:
|
subprocess.call(cmd, shell=False, stdout=sys.stdout,
|
||||||
subprocess.run(cmd, shell=False, stdout=sys.stdout,
|
stderr=sys.stderr, preexec_fn=preexec)
|
||||||
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):
|
def exec_chroot(cmd):
|
||||||
|
@ -115,7 +107,10 @@ def format_and_mount(config, mountpoint, filesystem, blockdevice):
|
||||||
if mountpoint == 'System':
|
if mountpoint == 'System':
|
||||||
mountpoint = '/mnt/'
|
mountpoint = '/mnt/'
|
||||||
elif mountpoint == 'Boot':
|
elif mountpoint == 'Boot':
|
||||||
mountpoint = '/mnt/boot/'
|
if efi:
|
||||||
|
mountpoint = '/mnt/boot/efi/'
|
||||||
|
else:
|
||||||
|
mountpoint = '/mnt/boot/'
|
||||||
elif mountpoint == 'User':
|
elif mountpoint == 'User':
|
||||||
mountpoint = '/mnt/home/'
|
mountpoint = '/mnt/home/'
|
||||||
else:
|
else:
|
||||||
|
@ -138,67 +133,60 @@ def inst_partition(config):
|
||||||
mode = config['partition']['mode']
|
mode = config['partition']['mode']
|
||||||
efi = config['partition']['efi']
|
efi = config['partition']['efi']
|
||||||
partitions = config['partition']['partitions']
|
partitions = config['partition']['partitions']
|
||||||
password = config['partition']['password']
|
|
||||||
|
# Delete partition table
|
||||||
|
exec(['dd', 'if=/dev/zero', f'of={device}', 'bs=512', 'count=1'])
|
||||||
|
exec(['sync'])
|
||||||
|
|
||||||
if mode == 'Auto':
|
if mode == 'Auto':
|
||||||
# Delete partition table
|
|
||||||
exec(['wipefs', '-a', device])
|
|
||||||
exec(['sync'])
|
|
||||||
|
|
||||||
if efi:
|
if efi:
|
||||||
# Create GPT label
|
# Create GPT label
|
||||||
exec(['parted', '-s', device, 'mklabel', 'gpt'])
|
exec(['parted', '-s', device, 'mklabel', 'gpt'])
|
||||||
# Create EFI partition
|
# Create EFI partition
|
||||||
exec(['parted', '-s', device, 'mkpart', 'fat32', '0%', '512MiB'])
|
exec(['parted', '-s', device, 'mkpart', 'fat32', '0', '500'])
|
||||||
else:
|
else:
|
||||||
# Create msdos label
|
# Create msdos label
|
||||||
exec(['parted', '-s', device, 'mklabel', 'msdos'])
|
exec(['parted', '-s', device, 'mklabel', 'msdos'])
|
||||||
# Create boot partition
|
# Create boot partition
|
||||||
exec(['parted', '-s', device, 'mkpart',
|
exec(['parted', '-s', device, 'mkpart',
|
||||||
'primary', 'ext4', '0%', '512MiB'])
|
'primary', 'ext4', '1MIB', '600MIB'])
|
||||||
|
|
||||||
# Create root partition
|
# Create root partition
|
||||||
exec(['parted', '-s', device, 'mkpart',
|
exec(['parted', '-s', device, 'mkpart',
|
||||||
'primary', 'btrfs', '513MiB', '100%'])
|
'primary', 'ext4', '700MB', '100%'])
|
||||||
|
|
||||||
global orig_main_partition
|
|
||||||
|
|
||||||
if 'nvme' in device or 'mmcblk' in device:
|
if 'nvme' in device or 'mmcblk' in device:
|
||||||
# Format EFI/boot partition
|
# Format EFI/boot partition
|
||||||
if efi:
|
if efi:
|
||||||
exec(['mkfs.vfat', '-F32', f'{device}p1'])
|
exec(['mkfs.vfat', '-F32', f'{device}p1'])
|
||||||
else:
|
else:
|
||||||
exec(['mkfs.ext4', '-F', f'{device}p1'])
|
exec(['mkfs.ext4', 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')
|
|
||||||
root_partition = '/dev/mapper/new_root'
|
|
||||||
# Format root partition
|
# Format root partition
|
||||||
exec(['mkfs.btrfs', '-F', root_partition])
|
exec(['mkfs.ext4', f'{device}p2'])
|
||||||
# Mount partitions
|
# Mount partitions
|
||||||
mount(root_partition, '/mnt')
|
mount(f'{device}p2', '/mnt')
|
||||||
mkdir('/mnt/boot')
|
if efi:
|
||||||
mount(f'{device}p1', '/mnt/boot')
|
mkdir('/mnt/boot/efi')
|
||||||
|
mount(f'{device}p1', '/mnt/boot/efi')
|
||||||
|
else:
|
||||||
|
mkdir('/mnt/boot')
|
||||||
|
mount(f'{device}p1', '/mnt/boot')
|
||||||
else:
|
else:
|
||||||
# Format EFI/boot partition
|
# Format EFI/boot partition
|
||||||
if efi:
|
if efi:
|
||||||
exec(['mkfs.vfat', '-F32', f'{device}1'])
|
exec(['mkfs.vfat', '-F32', f'{device}1'])
|
||||||
else:
|
else:
|
||||||
exec(['mkfs.ext4', '-F', f'{device}1'])
|
exec(['mkfs.ext4', 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')
|
|
||||||
root_partition = '/dev/mapper/new_root'
|
|
||||||
# Format root partition
|
# Format root partition
|
||||||
exec(['mkfs.btrfs', '-F', root_partition])
|
exec(['mkfs.ext4', f'{device}2'])
|
||||||
# Mount partitions
|
# Mount partitions
|
||||||
mount(root_partition, '/mnt')
|
mount(f'{device}2', '/mnt')
|
||||||
mkdir('/mnt/boot')
|
if efi:
|
||||||
mount(f'{device}1', '/mnt/boot')
|
mkdir('/mnt/boot/efi')
|
||||||
|
mount(f'{device}1', '/mnt/boot/efi')
|
||||||
|
else:
|
||||||
|
mkdir('/mnt/boot')
|
||||||
|
mount(f'{device}1', '/mnt/boot')
|
||||||
else:
|
else:
|
||||||
partitions.sort(key=lambda x: len(x[1]))
|
partitions.sort(key=lambda x: len(x[1]))
|
||||||
for p in partitions:
|
for p in partitions:
|
||||||
|
@ -211,7 +199,7 @@ def inst_partition(config):
|
||||||
print(
|
print(
|
||||||
"Invalid manual partitioning configuration. There must be a 'System' partition.")
|
"Invalid manual partitioning configuration. There must be a 'System' partition.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if '/mnt/boot/' not in mountpoints:
|
if '/mnt/boot/' not in mountpoints and '/mnt/boot/efi/' not in mountpoints:
|
||||||
print()
|
print()
|
||||||
print(
|
print(
|
||||||
"Invalid manual partitioning configuration. There must be a 'Boot' partition.")
|
"Invalid manual partitioning configuration. There must be a 'Boot' partition.")
|
||||||
|
@ -250,41 +238,33 @@ def inst_setup_base(config):
|
||||||
# Refresh package lists, pacman-key --init
|
# Refresh package lists, pacman-key --init
|
||||||
exec_chroot(['pacman-key', '--init'])
|
exec_chroot(['pacman-key', '--init'])
|
||||||
exec_chroot(['pacman-key', '--populate', 'archlinux'])
|
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
|
# Install linux-zen
|
||||||
exec_chroot(['pacman', '-Sy', '--noconfirm', 'linux-zen', 'xorriso'])
|
exec_chroot(['pacman', '-Sy', '--noconfirm', 'linux-zen', 'xorriso'])
|
||||||
# Remove jade-gui
|
# Remove jade-gui
|
||||||
exec_chroot(['pacman', '-Rn', '--noconfirm', '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):
|
def inst_bootloader(config):
|
||||||
# Install bootloader
|
# Install bootloader
|
||||||
if 'NVIDIA' in subprocess.check_output(['lspci']).decode('utf-8'):
|
if 'NVIDIA' in subprocess.check_output(['lspci']).decode('utf-8'):
|
||||||
|
exec_chroot(['pacman', '-S', '--noconfirm', 'nvidia-dkms'])
|
||||||
exec_chroot(
|
exec_chroot(
|
||||||
['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} nvidia_drm.modeset=1 splash"\' >> /etc/default/grub'])
|
['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'])
|
||||||
mkdir('/mnt/etc/udev/rules.d')
|
mkdir('/mnt/etc/udev/rules.d')
|
||||||
exec_chroot(['ln', '-s', '/dev/null',
|
exec_chroot(['ln', '-s', '/dev/null',
|
||||||
'/etc/udev/rules.d/61-gdm.rules'])
|
'/etc/udev/rules.d/61-gdm.rules'])
|
||||||
else:
|
else:
|
||||||
exec_chroot(
|
exec_chroot(
|
||||||
['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} splash"\' >> /etc/default/grub'])
|
['bash', '-c', 'echo -e \'\\nGRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} vt.global_cursor_default=0 splash"\' >> /etc/default/grub'])
|
||||||
if config['partition']['mode'] == 'Auto':
|
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(
|
exec_chroot(
|
||||||
['bash', '-c', 'echo -e \'\\nGRUB_TIMEOUT=3\' >> /etc/default/grub'])
|
['bash', '-c', 'echo -e \'\\nGRUB_TIMEOUT=0\' >> /etc/default/grub'])
|
||||||
if config['bootloader']['type'] == 'grub-efi':
|
if config['bootloader']['type'] == 'grub-efi':
|
||||||
exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory=/boot',
|
exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory={config["bootloader"]["location"]}',
|
||||||
'--bootloader-id=blend', '--removable'])
|
'--bootloader-id=blend', '--removable'])
|
||||||
exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory=/boot',
|
exec_chroot(['grub-install', '--target=x86_64-efi', f'--efi-directory={config["bootloader"]["location"]}',
|
||||||
'--bootloader-id=blend'])
|
'--bootloader-id=blend'])
|
||||||
else:
|
else:
|
||||||
exec_chroot(['grub-install', '--target=i386-pc',
|
exec_chroot(['grub-install', '--target=i386-pc',
|
||||||
|
@ -342,14 +322,6 @@ def inst_users(config):
|
||||||
# Akshara
|
# Akshara
|
||||||
|
|
||||||
def inst_akshara(config):
|
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} UTF-8" >> /etc/locale.gen'])
|
|
||||||
exec_chroot(
|
|
||||||
['locale-gen'])
|
|
||||||
|
|
||||||
system_config = {
|
system_config = {
|
||||||
'repo': 'https://pkg-repo.blendos.co',
|
'repo': 'https://pkg-repo.blendos.co',
|
||||||
'impl': 'http://github.com/blend-os/tracks/raw/main',
|
'impl': 'http://github.com/blend-os/tracks/raw/main',
|
||||||
|
@ -368,7 +340,7 @@ def inst_akshara(config):
|
||||||
]
|
]
|
||||||
|
|
||||||
if testing == False:
|
if testing == False:
|
||||||
with open('/mnt/system.yaml', 'w') as system_config_file:
|
with open('/system.yaml', 'w') as system_config_file:
|
||||||
yaml.dump(system_config, system_config_file)
|
yaml.dump(system_config, system_config_file)
|
||||||
else:
|
else:
|
||||||
print(system_config)
|
print(system_config)
|
||||||
|
|
Loading…
Reference in a new issue