NBash

Форк
0
154 строки · 4.3 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2013  Etersoft
4
# Copyright (C) 2013  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-query
21
load_helper epm-print
22

23
epm_provides_files()
24
{
25
    local pkg_files="$*"
26
    [ -n "$pkg_files" ] || return
27

28
    local PKGTYPE="$(get_package_type $pkg_files)"
29

30
    case $PKGTYPE in
31
        rpm)
32
            assure_exists rpm
33
            if [ -n "$short" ] ; then
34
                docmd rpm -q --provides -p $pkg_files | sed -e 's| .*||'
35
            else
36
                docmd rpm -q --provides -p $pkg_files
37
            fi
38
            ;;
39
        deb)
40
            assure_exists dpkg
41
            # FIXME: will we provide ourself?
42
            docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g"
43
            ;;
44
        *)
45
            fatal "Have no suitable command for $PMTYPE"
46
            ;;
47
    esac
48
}
49

50

51
epm_provides_names()
52
{
53
    local pkg_names="$*"
54
    local CMD
55
    [ -n "$pkg_names" ] || return
56

57
# by package name
58
case $PMTYPE in
59
    apt-rpm)
60
        # FIXME: need fix for a few names case
61
        # TODO: separate this function to two section
62
        if is_installed $pkg_names ; then
63
            CMD="rpm -q --provides"
64
        else
65
            EXTRA_SHOWDOCMD=' | grep "Provides:"'
66
            if [ -n "$short" ] ; then
67
                docmd apt-cache show $pkg_names | grep "Provides:" | sed -e 's|, |\n|g' -e 's|Provides: ||' -e 's| .*||'
68
            else
69
                docmd apt-cache show $pkg_names | grep "Provides:" | sed -e 's|, |\n|g' -e 's|Provides: ||'
70
            fi
71
            return
72
        fi
73
        ;;
74
    urpm-rpm)
75
        if is_installed $pkg_names ; then
76
            CMD="rpm -q --provides"
77
        else
78
            CMD="urpmq --provides"
79
        fi
80
        ;;
81
    zypper-rpm)
82
        if is_installed $pkg_names ; then
83
            CMD="rpm -q --provides"
84
        else
85
            fatal "FIXME: use hi level commands or download firstly"
86
        fi
87
        ;;
88
    yum-rpm)
89
        if is_installed $pkg_names ; then
90
            CMD="rpm -q --provides"
91
        else
92
            fatal "FIXME: use hi level commands or download firstly"
93
        fi
94
        ;;
95
    dnf-rpm)
96
        if is_installed $pkg_names ; then
97
            CMD="rpm -q --provides"
98
        else
99
            CMD="dnf repoquery --provides"
100
        fi
101
        ;;
102
    emerge)
103
        assure_exists equery
104
        CMD="equery files"
105
        ;;
106
#    yum-rpm)
107
#        CMD="yum deplist"
108
#        ;;
109
    pkgng)
110
        CMD="pkg info -b"
111
        ;;
112
    apt-dpkg)
113
        # FIXME: need fix for a few names case
114
        if is_installed $pkg_names ; then
115
            showcmd dpkg -s $pkg_names
116
            a='' dpkg -s $pkg_names | grep "^Provides:" | sed "s|^Provides:||g"
117
            return
118
        else
119
            EXTRA_SHOWDOCMD=' | grep "Provides:"'
120
            docmd apt-cache show $pkg_names | grep "Provides:" | sed -e 's|, |\n|g' | grep -v "^Provides:"
121
            return
122
        fi
123
        ;;
124
    *)
125
        fatal "Have no suitable command for $PMTYPE"
126
        ;;
127
esac
128

129
if [ -n "$direct" ] && [ "$CMD" = "rpm -q --provides" ] ; then
130
    # do universal provides
131
    docmd $CMD $pkg_names | sed -e 's| .*||' | grep -F "()"
132
    a= $CMD $pkg_names | sed -e 's| .*||' | grep -v -E "^(lib|ld-linux)"
133
elif [ -n "$short" ] ; then
134
    docmd $CMD $pkg_names | sed -e 's| .*||'
135
else
136
    docmd $CMD $pkg_names
137
fi
138

139
}
140

141
epm_provides()
142
{
143
    # if possible, it will put pkg_urls into pkg_files or pkg_names
144
    if [ -n "$pkg_urls" ] ; then
145
        load_helper epm-download
146
        __handle_pkg_urls_to_checking
147
    fi
148

149
    [ -n "$pkg_filenames" ] || fatal "Provides: package name is missed"
150

151
    epm_provides_files $pkg_files
152
    # shellcheck disable=SC2046
153
    epm_provides_names $(print_name $pkg_names)
154
}
155

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

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

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

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