Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2019-11-13 23:36:22 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2019-11-13 23:36:22 +0000
commitda008c6284b36255aaca3caa4b368d7b1c44de0d (patch)
tree660101eda7a7e02049310098c4b7334de0b71fb1
parent9774daa2b6bcf353d16510dc69194f4bf502f2ce (diff)
Adding runas in options to POST commands. To be able to run AUR commands as a certain user since yay refuses to build as root
-rw-r--r--archinstall.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/archinstall.py b/archinstall.py
index 18ad9f22..10266545 100644
--- a/archinstall.py
+++ b/archinstall.py
@@ -827,9 +827,10 @@ if __name__ == '__main__':
o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "su - aibuilder -c \\"(cd /home/aibuilder; git clone https://aur.archlinux.org/yay.git)\\""').exec())
o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "chown -R aibuilder.aibuilder /home/aibuilder/yay"').exec())
o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "su - aibuilder -c \\"(cd /home/aibuilder/yay; makepkg -si --noconfirm)\\" >/dev/null"').exec())
- o = b''.join(sys_command('/usr/bin/sed -i \'s/%wheel ALL=(ALL) NO/# %wheel ALL=(ALL) NO/\' /mnt/etc/sudoers').exec())
- o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "userdel aibuilder"').exec())
- o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "rm -rf /home/aibuilder"').exec())
+ ## Do not remove aibuilder just yet, can be used later for aur packages.
+ #o = b''.join(sys_command('/usr/bin/sed -i \'s/%wheel ALL=(ALL) NO/# %wheel ALL=(ALL) NO/\' /mnt/etc/sudoers').exec())
+ #o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "userdel aibuilder"').exec())
+ #o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "rm -rf /home/aibuilder"').exec())
print('[N] AUR support added. use "yay -Syy --noconfirm <package>" to deploy in POST.')
conf = {}
@@ -852,6 +853,7 @@ if __name__ == '__main__':
if type(conf[title]) == str:
print('[N] Loading {} configuration'.format(conf[title]))
conf[title] = get_application_instructions(conf[title])
+
for command in conf[title]:
raw_command = command
opts = conf[title][command] if type(conf[title][command]) in (dict, oDict) else {}
@@ -870,6 +872,10 @@ if __name__ == '__main__':
if 'pass-args' in opts and opts['pass-args']:
command = command.format(**args)
+ if 'runas' in opts and f'su - {opts["runas"]} -c' not in command:
+ command = command.replace('"', '\\"')
+ command = f'su - {opts["runas"]} -c "{command}"'
+
#print('[N] Command: {} ({})'.format(command, opts))
## https://superuser.com/questions/1242978/start-systemd-nspawn-and-execute-commands-inside
@@ -925,6 +931,11 @@ if __name__ == '__main__':
print('[W] Post install command failed: {}'.format(o.decode('UTF-8')))
#print(o)
+ if args['aur-support']:
+ o = b''.join(sys_command('/usr/bin/sed -i \'s/%wheel ALL=(ALL) NO/# %wheel ALL=(ALL) NO/\' /mnt/etc/sudoers').exec())
+ o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "userdel aibuilder"').exec())
+ o = b''.join(sys_command('/usr/bin/arch-chroot /mnt sh -c "rm -rf /home/aibuilder"').exec())
+
## == Passwords
# o = sys_command('arch-chroot /mnt usermod --password {} root'.format(args['password']))
# o = sys_command("arch-chroot /mnt sh -c 'echo {pin} | passwd --stdin root'".format(pin='"{pin}"'.format(**args, pin=args['password'])), echo=True)