-
Notifications
You must be signed in to change notification settings - Fork 2
/
pkg
executable file
·136 lines (126 loc) · 2.8 KB
/
pkg
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
#!/bin/sh
##
## pkg - A wrapper for package management tools.
## Copyright 2013 by Michal Nazarewicz ([email protected])
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
## This is part of Tiny Applications Collection
## -> http://tinyapps.sourceforge.net/
##
have() {
have=`which "$1" 2>/dev/null` && test -n "$have"
}
if [ -e /etc/slackware-version ]; then
cmd=slack
elif have apt-get || have yum; then
cmd=$have
else
echo "$0: could not find package manager software" >&2
exit 1
fi
if [ 0 -eq $(id -u) ]; then
sudo=
elif have sudo; then
sudo=sudo
elif have surun; then
sudo=surun
else
echo "$0: sudo or surun required" >&2
exit 1
fi
# If "$1" is not one of the known commands, assume install. Also do some
# mapping so yum commands look more like apt-get commands. I have nothing
# against yum but I'm more used to apt-get.
case "${cmd##*/}:$1" in
yum:remove|yum:purge)
shift
set -- erase "$@"
;;
yum:--help)
shift
set -- help "$@"
;;
yum:check | \
yum:check-update | \
yum:clean | \
yum:deplist | \
yum:distribution-synchronization | \
yum:downgrade | \
yum:groupinfo | \
yum:groupinstall | \
yum:grouplist | \
yum:groupremove | \
yum:history | \
yum:info | \
yum:install | \
yum:list | \
yum:load-transaction | \
yum:makecache | \
yum:provides | \
yum:reinstall | \
yum:repolist | \
yum:resolvedep | \
yum:search | \
yum:shell | \
yum:update-minimal | \
yum:updateinfo | \
yum:upgrade | \
yum:help | \
apt-get:install | \
apt-get:remove | \
apt-get:purge | \
apt-get:hold | \
apt-get:unhold | \
apt-get:markauto | \
apt-get:unmarkauto | \
apt-get:forbid-version | \
apt-get:update | \
apt-get:upgrade | \
apt-get:safe-upgrade | \
apt-get:full-upgrade | \
apt-get:forget-new | \
apt-get:search | \
apt-get:show | \
apt-get:clean | \
apt-get:autoclean | \
apt-get:changelog | \
apt-get:download | \
apt-get:reinstall | \
apt-get:why | \
apt-get:why-not)
;;
yum:?*|apt-get:?*)
set -- install "$@"
;;
slack:remove|slack:purge)
shift
cmd=removepkg
;;
slack:upgrade|slack:update)
shift
cmd=upgradepkg
;;
slack:?*.t?z)
cmd=upgradepkg
set -- --install-new "$@"
;;
*)
echo "$0: do not know what to do" >&2
exit 1
esac
$sudo "$cmd" "$@"
if [ $# -eq 1 ] && have apt-file && [ x"$1" = xupdate ]; then
exec $sudo apt-file update
fi