Commit 31d41b20 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm print: fix: check if file is real package

parent 5b621591
...@@ -17,6 +17,14 @@ ...@@ -17,6 +17,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# TODO: improve file
is_pkgfile()
{
[ -f "$1" ] || return
echo "$1" | grep -q "\.rpm$" && return
echo "$1" | grep -q "\.deb$" && return
return 1
}
# Query variables from rpm package # Query variables from rpm package
# TODO: rpm only # TODO: rpm only
...@@ -25,8 +33,8 @@ rpm_query_package_format_field() ...@@ -25,8 +33,8 @@ rpm_query_package_format_field()
local FORMAT="$1\n" local FORMAT="$1\n"
shift shift
local INSTALLED="" local INSTALLED=""
# if a file, ad -p for get from rpm base # if a file, add -p for get from rpm base
if [ -f "$1" ] ; then if is_pkgfile "$1" ; then
INSTALLED="-p" INSTALLED="-p"
fi fi
a= rpmquery $INSTALLED --queryformat "$FORMAT" "$@" a= rpmquery $INSTALLED --queryformat "$FORMAT" "$@"
...@@ -43,7 +51,7 @@ dpkg_query_package_format_field() ...@@ -43,7 +51,7 @@ dpkg_query_package_format_field()
{ {
local field="$1" local field="$1"
shift shift
if [ -f "$1" ] ; then if is_pkgfile "$1" ; then
a= dpkg-deb --show --showformat="$field\n" "$@" a= dpkg-deb --show --showformat="$field\n" "$@"
else else
#a= dpkg -s "$1" | grep "^$field: " | sed -e "s|^$field: ||" #a= dpkg -s "$1" | grep "^$field: " | sed -e "s|^$field: ||"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment