From b7a5d006761282e3b10c95c2d53fc71b898981f7 Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Sun, 12 Jan 2025 22:42:39 -0500 Subject: [PATCH] Remove superfluous /usr/bin/ from commands (#3115) --- archinstall/lib/boot.py | 2 +- archinstall/lib/general.py | 2 +- archinstall/lib/installer.py | 42 +++++++++++++++--------------- archinstall/lib/luks.py | 8 +++--- archinstall/lib/pacman/__init__.py | 4 +-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/archinstall/lib/boot.py b/archinstall/lib/boot.py index 605a0764..0d47b336 100644 --- a/archinstall/lib/boot.py +++ b/archinstall/lib/boot.py @@ -26,7 +26,7 @@ class Boot: # '-P' or --console=pipe could help us not having to do a bunch # of os.write() calls, but instead use pipes (stdin, stdout and stderr) as usual. self.session = SysCommandWorker([ - '/usr/bin/systemd-nspawn', + 'systemd-nspawn', '-D', str(self.instance.target), '--timezone=off', '-b', diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 181588b6..06961551 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -458,7 +458,7 @@ class SysCommand: def _pid_exists(pid: int) -> bool: try: - return any(subprocess.check_output(['/usr/bin/ps', '--no-headers', '-o', 'pid', '-p', str(pid)]).strip()) + return any(subprocess.check_output(['ps', '--no-headers', '-o', 'pid', '-p', str(pid)]).strip()) except subprocess.CalledProcessError: return False diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 692786a1..6e41096c 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -451,7 +451,7 @@ class Installer: if enable_resume: resume_uuid = SysCommand(f'findmnt -no UUID -T {self.target}{file}').decode() resume_offset = SysCommand( - f'/usr/bin/filefrag -v {self.target}{file}' + f'filefrag -v {self.target}{file}' ).decode().split('0:', 1)[1].split(":", 1)[1].split("..", 1)[0].strip() self._hooks.append('resume') @@ -499,7 +499,7 @@ class Installer: info(f"Updating {fstab_path}") try: - gen_fstab = SysCommand(f'/usr/bin/genfstab {flags} {self.target}').output() + gen_fstab = SysCommand(f'genfstab {flags} {self.target}').output() except SysCallError as err: raise RequirementError( f'Could not generate fstab, strapping in packages most likely failed (disk out of space?)\n Error: {err}') @@ -561,7 +561,7 @@ class Installer: return False try: - SysCommand(f'/usr/bin/arch-chroot {self.target} locale-gen') + SysCommand(f'arch-chroot {self.target} locale-gen') except SysCallError as e: error(f'Failed to run locale-gen on target: {e}') return False @@ -582,7 +582,7 @@ class Installer: if (Path("/usr") / "share" / "zoneinfo" / zone).exists(): (Path(self.target) / "etc" / "localtime").unlink(missing_ok=True) - SysCommand(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') + SysCommand(f'arch-chroot {self.target} ln -s /usr/share/zoneinfo/{zone} /etc/localtime') return True else: @@ -620,7 +620,7 @@ class Installer: plugin.on_service(service) def run_command(self, cmd: str, *args: str, **kwargs: str) -> SysCommand: - return SysCommand(f'/usr/bin/arch-chroot {self.target} {cmd}') + return SysCommand(f'arch-chroot {self.target} {cmd}') def arch_chroot(self, cmd: str, run_as: str | None = None) -> SysCommand: if run_as: @@ -629,7 +629,7 @@ class Installer: return self.run_command(cmd) def drop_to_shell(self) -> None: - subprocess.check_call(f"/usr/bin/arch-chroot {self.target}", shell=True) + subprocess.check_call(f"arch-chroot {self.target}", shell=True) def configure_nic(self, nic: Nic) -> None: conf = nic.as_systemd_config() @@ -723,7 +723,7 @@ class Installer: mkinit.write(content) try: - SysCommand(f'/usr/bin/arch-chroot {self.target} mkinitcpio {" ".join(flags)}', peek_output=True) + SysCommand(f'arch-chroot {self.target} mkinitcpio {" ".join(flags)}', peek_output=True) return True except SysCallError as e: if e.worker: @@ -865,8 +865,8 @@ class Installer: # TODO: Support locale and timezone # os.remove(f'{self.target}/etc/localtime') - # sys_command(f'/usr/bin/arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') - # sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime') + # sys_command(f'arch-chroot {self.target} ln -s /usr/share/zoneinfo/{localtime} /etc/localtime') + # sys_command('arch-chroot /mnt hwclock --hctosys --localtime') if hostname: self.set_hostname(hostname) @@ -874,7 +874,7 @@ class Installer: self.set_keyboard_language(locale_config.kb_layout) # TODO: Use python functions for this - SysCommand(f'/usr/bin/arch-chroot {self.target} chmod 700 /root') + SysCommand(f'arch-chroot {self.target} chmod 700 /root') if mkinitcpio and not self.mkinitcpio(['-P']): error('Error generating initramfs (continuing anyway)') @@ -1071,10 +1071,10 @@ class Installer: # Install the boot loader try: - SysCommand(f"/usr/bin/arch-chroot {self.target} bootctl {' '.join(bootctl_options)} install") + SysCommand(f"arch-chroot {self.target} bootctl {' '.join(bootctl_options)} install") except SysCallError: # Fallback, try creating the boot loader without touching the EFI variables - SysCommand(f"/usr/bin/arch-chroot {self.target} bootctl --no-variables {' '.join(bootctl_options)} install") + SysCommand(f"arch-chroot {self.target} bootctl --no-variables {' '.join(bootctl_options)} install") # Ensure that the $BOOT/loader/ directory exists before we try to create files in it. # @@ -1168,7 +1168,7 @@ class Installer: boot_dir = Path('/boot') command = [ - '/usr/bin/arch-chroot', + 'arch-chroot', str(self.target), 'grub-install', '--debug' @@ -1222,7 +1222,7 @@ class Installer: try: SysCommand( - f'/usr/bin/arch-chroot {self.target} ' + f'arch-chroot {self.target} ' f'grub-mkconfig -o {boot_dir}/grub/grub.cfg' ) except SysCallError as err: @@ -1277,7 +1277,7 @@ class Installer: shutil.copy(limine_path / 'limine-bios.sys', self.target / 'boot') # `limine bios-install` deploys the stage 1 and 2 to the disk. - SysCommand(f'/usr/bin/arch-chroot {self.target} limine bios-install {parent_dev_path}', peek_output=True) + SysCommand(f'arch-chroot {self.target} limine bios-install {parent_dev_path}', peek_output=True) except Exception as err: raise DiskError(f'Failed to install Limine on {parent_dev_path}: {err}') @@ -1523,7 +1523,7 @@ Exec = /bin/sh -c "{hook_command}" if not handled_by_plugin: info(f'Creating user {user}') try: - SysCommand(f'/usr/bin/arch-chroot {self.target} useradd -m -G wheel {user}') + SysCommand(f'arch-chroot {self.target} useradd -m -G wheel {user}') except SysCallError as err: raise SystemError(f"Could not create user inside installation: {err}") @@ -1537,7 +1537,7 @@ Exec = /bin/sh -c "{hook_command}" if groups: for group in groups: - SysCommand(f'/usr/bin/arch-chroot {self.target} gpasswd -a {user} {group}') + SysCommand(f'arch-chroot {self.target} gpasswd -a {user} {group}') if sudo and self.enable_sudo(user): self.helper_flags['user'] = True @@ -1554,7 +1554,7 @@ Exec = /bin/sh -c "{hook_command}" sh = shlex.join(['sh', '-c', echo]) try: - SysCommand(f"/usr/bin/arch-chroot {self.target} " + sh[:-1] + " | chpasswd'") + SysCommand(f"arch-chroot {self.target} " + sh[:-1] + " | chpasswd'") return True except SysCallError: return False @@ -1563,7 +1563,7 @@ Exec = /bin/sh -c "{hook_command}" info(f'Setting shell for {user} to {shell}') try: - SysCommand(f"/usr/bin/arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\"") + SysCommand(f"arch-chroot {self.target} sh -c \"chsh -s {shell} {user}\"") return True except SysCallError: return False @@ -1571,7 +1571,7 @@ Exec = /bin/sh -c "{hook_command}" def chown(self, owner: str, path: str, options: list[str] = []) -> bool: cleaned_path = path.replace('\'', '\\\'') try: - SysCommand(f"/usr/bin/arch-chroot {self.target} sh -c 'chown {' '.join(options)} {owner} {cleaned_path}'") + SysCommand(f"arch-chroot {self.target} sh -c 'chown {' '.join(options)} {owner} {cleaned_path}'") return True except SysCallError: return False @@ -1588,7 +1588,7 @@ Exec = /bin/sh -c "{hook_command}" # Setting an empty keymap first, allows the subsequent call to set layout for both console and x11. from .boot import Boot with Boot(self) as session: - os.system('/usr/bin/systemd-run --machine=archinstall --pty localectl set-keymap ""') + os.system('systemd-run --machine=archinstall --pty localectl set-keymap ""') try: session.SysCommand(["localectl", "set-keymap", language]) diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py index 3e4f5bdc..45990452 100644 --- a/archinstall/lib/luks.py +++ b/archinstall/lib/luks.py @@ -81,7 +81,7 @@ class Luks2: key_file = self._get_key_file(key_file) cryptsetup_args = shlex.join([ - '/usr/bin/cryptsetup', + 'cryptsetup', '--batch-mode', '--verbose', '--type', 'luks2', @@ -108,7 +108,7 @@ class Luks2: return key_file def _get_luks_uuid(self) -> str: - command = f'/usr/bin/cryptsetup luksUUID {self.luks_dev_path}' + command = f'cryptsetup luksUUID {self.luks_dev_path}' try: return SysCommand(command).decode() @@ -139,7 +139,7 @@ class Luks2: time.sleep(0.025) result = SysCommand( - '/usr/bin/cryptsetup open ' + 'cryptsetup open ' f'{self.luks_dev_path} ' f'{self.mapper_name} ' f'--key-file {key_file} ' @@ -202,7 +202,7 @@ class Luks2: def _add_key(self, key_file: Path) -> None: debug(f'Adding additional key-file {key_file}') - command = f'/usr/bin/cryptsetup -q -v luksAddKey {self.luks_dev_path} {key_file}' + command = f'cryptsetup -q -v luksAddKey {self.luks_dev_path} {key_file}' worker = SysCommandWorker(command) pw_injected = False diff --git a/archinstall/lib/pacman/__init__.py b/archinstall/lib/pacman/__init__.py index 8ecb664d..0bda7f5f 100644 --- a/archinstall/lib/pacman/__init__.py +++ b/archinstall/lib/pacman/__init__.py @@ -64,7 +64,7 @@ class Pacman: 'Could not sync mirrors', self.run, '-Syy', - default_cmd='/usr/bin/pacman' + default_cmd='pacman' ) self.synced = True @@ -84,6 +84,6 @@ class Pacman: 'Could not strap in packages', 'Pacstrap failed. See /var/log/archinstall/install.log or above message for error details', SysCommand, - f'/usr/bin/pacstrap -C /etc/pacman.conf -K {self.target} {" ".join(packages)} --noconfirm', + f'pacstrap -C /etc/pacman.conf -K {self.target} {" ".join(packages)} --noconfirm', peek_output=True )