Commit cf87f1a9 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-mark: big refactoring, add support for deb and dnf based systems

parent a57f6efb
#!/bin/sh
#
# Copyright (C) 2020, 2022 Etersoft
# Copyright (C) 2020, 2022 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2020, 2022, 2023 Etersoft
# Copyright (C) 2020, 2022, 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
......@@ -73,40 +73,219 @@ __alt_mark_showhold()
grep -h "RPM::Hold" /etc/apt/apt.conf.d/hold-*.conf 2>/dev/null | sed -e 's|RPM::Hold {"^\(.*\)";};|\1|'
}
epm_mark()
epm_mark_hold()
{
case $DISTRNAME in
ALTLinux|ALTServer)
__alt_mark_hold "$@"
exit
;;
esac
case $PMTYPE in
apt-rpm)
if [ "$1" = "hold" ] ; then
shift
__alt_mark_hold "$@"
exit
fi
if [ "$1" = "unhold" ] ; then
shift
__alt_mark_unhold "$@"
exit
fi
if [ "$1" = "showhold" ] ; then
shift
__alt_mark_showhold "$@"
exit
fi
sudocmd apt-mark "$@"
if [ "$1" = "" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then
echo
echo "EPM additionals: "
echo " hold pkg1 [pkg2 ...] - hold the given package(s)"
echo " unhold pkg1 [pkg2 ...] - unhold the given package(s)"
fi
apt-dpkg)
sudocmd apt-mark hold "$@"
;;
yum-rpm|dnf-rpm)
fatal "Improve me"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_mark_unhold()
{
case $DISTRNAME in
ALTLinux|ALTServer)
__alt_mark_unhold "$@"
exit
;;
esac
case $PMTYPE in
apt-dpkg)
sudocmd apt-mark unhold "$@"
;;
yum-rpm|dnf-rpm)
fatal "Improve me"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_mark_showhold()
{
case $DISTRNAME in
ALTLinux|ALTServer)
__alt_mark_showhold "$@"
exit
;;
esac
case $PMTYPE in
apt-dpkg)
sudocmd apt-mark showhold "$@"
;;
# yum-rpm|dnf-rpm)
# fatal "Improve me"
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_mark_auto()
{
case $DISTRNAME in
ALTLinux|ALTServer)
sudocmd apt-mark auto "$@"
exit
;;
esac
case $PMTYPE in
apt-dpkg)
sudocmd apt-mark auto "$@"
;;
# yum-rpm|dnf-rpm)
# sudocmd dnf mark remove "$@"
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_mark_manual()
{
case $DISTRNAME in
ALTLinux|ALTServer)
sudocmd apt-mark manual "$@"
exit
;;
esac
case $PMTYPE in
apt-dpkg)
sudocmd apt-mark "$@"
sudocmd apt-mark manual "$@"
;;
# yum-rpm|dnf-rpm)
# sudocmd dnf mark install "$@"
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_mark_showauto()
{
case $DISTRNAME in
ALTLinux|ALTServer)
sudocmd apt-mark showauto "$@"
exit
;;
esac
case $PMTYPE in
apt-dpkg)
sudocmd apt-mark showauto "$@"
;;
# yum-rpm|dnf-rpm)
# sudocmd dnf mark remove "$@"
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_mark_showmanual()
{
case $DISTRNAME in
ALTLinux|ALTServer)
sudocmd apt-mark showmanual "$@"
exit
;;
esac
case $PMTYPE in
apt-dpkg)
sudocmd apt-mark showmanual "$@"
;;
# yum-rpm|dnf-rpm)
# sudocmd dnf mark install "$@"
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_mark()
{
local CMD="$1"
[ -n "$CMD" ] && shift
case "$CMD" in
""|"-h"|"--help"|help) # HELPCMD: help
echo "mark is the interface for marking packages"
get_help HELPCMD $SHAREDIR/epm-mark
cat <<EOF
Examples:
epm mark hold mc
epm manual mc
EOF
;;
hold) # HELPCMD: mark the given package(s) as held back
epm_mark_hold "$@"
;;
unhold) # HELPCMD: unset the given package(s) as held back
epm_mark_unhold "$@"
;;
showhold) # HELPCMD: print the list of packages on hold
epm_mark_showhold "$@"
;;
auto) # HELPCMD: mark the given package(s) as automatically installed
epm_mark_auto "$@"
;;
manual) # HELPCMD: mark the given package(s) as manually installed
epm_mark_manual "$@"
;;
showauto) # HELPCMD: print the list of automatically installed packages
epm_mark_showauto "$@"
;;
showmanual) # HELPCMD: print the list of manually installed packages
epm_mark_showmanual "$@"
;;
*)
fatal "Unknown command $ epm repo '$CMD'"
;;
esac
}
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