NBash

Форк
0
130 строк · 3.2 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2023  Etersoft
4
# Copyright (C) 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
load_helper epm-sh-altlinux
21

22
# copied from epm-addrepo
23
get_archlist()
24
{
25
    echo "noarch"
26
    echo "$DISTRARCH"
27
    case $DISTRARCH in
28
        x86_64)
29
            echo "i586"
30
            ;;
31
    esac
32
}
33

34
# https://www.altlinux.org/APT_%D0%B2_ALT_Linux/CreateRepository
35
__epm_repoindex_alt()
36
{
37
    local archlist="i586 x86_64 x86_64-i586 aarch64 noarch"
38

39
    local init=''
40
    if [ "$1" = "--init" ] ; then
41
        init='--init'
42
        shift
43
    fi
44

45
    epm assure genbasedir apt-repo-tools || fatal
46
    REPO_DIR="$1"
47
    # TODO: check if we inside arch dir or RPMS.*
48
    [ -n "$REPO_DIR" ] || REPO_DIR="$(pwd)"
49
    if [ -z "$init" ] ; then
50
        [ -d "$REPO_DIR" ] || fatal "Repo dir $REPO_DIR does not exist"
51
    fi
52

53
    REPO_NAME="$2"
54
    if [ -z "$REPO_NAME" ] ; then
55
        # default name
56
        REPO_NAME="addon"
57
        # detect name if already exists
58
        for arch in $archlist ; do
59
            local rd="$(echo $REPO_DIR/$arch/RPMS.*)"
60
            [ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break
61
        done
62
    fi
63

64
    if [ -n "$init" ] ; then
65
        for arch in $(get_archlist); do
66
            mkdir -pv "$REPO_DIR/$arch/base/"
67
            mkdir -pv "$REPO_DIR/$arch/RPMS.$REPO_NAME/"
68
        done
69
        return
70
    fi
71

72
    for arch in $archlist; do
73
        [ -d "$REPO_DIR/$arch/RPMS.$REPO_NAME" ] || continue
74
        mkdir -pv "$REPO_DIR/$arch/base/"
75
        docmd genbasedir --bloat --progress --topdir=$REPO_DIR $arch $REPO_NAME
76
    done
77
}
78

79
__epm_repoindex_deb()
80
{
81
    local init=''
82
    if [ "$1" = "--init" ] ; then
83
        init='--init'
84
        shift
85
    fi
86

87
    local dir="$1"
88
    docmd mkdir -pv "$dir" || fatal
89
    assure_exists gzip
90
    docmd dpkg-scanpackages -t deb "$dir" | gzip | cat > "$dir/Packages.gz"
91
}
92

93

94
epm_repoindex()
95
{
96

97
case $PMTYPE in
98
    apt-rpm)
99
        __epm_repoindex_alt "$@"
100
        ;;
101
    apt-dpkg|aptitude-dpkg)
102
        __epm_repoindex_deb "$@"
103
        ;;
104
    yum-rpm)
105
        epm install --skip-installed yum-utils createrepo || fatal
106
        docmd mkdir -pv "$@"
107
        docmd createrepo -v -s md5 "$@"
108
        docmd verifytree
109
        ;;
110
    dnf-rpm)
111
        epm install --skip-installed yum-utils createrepo || fatal
112
        docmd mkdir -pv "$@"
113
        docmd createrepo -v -s md5 "$@"
114
        docmd verifytree
115
        ;;
116
    eoget)
117
        docmd eoget index "$@"
118
        ;;
119
    *)
120
        fatal "Have no suitable command for $PMTYPE"
121
        ;;
122
esac
123

124
}
125

126

127
epm_repocreate()
128
{
129
    epm_repoindex --init "$@"
130
}
131

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

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

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

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