-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_orphan_packages
executable file
·90 lines (76 loc) · 1.53 KB
/
list_orphan_packages
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
#!/bin/bash
#
# List dependency packages that are no longer required by any installed package.
#
# Dependencies: coreutils, pacman, util-linux
set -o nounset -o pipefail
readonly L_OPTS="help,version"
readonly OPTS="hVv"
readonly CMD="${0##*/}"
readonly USAGE="${CMD} [OPTION]..."
readonly USAGE_ERR_MSG=$(
cat <<END
Usage: ${USAGE}
Try '${CMD} --help' for more information.
END
)
readonly VERSION_INFO=$(
cat <<END
${CMD} (scripts) 1.0.0
This is free and unencumbered software released into the public domain.
For more information, please refer to <https://unlicense.org/>.
END
)
readonly HELP=$(
cat <<END
SYNOPSIS
${USAGE}
DESCRIPTION
List dependency packages that are no longer required by any installed package.
OPTIONS
-h, --help
display this help and exit
-V, -v, --version
display version and exit
END
)
opts=$(getopt --options=${OPTS} --longoptions=${L_OPTS} --name "${CMD}" -- "$@")
if (($? != 0)); then
echo "${USAGE_ERR_MSG}"
exit 2
fi
eval set -- "${opts}"
need_help=false
need_version=false
while true; do
case "$1" in
-h | --help)
need_help=true
shift
break
;;
-V | -v | --version)
need_version=true
shift
break
;;
--)
shift
break
;;
esac
done
if [[ $need_help == true ]]; then
echo "${HELP}"
exit 0
fi
if [[ $need_version == true ]]; then
echo "${VERSION_INFO}"
exit 0
fi
if (($# != 0)); then
echo "${CMD}: expected 0 arguments; got $#"
echo "${USAGE_ERR_MSG}"
exit 2
fi
pacman --query --deps --unrequired --quiet