epm-conflicts 2.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/bin/sh
#
# Copyright (C) 2013  Etersoft
# Copyright (C) 2013  Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

load_helper epm-query

epm_conflicts_files()
{
24
    [ -n "$pkg_files" ] || return
25

26 27 28 29 30 31 32 33 34 35 36 37
    case $(get_package_type $pkg_files) in
        rpm)
            assure_exists rpm
            docmd rpm -q --conflicts -p $pkg_files
            ;;
        #deb)
        #    a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
        #    ;;
        *)
            fatal "Have no suitable command for $PMTYPE"
            ;;
    esac
38 39 40 41
}

epm_conflicts_names()
{
42 43
    local CMD
    [ -n "$pkg_names" ] || return
44 45 46

# by package name
case $PMTYPE in
47 48 49 50 51 52 53 54 55 56
    apt-rpm)
        # FIXME: need fix for a few names case
        # FIXME: too low level of requires name (libSOME.so)
        if is_installed $pkg_names ; then
            CMD="rpm -q --conflicts"
        else
            EXTRA_SHOWDOCMD=' | grep "Conflicts:"'
            docmd apt-cache show $pkg_names | grep "Conflicts:"
            return
        fi
57

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
        ;;
    urpm-rpm|zypper-rpm)
        # FIXME: use hi level commands
        CMD="rpm -q --conflicts"
        ;;
    #yum-rpm)
    #    CMD="yum deplist"
    #    ;;
    #pacman)
    #    CMD="pactree"
    #    ;;
    apt-dpkg)
        # FIXME: need fix for a few names case
        if is_installed $pkg_names ; then
            showcmd dpkg -s $pkg_names
            a='' dpkg -s $pkg_names | grep "^Conflicts:" | sed "s|^Conflicts:||g"
            return
        else
            EXTRA_SHOWDOCMD=' | grep "Conflicts:"'
            docmd apt-cache show $pkg_names | grep "Conflicts:"
            return
        fi
        ;;
    # TODO: why-not show who conflicts with us
    #aptitude-dpkg)
    #    docmd aptitude why-not $pkg_names
    #    ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
85

86 87 88 89 90 91 92
    #emerge)
    #    assure_exists equery
    #    CMD="equery depgraph"
    #    ;;
    *)
        fatal "Have no suitable command for $PMTYPE"
        ;;
93 94 95 96 97 98 99 100 101
esac


docmd $CMD $pkg_names

}

epm_conflicts()
{
102 103 104
    [ -n "$pkg_filenames" ] || fatal "Conflicts: Missing package(s) name"
    epm_conflicts_files
    epm_conflicts_names
105
}