Commit 49b8e6e1 authored by Vitaly Lipatov's avatar Vitaly Lipatov

implement epm status [--installed|--original|--thirdpart|--repacked]

parent 1ca0b7fd
......@@ -240,6 +240,9 @@ check_command()
installed) # HELPCMD: check presence of package(s) (like -q with --quiet)
epm_cmd=installed
;;
status) # HELPCMD: get status of package(s) (see epm status --help)
epm_cmd=status
;;
-sf|sf|filesearch|search-file) # HELPCMD: search in which package a file is included
epm_cmd=search_file
;;
......
......@@ -776,11 +776,12 @@ __epm_check_if_package_from_repo()
#vendor="$(epm print field Vendor for "$pkg" 2>/dev/null))"
#[ "$vendor" = "ALT Linux Team" ] || return
local distribution="$(epm print field Distribution for "$pkg" 2>/dev/null))"
local distribution
distribution="$(epm print field Distribution for "$pkg" 2>/dev/null )"
echo "$distribution" | grep -q "^ALT" || return
# FIXME: how to check if the package is from ALT repo (verified)?
local release="$(epm print release from package "$pkg" 2>/dev/null)"
local release="$(epm print release from package "$pkg" 2>/dev/null )"
echo "$release" | grep -q "^alt" || return
return 0
......
#!/bin/sh
#
# Copyright (C) 2023 Etersoft
# Copyright (C) 2023 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_status_original()
{
local pkg="$1"
#is_installed $pkg || fatal "FIXME: implemented for installed packages as for now"
case $DISTRNAME in
ALTLinux|ALTServer)
#[ "$(epm print field Vendor for package $pkg)" = "ALT Linux Team" ] && return
epm_status_repacked $pkg && return 1
__epm_check_if_package_from_repo $pkg && return
;;
*)
fatal "Unsupported $DISTRNAME"
;;
esac
return 1
}
epm_status_repacked()
{
local pkg="$1"
#is_installed $pkg || fatal "FIXME: implemented for installed packages as for now"
case $BASEDISTRNAME in
alt)
local packager="$(epm print field Packager for "$1" 2>/dev/null)"
[ "$packager" = "EPM <support@etersoft.ru>" ] && return 0
[ "$packager" = "EPM <support@eepm.ru>" ] && return 0
;;
*)
fatal "Unsupported $DISTRNAME"
;;
esac
return 1
}
epm_status_thirdpart()
{
local pkg="$1"
#is_installed $pkg || fatal "FIXME: implemented for installed packages as for now"
case $BASEDISTRNAME in
alt)
## FIXME: some repo packages have wrong Packager
#local packager="$(epm print field Packager for "$1" 2>/dev/null)"
#echo "$packager" && grep -q "altlinux" && return 0
#echo "$packager" && grep -q "basealt" && return 0
local distribution
distribution="$(epm print field Distribution for "$pkg" 2>/dev/null )"
echo "$distribution" | grep -q "^ALT" || return 0
;;
*)
fatal "Unsupported $DISTRNAME"
;;
esac
return 1
}
epm_status_help()
{
cat <<EOF
epm status - check status of the package and return result via exit code
Usage: epm status [options] <package>
Options:
--installed check if <package> is installed
--original check if <package> is from distro repo
--thirdpart check if <package> from a third part source (didn't packed for this distro)
--repacked check if <package> was repacked with epm repack
EOF
}
epm_status()
{
local option="$1"
if [ -z "$1" ] ; then
epm_status_help >&2
exit 1
fi
shift
# TODO: allow both option
case "$option" in
-h|--help)
epm_status_help
return
;;
--installed)
is_installed "$@"
return
;;
--original)
epm_status_original "$@"
return
;;
--thirdpart)
epm_status_thirdpart "$@"
return
;;
--repacked)
epm_status_repacked "$@"
return
;;
*)
fatal "Unknown option $option, use epm status --help to get info"
;;
esac
epm_status_help >&2
fatal "Run with appropriate option"
}
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