Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc2ce1a4

Browse files
committed
Fri Apr 21 13:19:21 ADT 2023
1 parentf116af8 commitc2ce1a4

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

‎src/distros/alpine/installer.py‎

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@
3131

3232
definitram_update():
3333
ifis_luks:
34-
os.system("sudo dd bs=512 count=4 if=/dev/random of=/mnt/etc/crypto_keyfile.bin iflag=fullblock")
35-
os.system("sudo chmod 000 /mnt/etc/crypto_keyfile.bin")# Changed from 600 as even root doesn't need access
36-
os.system(f"sudo cryptsetup luksAddKey{args[1]} /mnt/etc/crypto_keyfile.bin")
37-
os.system("sudo sed -i -e '/^HOOKS/ s/filesystems/encrypt filesystems/'\
34+
os.system(f"{SUDO} dd bs=512 count=4 if=/dev/random of=/mnt/etc/crypto_keyfile.bin iflag=fullblock")
35+
os.system(f"{SUDO} chmod 000 /mnt/etc/crypto_keyfile.bin")# Changed from 600 as even root doesn't need access
36+
os.system(f"{SUDO} cryptsetup luksAddKey{args[1]} /mnt/etc/crypto_keyfile.bin")
37+
os.system(f"{SUDO} sed -i -e '/^HOOKS/ s/filesystems/encrypt filesystems/'\
3838
-e 's|^FILES=(|FILES=(/etc/crypto_keyfile.bin|' /mnt/etc/mkinitcpio.conf")### IMPORTANT TODO
3939
ifis_format_btrfs:### REVIEW TEMPORARY
40-
os.system("sudo sed -i 's|ext4|ext4 btrfs|' /mnt/etc/mkinitfs/mkinitfs.conf")### TODO if array not empty, needs to be "btrfs "
40+
os.system(f"{SUDO} sed -i 's|ext4|ext4 btrfs|' /mnt/etc/mkinitfs/mkinitfs.conf")### TODO if array not empty, needs to be "btrfs "
4141
ifis_luksoris_format_btrfs:### REVIEW: does mkinitcpio need to be run without these conditions too?
4242
try:# work with default kernel modules first
43-
subprocess.check_output("sudo chroot /mntsudo mkinitfs -b / -f /etc/fstab",shell=True)### REVIEW <kernelvers>
43+
subprocess.check_output(f"{SUDO} chroot /mnt{SUDO} mkinitfs -b / -f /etc/fstab",shell=True)### REVIEW <kernelvers>
4444
exceptsubprocess.CalledProcessError:# and if errors
4545
kv=os.listdir('/mnt/lib/modules')
4646
try:
4747
iflen(kv)==1:
48-
subprocess.check_output(f"sudo chroot /mntsudo mkinitfs -b / -f /etc/fstab -k{''.join(kv)}",shell=True)
48+
subprocess.check_output(f"{SUDO} chroot /mnt{SUDO} mkinitfs -b / -f /etc/fstab -k{''.join(kv)}",shell=True)
4949
except:
5050
print(f"F: Creating initfs with either live default or{kv} kernels failed!")
5151
print("Next, type just folder name from /mnt/lib/modules i.e. 5.15.104-0-lts")
5252
whileTrue:
5353
try:
5454
kv=get_item_from_path("kernel version","/mnt/lib/modules")
55-
subprocess.check_output(f"sudo chroot /mntsudo mkinitfs -b / -f /etc/fstab -k{kv}",shell=True)
55+
subprocess.check_output(f"{SUDO} chroot /mnt{SUDO} mkinitfs -b / -f /etc/fstab -k{kv}",shell=True)
5656
break# Success
5757
exceptsubprocess.CalledProcessError:
5858
print(f"F: Creating initfs with kernel{kv} failed!")
@@ -64,9 +64,9 @@ def initram_update():
6464
# 2. Bootstrap and install packages in chroot
6565
os.system(f"curl -LO{URL}/{ARCH}/apk-tools-static-{APK}.apk")
6666
os.system("tar zxf apk-tools-static-*.apk")
67-
excode1=os.system(f"sudo ./sbin/apk.static --arch{ARCH} -X{URL} -U --allow-untrusted --root /mnt --initdb --no-cache add alpine-base")### REVIEW Is "/" needed after {URL} ?
67+
excode1=os.system(f"{SUDO} ./sbin/apk.static --arch{ARCH} -X{URL} -U --allow-untrusted --root /mnt --initdb --no-cache add alpine-base")### REVIEW Is "/" needed after {URL} ?
6868
copy("./src/distros/alpine/repositories","/mnt/etc/apk/")### REVIEW MOVED from down at section 3 to here as installing 'bash' was giving error
69-
os.system("sudo cp --dereference /etc/resolv.conf /mnt/etc/")# --remove-destination ### not writing through dangling symlink! (TODO: try except)
69+
os.system(f"{SUDO} cp --dereference /etc/resolv.conf /mnt/etc/")# --remove-destination ### not writing through dangling symlink! (TODO: try except)
7070

7171
try:
7272
os.system(f"chroot /mnt /bin/sh -c '/sbin/apk update && /sbin/apk add{packages}'")
@@ -80,55 +80,55 @@ def initram_update():
8080
ash_chroot()
8181

8282
# 3. Package manager database and config files
83-
#os.system("sudo cp -r /mnt/var/lib/apk/. /mnt/usr/share/ash/db") ### REVIEW seems always empty?
83+
#os.system(f"{SUDO} cp -r /mnt/var/lib/apk/. /mnt/usr/share/ash/db") ### REVIEW seems always empty?
8484
# /var/cache/apk/ , /var/lib/apk/ , /etc/apk/cache/
85-
os.system("sudo mv /mnt/lib/apk /mnt/usr/share/ash/db/")
86-
os.system("sudo ln -srf /mnt/usr/share/ash/db/apk /mnt/lib/apk")
85+
os.system(f"{SUDO} mv /mnt/lib/apk /mnt/usr/share/ash/db/")
86+
os.system(f"{SUDO} ln -srf /mnt/usr/share/ash/db/apk /mnt/lib/apk")
8787

8888
# 4. Update hostname, hosts, locales and timezone, hosts
89-
os.system(f"echo{hostname} |sudo tee /mnt/etc/hostname")
90-
os.system(f"echo 127.0.0.1{hostname}{distro} |sudo tee -a /mnt/etc/hosts")
91-
#os.system("sudo sed -i 's|^#en_US.UTF-8|en_US.UTF-8|g' /mnt/etc/locale.gen")
92-
#os.system("sudo chroot /mntsudo locale-gen")
93-
#os.system("echo 'LANG=en_US.UTF-8' |sudo tee /mnt/etc/locale.conf")
94-
os.system(f"sudo ln -srf /mnt/usr/share/zoneinfo/{tz} /mnt/etc/localtime")
95-
os.system("sudo chroot /mnt /sbin/hwclock --systohc")
89+
os.system(f"echo{hostname} |{SUDO} tee /mnt/etc/hostname")
90+
os.system(f"echo 127.0.0.1{hostname}{distro} |{SUDO} tee -a /mnt/etc/hosts")
91+
#os.system(f"{SUDO} sed -i 's|^#en_US.UTF-8|en_US.UTF-8|g' /mnt/etc/locale.gen")
92+
#os.system(f"{SUDO} chroot /mnt{SUDO} locale-gen")
93+
#os.system(f"echo 'LANG=en_US.UTF-8' |{SUDO} tee /mnt/etc/locale.conf")
94+
os.system(f"{SUDO} ln -srf /mnt/usr/share/zoneinfo/{tz} /mnt/etc/localtime")
95+
os.system(f"{SUDO} chroot /mnt /sbin/hwclock --systohc")
9696

9797
# Post bootstrap
9898
post_bootstrap(super_group)
9999
ifyes_no("Replace Busybox's ash with Ash? (NOT recommended yet!)"):
100-
os.system(f"sudo mv /mnt/bin/ash /mnt/bin/busyash")
101-
#os.system(f"sudo mv /mnt/bin/ash /mnt/usr/bin/ash")
102-
#os.system(f"sudo mv /mnt/usr/bin/ash /mnt/bin/ash")
100+
os.system(f"{SUDO} mv /mnt/bin/ash /mnt/bin/busyash")
101+
#os.system(f"{SUDO} mv /mnt/bin/ash /mnt/usr/bin/ash")
102+
#os.system(f"{SUDO} mv /mnt/usr/bin/ash /mnt/bin/ash")
103103
print("Ash replaced Busybox's ash (which is now busyash)!")
104104
else:
105-
os.system(f"sudo mv /mnt/usr/bin/ash /mnt/usr/bin/asd")
105+
os.system(f"{SUDO} mv /mnt/usr/bin/ash /mnt/usr/bin/asd")
106106
print("Use asd instead of ash!")
107107

108108
# 5. Services (init, network, etc.)
109-
os.system("sudo chroot /mnt /bin/bash -c '/sbin/setup-interfaces'")
110-
os.system(f"sudo chroot /mnt /bin/bash -c '/usr/sbin/adduser{username} plugdev'")
111-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add devfs sysinit'")
112-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add dmesg sysinit'")
113-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add mdev sysinit'")
114-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add hwdrivers sysinit'")
115-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add cgroups sysinit'")
116-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add hwclock boot'")
117-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add modules boot'")
118-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add sysctl boot'")
119-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add hostname boot'")
120-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add bootmisc boot'")
121-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add syslog boot'")
122-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add swap boot'")
123-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add networking boot'")
124-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add seedrng boot'")
125-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add mount-ro shutdown'")
126-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add killprocs shutdown'")
127-
os.system("sudo chroot /mnt /bin/bash -c 'sudo /sbin/rc-update add savecache shutdown'")
128-
#os.system("sudo chroot /mnt /bin/bash -c '/sbin/rc-service networkmanager start'")
109+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '/sbin/setup-interfaces'")
110+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '/usr/sbin/adduser{username} plugdev'")
111+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add devfs sysinit'")
112+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add dmesg sysinit'")
113+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add mdev sysinit'")
114+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add hwdrivers sysinit'")
115+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add cgroups sysinit'")
116+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add hwclock boot'")
117+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add modules boot'")
118+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add sysctl boot'")
119+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add hostname boot'")
120+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add bootmisc boot'")
121+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add syslog boot'")
122+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add swap boot'")
123+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add networking boot'")
124+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add seedrng boot'")
125+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add mount-ro shutdown'")
126+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add killprocs shutdown'")
127+
os.system(f"{SUDO} chroot /mnt /bin/bash -c '{SUDO} /sbin/rc-update add savecache shutdown'")
128+
#os.system(f"{SUDO} chroot /mnt /bin/bash -c '/sbin/rc-service networkmanager start'")
129129

130130
# 6. Boot and EFI
131-
os.system('echo GRUB_CMDLINE_LINUX_DEFAULT=\\"modules=sd-mod,usb-storage,btrfs quiet rootfstype=btrfs\\" |sudo tee -a /mnt/etc/default/grub')# should be before initram create otherwise canonical error in grub-probe
131+
os.system(f'echo GRUB_CMDLINE_LINUX_DEFAULT=\\"modules=sd-mod,usb-storage,btrfs quiet rootfstype=btrfs\\" |{SUDO} tee -a /mnt/etc/default/grub')# should be before initram create otherwise canonical error in grub-probe
132132
initram_update()
133133
grub_ash(v)
134134

‎src/distros/arch/installer.py‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
#from src.installer_core import is_luks, ash_chroot, clear, deploy_base_snapshot, deploy_to_common, grub_ash, is_efi, post_bootstrap, pre_bootstrap, unmounts
88
fromsetupimportargs,distro
99

10+
# 1. Define variables
11+
is_format_btrfs=True### REVIEW TEMPORARY
12+
KERNEL=""# options: https://wiki.archlinux.org/title/kernel e.g. "-xanmod"
13+
packages=f"base linux{KERNEL} btrfs-progs sudo grub python3 python-anytree dhcpcd networkmanager nano linux-firmware"# os-prober bash tmux arch-install-scripts
14+
ifis_efi:
15+
packages+=" efibootmgr"
16+
ifis_luks:
17+
packages+=" cryptsetup"### REVIEW_LATER
18+
super_group="wheel"
19+
v=""# GRUB version number in /boot/grubN
20+
1021
definitram_update():
1122
ifis_luks:
1223
os.system(f"{SUDO} dd bs=512 count=4 if=/dev/random of=/mnt/etc/crypto_keyfile.bin iflag=fullblock")
@@ -28,17 +39,6 @@ def strap(pkg):
2839
else:# Success
2940
return0
3041

31-
# 1. Define variables
32-
is_format_btrfs=True### REVIEW TEMPORARY
33-
KERNEL=""# options: https://wiki.archlinux.org/title/kernel e.g. "-xanmod"
34-
packages=f"base linux{KERNEL} btrfs-progs sudo grub python3 python-anytree dhcpcd networkmanager nano linux-firmware"# os-prober bash tmux arch-install-scripts
35-
ifis_efi:
36-
packages+=" efibootmgr"
37-
ifis_luks:
38-
packages+=" cryptsetup"### REVIEW_LATER
39-
super_group="wheel"
40-
v=""# GRUB version number in /boot/grubN
41-
4242
# Pre bootstrap
4343
pre_bootstrap()
4444

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp