NBash

Форк
0
120 строк · 3.1 Кб
1
#!/bin/sh
2
#
3
# Copyright (C) 2012, 2016, 2017, 2019  Etersoft
4
# Copyright (C) 2012, 2016, 2017, 2019  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
# TODO: see epm-search (colorify for all distro)
21

22
# args: index_lists word grep_string
23
__alt_search_file_output()
24
{
25
    # grep only on left part (filename), then revert order and grep with color
26
    ercat $quiet $1 | grep -h -- ".*$2.*[[:space:]]" | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g" $3
27
}
28

29
__alt_local_content_search()
30
{
31
    load_helper epm-sh-altlinux
32
    load_helper epm-sh-altlinux-contents-index
33
    load_helper epm-search
34

35
    check_alt_contents_index || init_alt_contents_index
36
    update_repo_if_needed
37

38
    if [ ! -s "$ALT_CONTENTS_INDEX_LIST" ] ; then
39
        fatal "Have no local contents index. Check epm repo --help."
40
    fi
41

42
    local CI="$(cat $ALT_CONTENTS_INDEX_LIST)"
43

44
    info "Searching for $1 ... "
45

46
    # FIXME: do it better
47
    local MGS
48
    MGS=$(eval __epm_search_make_grep $quoted_args)
49
    showcmd "$ cat contents_index $MGS"
50
    eval "__alt_search_file_output \"$CI\" \"$(eval get_firstarg $quoted_args)\" $MGS"
51
}
52

53
epm_search_file()
54
{
55
    local CMD
56
    [ -n "$pkg_filenames" ] || fatal "Search file: file name is missed"
57

58
case $BASEDISTRNAME in
59
    "alt")
60
        __alt_local_content_search $pkg_filenames
61
        return ;;
62
esac
63

64
case $PMTYPE in
65
    apt-dpkg|aptitude-dpkg)
66
        if ! is_command apt-file ; then
67
            assure_exists apt-file
68
            sudocmd apt-file update
69
        else
70
            load_helper epm-check_updated_repo
71
            update_repo_if_needed
72
        fi
73
        docmd apt-file search $pkg_filenames
74
        return ;;
75
    packagekit)
76
        CMD="pkcon search file"
77
        ;;
78
    yum-rpm)
79
        # TODO
80
        info "Search by full packages list is not implemented yet"
81
        CMD="yum provides"
82
        ;;
83
    dnf-rpm)
84
        # TODO
85
        info "Search by full packages list is not implemented yet"
86
        CMD="dnf provides"
87
        ;;
88
    urpm-rpm)
89
        CMD="urpmf"
90
        ;;
91
    zypper-rpm)
92
        CMD="zypper search --file-list"
93
        ;;
94
    pacman)
95
        CMD="pacman -Qo"
96
        ;;
97
    slackpkg)
98
        CMD="/usr/sbin/slackpkg file-search"
99
        ;;
100
    opkg)
101
        CMD="opkg -A search"
102
        ;;
103
    eopkg)
104
        CMD="eopkg search-file"
105
        ;;
106
    xbps)
107
        CMD="xbps-query -Ro"
108
        ;;
109
    aptcyg)
110
        docmd apt-cyg searchall $(echo " $pkg_filenames" | sed -e "s| /| |g")
111
        return
112
        ;;
113
    *)
114
        fatal "Have no suitable search file command for $PMTYPE"
115
        ;;
116
esac
117

118
docmd $CMD $pkg_filenames
119

120
}
121

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

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

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

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