Merge pull request #294 from fsquillace/sudoj

Default to ns mode (not fakeroot) for bin wrappers and add sudoj command
This commit is contained in:
Filippo Squillace 2022-04-23 19:32:10 +02:00 committed by GitHub
commit 98775b538f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 6 deletions

View file

@ -110,25 +110,34 @@ used, see the [Usage](#usage) section below.
Run JuNest installed programs directly from host OS
---------------------------------------
Installed programs can be accessible directly from host without
entering directly into a JuNest session (no need to call `junest` command).
Program installed within JuNest can be accessible directly from host machine
without entering directly into a JuNest session
(no need to call `junest` command first).
For instance, supposing the host OS is an Ubuntu distro you can directly
run `pacman` by simply updating the `PATH` variable:
```sh
export PATH="$PATH:~/.junest/usr/bin_wrappers"
pacman -S htop
sudoj pacman -S htop
htop
```
By default the wrappers use `"ns --fakeroot"` but you can change it via `JUNEST_ARGS` environment variable.
By default the wrappers use `ns` mode. To use the `ns --fakeroot` you can use the convenient command helper `sudoj`.
For more control on backend mode you can use the `JUNEST_ARGS` environment variable.
For instance, if you want to run `iftop` with real root privileges:
```
pacman -S iftop
sudoj pacman -S iftop
sudo JUNEST_ARGS="groot" iftop
```
Bin wrappers can be always recreated (e.g. in case for some reasons they get
corrupted) with:
```
junest create-bin-wrappers -f
```
Install packages from AUR
-------------------------

8
bin/sudoj Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
#
# This file is part of JuNest (https://github.com/fsquillace/junest).
#
export PATH="${PATH}:${JUNEST_HOME}/usr/bin_wrappers"
JUNEST_ARGS="ns --fakeroot" "$@"

View file

@ -24,3 +24,4 @@ sudo -E "$JUNEST_SCRIPT" groot -- "$CHECK_SCRIPT" --run-root-tests --skip-aur-te
# Test the wrappers work
"$JUNEST_SCRIPT" create-bin-wrappers --force
"$JUNEST_HOME"/usr/bin_wrappers/pacman --help
"${JUNEST_BASE}/bin/sudoj" pacman -Syu

View file

@ -36,7 +36,7 @@ function create_wrappers() {
cat <<EOF > "${JUNEST_HOME}/usr/bin_wrappers/${file}"
#!/usr/bin/env bash
JUNEST_ARGS=\${JUNEST_ARGS:-ns --fakeroot}
JUNEST_ARGS=\${JUNEST_ARGS:-ns}
eval junest "\${JUNEST_ARGS}" -- ${file} "\$(printf "%q" "\$@")"
EOF