Skip to content

Commit

Permalink
Remove superfluous /usr/bin/ from commands (#3115)
Browse files Browse the repository at this point in the history
  • Loading branch information
codefiles authored Jan 13, 2025
1 parent c0a2de4 commit b7a5d00
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion archinstall/lib/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __enter__(self) -> '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',
Expand Down
2 changes: 1 addition & 1 deletion archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def trace_log(self) -> bytes | None:

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

Expand Down
42 changes: 21 additions & 21 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def add_swapfile(self, size: str = '4G', enable_resume: bool = True, file: str =
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')
Expand Down Expand Up @@ -499,7 +499,7 @@ def genfstab(self, flags: str = '-pU') -> None:
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}')
Expand Down Expand Up @@ -561,7 +561,7 @@ def set_locale(self, locale_config: LocaleConfiguration) -> bool:
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
Expand All @@ -582,7 +582,7 @@ def set_timezone(self, zone: str) -> bool:

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:
Expand Down Expand Up @@ -620,7 +620,7 @@ def enable_service(self, services: str | list[str]) -> None:
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:
Expand All @@ -629,7 +629,7 @@ def arch_chroot(self, cmd: str, run_as: str | None = None) -> SysCommand:
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()
Expand Down Expand Up @@ -723,7 +723,7 @@ def mkinitcpio(self, flags: list[str]) -> bool:
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:
Expand Down Expand Up @@ -865,16 +865,16 @@ def minimal_installation(

# 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)

self.set_locale(locale_config)
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)')
Expand Down Expand Up @@ -1071,10 +1071,10 @@ def _add_systemd_bootloader(

# 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.
#
Expand Down Expand Up @@ -1168,7 +1168,7 @@ def _add_grub_bootloader(
boot_dir = Path('/boot')

command = [
'/usr/bin/arch-chroot',
'arch-chroot',
str(self.target),
'grub-install',
'--debug'
Expand Down Expand Up @@ -1222,7 +1222,7 @@ def _add_grub_bootloader(

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:
Expand Down Expand Up @@ -1277,7 +1277,7 @@ def _add_limine_bootloader(
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}')

Expand Down Expand Up @@ -1523,7 +1523,7 @@ def user_create(self, user: str, password: str | None = None, groups: list[str]
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}")

Expand All @@ -1537,7 +1537,7 @@ def user_create(self, user: str, password: str | None = None, groups: list[str]

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
Expand All @@ -1554,7 +1554,7 @@ def user_set_pw(self, user: str, password: str) -> bool:
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
Expand All @@ -1563,15 +1563,15 @@ def user_set_shell(self, user: str, shell: str) -> bool:
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

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
Expand All @@ -1588,7 +1588,7 @@ def set_keyboard_language(self, language: str) -> bool:
# 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])
Expand Down
8 changes: 4 additions & 4 deletions archinstall/lib/luks.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def encrypt(
key_file = self._get_key_file(key_file)

cryptsetup_args = shlex.join([
'/usr/bin/cryptsetup',
'cryptsetup',
'--batch-mode',
'--verbose',
'--type', 'luks2',
Expand All @@ -108,7 +108,7 @@ def encrypt(
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()
Expand Down Expand Up @@ -139,7 +139,7 @@ def unlock(self, key_file: Path | None = None) -> None:
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} '
Expand Down Expand Up @@ -202,7 +202,7 @@ def create_keyfile(self, target_path: Path, override: bool = False) -> None:
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

Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/pacman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def sync(self) -> None:
'Could not sync mirrors',
self.run,
'-Syy',
default_cmd='/usr/bin/pacman'
default_cmd='pacman'
)
self.synced = True

Expand All @@ -84,6 +84,6 @@ def strap(self, packages: str | list[str]) -> None:
'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
)

0 comments on commit b7a5d00

Please sign in to comment.