NBash

Форк
0
143 строки · 3.5 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2009, 2012, 2013, 2014, 2016, 2018, 2022  Etersoft
4
# Copyright (C) 2009, 2012, 2013, 2014, 2016, 2018, 2022  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
# changed since rpm 4.0.4
21
__rpm_allows_nosignature()
22
{
23
    a= rpm --help | grep -q -- "--nosignature"
24
}
25

26
check_pkg_integrity()
27
{
28
    local PKG="$1"
29
    local RET
30
    local NOSIGNATURE
31

32
    case $(get_package_type $PKG) in
33
    rpm)
34
        assure_exists rpm
35
        __rpm_allows_nosignature && NOSIGNATURE="--nosignature" || NOSIGNATURE="--nogpg"
36
        docmd rpm --checksig $NOSIGNATURE $PKG
37
        ;;
38
    deb)
39
        assure_exists dpkg
40
        # FIXME: debsums -ca package ?
41
        docmd dpkg --contents $PKG >/dev/null && echo "Package $PKG is correct."
42
        ;;
43
    apk)
44
        docmd apkg verify $PKG
45
        ;;
46
    exe)
47
        file $PKG | grep -q "executable for MS Windows"
48
        ;;
49
    msi)
50
        # TODO: add to patool via cabextract
51
        assure_exists cabextract
52
        #file $PKG | grep -q "Microsoft Office Document"
53
        docmd cabextract -t $PKG
54
        ;;
55
    ebuild)
56
        true
57
        ;;
58
    *)
59
        docmd erc test "$PKG" && return
60
        ;;
61
    esac
62
}
63

64
__epm_check_all_pkgs()
65
{
66
case $PMTYPE in
67
    eopkg)
68
        sudocmd eopkg check
69
        return
70
        ;;
71
esac
72

73
    local j cl
74
    #local play_installed="$(epm play --list-installed-packages)"
75
    epm qa --short | xargs -n20 | while read cl ; do
76
        #cl="$(estrlist exclude "$play_installed" "$i")"
77
        __epm_check_installed_pkg $cl && continue
78
        # check each package
79
        for j in $cl ; do
80
            __epm_check_installed_pkg $j && continue
81
            # TODO: check play installed too
82
            epm --auto reinstall $j </dev/null || exit
83
        done
84
    done
85
}
86

87
__epm_check_installed_pkg()
88
{
89
case $PMTYPE in
90
    *-rpm)
91
        docmd rpm -V $@
92
        ;;
93
    *-dpkg)
94
        assure_exists debsums
95
        docmd debsums $@
96
        ;;
97
    emerge)
98
        assure_exists equery
99
        docmd equery check $@
100
        ;;
101
    eopkg)
102
        sudocmd eopkg check $@
103
        ;;
104
    *)
105
        fatal "Have no suitable command for $PMTYPE"
106
        ;;
107
esac
108

109
}
110

111

112
epm_checkpkg()
113
{
114
    if [ "$1" = "--all" ] ; then
115
        __epm_check_all_pkgs
116
        return
117
    fi
118

119
    if [ -n "$pkg_names" ] ; then
120
        # TODO: если есть / или расширение, это отсутствующий файл
121
        info "Suggest $pkg_names are name(s) of installed package(s)"
122
        __epm_check_installed_pkg $pkg_names
123
        return
124
    fi
125

126
    # if possible, it will put pkg_urls into pkg_files or pkg_names
127
    if [ -n "$pkg_urls" ] ; then
128
        load_helper epm-download
129
        __handle_pkg_urls_to_checking
130
    fi
131

132
    [ -n "$pkg_files" ] || fatal "Checkpkg: filename(s) is missed"
133

134
    local RETVAL=0
135

136
    local pkg
137
    for pkg in $pkg_files ; do
138
        check_pkg_integrity $pkg || RETVAL=1
139
    done
140

141
    #fatal "Broken package $pkg"
142
    return $RETVAL
143
}
144

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

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

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

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