-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathdpkg.sh
158 lines (131 loc) · 2.64 KB
/
dpkg.sh
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# Purpose: Debian / Ubuntu support
# Author : Anh K. Huynh
# License: Fair license (http://www.opensource.org/licenses/fair)
# Source : http://github.com/icy/pacapt/
# Copyright (C) 2010 - 2014 Anh K. Huynh
#
# Usage of the works is permitted provided that this instrument is
# retained with the works, so that any entity that uses the works is
# notified of this instrument.
#
# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
_dpkg_init() {
:
}
# dpkg_Q may _not_implemented
dpkg_Q() {
if [[ "$_TOPT" == "q" ]]; then
dpkg -l \
| grep -E '^[hi]i' \
| awk '{print $2}'
elif [[ "$_TOPT" == "" ]]; then
dpkg -l "$@" \
| grep -E '^[hi]i'
else
_not_implemented
fi
}
dpkg_Qi() {
dpkg-query -s "$@"
}
dpkg_Ql() {
if [[ -n "$*" ]]; then
dpkg-query -L "$@"
return
fi
dpkg -l \
| grep -E '^[hi]i' \
| awk '{print $2}' \
| while read -r _pkg; do
if [[ "$_TOPT" == "q" ]]; then
dpkg-query -L "$_pkg"
else
dpkg-query -L "$_pkg" \
| while read -r _line; do
echo "$_pkg $_line"
done
fi
done
}
dpkg_Qo() {
dpkg-query -S "$@"
}
dpkg_Qp() {
dpkg-deb -I "$@"
}
dpkg_Qu() {
apt-get upgrade --trivial-only "$@"
}
# NOTE: Some field is available for dpkg >= 1.16.2
# NOTE: Debian:Squeeze has dpkg < 1.16.2
dpkg_Qs() {
# dpkg >= 1.16.2 dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\t${Version}\t${binary:Summary}\n'
dpkg-query -W -f='${Status} ${Package}\t${Version}\t${Description}\n' \
| grep -E '^((hold)|(install)|(deinstall))' \
| sed -r -e 's#^(\w+ ){3}##g' \
| grep -Ei "${@:-.}"
}
# dpkg_Rs may _not_implemented
dpkg_Rs() {
if [[ "$_TOPT" == "" ]]; then
apt-get autoremove "$@"
else
_not_implemented
fi
}
dpkg_Rn() {
apt-get purge "$@"
}
dpkg_Rns() {
apt-get --purge autoremove "$@"
}
dpkg_R() {
apt-get remove "$@"
}
dpkg_Si() {
apt-cache show "$@"
}
dpkg_Suy() {
apt-get update \
&& apt-get upgrade "$@" \
&& apt-get dist-upgrade "$@"
}
dpkg_Su() {
apt-get upgrade "$@" \
&& apt-get dist-upgrade "$@"
}
# See also https://github.com/icy/pacapt/pull/78
# This `-w` option is implemented in `00_core/_translate_w`
#
# dpkg_Sw() {
# apt-get --download-only install "$@"
# }
# FIXME: Should we remove "$@"?
dpkg_Sy() {
apt-get update "$@"
}
dpkg_Ss() {
apt-cache search "$@"
}
dpkg_Sc() {
apt-get clean "$@"
}
dpkg_Scc() {
apt-get autoclean "$@"
}
dpkg_S() {
apt-get install $_TOPT "$@"
}
dpkg_U() {
dpkg -i "$@"
}
dpkg_Sii() {
apt-cache rdepends "$@"
}
dpkg_Sccc() {
rm -fv /var/cache/apt/*.bin
rm -fv /var/cache/apt/archives/*.*
rm -fv /var/lib/apt/lists/*.*
apt-get autoclean
}