From 31d41b20b4085fd91078f3c95d34e9ee17e003bb Mon Sep 17 00:00:00 2001 From: Vitaly Lipatov <lav@etersoft.ru> Date: Fri, 21 Apr 2023 03:01:19 +0300 Subject: [PATCH] epm print: fix: check if file is real package --- bin/epm-print | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/epm-print b/bin/epm-print index 4d1d0067..a5e1940f 100644 --- a/bin/epm-print +++ b/bin/epm-print @@ -17,6 +17,14 @@ # 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 # TODO: rpm only @@ -25,8 +33,8 @@ rpm_query_package_format_field() local FORMAT="$1\n" shift local INSTALLED="" - # if a file, ad -p for get from rpm base - if [ -f "$1" ] ; then + # if a file, add -p for get from rpm base + if is_pkgfile "$1" ; then INSTALLED="-p" fi a= rpmquery $INSTALLED --queryformat "$FORMAT" "$@" @@ -43,7 +51,7 @@ dpkg_query_package_format_field() { local field="$1" shift - if [ -f "$1" ] ; then + if is_pkgfile "$1" ; then a= dpkg-deb --show --showformat="$field\n" "$@" else #a= dpkg -s "$1" | grep "^$field: " | sed -e "s|^$field: ||" -- 2.24.1