Commit 3f486672 authored by Vitaly Lipatov's avatar Vitaly Lipatov

introduce PMTYPE (apt-rpm, apt-dpkg) and use it

parent 7ce6c057
......@@ -81,6 +81,9 @@ for opt in "$@" ; do
-e|remove)
epm_cmd=remove
;;
dist-upgrade|upgrade)
epm_cmd=upgrade
;;
-s|search)
epm_cmd=search
;;
......@@ -117,6 +120,8 @@ DISTRVENDOR=distr_vendor
[ -n "$DISTRVERSION" ] || DISTRVERSION=$($DISTRVENDOR -v)
set_target_pkg_env
set_pm_type
[ -n "$epm_cmd" ] || fatal "Run without command"
epm_cmd_file=$(dirname $0)/epm-$epm_cmd
......
......@@ -67,3 +67,33 @@ fatal()
fi
exit 1
}
# FIXME: detect if not recognized
set_pm_type()
{
local CMD
case $DISTRNAME in
"ALTLinux"|"PCLinux")
CMD="apt-rpm"
;;
"FreeBSD")
CMD="pkg_add"
;;
"Ubuntu"|"Debian")
CMD="apt-dpkg"
;;
"LinuxXP"|"Fedora"|"ASPLinux"|"CentOS"|"RHEL"|"Scientific")
CMD="yum-rpm"
;;
"Mandriva")
CMD="urpm-rpm"
;;
"SUSE")
CMD="zypper-rpm"
;;
*)
fatal "Do not known command for DISTRNAME $DISTRNAME"
;;
esac
PMTYPE=$CMD
}
......@@ -22,13 +22,12 @@
epm_update()
{
#docmd $CMD $pkg_files $pkg_names
case $DISTRNAME in
"ALTLinux")
exit 0
case $PMTYPE in
"apt-rpm")
apt-get update || exit
apt-get -f install || exit
;;
"Ubuntu"|"Debian"|"PCLinux")
"apt-dpkg")
apt-get update || exit
apt-get -f install || exit
apt-get autoremove
......
......@@ -18,31 +18,29 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# copied from korinf/tools/run-script/scripts/search
epm_search()
epm_upgrade()
{
[ -n "$pkg_filenames" ] || fatal "Run search without names"
[ -n "$pkg_filenames" ] && fatal "No need any args for upgrade command"
case $DISTRNAME in
"ALTLinux"|"Ubuntu"|"Debian"|"PCLinux")
echo "Run command for upgrade packages"
case $PMTYPE in
apt-rpm|apt-dpkg)
# FIXME: apt-get update before
CMD="apt-get dist-upgrade"
;;
"LinuxXP"|"Fedora"|"ASPLinux"|"CentOS"|"RHEL"|"Scientific")
yum-rpm)
CMD="yum update"
;;
# "Mandriva")
# CMD="urpmf"
# ;;
"SUSE")
urpm-rpm)
CMD="urpmi --auto-update"
;;
zypper-rpm)
CMD="zypper update"
;;
*)
RET=1
CMD="echo \"Do not known install command for DISTRNAME $DISTRNAME\""
fatal "Do not known command for $PMTYPE"
;;
esac
docmd $CMD $pkg_filenames
esac
docmd $CMD
}
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