-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacdeps
executable file
·63 lines (50 loc) · 1014 Bytes
/
pacdeps
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
#!/bin/bash
set -eu
readonly THIS_CMD="${0##*/}"
readonly VERSION='0.0.1'
readonly PACMANS=(
"paru"
"yay"
"pacman"
)
function _help() {
echo -e "
${THIS_CMD} -- Get a list of dependent packages
USAGE
${THIS_CMD} [OPTIONS] PKGNAMES...
OPTIONS
-l --local Search from installed packages
-o --only-result Print dependent package names only.
"
}
function _main() {
if [ "$#" -le 0 ]; then
_help
fi
_get_dependent_pkgs "${@}"
}
function _get_pacman_cmd() {
local _cmd
for _cmd in "${PACMANS[@]}"; do
if command -v "${_cmd}" &>/dev/null; then
echo -n "${_cmd}"
return 0
fi
done
_err 'The command for pacman or AUR helper was not found.'
exit 1
}
function _get_dependent_pkgs() {
local pacman_cmd
pacman_cmd="$(_get_pacman_cmd)"
for pkg_name in "${@}"; do
echo "${pkg_name}"
LANG=C "${pacman_cmd}" --sync --info "${pkg_name}" |
awk -F '[:<=>]' '/^Depends/ {print $2}' |
xargs -n1 |
sort |
sed 's/^/\t/'
done
}
_main "${@}"
exit "${?}"