NBash

Форк
0
207 строк · 4.9 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2012, 2014, 2016-2017, 2023  Etersoft
4
# Copyright (C) 2012, 2014, 2016-2017, 2023  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
# copied from korinf/tools/run-script/scripts/update
21

22
load_helper epm-sh-warmup
23
load_helper epm-check_updated_repo
24

25
# TODO: restore mirroring
26
get_latest_version()
27
{
28
    URL="https://eepm.ru/app-versions"
29
    #update_url_if_need_mirrored
30
    local var
31
    var="$(epm tool eget -q -O- "$URL/$1")" || return
32
    echo "$var" | head -n1 | cut -d" " -f1
33
}
34

35
__check_for_epm_version()
36
{
37
    # skip update checking for eepm from repo (ALT bug #44314)
38
    [ "$BASEDISTRNAME" = "alt" ] &&  [ "$DISTRVERSION" != "Sisyphus" ] && epm status --original eepm && return
39

40
    local latest="$(get_latest_version eepm)"
41
    #[ -z "$latest" ] && return
42
    local res="$(epm print compare "$EPMVERSION" "$latest")"
43
    [ "$res" = "-1" ] && info "Latest EPM version in Korinf repository is $latest. You have version $EPMVERSION running." && info "You can update eepm with \$ epm ei command."
44
}
45

46
__save_available_packages()
47
{
48
    [ -d "$epm_vardir" ] || return 0
49

50
    # TODO: ignore in docker
51
    # update list only if the system supports bash completion
52
    [ -d /etc/bash_completion.d ] || return 0
53

54
    info "Retrieving list of all available packages (for autocompletion) ..."
55
    load_helper epm-list_available
56
    short=--short epm_list_available | sort | sudorun tee $epm_vardir/available-packages >/dev/null
57
}
58

59
__epm_update_content_index()
60
{
61
case $BASEDISTRNAME in
62
    "alt")
63
        load_helper epm-sh-altlinux-contents-index
64
        update_alt_contents_index
65
        return
66
        ;;
67
esac
68

69
case $PMTYPE in
70
    apt-dpkg)
71
        is_command apt-file || return 0
72
        assure_exists apt-file || return 0
73
        sudocmd apt-file update
74
        ;;
75
esac
76

77
}
78

79
__epm_update()
80
{
81

82
    [ -z "$*" ] || fatal "No arguments are allowed here"
83

84
    info "Running update the package index files from remote package repository database ..."
85

86
local ret=0
87
warmup_hibase
88

89
case $BASEDISTRNAME in
90
    "alt")
91
        # TODO: hack against cd to cwd in apt-get on ALT
92
        cd /
93
        sudocmd apt-get update
94
        ret="$?"
95
        cd - >/dev/null
96
        return $ret
97
        ;;
98
esac
99

100

101
case $PMTYPE in
102
    apt-rpm)
103
        # TODO: hack against cd to cwd in apt-get on ALT
104
        cd /
105
        sudocmd apt-get update
106
        ret="$?"
107
        cd - >/dev/null
108
        return $ret
109
        ;;
110
    apt-dpkg)
111
        sudocmd apt-get update || return
112
        # apt-get update retrieve Contents file too
113
        #sudocmd apt-file update
114
        ;;
115
    packagekit)
116
        docmd pkcon refresh
117
        ;;
118
    #snappy)
119
    #    sudocmd snappy
120
    #    ;;
121
    aptitude-dpkg)
122
        sudocmd aptitude update || return
123
        ;;
124
    yum-rpm)
125
        # just skipped
126
        [ -z "$verbose" ] || info "update command is stubbed for yum"
127
        ;;
128
    dnf-rpm)
129
        # just skipped
130
        [ -z "$verbose" ] || info "update command is stubbed for dnf"
131
        ;;
132
    urpm-rpm)
133
        sudocmd urpmi.update -a
134
        ;;
135
    pacman)
136
        sudocmd pacman -S -y
137
        ;;
138
    aura)
139
        sudocmd aura -A -y
140
        ;;
141
    zypper-rpm)
142
        sudocmd zypper $(subst_option non_interactive --non-interactive) refresh
143
        ;;
144
    emerge)
145
        sudocmd emerge --sync
146
        ;;
147
    slackpkg)
148
        sudocmd /usr/sbin/slackpkg -batch=on update
149
        ;;
150
    deepsolver-rpm)
151
        sudocmd ds-update
152
        ;;
153
    npackd)
154
        sudocmd packdcl detect # get packages from MSI database
155
        ;;
156
    homebrew)
157
        docmd brew update
158
        ;;
159
    opkg)
160
        sudocmd opkg update
161
        ;;
162
    eopkg)
163
        sudocmd eopkg update-repo
164
        ;;
165
    apk)
166
        sudocmd apk update
167
        ;;
168
    nix)
169
        sudocmd nix-channel --update
170
        ;;
171
    pkgsrc)
172
        # portsnap extract for the first time?
173
        sudocmd portsnap fetch update
174
        ;;
175
    aptcyg)
176
        sudocmd apt-cyg update
177
        ;;
178
    xbps)
179
        sudocmd xbps-install -S
180
        ;;
181
    winget)
182
        sudocmd winget source update
183
        ;;
184
    *)
185
        fatal "Have no suitable update command for $PMTYPE"
186
        ;;
187
esac
188
}
189

190

191
epm_update()
192
{
193
    if [ "$1" = "--content-index" ] ; then
194
        __epm_update_content_index
195
        return
196
    fi
197

198
    __epm_update "$@" || return
199

200
    __epm_touch_pkg
201

202
    __save_available_packages
203

204
    __epm_update_content_index
205

206
    return 0
207
}
208

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

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

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

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