Commit ee708964 authored by Vitaly Lipatov's avatar Vitaly Lipatov

update packed

parent b752a4f1
...@@ -151,6 +151,27 @@ strip_spaces() ...@@ -151,6 +151,27 @@ strip_spaces()
echo "$*" | filter_strip_spaces echo "$*" | filter_strip_spaces
} }
subst_option()
{
eval "[ -n \"\$$1\" ]" && echo "$2" || echo "$3"
}
store_output()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
#RC_STDERR=$(mktemp)
"$@" 2>&1 | tee $RC_STDOUT
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return $PIPESTATUS
}
clean_store_output()
{
rm -f $RC_STDOUT
}
epm() epm()
{ {
$PROGDIR/epm $@ $PROGDIR/epm $@
...@@ -322,7 +343,7 @@ case $PMTYPE in ...@@ -322,7 +343,7 @@ case $PMTYPE in
yum-rpm) yum-rpm)
# cleanup orphanes? # cleanup orphanes?
while true ; do while true ; do
docmd package-cleanup --leaves docmd package-cleanup --leaves $(subst_option non_interactive --assumeyes)
# FIXME: package-cleanup have to use stderr for errors # FIXME: package-cleanup have to use stderr for errors
local PKGLIST=$(package-cleanup --leaves | grep -v "Loaded plugins" | grep -v "Unable to") local PKGLIST=$(package-cleanup --leaves | grep -v "Loaded plugins" | grep -v "Unable to")
[ -n "$PKGLIST" ] || break [ -n "$PKGLIST" ] || break
...@@ -1679,8 +1700,7 @@ epm_remove_low() ...@@ -1679,8 +1700,7 @@ epm_remove_low()
sudocmd rpm -ev $nodeps $@ sudocmd rpm -ev $nodeps $@
return ;; return ;;
apt-dpkg) apt-dpkg)
[ -n "$nodeps" ] && nodeps="--force-all" sudocmd dpkg -P $(subst_option nodeps --force-all) $@
sudocmd dpkg -P $nodeps $@
return ;; return ;;
pkgsrc) pkgsrc)
sudocmd pkg_delete -r $@ sudocmd pkg_delete -r $@
...@@ -1750,8 +1770,7 @@ epm_remove_names() ...@@ -1750,8 +1770,7 @@ epm_remove_names()
sudocmd brew remove $@ sudocmd brew remove $@
return ;; return ;;
ipkg) ipkg)
[ -n "$force" ] && force=-force-depends sudocmd ipkg $(subst_option force -force-depends) remove $@
sudocmd ipkg $force remove $@
return ;; return ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
...@@ -2124,9 +2143,22 @@ __use_yum_assumeno() ...@@ -2124,9 +2143,22 @@ __use_yum_assumeno()
a= yum --help 2>&1 | grep -q -- "--assumeno" a= yum --help 2>&1 | grep -q -- "--assumeno"
} }
__check_yum_result()
{
grep "^No package" $1 && return 1
grep "^Complete!" $1 && return 0
grep "^Exiting on user Command" $1 && return 0
grep "^Exiting on user command" $1 && return 0
# return default result by default
return $2
}
_epm_do_simulate() _epm_do_simulate()
{ {
local CMD local CMD
local RES=0
local filenames="$*" local filenames="$*"
case $PMTYPE in case $PMTYPE in
...@@ -2135,20 +2167,15 @@ _epm_do_simulate() ...@@ -2135,20 +2167,15 @@ _epm_do_simulate()
;; ;;
yum-rpm) yum-rpm)
if __use_yum_assumeno ; then if __use_yum_assumeno ; then
LC_ALL=C sudocmd yum --assumeno install $filenames LC_ALL=C store_output sudocmd yum --assumeno install $filenames
# FIXME: check only error output __check_yum_result $RC_STDOUT $?
LC_ALL=C sudocmd yum --assumeno install $filenames 2>&1 | grep "^No package" && return 1
LC_ALL=C sudocmd yum --assumeno install $filenames 2>&1 | grep "^Complete!" && return 0
LC_ALL=C sudocmd yum --assumeno install $filenames 2>&1 | grep "^Exiting on user Command" && return 0
LC_ALL=C sudocmd yum --assumeno install $filenames >/dev/null 2>&1 || return
else else
LC_ALL=C echo n | sudocmd yum install $filenames LC_ALL=C echo n | store_output sudocmd yum install $filenames
# FIXME: check only error output __check_yum_result $RC_STDOUT $?
LC_ALL=C echo n | sudocmd yum install $filenames 2>&1 | grep "^No package" && return 1
LC_ALL=C echo n | sudocmd yum install $filenames 2>&1 | grep "^Complete!" && return 0
LC_ALL=C echo n | sudocmd yum install $filenames >/dev/null 2>&1 || return
fi fi
return 0 ;; RES=$?
clean_store_output
return $RES ;;
urpm-rpm) urpm-rpm)
CMD="urpmi --test --auto" CMD="urpmi --test --auto"
;; ;;
...@@ -2686,7 +2713,7 @@ $(get_help HELPOPT) ...@@ -2686,7 +2713,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "EPM package manager version 1.2.7" echo "EPM package manager version 1.2.8"
echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)" echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
echo "Copyright (c) Etersoft 2012-2013" echo "Copyright (c) Etersoft 2012-2013"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
...@@ -2740,6 +2767,9 @@ case $progname in ...@@ -2740,6 +2767,9 @@ case $progname in
epmqp) epmqp)
epm_cmd=query_package epm_cmd=query_package
;; ;;
epmql)
epm_cmd=filelist
;;
epmu) epmu)
epm_cmd=update epm_cmd=update
;; ;;
......
...@@ -149,6 +149,27 @@ strip_spaces() ...@@ -149,6 +149,27 @@ strip_spaces()
echo "$*" | filter_strip_spaces echo "$*" | filter_strip_spaces
} }
subst_option()
{
eval "[ -n \"\$$1\" ]" && echo "$2" || echo "$3"
}
store_output()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
#RC_STDERR=$(mktemp)
"$@" 2>&1 | tee $RC_STDOUT
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return $PIPESTATUS
}
clean_store_output()
{
rm -f $RC_STDOUT
}
epm() epm()
{ {
$PROGDIR/epm $@ $PROGDIR/epm $@
...@@ -945,7 +966,7 @@ $(get_help HELPOPT) ...@@ -945,7 +966,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.2.7" echo "Service manager version 1.2.8"
echo "Running on $($DISTRVENDOR)" echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013" echo "Copyright (c) Etersoft 2012, 2013"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
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