epm-search_file 1.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#!/bin/sh
#
# Copyright (C) 2012  Etersoft
# Copyright (C) 2012  Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#

21
# TODO: port or rewrite apt-file
22 23 24 25 26 27 28 29 30 31
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
local_content_search()
{
    local SYSARCH
    SYSARCH=$(uname -m)
    [ "$SYSARCH" = "x86_64" ] || SYSARCH=i586

    local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
    local CI=$REPODIR/$SYSARCH/base/contents_index
    local CINOA=$REPODIR/noarch/base/contents_index
32 33 34
    #local OUTCMD="less"
    #[ -n "$USETTY" ] || OUTCMD="cat"
    OUTCMD="cat"
35 36 37 38 39 40 41 42 43

    test -r $CI && test -r $CINOA || fatal "Can't locate $CI or $CINOA"

    {
        [ -n "$USETTY" ] && echo "Search in $CI and $CINOA for $1..."
        grep -h ".*$1.*\t" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
    } | $OUTCMD
}

44 45 46 47 48
epm_search_file()
{
    [ -n "$pkg_filenames" ] || fatal "Run search without names"

case $PMTYPE in
49 50 51 52
	apt-rpm)
		local_content_search $pkg_filenames
		return ;;
	apt-dpkg)
53
		sudocmd apt-file update
54 55 56
		docmd apt-file search $pkg_filenames
		return ;;
	yum-rpm)
57
		CMD="yum provides"
58 59 60 61
		;;
	urpm-rpm)
		CMD="urpmf"
		;;
62
	zypper-rpm)
63 64
		CMD="zypper wp vi"
		;;
65 66 67
	pacman)
		CMD="pacman -Qo"
		;;
68
	slackpkg)
69
		CMD="/usr/sbin/slackpkg file-search"
70
		;;
71 72 73 74 75 76 77 78
	*)
		fatal "Do not known search file command for $PMTYPE"
		;;
esac

docmd $CMD $pkg_filenames

}