-
Notifications
You must be signed in to change notification settings - Fork 536
Expand file tree
/
Copy pathuninstall
More file actions
executable file
·120 lines (107 loc) · 3.09 KB
/
Copy pathuninstall
File metadata and controls
executable file
·120 lines (107 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
#
# This file is part of the distrobox project: https://github.com/89luca89/distrobox
#
# Copyright (C) 2021 distrobox contributors
#
# distrobox is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3
# as published by the Free Software Foundation.
#
# distrobox is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with distrobox; if not, see <http://www.gnu.org/licenses/>.
# POSIX
# uninstall.sh — remove distrobox (v1 legacy or v2 Go) from the given
# prefix. The prefix must match the one used at install time (default:
# /usr/local for root, ~/.local otherwise). Both the v1 split-script
# layout and the v2 single-binary layout are wiped in a single pass,
# so you don't need to remember which version you installed.
prefix=""
no_color=0
verbose=0
show_help()
{
cat << EOF
uninstall --prefix /usr/local
Removes distrobox (v1 or v2) from the given prefix.
Options:
--prefix/-P: base path where distrobox was installed
(default: /usr/local if root, ~/.local otherwise)
--no-color: disable color formatting
--help/-h: show this message
-v/--verbose: show more verbosity
EOF
}
while [ $# -gt 0 ]; do
case $1 in
-h | --help)
show_help
exit 0
;;
-v | --verbose)
verbose=1
shift
;;
--no-color)
no_color=1
shift
;;
-P | --prefix)
if [ -n "${2:-}" ]; then
prefix="$2"
shift 2
else
show_help
exit 1
fi
;;
*)
printf >&2 "Error: unknown argument %s\n" "$1"
show_help
exit 1
;;
esac
done
set -o errexit
set -o nounset
BOLD_GREEN=""
CLEAR=""
if [ -t 0 ] && [ -t 1 ] && [ "${no_color}" -ne 1 ]; then
BOLD_GREEN='\033[1;32m'
CLEAR='\033[0m'
fi
if [ "${verbose}" -ne 0 ]; then
set -o xtrace
fi
if [ -z "${prefix}" ]; then
prefix="/usr/local"
if [ "$(id -u)" -ne 0 ]; then
prefix="${HOME}/.local"
fi
fi
bindir="${prefix}/bin"
mandir="${prefix}/share/man/man1"
bashdir="${prefix}/share/bash-completion/completions"
zshdir="${prefix}/share/zsh/site-functions"
icondir="${prefix}/share/icons/hicolor"
icon_sizes="16 22 24 32 36 48 64 72 96 128 256"
rm -f "${bindir}/distrobox"
# `distrobox-*` matches v1 split scripts and v2 argv[0] symlinks alike
# (the helpers distrobox-init/export/host-exec are also picked up here).
rm -f "${bindir}"/distrobox-*
rm -f "${mandir}/distrobox.1" "${mandir}"/distrobox-*.1
# v1 ships per-subcommand bash/zsh completions; the v2 release only
# ships a single `distrobox` / `_distrobox`. The globs cover both.
rm -f "${bashdir}/distrobox" "${bashdir}"/distrobox-*
rm -f "${zshdir}/_distrobox" "${zshdir}"/_distrobox-*
rm -f "${icondir}/scalable/apps/terminal-distrobox-icon.svg"
for sz in ${icon_sizes}; do
rm -f "${icondir}/${sz}x${sz}/apps/terminal-distrobox-icon.png"
done
printf >&2 "%b Uninstalled distrobox from %s%b\n" "${BOLD_GREEN}" "${prefix}" "${CLEAR}"