NBash

Форк
0
148 строк · 3.3 Кб
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
__epm_repo_pkgadd_alt()
23
{
24
    local archlist="i586 x86_64 aarch64 noarch"
25

26
    local REPO_DIR="$1"
27
    shift
28
    [ -d "$REPO_DIR" ] || fatal "Can't find repo dir $REPO_DIR."
29

30
    # default name
31
    REPO_NAME="addon"
32
    # detect if already exists
33
    for arch in $archlist ; do
34
        local rd="$(echo $REPO_DIR/$arch/RPMS.*)"
35
        [ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break
36
    done
37

38
    [ -n "$1" ] || fatal "Missed package name"
39

40
    while [ -s "$1" ] ; do
41
        arch="$(epm print arch from filename "$1")" || fatal
42
        # arch hack (it is better to repack firstly)
43
        [ "$arch" = "i686" ] && arch="i586"
44
        [ "$arch" = "i386" ] && arch="i586"
45
        [ -d $REPO_DIR/$arch/RPMS.$REPO_NAME ] || fatal
46
        epm checkpkg "$1" || fatal
47
        cp -v "$1" $REPO_DIR/$arch/RPMS.$REPO_NAME || fatal
48
        shift
49
    done
50

51
}
52

53

54
__epm_repo_pkgdel_alt()
55
{
56
    local archlist="i586 x86_64 aarch64 noarch"
57

58
    local REPO_DIR="$1"
59
    shift
60
    [ -d "$REPO_DIR" ] || fatal "Can't find repo dir $REPO_DIR."
61

62
    [ -n "$1" ] || fatal "Missed package name"
63

64
    # default name
65
    REPO_NAME="addon"
66
    # detect if already exists
67
    for arch in $archlist ; do
68
        local rd="$(echo $REPO_DIR/$arch/RPMS.*)"
69
        [ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break
70
    done
71

72
    while [ -s "$1" ] ; do
73
        for arch in $archlist ; do
74
            local rd="$REPO_DIR/$arch/RPMS.$REPO_NAME"
75
            [ -d $REPO_DIR/$arch/RPMS.$REPO_NAME ] || continue
76
            for i in $rd/$1* ; do
77
                [ "$1" = "$(epm print name for package $i)" || continue
78
                rm -v $rd/$1*
79
            done
80
        done
81
        shift
82
    done
83

84
}
85

86

87
__epm_repo_pkgupdate_alt()
88
{
89
    local dir="$1"
90
    shift
91
    for i in "$@" ; do
92
        pkg="$(epm print name for package $i)" || fatal
93
        __epm_repo_pkgdel_alt "$dir" $pkg
94
    done
95
    __epm_repo_pkgadd_alt "$dir" "$@"
96
}
97

98

99

100
epm_repo_pkgadd()
101
{
102

103
case $PMTYPE in
104
    apt-rpm)
105
        __epm_repo_pkgadd_alt "$@"
106
        ;;
107
    *)
108
        fatal "Have no suitable command for $PMTYPE"
109
        ;;
110
esac
111

112
}
113

114

115
epm_repo_pkgupdate()
116
{
117

118
case $PMTYPE in
119
    apt-rpm)
120
        __epm_repo_pkgupdate_alt "$@"
121
        ;;
122
    *)
123
        fatal "Have no suitable command for $PMTYPE"
124
        ;;
125
esac
126

127
}
128

129

130
epm_repo_pkgdel()
131
{
132

133
case $PMTYPE in
134
    apt-rpm)
135
        __epm_repo_pkgdel_alt "$@"
136
        ;;
137
    *)
138
        fatal "Have no suitable command for $PMTYPE"
139
        ;;
140
esac
141

142
}
143

144
# call with packages to put to $put_to_repo
145
epm_put_to_repo()
146
{
147
    epm_repo_pkgupdate "$put_to_repo" "$@"
148
}
149

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

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

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

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