#!/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 load_helper epm-print epm_provides_files() { local pkg_files="$*" [ -n "$pkg_files" ] || return local PKGTYPE="$(get_package_type $pkg_files)" case $PKGTYPE in rpm) assure_exists rpm docmd rpm -q --provides -p $pkg_files ;; deb) assure_exists dpkg # FIXME: will we provide ourself? docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g" ;; *) fatal "Have no suitable command for $PMTYPE" ;; esac } epm_provides_names() { local pkg_names="$*" local CMD [ -n "$pkg_names" ] || return # by package name case $PMTYPE in apt-rpm) # FIXME: need fix for a few names case # TODO: separate this function to two section if is_installed $pkg_names ; then CMD="rpm -q --provides" else EXTRA_SHOWDOCMD=' | grep "Provides:"' docmd apt-cache show $pkg_names | grep "Provides:" return fi ;; urpm-rpm|zypper-rpm|yum-rpm|dnf-rpm) if is_installed $pkg_names ; then CMD="rpm -q --provides" else fatal "FIXME: use hi level commands" fi ;; emerge) assure_exists equery CMD="equery files" ;; # yum-rpm) # CMD="yum deplist" # ;; pkgng) CMD="pkg info -b" ;; apt-dpkg) # FIXME: need fix for a few names case if is_installed $pkg_names ; then info "Please inform the author how to get provides from dpkg" fi # CMD="rpm -q --provides" #else EXTRA_SHOWDOCMD=' | grep "Provides:"' docmd apt-cache show $pkg_names | grep "Provides:" return #fi ;; *) fatal "Have no suitable command for $PMTYPE" ;; esac docmd $CMD $pkg_names } epm_provides() { [ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name" epm_provides_files $pkg_files # shellcheck disable=SC2046 epm_provides_names $(print_name $pkg_names) }