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
159
160
161
162
163
164
165
166
167
168
169
#!/bin/sh
#
# Copyright (C) 2012, 2014, 2016, 2019, 2021 Etersoft
# Copyright (C) 2012, 2014, 2016, 2019, 2021 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
load_helper epm-sh-warmup
epm_upgrade()
{
local CMD
# it is useful for first time running
update_repo_if_needed
warmup_bases
if [ "$DISTRNAME" = "ALTLinux" ] || [ "$DISTRNAME" = "ALTServer" ] ; then
load_helper epm-sh-altlinux
if tasknumber "$@" >/dev/null ; then
load_helper epm-addrepo
load_helper epm-reposave
load_helper epm-removerepo
load_helper epm-Install
local installlist="$(get_task_packages $*)"
# hack: drop -devel packages to avoid package provided by multiple packages
installlist="$(estrlist reg_exclude ".*-devel .*-devel-static" "$installlist")"
[ -n "$verbose" ] && info "Packages from task(s): $installlist"
# install only installed packages (simulate upgrade packages)
installlist="$(get_only_installed_packages "$installlist")"
[ -n "$verbose" ] && info "Packages to upgrade: $installlist"
if [ -z "$installlist" ] ; then
warning "There is no installed packages for upgrade from task $*"
return 22
fi
try_change_alt_repo
epm_addrepo "$@"
(pkg_names="$installlist" epm_Install) || fatal "Can't update repo"
epm_removerepo "$@"
end_change_alt_repo
return
fi
fi
info "Running command for upgrade packages"
case $PMTYPE in
*-rpm)
# upgrade only install files from the list
if [ -n "$pkg_files" ] ; then
load_helper epm-install
#sudocmd rpm -Fvh $pkg_files
(pkg_files=$pkg_files force="$force -F" epm_install)
return
elif [ -n "$pkg_names" ] ; then
# hack for https://bugzilla.altlinux.org/41225
case "$pkg_names" in
-*)
fatal "Option $pkg_names is not allowed here"
esac
load_helper epm-install
(pkg_names=$(get_only_installed_packages $pkg_names) epm_install)
return
fi
;;
esac
case $PMTYPE in
apt-rpm|apt-dpkg)
local APTOPTIONS="$(subst_option non_interactive -y) $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")"
CMD="apt-get $APTOPTIONS $noremove $force_yes dist-upgrade"
;;
aptitude-dpkg)
CMD="aptitude dist-upgrade"
;;
packagekit)
docmd pkcon update
return
;;
yum-rpm)
local OPTIONS="$(subst_option non_interactive -y)"
# can do update repobase automagically
CMD="yum $OPTIONS update $*"
;;
dnf-rpm)
local OPTIONS="$(subst_option non_interactive -y)"
CMD="dnf $OPTIONS distro-sync $*"
;;
snappy)
CMD="snappy update"
;;
urpm-rpm)
# or --auto-select --replace-files
CMD="urpmi --update --auto-select $*"
;;
zypper-rpm)
CMD="zypper $(subst_option non_interactive --non-interactive) dist-upgrade"
;;
pacman)
CMD="pacman -S -u $force"
;;
aura)
CMD="aura -A -u"
;;
emerge)
CMD="emerge -NuDa world"
;;
conary)
CMD="conary updateall"
;;
pkgsrc)
CMD="freebsd-update fetch install"
;;
pkgng)
CMD="pkg upgrade"
;;
chocolatey)
CMD="chocolatey update all"
;;
homebrew)
#CMD="brew upgrade"
docmd brew upgrade $(brew outdated)
return
;;
opkg)
CMD="opkg upgrade"
;;
slackpkg)
CMD="/usr/sbin/slackpkg upgrade-all"
;;
guix)
CMD="guix package -u"
;;
appget|winget)
CMD="$PMTYPE update-all"
;;
aptcyg)
# shellcheck disable=SC2046
docmd_foreach "epm install" $(short=1 epm packages)
return
;;
xbps)
CMD="xbps-install -Su"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
sudocmd $CMD "$@"
}