LukeShortCloud / rootpages

Root Pages is a collection of easy-to-reference tutorials and guides primarily for Linux and other UNIX-like systems.
Other
56 stars 6 forks source link

[linux_distributions][arch_linux] Passing multiple arguments via a single shell environment variable to 'arch-chroot' #609

Open LukeShortCloud opened 2 years ago

LukeShortCloud commented 2 years ago

Two options:

  1. Add the shell environment variable to /mnt/etc/profile.d/<PROFILE>.sh
  2. Use a multi-line Bash command:
arch-chroot /mnt /bin/bash -- << EOF
    CMD="pacman -S --noconfirm"
    ${CMD} linux-headers
EOF

https://unix.stackexchange.com/questions/627872/how-to-pass-multiple-variables-and-functions-to-chroot-envrionment

LukeShortCloud commented 2 years ago

Update: based on testing, using a Bash array is the best way to pass commands to chroot and arch-chroot.

It is important to note that manjaro-chroot tries to be too clever for its own good. It will try to convert strings into an array which leads to unexpected behavior. For example:

Does not work:

manjaro-chroot /mnt crudini --set /home/stick/Desktop/steam_runtime.desktop "Desktop Entry" Name "Steam (Runtime) - GameMode"

Works:

arch-chroot /mnt crudini --set /home/stick/Desktop/steam_runtime.desktop "Desktop Entry" Name "Steam (Runtime) - GameMode"