Commit 72a29942 authored by Vitaly Lipatov's avatar Vitaly Lipatov

update packed

parent b4ceac0c
...@@ -37,7 +37,7 @@ load_helper() ...@@ -37,7 +37,7 @@ load_helper()
inputisatty() inputisatty()
{ {
# check stdin # check stdin
tty -s tty -s 2>/dev/null
} }
isatty() isatty()
...@@ -60,6 +60,12 @@ check_tty() ...@@ -60,6 +60,12 @@ check_tty()
[ -n "$TERM" ] || TERM=dumb [ -n "$TERM" ] || TERM=dumb
export TERM export TERM
# egrep from busybox may not --color
# egrep from MacOS print help to stderr
if egrep --help 2>&1 | grep -q -- "--color" ; then
EGREPCOLOR="--color"
fi
which tput >/dev/null 2>/dev/null || return which tput >/dev/null 2>/dev/null || return
# FreeBSD does not support tput -S # FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return echo | tput -S >/dev/null 2>/dev/null || return
...@@ -89,10 +95,17 @@ restore_color() ...@@ -89,10 +95,17 @@ restore_color()
echover() echover()
{ {
[ -n "$verbose" ] || return [ -z "$verbose" ] && return
echo "$*" >&2 echo "$*" >&2
} }
echon()
{
# default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@"
}
set_target_pkg_env() set_target_pkg_env()
{ {
[ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME" [ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME"
...@@ -120,47 +133,47 @@ showcmd() ...@@ -120,47 +133,47 @@ showcmd()
docmd() docmd()
{ {
showcmd "$@$EXTRA_SHOWDOCMD" showcmd "$@$EXTRA_SHOWDOCMD"
"$@" $@
} }
docmd_foreach() docmd_foreach()
{ {
local cmd local cmd pkg
cmd="$1" cmd="$1"
#showcmd "$@" #showcmd "$@"
shift shift
for pkg in "$@" ; do for pkg in "$@" ; do
docmd $cmd $pkg docmd "$cmd" $pkg
done done
} }
sudocmd() sudocmd()
{ {
showcmd "$SUDO $@" showcmd "$SUDO $@"
$SUDO "$@" $SUDO $@
} }
sudocmd_foreach() sudocmd_foreach()
{ {
local cmd local cmd pkg
cmd="$1" cmd="$1"
#showcmd "$@" #showcmd "$@"
shift shift
for pkg in "$@" ; do for pkg in "$@" ; do
sudocmd $cmd $pkg sudocmd "$cmd" $pkg
done done
} }
get_firstarg() get_firstarg()
{ {
echo -n "$1" echon "$1"
} }
get_lastarg() get_lastarg()
{ {
local lastarg local lastarg
eval lastarg=\${$#} eval lastarg=\${$#}
echo -n "$lastarg" echon "$lastarg"
} }
...@@ -189,7 +202,7 @@ store_output() ...@@ -189,7 +202,7 @@ store_output()
local CMDSTATUS=$RC_STDOUT.pipestatus local CMDSTATUS=$RC_STDOUT.pipestatus
echo 1 >$CMDSTATUS echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp) #RC_STDERR=$(mktemp)
( "$@" 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT ( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS) return $(cat $CMDSTATUS)
# bashism # bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
...@@ -201,7 +214,6 @@ clean_store_output() ...@@ -201,7 +214,6 @@ clean_store_output()
rm -f $RC_STDOUT $RC_STDOUT.pipestatus rm -f $RC_STDOUT $RC_STDOUT.pipestatus
} }
epm() epm()
{ {
$PROGDIR/epm $@ $PROGDIR/epm $@
...@@ -321,15 +333,16 @@ if [ -n "$FORCEPM" ] ; then ...@@ -321,15 +333,16 @@ if [ -n "$FORCEPM" ] ; then
fi fi
case $DISTRNAME in case $DISTRNAME in
ALTLinux|PCLinux) ALTLinux)
CMD="apt-rpm" CMD="apt-rpm"
#which deepsolver 2>/dev/null >/dev/null && CMD=deepsolver-rpm #which ds-install 2>/dev/null >/dev/null && CMD=deepsolver-rpm
;; ;;
PCLinux) PCLinux)
CMD="apt-rpm" CMD="apt-rpm"
;; ;;
Ubuntu|Debian|Mint) Ubuntu|Debian|Mint)
CMD="apt-dpkg" CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
;; ;;
Mandriva|ROSA) Mandriva|ROSA)
CMD="urpm-rpm" CMD="urpm-rpm"
...@@ -345,6 +358,7 @@ case $DISTRNAME in ...@@ -345,6 +358,7 @@ case $DISTRNAME in
;; ;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific)
CMD="yum-rpm" CMD="yum-rpm"
#which dnf 2>/dev/null >/dev/null && CMD=dnf-rpm
;; ;;
Slackware) Slackware)
CMD="slackpkg" CMD="slackpkg"
...@@ -1078,7 +1092,7 @@ $(get_help HELPOPT) ...@@ -1078,7 +1092,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.4.6" echo "Service manager version 1.5.0"
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