Skip to content

Commit 346b166

Browse files
committed
Add executable Aptitude lifecycle adapter
1 parent a7e66c7 commit 346b166

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# JWSTF Aptitude adapter.
5+
# Usage: aptitude-module.sh {search|install|update|verify|remove} [package...]
6+
7+
usage() {
8+
echo "Usage: $0 {search|install|update|verify|remove} [package ...]" >&2
9+
exit 2
10+
}
11+
12+
command -v aptitude >/dev/null 2>&1 || {
13+
echo "aptitude is not installed on this Debian/Ubuntu host." >&2
14+
exit 127
15+
}
16+
17+
[[ $# -ge 1 ]] || usage
18+
op="$1"
19+
shift
20+
21+
case "$op" in
22+
search)
23+
[[ $# -ge 1 ]] || usage
24+
aptitude search "$@"
25+
;;
26+
install)
27+
[[ $# -ge 1 ]] || usage
28+
echo "Planned installation: $*"
29+
aptitude -s install "$@"
30+
read -r -p "Apply this installation? [y/N] " answer
31+
[[ "$answer" =~ ^[Yy]$ ]] || { echo "Cancelled."; exit 0; }
32+
sudo aptitude install "$@"
33+
;;
34+
update)
35+
sudo aptitude update
36+
if [[ $# -gt 0 ]]; then
37+
sudo aptitude safe-upgrade "$@"
38+
else
39+
sudo aptitude safe-upgrade
40+
fi
41+
;;
42+
verify)
43+
[[ $# -ge 1 ]] || usage
44+
for package in "$@"; do
45+
aptitude show "$package"
46+
done
47+
;;
48+
remove)
49+
[[ $# -ge 1 ]] || usage
50+
echo "Planned removal: $*"
51+
aptitude -s remove "$@"
52+
read -r -p "Apply this removal? [y/N] " answer
53+
[[ "$answer" =~ ^[Yy]$ ]] || { echo "Cancelled."; exit 0; }
54+
sudo aptitude remove "$@"
55+
;;
56+
*)
57+
usage
58+
;;
59+
esac

0 commit comments

Comments
 (0)