File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments