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

update packed

parent 292cf113
...@@ -35,17 +35,33 @@ load_helper() ...@@ -35,17 +35,33 @@ load_helper()
# File bin/epm-sh-functions: # File bin/epm-sh-functions:
inputisatty()
{
# check stdin
tty -s
}
isatty() isatty()
{ {
# Set a sane TERM required for tput # check stdout
[ -n "$TERM" ] || TERM=dumb
export TERM
test -t 1 test -t 1
} }
isatty2()
{
# check stderr
test -t 2
}
check_tty() check_tty()
{ {
isatty || return isatty2 || return
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
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
...@@ -232,7 +248,8 @@ set_eatmydata() ...@@ -232,7 +248,8 @@ set_eatmydata()
# use if possible # use if possible
which eatmydata >/dev/null 2>/dev/null || return which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata" SUDO="$SUDO eatmydata"
echo "Uwaga! eatmydata is installed, we will use it for disable all sync operations." isatty && echo "Uwaga! eatmydata is installed, we will use it for disable all sync operations." >&2
return 0
} }
assure_exists() assure_exists()
...@@ -352,6 +369,9 @@ case $DISTRNAME in ...@@ -352,6 +369,9 @@ case $DISTRNAME in
GNU/Linux/Guix) GNU/Linux/Guix)
CMD="guix" CMD="guix"
;; ;;
Android)
CMD="android"
;;
*) *)
fatal "Have no suitable DISTRNAME $DISTRNAME" fatal "Have no suitable DISTRNAME $DISTRNAME"
;; ;;
...@@ -404,12 +424,32 @@ esac ...@@ -404,12 +424,32 @@ esac
# File bin/epm-autoremove: # File bin/epm-autoremove:
__epm_autoremove_altrpm()
{
local pkg
local flag=
load_helper epm-packages
echo
echo "Just remove all non -devel libs packages not need by anything"
for pkg in $(short=1 pkg_filenames= epm_packages | grep -- "^lib" | grep -v -- "-devel$" | grep -v -- ^libreoffice ) ; do
sudocmd rpm -v -e $pkg && flag=1
done
# call again for next cycle until all libs will removed
[ -n "$flag" ] && __epm_autoremove_altrpm
return 0
}
epm_autoremove() epm_autoremove()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
assure_exists remove-old-kernels assure_exists remove-old-kernels
# ALT Linux only # ALT Linux only
__epm_autoremove_altrpm
# ALT Linux only
sudocmd remove-old-kernels sudocmd remove-old-kernels
;; ;;
apt-dpkg) apt-dpkg)
...@@ -843,8 +883,7 @@ __epm_filelist_file() ...@@ -843,8 +883,7 @@ __epm_filelist_file()
;; ;;
esac esac
# TODO: add less docmd $CMD $@ | less
docmd $CMD $@
} }
__epm_filelist_name() __epm_filelist_name()
...@@ -869,11 +908,14 @@ __epm_filelist_name() ...@@ -869,11 +908,14 @@ __epm_filelist_name()
zypper-rpm) zypper-rpm)
CMD="rpm -ql" CMD="rpm -ql"
;; ;;
android)
CMD="pm list packages -f"
;;
conary) conary)
CMD="conary query --ls" CMD="conary query --ls"
;; ;;
pacman) pacman)
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g" docmd pacman -Ql $pkg_names | sed -e "s|.* ||g" | less
return return
;; ;;
emerge) emerge)
...@@ -882,7 +924,7 @@ __epm_filelist_name() ...@@ -882,7 +924,7 @@ __epm_filelist_name()
;; ;;
slackpkg) slackpkg)
is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized" is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized"
docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* | less
return return
;; ;;
*) *)
...@@ -1109,6 +1151,9 @@ epm_install_names() ...@@ -1109,6 +1151,9 @@ epm_install_names()
guix) guix)
__separate_sudocmd "guix package -i" "guix package -i" $@ __separate_sudocmd "guix package -i" "guix package -i" $@
return ;; return ;;
guix)
__separate_sudocmd "guix package -i" "guix package -i" $@
return ;;
*) *)
fatal "Have no suitable install command for $PMTYPE" fatal "Have no suitable install command for $PMTYPE"
;; ;;
...@@ -1158,6 +1203,9 @@ epm_ni_install_names() ...@@ -1158,6 +1203,9 @@ epm_ni_install_names()
nix) nix)
sudocmd nix-env --install $@ sudocmd nix-env --install $@
return ;; return ;;
android
sudocmd pm install $@
return ;;
slackpkg) slackpkg)
# FIXME: broken status when use batch and default answer # FIXME: broken status when use batch and default answer
__separate_sudocmd_foreach "/usr/sbin/slackpkg -batch=on -default_answer=yes install" "/usr/sbin/slackpkg -batch=on -default_answer=yes upgrade" $@ __separate_sudocmd_foreach "/usr/sbin/slackpkg -batch=on -default_answer=yes install" "/usr/sbin/slackpkg -batch=on -default_answer=yes upgrade" $@
...@@ -1247,6 +1295,9 @@ epm_install_files() ...@@ -1247,6 +1295,9 @@ epm_install_files()
pkgsrc) pkgsrc)
sudocmd pkg_add $@ sudocmd pkg_add $@
return ;; return ;;
android)
sudocmd pm install $@
return ;;
emerge) emerge)
load_helper epm-install-emerge load_helper epm-install-emerge
sudocmd epm_install_emerge $@ sudocmd epm_install_emerge $@
...@@ -1297,6 +1348,9 @@ epm_print_install_command() ...@@ -1297,6 +1348,9 @@ epm_print_install_command()
ipkg) ipkg)
echo "ipkg install $@" echo "ipkg install $@"
;; ;;
android)
echo "pm install $@"
;;
*) *)
fatal "Have no suitable appropriate install command for $PMTYPE" fatal "Have no suitable appropriate install command for $PMTYPE"
;; ;;
...@@ -1518,6 +1572,11 @@ case $PMTYPE in ...@@ -1518,6 +1572,11 @@ case $PMTYPE in
guix) guix)
CMD="guix package -I" CMD="guix package -I"
;; ;;
android)
CMD="pm list packages"
docmd $CMD | sed -e "s|^package:||g"
return
;;
*) *)
fatal "Have no suitable query command for $PMTYPE" fatal "Have no suitable query command for $PMTYPE"
;; ;;
...@@ -1549,7 +1608,7 @@ epm_provides_files() ...@@ -1549,7 +1608,7 @@ epm_provides_files()
case $(get_package_type $pkg_files) in case $(get_package_type $pkg_files) in
rpm) rpm)
docmd "rpm -q --provides -p" docmd rpm -q --provides -p $pkg_files
;; ;;
deb) deb)
# FIXME: will we provide ourself? # FIXME: will we provide ourself?
...@@ -1911,7 +1970,7 @@ epm_query_file() ...@@ -1911,7 +1970,7 @@ epm_query_file()
for pkg in $pkg_filenames ; do for pkg in $pkg_filenames ; do
__do_query_real_file "$pkg" __do_query_real_file "$pkg"
__do_query $FULLFILEPATH || pkg_filenames=$pkg epm_search_file __do_query $FULLFILEPATH || pkg_filenames=$FULLFILEPATH epm_search_file
done done
} }
...@@ -1923,7 +1982,8 @@ epm_query_package() ...@@ -1923,7 +1982,8 @@ epm_query_package()
{ {
[ -n "$pkg_filenames" ] || fatal "Please, use search with some argument or run epmqa for get all packages." [ -n "$pkg_filenames" ] || fatal "Please, use search with some argument or run epmqa for get all packages."
# FIXME: do it better # FIXME: do it better
local MGS=$(eval __epm_search_make_grep $quoted_args) local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS EXTRA_SHOWDOCMD=$MGS
eval "pkg_filenames= epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS" eval "pkg_filenames= epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS"
} }
...@@ -2123,6 +2183,9 @@ epm_remove_names() ...@@ -2123,6 +2183,9 @@ epm_remove_names()
guix) guix)
sudocmd guix package -r $@ sudocmd guix package -r $@
return ;; return ;;
android)
sudocmd pm uninstall $@
return ;;
chocolatey) chocolatey)
sudocmd chocolatey uninstall $@ sudocmd chocolatey uninstall $@
return ;; return ;;
...@@ -2335,7 +2398,7 @@ epm_requires_files() ...@@ -2335,7 +2398,7 @@ epm_requires_files()
case $(get_package_type $pkg_files) in case $(get_package_type $pkg_files) in
rpm) rpm)
docmd "rpm -q --requires -p" docmd rpm -q --requires -p $pkg_files
;; ;;
deb) deb)
a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g" a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
...@@ -2417,7 +2480,8 @@ case $PMTYPE in ...@@ -2417,7 +2480,8 @@ case $PMTYPE in
CMD="apt-cache search --" CMD="apt-cache search --"
;; ;;
urpm-rpm) urpm-rpm)
CMD="urpmq -y --" # urpmq does not support --
CMD="urpmq -y"
;; ;;
pkgsrc) pkgsrc)
CMD="pkg_info -x --" CMD="pkg_info -x --"
...@@ -2456,7 +2520,7 @@ case $PMTYPE in ...@@ -2456,7 +2520,7 @@ case $PMTYPE in
slackpkg) slackpkg)
# FIXME # FIXME
echo "Note: case sensitive search" echo "Note: case sensitive search"
CMD="/usr/sbin/slackpkg search --" CMD="/usr/sbin/slackpkg search"
;; ;;
homebrew) homebrew)
CMD="brew search" CMD="brew search"
...@@ -2464,6 +2528,9 @@ case $PMTYPE in ...@@ -2464,6 +2528,9 @@ case $PMTYPE in
guix) guix)
CMD="guix package -A" CMD="guix package -A"
;; ;;
android)
CMD="pm list packages"
;;
*) *)
fatal "Have no suitable search command for $PMTYPE" fatal "Have no suitable search command for $PMTYPE"
;; ;;
...@@ -2503,6 +2570,13 @@ __epm_search_make_grep() ...@@ -2503,6 +2570,13 @@ __epm_search_make_grep()
echo -n " | egrep -i -- \"$i\"" echo -n " | egrep -i -- \"$i\""
done done
if [ "$short" ] ; then
echo -n " | sed -e \"s| .*||g\""
fi
# FIXME: move from it
#isatty || return
local COLO="" local COLO=""
# rule for colorife # rule for colorife
for i in $list $listN; do for i in $list $listN; do
...@@ -2519,8 +2593,10 @@ __epm_search_make_grep() ...@@ -2519,8 +2593,10 @@ __epm_search_make_grep()
epm_search() epm_search()
{ {
[ -n "$pkg_filenames" ] || fatal "Please, use search with some argument" [ -n "$pkg_filenames" ] || fatal "Please, use search with some argument"
# FIXME: do it better # FIXME: do it better
local MGS=$(eval __epm_search_make_grep $quoted_args) local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD="$MGS" EXTRA_SHOWDOCMD="$MGS"
eval "__epm_search_output \"$(eval get_firstarg $quoted_args)\" $MGS" eval "__epm_search_output \"$(eval get_firstarg $quoted_args)\" $MGS"
} }
...@@ -2969,6 +3045,7 @@ pkgtype() ...@@ -2969,6 +3045,7 @@ pkgtype()
archlinux) echo "pkg.tar.xz" ;; archlinux) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;; gentoo) echo "tbz2" ;;
windows) echo "exe" ;; windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;; debian|ubuntu|mint|runtu) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles) alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;; echo "rpm" ;;
...@@ -3166,6 +3243,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then ...@@ -3166,6 +3243,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix" DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
# try use standart LSB info by default # try use standart LSB info by default
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB # use LSB
...@@ -3225,7 +3307,6 @@ esac ...@@ -3225,7 +3307,6 @@ esac
#PATH=$PATH:/sbin:/usr/sbin #PATH=$PATH:/sbin:/usr/sbin
set_sudo set_sudo
set_eatmydata
check_tty check_tty
...@@ -3245,7 +3326,7 @@ $(get_help HELPOPT) ...@@ -3245,7 +3326,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "EPM package manager version 1.4.2" echo "EPM package manager version 1.4.6"
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."
...@@ -3480,18 +3561,34 @@ check_option() ...@@ -3480,18 +3561,34 @@ check_option()
return 0 return 0
} }
for opt in "$@" ; do check_filenames()
check_command $opt && continue {
check_option $opt && continue local opt="$1"
if [ -f "$opt" ] && echo $opt | grep -q "\." ; then if [ -f "$opt" ] && echo $opt | grep -q "\." ; then
pkg_files="$pkg_files $opt" pkg_files="$pkg_files $opt"
else else
pkg_names="$pkg_names $opt" pkg_names="$pkg_names $opt"
fi fi
quoted_args="$quoted_args \"$opt\"" quoted_args="$quoted_args \"$opt\""
}
FLAGENDOPTS=
for opt in "$@" ; do
[ "$opt" = "--" ] && FLAGENDOPTS=1 && continue
if [ -z "$FLAGENDOPTS" ] ; then
check_command $opt && continue
check_option $opt && continue
fi
check_filenames $opt
done done
# if input is not console, get pkg from it too
if ! inputisatty ; then
for opt in $(cat) ; do
check_filenames $opt
done
fi
pkg_files=$(strip_spaces "$pkg_files") pkg_files=$(strip_spaces "$pkg_files")
pkg_names=$(strip_spaces "$pkg_names") pkg_names=$(strip_spaces "$pkg_names")
...@@ -3509,6 +3606,13 @@ if [ -z "$epm_cmd" ] ; then ...@@ -3509,6 +3606,13 @@ if [ -z "$epm_cmd" ] ; then
fatal "Run $ $progname --help for get help" fatal "Run $ $progname --help for get help"
fi fi
# Use eatmydata for write specific operations
case $epm_cmd in
update|upgrade|Upgrade|install|reinstall|Install|remove|kernel_update|release_upgrade|)
set_eatmydata
break;
esac
# Run helper for command # Run helper for command
epm_$epm_cmd epm_$epm_cmd
# return last error code (from subroutine) # return last error code (from subroutine)
...@@ -33,17 +33,33 @@ load_helper() ...@@ -33,17 +33,33 @@ load_helper()
# File bin/epm-sh-functions: # File bin/epm-sh-functions:
inputisatty()
{
# check stdin
tty -s
}
isatty() isatty()
{ {
# Set a sane TERM required for tput # check stdout
[ -n "$TERM" ] || TERM=dumb
export TERM
test -t 1 test -t 1
} }
isatty2()
{
# check stderr
test -t 2
}
check_tty() check_tty()
{ {
isatty || return isatty2 || return
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
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
...@@ -230,7 +246,8 @@ set_eatmydata() ...@@ -230,7 +246,8 @@ set_eatmydata()
# use if possible # use if possible
which eatmydata >/dev/null 2>/dev/null || return which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata" SUDO="$SUDO eatmydata"
echo "Uwaga! eatmydata is installed, we will use it for disable all sync operations." isatty && echo "Uwaga! eatmydata is installed, we will use it for disable all sync operations." >&2
return 0
} }
assure_exists() assure_exists()
...@@ -350,6 +367,9 @@ case $DISTRNAME in ...@@ -350,6 +367,9 @@ case $DISTRNAME in
GNU/Linux/Guix) GNU/Linux/Guix)
CMD="guix" CMD="guix"
;; ;;
Android)
CMD="android"
;;
*) *)
fatal "Have no suitable DISTRNAME $DISTRNAME" fatal "Have no suitable DISTRNAME $DISTRNAME"
;; ;;
...@@ -710,6 +730,7 @@ pkgtype() ...@@ -710,6 +730,7 @@ pkgtype()
archlinux) echo "pkg.tar.xz" ;; archlinux) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;; gentoo) echo "tbz2" ;;
windows) echo "exe" ;; windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;; debian|ubuntu|mint|runtu) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles) alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;; echo "rpm" ;;
...@@ -907,6 +928,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then ...@@ -907,6 +928,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix" DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
# try use standart LSB info by default # try use standart LSB info by default
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB # use LSB
...@@ -1052,7 +1078,7 @@ $(get_help HELPOPT) ...@@ -1052,7 +1078,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.4.2" echo "Service manager version 1.4.6"
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