epm-search_file 1.95 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 32 33 34 35 36 37 38 39 40 41 42
# 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
    local OUTCMD="less"
    [ -n "$USETTY" ] || OUTCMD="cat"

    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
}

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

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

docmd $CMD $pkg_filenames

}