From 6c5c24ecefb8512a77225d772d2758391ed5b54f Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 22 Jul 2020 14:19:41 +0000 Subject: Added a function to the installer, also added a function to make it easier to enable it in a installation, after which can be called. --- archinstall/lib/installer.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'archinstall') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 9247c635..3310c335 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -91,10 +91,10 @@ class Installer(): o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} ln -s /usr/share/zoneinfo/{zone} /etc/localtime')) return True - def run_command(self, cmd): + def run_command(self, cmd, *args, **kwargs): return sys_command(f'/usr/bin/arch-chroot {self.mountpoint} {cmd}') - def arch_chroot(self, cmd): + def arch_chroot(self, cmd, *args, **kwargs): return self.run_command(cmd) def minimal_installation(self): @@ -196,4 +196,26 @@ class Installer(): o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "chown -R aibuilder.aibuilder /home/aibuilder/yay"')) o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "su - aibuilder -c \\"(cd /home/aibuilder/yay; makepkg -si --noconfirm)\\" >/dev/null"')) - o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "userdel aibuilder; rm -rf /hoem/aibuilder"')) \ No newline at end of file + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "userdel aibuilder; rm -rf /hoem/aibuilder"')) + o = b''.join(sys_command(f"/usr/bin/sed -i 's/^%wheel ALL=(ALL) NO/# %wheel ALL=(ALL) NO/' {self.mountpoint}/etc/sudoers")) + + def yay(self, *packages, **kwargs): + if type(packages[0]) in (list, tuple): packages = packages[0] + log(f'Installing AUR packages: {packages}') + + if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0: + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "useradd -m -G wheel aibuilder"')) + o = b''.join(sys_command(f"/usr/bin/sed -i 's/# %wheel ALL=(ALL) NO/%wheel ALL=(ALL) NO/' {self.mountpoint}/etc/sudoers")) + + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "su - aibuilder -c \\"/usr/bin/yay -S --noconfirm {" ".join(packages)}\\" >/dev/null"')) + + o = b''.join(sys_command(f'/usr/bin/arch-chroot {self.mountpoint} sh -c "userdel aibuilder; rm -rf /hoem/aibuilder"')) + o = b''.join(sys_command(f"/usr/bin/sed -i 's/^%wheel ALL=(ALL) NO/# %wheel ALL=(ALL) NO/' {self.mountpoint}/etc/sudoers")) + + return True + else: + log(f'Could not sync mirrors: {sync_mirrors.exit_code}') + + + def add_AUR_packages(self, *packages): + return self.yay(*packages) \ No newline at end of file -- cgit v1.2.3-54-g00ecf