NBash

Форк
0
148 строк · 4.8 Кб
1
#!/bin/sh
2

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

21
load_helper epm-install
22

23
# default repo
24
EPM_KORINF_REPO_URL="https://updates.etersoft.ru/pub/Korinf"
25

26
__epm_korinf_site_mask() {
27
    local MASK="$1"
28
    local archprefix=""
29
    # short hack to install needed package
30
    rhas "$MASK" "[-_]" || MASK="${MASK}[-_][0-9]"
31
    # set arch for Korinf compatibility
32
    [ "$SYSTEMARCH" = "x86_64" ] && archprefix="x86_64/"
33
    local URL="$EPM_KORINF_REPO_URL/$archprefix$DISTRNAME/$DISTRVERSION"
34
    if ! eget --check "$URL" ; then
35
        tURL="$EPM_KORINF_REPO_URL/$archprefix$BASEDISTRNAME/$DISTRREPONAME"
36
        docmd eget --check "$tURL" && URL="$tURL"
37
    fi
38
    eget --list --latest "$URL/$MASK*.$PKGFORMAT"
39
}
40

41
__epm_korinf_list() {
42
    local MASK="$1"
43
    MASK="$(__epm_korinf_site_mask "$MASK")"
44
    showcmd eget --list "$MASK"
45
    eget --list "$MASK" | sort
46
}
47

48

49
__epm_korinf_install() {
50

51
    local pkg pkgurl
52
    local pkg_urls=''
53
    for pkgurl in $* ; do
54
        pkg="$(__epm_korinf_site_mask "$pkgurl")"
55
        [ -n "$pkg" ] || fatal "Can't get package url from $pkgurl"
56
        [ -n "$pkg_urls" ] && pkg_urls="$pkg_urls $pkg" || pkg_urls="$pkg"
57
    done
58
    # due Error: Can't use epm call from the piped script
59
    #epm install $(__epm_korinf_site_mask "$PACKAGE")
60
    pkg_names='' pkg_files='' epm_install
61
}
62

63
__epm_korinf_install_eepm()
64
{
65

66
    if [ "$BASEDISTRNAME" = "alt" ] && [ "$DISTRVERSION" != "Sisyphus" ] && [ "$EPMMODE" = "package" ] ; then
67
        if epm status --original eepm ; then
68
            warning "Using external (Korinf) repo is forbidden for stable ALT branch $DISTRVERSION."
69
            info "Check https://bugzilla.altlinux.org/44314 for reasons."
70
            info "You can install eepm package from Korinf manually, check instruction at https://eepm.ru"
71
            info ""
72
            info "Trying update eepm from the stable ALT repository ..."
73
            docmd epm install eepm
74
            return
75
        fi
76
    fi
77

78
    # enable interactive for install eepm from console
79
    if inputisatty && [ "$EPMMODE" != "pipe" ] ; then
80
        [ -n "$non_interactive" ] || interactive="--interactive"
81
    else
82
        [ -n "$interactive" ] || non_interactive="--auto"
83
    fi
84

85
    # as now, can't install one package from task (and old apt-repo can't install one package)
86
    if false && [ "$BASEDISTRNAME" = "alt" ] && [ -z "$direct" ] ; then
87
        local task="$(docmd eget -O- https://eepm.ru/vendor/alt/task)"
88
        if [ -n "$task" ] ; then
89
            docmd epm install $task
90
            return
91
        else
92
            info "Can't get actual task for ALT, fallback to Korinf"
93
        fi
94
    fi
95

96
    pkg_list="eepm"
97
    # TODO: reenable eepm-repack build
98
    # don't lose epm-repack if installed
99
    # is_installed epm-repack && pkg_list="$pkg_list eepm-repack"
100

101
    # enable scripts to resolve dependencies with apt
102
    scripts='--scripts' __epm_korinf_install $pkg_list
103
}
104

105
epm_epm_install_help()
106
{
107
    echo "epm ei [URL] [packages] - install packages from EPM based Korinf repository"
108
            get_help HELPCMD $SHAREDIR/epm-epm_install
109
    cat <<EOF
110

111
Default Korinf repository: $EPM_KORINF_REPO_URL
112

113
Examples:
114
  epm ei [epm|eepm]                 - install latest eepm (default action)
115
  epm ei <package1> [<package2>...] - install package(s) from default Korinf repo
116
  epm http://someurl.ru <package>   - install package(s) from a repo defined by URL
117
  epm --list <package mask>         - list available packages by mask
118
EOF
119
}
120

121

122
epm_epm_install()
123
{
124
    if is_url "$1" ; then
125
        EPM_KORINF_REPO_URL="$1"
126
        info "Using $EPM_KORINF_REPO_URL repo ..."
127
        shift
128
    fi
129

130
    case "$1" in
131
        ""|epm|eepm)
132
            # install epm by default
133
            __epm_korinf_install_eepm
134
            return
135
            ;;
136
        -h|--help)                     # HELPCMD: help
137
            epm_epm_install_help
138
            return
139
            ;;
140
        --list)                        # HELPCMD: list only packages
141
            shift
142
            __epm_korinf_list "$1"
143
            return
144
            ;;
145
    esac
146

147
    __epm_korinf_install "$@"
148
}
149

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

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

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

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