Prefix install/uninstall option (#190)

This fixes #184 
right now --path/-p is DEPRECATED.
Gradually switch to a more ubiquitous  use of --prefix/-P
This commit is contained in:
Mišo Barišić authored and GitHub committed 2022-02-26 11:43:59 +01:00
1 parent 3c950a77b0
commit 7960dbdf07
4 files changed
+70 -24

No files matched your search

+1 -1
View File
@@ -220,7 +220,7 @@ generate_command() {
workdir="$(echo "${PWD:-${HOME:-"/"}}" | sed -e 's/"/\\\"/g')"
result_command="${result_command}
--workdir=\"${workdir}\"
--env=\"DISTROBOX_ENTER_PATH=${distrobox_enter_path}"\"
--env=\"DISTROBOX_ENTER_PATH=${distrobox_enter_path}\""
# Loop through all the environment vars
# and export them to the container.
+6 -4
View File
@@ -134,11 +134,13 @@ If you like to live your life dangerously, you can trust me and simply run this
or if you want to select a custom directory to install without sudo:
`curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- -p ~/.local/bin`
`curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --prefix ~/.local`
Else you can clone the project using `git clone` or using the latest release [HERE](https://github.com/89luca89/distrobox/releases/latest).
Enter the directory and run `./install`, by default it will attempt to install in `~/.local/bin` but if you run the script as root, it will default to `/usr/local/bin`. You can specify a custom directory with the `-p` flag such as `./install -p ~/.bin`.
Enter the directory and run `./install`, by default it will attempt to install in `~/.local` but if you run the script as root, it will default to `/usr/local`. You can specify a custom directory with the `--prefix` flag such as `./install --prefix ~/.distrobox`.
Prefix explained: main distrobox files get installed to `${prefix}/bin` whereas the manpages get installed to `${prefix}/share/man`.
Or check the [Host Distros](compatibility.md#host-distros) compatibility list for distro-specific instructions.
@@ -157,11 +159,11 @@ If you installed distrobox using the `install` script in the default install dir
or if you specified a custom path:
`curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/uninstall | sh -s -- -p ~/.local/bin`
`curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/uninstall | sh -s -- --prefix ~/.local`
Else if cloned the project using `git clone` or using the latest archive release from [HERE](https://github.com/89luca89/distrobox/releases/latest),
enter the directory and run `./uninstall`, by default it will assume the install directory was `/usr/local/bin`, you can specify another directory if needed with `./uninstall -p ~/.local/bin`
enter the directory and run `./uninstall`, by default it will assume the install directory was `/usr/local` if ran as root or `~/.local`, you can specify another directory if needed with `./uninstall --prefix ~/.local`
---
+31 -10
View File
@@ -19,12 +19,6 @@
# POSIX
dest_path="/usr/local/bin"
# in case we're not root, just default to the home directory
if [ "$(id -u)" -ne 0 ]; then
dest_path="${HOME}/.local/bin"
fi
verbose=0
# Print usage to stdout.
@@ -34,10 +28,11 @@ verbose=0
# print usage with examples.
show_help() {
cat <<EOF
install -p /usr/local/bin
install --prefix /usr/local
Options:
--path/-p: path where to deploy the files (default /usr/local/bin if root, ~/.local/bin if not)
--prefix/-P: base bath where all files will be deployed (default /usr/local if root, ~/.local if not)
--path/-p: (DEPRECATED) path where to deploy the files (default /usr/local/bin if root, ~/.local/bin if not)
--help/-h: show this message
-v: show more verbosity
EOF
@@ -62,11 +57,39 @@ while :; do
shift
fi
;;
-P | --prefix)
if [ -n "$2" ]; then
prefix="$2"
shift
shift
fi
;;
*) # Default case: If no more options then break out of the loop.
break ;;
esac
done
if [ -n "${dest_path}" ] && [ -n "${prefix}" ]; then
printf >&2 "Both -p and -P are set. Cannot continue. Exiting.\n"
exit 1
fi
if [ -z "${dest_path}" ]; then
if [ -z "${prefix}" ]; then
prefix="/usr/local"
# in case we're not root, just default to the home directory
if [ "$(id -u)" -ne 0 ]; then
prefix="${HOME}/.local"
fi
fi
dest_path="${prefix}/bin"
man_dest_path="${prefix}/share/man/man1"
else
printf >&2 "Warning: -p/--path is deprecated. Please refer to the documentation and switch to -P/--prefix.\n"
# dest_path is already set
man_dest_path="${dest_path}/../share/man/man1"
fi
set -o errexit
set -o nounset
# set verbosity
@@ -74,8 +97,6 @@ if [ "${verbose}" -ne 0 ]; then
set -o xtrace
fi
man_dest_path="${dest_path}/../share/man/man1"
# get current dir
curr_dir=$(dirname "$0")
cd "${curr_dir}" || exit 1
+32 -9
View File
@@ -19,12 +19,6 @@
# POSIX
dest_path="/usr/local/bin"
# in case we're not root, just default to the home directory
if [ "$(id -u)" -ne 0 ]; then
dest_path="${HOME}/.local/bin"
fi
verbose=0
# Print usage to stdout.
@@ -34,10 +28,11 @@ verbose=0
# print usage with examples.
show_help() {
cat <<EOF
uninstall -p /usr/local/bin
uninstall --prefix /usr/local
Options:
--path/-p: path where to deploy the files (default /usr/local/bin if root, ~/.local/bin if not)
--prefix/-P: base bath where all files will be deployed (default /usr/local if root, ~/.local if not)
--path/-p: (DEPRECATED) path where to deploy the files (default /usr/local/bin if root, ~/.local/bin if not)
--help/-h: show this message
-v: show more verbosity
EOF
@@ -62,11 +57,39 @@ while :; do
shift
fi
;;
-P | --prefix)
if [ -n "$2" ]; then
prefix="$2"
shift
shift
fi
;;
*) # Default case: If no more options then break out of the loop.
break ;;
esac
done
if [ -n "${dest_path}" ] && [ -n "${prefix}" ]; then
printf >&2 "Both -p and -P are set. Cannot continue. Exiting.\n"
exit 1
fi
if [ -z "${dest_path}" ]; then
if [ -z "${prefix}" ]; then
prefix="/usr/local"
# in case we're not root, just default to the home directory
if [ "$(id -u)" -ne 0 ]; then
prefix="${HOME}/.local"
fi
fi
dest_path="${prefix}/bin"
man_dest_path="${prefix}/share/man/man1"
else
printf >&2 "Warning: -p/--path is deprecated. Please refer to the documentation and switch to -P/--prefix.\n"
# dest_path is already set
man_dest_path="${dest_path}/../share/man/man1"
fi
set -o errexit
set -o nounset
# set verbosity
@@ -82,7 +105,7 @@ fi
for file in "${dest_path}/distrobox"*; do
[ -e "${file}" ] && rm -i "${file}"
done
for file in "${dest_path}/../share/man/man1/distrobox"*; do
for file in "${man_dest_path}/distrobox"*; do
[ -e "${file}" ] && rm -i "${file}"
done
echo "Thank you for using Distrobox. Uninstall complete."