NBash

Форк
0
149 строк · 5.2 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2012-2020  Etersoft
4
# Copyright (C) 2012-2020  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
load_helper epm-query
22

23
__fast_hack_for_filter_out_installed_rpm()
24
{
25
    LC_ALL=C xargs -n1 rpm -q 2>&1 | grep 'is not installed' |
26
        sed -e 's|^.*package \(.*\) is not installed.*|\1|g'
27
}
28

29
# pass only uninstalled packages
30
filter_out_installed_packages()
31
{
32
    [ -z "$skip_installed" ] && cat && return
33

34
    case $PMTYPE in
35
        yum-rpm|dnf-rpm)
36
            if [ "$DISTRARCH" = "x86_64" ] && [ "$DISTRNAME" != "ROSA" ] ; then
37
                # shellcheck disable=SC2013
38
                for i in $(cat) ; do
39
                    is_installed "$(__print_with_arch_suffix $i .x86_64)" && continue
40
                    is_installed "$(__print_with_arch_suffix $i .noarch)" && continue
41
                    echo $i
42
                done
43
            else
44
                __fast_hack_for_filter_out_installed_rpm
45
            fi
46
            ;;
47
        *-rpm)
48
            __fast_hack_for_filter_out_installed_rpm
49
            ;;
50
        # dpkg -l lists some non ii status (un, etc)
51
        #"deb")
52
        #    LANG=C LC_ALL=C xargs -n1 dpkg -l 2>&1 | grep -i 'no packages found matching' |
53
        #        sed -e 's|\.\+$||g' -e 's|^.*[Nn]o packages found matching \(.*\)|\1|g'
54
        #    ;;
55
        *)
56
            # shellcheck disable=SC2013
57
            for i in $(cat) ; do
58
                is_installed $i || echo $i
59
            done
60
            ;;
61
    esac | sed -e "s|rpm-build-altlinux-compat[^ ]*||g" | filter_strip_spaces
62
}
63

64
get_only_installed_packages()
65
{
66
    local installlist="$*"
67
    estrlist exclude "$(echo "$installlist" | (skip_installed='yes' filter_out_installed_packages))" "$installlist"
68
}
69

70

71
__epm_print_warning_for_nonalt_packages()
72
{
73
    [ -n "$dryrun" ] && return 0
74
    # only ALT
75
    [ "$BASEDISTRNAME" = "alt" ] || return 0
76

77
    # download only
78
    [ -n "$save_only$download_only" ] && return 0
79

80
    load_helper epm-status
81

82
    local i
83
    for i in $* ; do
84
        if epm_status_repacked "$i" ; then
85
            warning "%%% You are trying install package $i repacked from third-party software source. Use it at your own risk. %%%"
86
            continue
87
        fi
88

89
        if epm_status_thirdparty "$i" ; then
90
            warning "%%% You are trying install package $i from third-party software source. Use it at your own risk. %%%"
91
            continue
92
        fi
93

94
        if ! epm_status_original "$i" ; then
95
            warning "%%% You are trying install package $i not from official $DISTRNAME/$DISTRVERSION repository. Use it at your own risk. %%%"
96
            continue
97
        fi
98
    done
99
}
100

101
# Args: package names. Set noscripts for outside packages.
102
__epm_check_vendor()
103
{
104
    # don't check vendor if there are forced script options
105
    [ -n "$scripts$noscripts" ] && return
106
    [ -n "$dryrun" ] && return 0
107

108
    # only ALT
109
    [ "$BASEDISTRNAME" = "alt" ] || return 0
110

111
    load_helper epm-status
112

113
    local i
114
    for i in $* ; do
115
        bi="$(basename $i)"
116
        if ! epm_status_validate "$i" ; then
117
            # it is missed package probably (package remove case)
118
            if is_installed "$i" ; then
119
                warning "Can't get any info for $i package. Scripts are DISABLED for package $bi. Use --scripts if you need run scripts from such packages."
120
            fi
121
            noscripts="--noscripts"
122
            continue
123
        fi
124

125
        local vendor
126
        vendor="$(epm print field Vendor for "$i")"
127

128
        if [ -z "$vendor" ] ; then
129
            warning "Can't get info about vendor for $i package. Scripts are DISABLED for package $bi. Use --scripts if you need run scripts from such packages."
130
            noscripts="--noscripts"
131
            continue
132
        fi
133

134
        epm_status_original "$i" && continue
135
        epm_status_repacked "$i" && continue
136

137
        if __epm_vendor_ok_scripts "$vendor" ; then
138
            warning "Scripts are ENABLED for package $bi from outside vendor '$vendor' (this vendor is listed in $CONFIGDIR/vendorallowscripts.list).  Use --noscripts if you need disable scripts in such packages."
139
            continue
140
        fi
141

142
        if __epm_package_ok_scripts "$i" ; then
143
            warning "Scripts are ENABLED for package $bi from outside vendor '$vendor' (the package is listed in $CONFIGDIR/pkgallowscripts.list).  Use --noscripts if you need disable scripts in such packages."
144
            continue
145
        fi
146
        warning "Scripts are DISABLED for package $bi from outside vendor '$vendor'. Use --scripts if you need run scripts from such packages."
147
        noscripts="--noscripts"
148
    done
149
}
150

151

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

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

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

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