NBash

Форк
0
203 строки · 5.7 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2012, 2014, 2016, 2019, 2021  Etersoft
4
# Copyright (C) 2012, 2014, 2016, 2019, 2021  Vitaly Lipatov <lav@etersoft.ru>
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
15
#
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#
19

20
load_helper epm-check_updated_repo
21
load_helper epm-sh-warmup
22

23
epm_upgrade()
24
{
25
    local CMD
26

27
    # it is useful for first time running
28
    update_repo_if_needed
29

30
    warmup_bases
31

32
    if [ "$BASEDISTRNAME" = "alt" ] ; then
33
        load_helper epm-sh-altlinux
34
        if tasknumber "$@" >/dev/null ; then
35
            load_helper epm-addrepo
36
            load_helper epm-reposave
37
            load_helper epm-removerepo
38
            load_helper epm-Install
39

40
            local installlist="$(get_task_packages $*)"
41
            # hack: drop -devel packages to avoid package provided by multiple packages
42
            installlist="$(estrlist reg_exclude ".*-devel .*-devel-static" "$installlist")"
43
            [ -n "$verbose" ] && info "Packages from task(s): $installlist"
44
            # install only installed packages (simulate upgrade packages)
45
            installlist="$(get_only_installed_packages "$installlist")"
46
            [ -n "$verbose" ] && info "Packages to upgrade: $installlist"
47
            if [ -z "$installlist" ] ; then
48
                warning "There is no installed packages for upgrade from task $*"
49
                return 22
50
            fi
51

52
            try_change_alt_repo
53
            epm_addrepo "$@"
54
            __epm_update
55
            (pkg_names="$installlist" epm_install) || fatal "Can't update repo"
56
            epm_removerepo "$@"
57
            end_change_alt_repo
58

59
            return
60
        fi
61
    fi
62

63
    # Solus supports upgrade for a package (with all dependencies)
64
    if [ -n "$1" ] && [ "$DISTRNAME" = "Solus" ] ; then
65
        sudocmd eopkg upgrade "$@"
66
        return
67
    fi
68

69
    # if possible, it will put pkg_urls into pkg_files and reconstruct pkg_filenames
70
    if [ -n "$pkg_urls" ] ; then
71
        info "Downloading packages assigned to upgrade ..."
72
        load_helper epm-download
73
        __handle_pkg_urls_to_install
74
    fi
75

76
    info "Running command for upgrade packages"
77

78

79
    case $PMTYPE in
80
        *-rpm)
81
            # upgrade only install files from the list
82
            if [ -n "$pkg_files" ] ; then
83
                load_helper epm-install
84
                #sudocmd rpm -Fvh $pkg_files
85
                (pkg_files=$pkg_files force="$force -F" epm_install)
86
                return
87
            elif [ -n "$pkg_names" ] ; then
88
                # hack for https://bugzilla.altlinux.org/41225
89
                case "$pkg_names" in
90
                    -*)
91
                        fatal "Option $pkg_names is not allowed here"
92
                esac
93
                load_helper epm-install
94
                (pkg_names=$(get_only_installed_packages $pkg_names) epm_install)
95
                return
96
            fi
97
        ;;
98
    esac
99

100
    case $PMTYPE in
101
    apt-rpm|apt-dpkg)
102
        local APTOPTIONS="$dryrun $(subst_option non_interactive -y) $(subst_option verbose "-V -o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")"
103
        CMD="apt-get $APTOPTIONS $noremove $force_yes dist-upgrade"
104
        ;;
105
    aptitude-dpkg)
106
        CMD="aptitude dist-upgrade"
107
        ;;
108
    packagekit)
109
        docmd pkcon update
110
        return
111
        ;;
112
    yum-rpm)
113
        local OPTIONS="$(subst_option non_interactive -y)"
114
        # can do update repobase automagically
115
        CMD="yum $OPTIONS update $*"
116
        ;;
117
    dnf-rpm)
118
        local OPTIONS="$(subst_option non_interactive -y)"
119
        CMD="dnf $OPTIONS distro-sync $*"
120
        ;;
121
    snappy)
122
        CMD="snappy update"
123
        ;;
124
    urpm-rpm)
125
        # or --auto-select --replace-files
126
        CMD="urpmi --update --auto-select $*"
127
        ;;
128
    zypper-rpm)
129
        CMD="zypper $(subst_option non_interactive --non-interactive) dist-upgrade"
130
        ;;
131
    pacman)
132
        CMD="pacman -S -u $force"
133
        ;;
134
    aura)
135
        CMD="aura -A -u"
136
        ;;
137
    emerge)
138
        CMD="emerge -NuDa world"
139
        ;;
140
    conary)
141
        CMD="conary updateall"
142
        ;;
143
    pkgsrc)
144
        CMD="freebsd-update fetch install"
145
        ;;
146
    pkgng)
147
        CMD="pkg upgrade"
148
        ;;
149
    apk)
150
        CMD="apk upgrade"
151
        ;;
152
    choco)
153
        CMD="choco update all"
154
        ;;
155
    homebrew)
156
        #CMD="brew upgrade"
157
        sudocmd brew upgrade $(brew outdated)
158
        return
159
        ;;
160
    opkg)
161
        CMD="opkg upgrade"
162
        ;;
163
    eopkg)
164
        CMD="eopkg upgrade"
165
        ;;
166
    slackpkg)
167
        CMD="/usr/sbin/slackpkg upgrade-all"
168
        ;;
169
    guix)
170
        CMD="guix package -u"
171
        ;;
172
    appget)
173
        CMD="$PMTYPE update-all"
174
        ;;
175
    winget)
176
        if [ -z "$1" ] ; then
177
            sudocmd winget upgrade --all
178
            return
179
        fi
180
        CMD="winget upgrade"
181
        ;;
182
    aptcyg)
183
        # shellcheck disable=SC2046
184
        docmd_foreach "epm install" $(short=1 epm packages)
185
        return
186
        ;;
187
    xbps)
188
        CMD="xbps-install -Su"
189
        ;;
190
    nix)
191
        CMD="nix-env -u $dryrun"
192
        ;;
193
    termux-pkg)
194
        CMD="pkg upgrade"
195
        ;;
196
    *)
197
        fatal "Have no suitable command for $PMTYPE"
198
        ;;
199
    esac
200

201
    sudocmd $CMD "$@"
202

203
}
204

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.