Commit 8a3a474d authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to p7 as 1.5.0-alt0.M70P.1 (with rpmbph script)

parents c8bae544 dc6305bf
Загрузку конфига
Проверить всё с кавычками
Неверно передаёт кавычки:
__separate_sudocmd()
А другие?
readlink -f — что делать и нужен ли
Нужен realfullpath
Использование | less теряет код возврата команды. Нужно сделать nobash решение, которое сохранит статус
Команда
docmdmore
Дописывать .service для systemd, если не указано другое.
Установка (для отсутствующих файлов пакетов) и удаление (в любом случае) должны производиться с укороченными именами (которые воспримет верхний уровень)
Чтобы было легко выстраивать цепочки, нужно ввод не с консоли (если есть) воспринимать как параметры. Чтобы было легко выстраивать цепочки, нужно ввод не с консоли (если есть) воспринимать как параметры.
То же для EPM
2. Дописать таблицу на вики на основании реализованных команд. 2. Дописать таблицу на вики на основании реализованных команд.
3. Доделать и проверить deplist|requires 3. Доделать и проверить deplist|requires
......
...@@ -50,6 +50,7 @@ pkgtype() ...@@ -50,6 +50,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" ;;
...@@ -247,6 +248,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then ...@@ -247,6 +248,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
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012, 2013 Etersoft # Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -37,7 +37,6 @@ load_helper epm-sh-functions ...@@ -37,7 +37,6 @@ load_helper epm-sh-functions
#PATH=$PATH:/sbin:/usr/sbin #PATH=$PATH:/sbin:/usr/sbin
set_sudo set_sudo
set_eatmydata
check_tty check_tty
...@@ -59,7 +58,7 @@ print_version() ...@@ -59,7 +58,7 @@ print_version()
{ {
echo "EPM package manager version @VERSION@" echo "EPM package manager version @VERSION@"
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-2014"
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."
} }
...@@ -149,7 +148,7 @@ check_command() ...@@ -149,7 +148,7 @@ check_command()
-qp|qp|query_package) # HELPCMD: search in the list of installed packages -qp|qp|query_package) # HELPCMD: search in the list of installed packages
epm_cmd=query_package epm_cmd=query_package
;; ;;
-qf|qf|which|belongs) # HELPCMD: query package(s) owning file -qf|qf|-S|which|belongs) # HELPCMD: query package(s) owning file
epm_cmd=query_file epm_cmd=query_file
;; ;;
...@@ -178,10 +177,10 @@ check_command() ...@@ -178,10 +177,10 @@ check_command()
-qi|qi|info|show) # HELPCMD: print package detail info -qi|qi|info|show) # HELPCMD: print package detail info
epm_cmd=info epm_cmd=info
;; ;;
requires|deplist) # HELPCMD: print package requires requires|deplist|req) # HELPCMD: print package requires
epm_cmd=requires epm_cmd=requires
;; ;;
provides) # HELPCMD: print package provides provides|prov) # HELPCMD: print package provides
epm_cmd=provides epm_cmd=provides
;; ;;
whatdepends) # HELPCMD: print packages dependences on that whatdepends) # HELPCMD: print packages dependences on that
...@@ -193,12 +192,15 @@ check_command() ...@@ -193,12 +192,15 @@ check_command()
conflicts) # HELPCMD: print package conflicts conflicts) # HELPCMD: print package conflicts
epm_cmd=conflicts epm_cmd=conflicts
;; ;;
-qa|list|packages|-l|qa) # HELPCMD: list of installed package(s) -qa|list|packages|-l|qa) # HELPCMD: print list of installed package(s)
epm_cmd=packages epm_cmd=packages
;; ;;
programs) # HELPCMD: list of installed GUI program(s) programs) # HELPCMD: print list of installed GUI program(s)
epm_cmd=programs epm_cmd=programs
;; ;;
assure) # HELPCMD: <command> [package]: install package if command does not exists
epm_cmd=assure
;;
# Repository control # Repository control
update) # HELPCMD: update remote package repository databases update) # HELPCMD: update remote package repository databases
...@@ -230,13 +232,13 @@ check_command() ...@@ -230,13 +232,13 @@ check_command()
upgrade|dist-upgrade) # HELPCMD: performs upgrades of package software distributions upgrade|dist-upgrade) # HELPCMD: performs upgrades of package software distributions
epm_cmd=upgrade epm_cmd=upgrade
;; ;;
Upgrade) # HELPCMD: performs update && upgrade command Upgrade) # HELPCMD: force update package base, then run upgrade
epm_cmd=Upgrade epm_cmd=Upgrade
;; ;;
simulate) # HELPCMD: simulate install (it does check requires, minimally) simulate) # HELPCMD: simulate install with check requires
epm_cmd=simulate epm_cmd=simulate
;; ;;
checkpkg|integrity) # HELPCMD: check package integrity checkpkg|integrity) # HELPCMD: check package file integrity (checksum)
epm_cmd=checkpkg epm_cmd=checkpkg
;; ;;
...@@ -261,7 +263,7 @@ check_option() ...@@ -261,7 +263,7 @@ check_option()
--verbose) # HELPOPT: verbose mode --verbose) # HELPOPT: verbose mode
verbose=1 verbose=1
;; ;;
--skip-installed) # HELPOPT: skip already install during install --skip-installed) # HELPOPT: skip already installed packages during install
skip_installed=1 skip_installed=1
;; ;;
--show-command-only) # HELPOPT: show command only, do not any action (supports install and remove ONLY) --show-command-only) # HELPOPT: show command only, do not any action (supports install and remove ONLY)
...@@ -315,7 +317,7 @@ done ...@@ -315,7 +317,7 @@ done
# if input is not console, get pkg from it too # if input is not console, get pkg from it too
if ! inputisatty ; then if ! inputisatty ; then
for opt in $(cat) ; do for opt in $(timeout 1 cat) ; do
check_filenames $opt check_filenames $opt
done done
fi fi
...@@ -337,6 +339,13 @@ if [ -z "$epm_cmd" ] ; then ...@@ -337,6 +339,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|autoremove|kernel_update|release_upgrade|check)
set_eatmydata
;;
esac
# Run helper for command # Run helper for command
load_helper epm-$epm_cmd load_helper epm-$epm_cmd
epm_$epm_cmd epm_$epm_cmd
......
...@@ -24,7 +24,7 @@ case $PMTYPE in ...@@ -24,7 +24,7 @@ case $PMTYPE in
assure_exists apt-repo assure_exists apt-repo
sudocmd apt-repo add $pkg_filenames sudocmd apt-repo add $pkg_filenames
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
echo "You need manually add repo to /etc/apt/sources.list" echo "You need manually add repo to /etc/apt/sources.list"
;; ;;
yum-rpm) yum-rpm)
......
#!/bin/sh
#
# Copyright (C) 2013, 2014 Etersoft
# Copyright (C) 2013, 2014 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-install
__check_command_in_path()
{
PATH=$PATH:/sbin:/usr/sbin which "$1" 2>/dev/null
}
# Do fast checking for command and install package if the command does not exist
# $1 - command name
# $2 - package name
__epm_assure()
{
if __check_command_in_path "$1" >/dev/null ; then
if [ -n "$verbose" ] ; then
local compath="$(__check_command_in_path "$1")"
echo "Command $1 is exists: $compath"
epm qf "$compath"
fi
return
fi
# TODO: use package name normalization
echo "Install appropriate package for $1 command..."
local PACKAGE="$2"
[ -n "$PACKAGE" ] || PACKAGE="$1"
#epm install $2
# copied from epm_install
local names="$(echo "$PACKAGE" | filter_out_installed_packages)"
non_interactive=1 epm_install_names $names
}
epm_assure()
{
[ -n "$pkg_filenames" ] || fatal "Run assure without params"
# use helper func for extract separate params
__epm_assure $pkg_filenames
}
...@@ -45,7 +45,7 @@ case $PMTYPE in ...@@ -45,7 +45,7 @@ case $PMTYPE in
# ALT Linux only # ALT Linux only
sudocmd remove-old-kernels sudocmd remove-old-kernels
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
sudocmd apt-get autoremove sudocmd apt-get autoremove
;; ;;
aura) aura)
......
...@@ -53,7 +53,7 @@ __epm_changelog_local_names() ...@@ -53,7 +53,7 @@ __epm_changelog_local_names()
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm) apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm --changelog" $@ | less docmd_foreach "rpm --changelog" $@ | less
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
;; ;;
emerge) emerge)
......
...@@ -31,6 +31,10 @@ case $PMTYPE in ...@@ -31,6 +31,10 @@ case $PMTYPE in
sudocmd apt-get -f install || exit sudocmd apt-get -f install || exit
sudocmd apt-get autoremove sudocmd apt-get autoremove
;; ;;
aptitude-dpkg)
sudocmd aptitude -f install || exit
#sudocmd apt-get autoremove
;;
yum-rpm) yum-rpm)
docmd yum check docmd yum check
docmd package-cleanup --problems docmd package-cleanup --problems
...@@ -52,6 +56,9 @@ case $PMTYPE in ...@@ -52,6 +56,9 @@ case $PMTYPE in
conary) conary)
sudocmd conary verify sudocmd conary verify
;; ;;
homebrew)
sudocmd brew doctor
;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
......
#!/bin/sh
#
# Copyright (C) 2014 Etersoft
# Copyright (C) 2014 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__is_repo_info_download()
{
case $PMTYPE in
apt-*)
test -r /var/cache/apt/pkgcache.bin || return
;;
*)
;;
esac
return 0
}
update_repo_if_needed()
{
if ! __is_repo_info_download ; then
load_helper epm-update
epm_update
return
fi
# TODO: if repo info is very obsoleted (a few days?), we need run update
}
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012 Etersoft # Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -23,6 +23,9 @@ case $PMTYPE in ...@@ -23,6 +23,9 @@ case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
sudocmd apt-get clean sudocmd apt-get clean
;; ;;
aptitude-dpkg)
sudocmd aptitude clean
;;
yum-rpm) yum-rpm)
sudocmd yum clean all sudocmd yum clean all
#sudocmd yum makecache #sudocmd yum makecache
......
...@@ -25,7 +25,7 @@ epm_conflicts_files() ...@@ -25,7 +25,7 @@ epm_conflicts_files()
case $(get_package_type $pkg_files) in case $(get_package_type $pkg_files) in
rpm) rpm)
docmd "rpm -q --conflicts -p" docmd "rpm -q --conflicts -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"
...@@ -77,6 +77,11 @@ case $PMTYPE in ...@@ -77,6 +77,11 @@ case $PMTYPE in
return return
fi fi
;; ;;
# TODO: why-not show who conflicts with us
#aptitude-dpkg)
# docmd aptitude why-not $pkg_names
# ;;
#emerge) #emerge)
# assure_exists equery # assure_exists equery
# CMD="equery depgraph" # CMD="equery depgraph"
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012-2013 Etersoft # Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -91,7 +91,7 @@ __epm_filelist_name() ...@@ -91,7 +91,7 @@ __epm_filelist_name()
apt-rpm) apt-rpm)
CMD="rpm -ql" CMD="rpm -ql"
;; ;;
apt-dpkg) *-dpkg)
CMD="dpkg -L" CMD="dpkg -L"
;; ;;
yum-rpm) yum-rpm)
...@@ -103,6 +103,9 @@ __epm_filelist_name() ...@@ -103,6 +103,9 @@ __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"
;; ;;
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012 Etersoft # Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -32,6 +32,9 @@ __epm_info_rpm_low() ...@@ -32,6 +32,9 @@ __epm_info_rpm_low()
# realize _files part per package, not by PMTYPE (see filelist) # realize _files part per package, not by PMTYPE (see filelist)
epm_info() epm_info()
{ {
[ -n "$pkg_filenames" ] || fatal "Run info without names"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_info_rpm_low && return __epm_info_rpm_low && return
...@@ -45,6 +48,13 @@ case $PMTYPE in ...@@ -45,6 +48,13 @@ case $PMTYPE in
is_installed $pkg_names && docmd dpkg -p $pkg_names && return is_installed $pkg_names && docmd dpkg -p $pkg_names && return
docmd apt-cache show $pkg_names docmd apt-cache show $pkg_names
;; ;;
aptitude-dpkg)
if [ -n "$pkg_files" ] ; then
docmd dpkg -I $pkg_files
fi
[ -z "$pkg_names" ] && return
docmd aptitude show $pkg_names
;;
yum-rpm) yum-rpm)
__epm_info_rpm_low && return __epm_info_rpm_low && return
docmd yum info $pkg_names docmd yum info $pkg_names
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# #
load_helper epm-query load_helper epm-query
load_helper epm-check_updated_repo
# TODO: use when run install with epm --skip-installed install # TODO: use when run install with epm --skip-installed install
filter_out_installed_packages() filter_out_installed_packages()
...@@ -93,6 +94,9 @@ epm_install_names() ...@@ -93,6 +94,9 @@ epm_install_names()
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
sudocmd apt-get $APTOPTIONS install $@ sudocmd apt-get $APTOPTIONS install $@
return ;; return ;;
aptitude-dpkg)
sudocmd aptitude install $@
return ;;
deepsolver-rpm) deepsolver-rpm)
sudocmd ds-install $@ sudocmd ds-install $@
return ;; return ;;
...@@ -134,6 +138,7 @@ epm_install_names() ...@@ -134,6 +138,7 @@ epm_install_names()
__separate_sudocmd_foreach "/usr/sbin/slackpkg install" "/usr/sbin/slackpkg upgrade" $@ __separate_sudocmd_foreach "/usr/sbin/slackpkg install" "/usr/sbin/slackpkg upgrade" $@
return ;; return ;;
homebrew) homebrew)
# FIXME: sudo and quote
__separate_sudocmd "brew install" "brew upgrade" $@ __separate_sudocmd "brew install" "brew upgrade" $@
return ;; return ;;
ipkg) ipkg)
...@@ -146,6 +151,9 @@ epm_install_names() ...@@ -146,6 +151,9 @@ epm_install_names()
guix) guix)
__separate_sudocmd "guix package -i" "guix package -i" $@ __separate_sudocmd "guix package -i" "guix package -i" $@
return ;; return ;;
android)
warning "We have no idea how to use package repository, ever if it is F-Droid."
return ;;
*) *)
fatal "Have no suitable install command for $PMTYPE" fatal "Have no suitable install command for $PMTYPE"
;; ;;
...@@ -161,6 +169,9 @@ epm_ni_install_names() ...@@ -161,6 +169,9 @@ epm_ni_install_names()
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
sudocmd apt-get -y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@ sudocmd apt-get -y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@
return ;; return ;;
aptitude-dpkg)
sudocmd aptitde -y install $@
return ;;
yum-rpm) yum-rpm)
sudocmd yum -y $YUMOPTIONS install $@ sudocmd yum -y $YUMOPTIONS install $@
return ;; return ;;
...@@ -196,6 +207,9 @@ epm_ni_install_names() ...@@ -196,6 +207,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" $@
...@@ -229,7 +243,7 @@ epm_install_files() ...@@ -229,7 +243,7 @@ epm_install_files()
# use install_names # use install_names
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
# the new version of the conf. file is installed with a .dpkg-dist suffix # the new version of the conf. file is installed with a .dpkg-dist suffix
if [ -n "$non_interactive" ] ; then if [ -n "$non_interactive" ] ; then
DPKGOPTIONS="--force-confdef --force-confold" DPKGOPTIONS="--force-confdef --force-confold"
...@@ -285,6 +299,9 @@ epm_install_files() ...@@ -285,6 +299,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 $@
...@@ -313,7 +330,7 @@ epm_print_install_command() ...@@ -313,7 +330,7 @@ epm_print_install_command()
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm) apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $@" echo "rpm -Uvh --force $nodeps $@"
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
echo "dpkg -i $@" echo "dpkg -i $@"
;; ;;
pkgsrc) pkgsrc)
...@@ -335,6 +352,9 @@ epm_print_install_command() ...@@ -335,6 +352,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"
;; ;;
...@@ -356,6 +376,9 @@ epm_install() ...@@ -356,6 +376,9 @@ epm_install()
[ -z "$files$names" ] && echo "Skip empty install list" && return 22 [ -z "$files$names" ] && echo "Skip empty install list" && return 22
# it is useful for first time running
update_repo_if_needed
epm_install_names $names || return epm_install_names $names || return
epm_install_files $files epm_install_files $files
} }
...@@ -43,7 +43,7 @@ case $PMTYPE in ...@@ -43,7 +43,7 @@ case $PMTYPE in
CMD="rpm -qa $pkg_filenames" CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames" [ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
;; ;;
apt-dpkg) *-dpkg)
#CMD="dpkg -l $pkg_filenames" #CMD="dpkg -l $pkg_filenames"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n $pkg_filenames" CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n $pkg_filenames"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n $pkg_filenames" [ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n $pkg_filenames"
...@@ -96,6 +96,11 @@ case $PMTYPE in ...@@ -96,6 +96,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"
;; ;;
......
...@@ -25,7 +25,7 @@ epm_programs() ...@@ -25,7 +25,7 @@ epm_programs()
local DESKTOPDIR=/usr/share/applications local DESKTOPDIR=/usr/share/applications
[ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system." [ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system."
#find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u #find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u
showcmd "find /usr/share/applications -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u" showcmd "find $DESKTOPDIR -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u"
find /usr/share/applications -type f -name "*.desktop" | \ find /usr/share/applications -type f -name "*.desktop" | \
xargs $0 -qf --quiet --short | sort -u xargs $0 -qf --quiet --short | sort -u
} }
...@@ -73,12 +73,14 @@ case $PMTYPE in ...@@ -73,12 +73,14 @@ case $PMTYPE in
apt-dpkg) apt-dpkg)
# FIXME: need fix for a few names case # FIXME: need fix for a few names case
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
CMD="rpm -q --provides" echo "Please inform the author how to get provides from dpkg"
else fi
# CMD="rpm -q --provides"
#else
EXTRA_SHOWDOCMD=' | grep "Provides:"' EXTRA_SHOWDOCMD=' | grep "Provides:"'
docmd apt-cache show $pkg_names | grep "Provides:" docmd apt-cache show $pkg_names | grep "Provides:"
return return
fi #fi
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
......
...@@ -107,7 +107,7 @@ __epm_query_file() ...@@ -107,7 +107,7 @@ __epm_query_file()
CMD="rpm -qp" CMD="rpm -qp"
[ -n "$short" ] && CMD="rpm -qp --queryformat %{name}\n" [ -n "$short" ] && CMD="rpm -qp --queryformat %{name}\n"
;; ;;
apt-dpkg) *-dpkg)
CMD="dpkg-deb --show --showformat=\${Package}-\${Version}\n" CMD="dpkg-deb --show --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query --show --showformat=\${Package}\n" [ -n "$short" ] && CMD="dpkg-query --show --showformat=\${Package}\n"
;; ;;
...@@ -130,7 +130,7 @@ __epm_query_name() ...@@ -130,7 +130,7 @@ __epm_query_name()
CMD="rpm -q" CMD="rpm -q"
[ -n "$short" ] && CMD="rpm -q --queryformat %{name}\n" [ -n "$short" ] && CMD="rpm -q --queryformat %{name}\n"
;; ;;
apt-dpkg) *-dpkg)
#docmd dpkg -l $@ | grep "^ii" #docmd dpkg -l $@ | grep "^ii"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n" CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n" [ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n"
......
...@@ -68,7 +68,7 @@ __do_query() ...@@ -68,7 +68,7 @@ __do_query()
apt-rpm) apt-rpm)
CMD="rpm -qf" CMD="rpm -qf"
;; ;;
apt-dpkg) *-dpkg)
showcmd dpkg -S $1 showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||") dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")
return ;; return ;;
...@@ -152,7 +152,7 @@ epm_query_file() ...@@ -152,7 +152,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
} }
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012 Etersoft # Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -27,6 +27,9 @@ epm_reinstall_names() ...@@ -27,6 +27,9 @@ epm_reinstall_names()
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
sudocmd apt-get --reinstall install $@ sudocmd apt-get --reinstall install $@
return ;; return ;;
aptitude-dpkg)
sudocmd aptitude reinstall $@
return ;;
dnf-rpm) dnf-rpm)
sudocmd dnf reinstall $@ sudocmd dnf reinstall $@
return ;; return ;;
...@@ -48,7 +51,7 @@ epm_reinstall_files() ...@@ -48,7 +51,7 @@ epm_reinstall_files()
sudocmd rpm -Uvh --force $@ && return sudocmd rpm -Uvh --force $@ && return
sudocmd apt-get --reinstall install $@ sudocmd apt-get --reinstall install $@
return ;; return ;;
apt-pkg) apt-dpkg|aptitude-dpkg)
sudocmd dpkg -i $@ sudocmd dpkg -i $@
return ;; return ;;
slackpkg) slackpkg)
......
...@@ -30,7 +30,7 @@ epm_release_upgrade() ...@@ -30,7 +30,7 @@ epm_release_upgrade()
docmd epm Upgrade docmd epm Upgrade
docmd epm update-kernel docmd epm update-kernel
;; ;;
apt-dpkg) *-dpkg)
sudocmd do-release-upgrade -d sudocmd do-release-upgrade -d
;; ;;
yum-rpm) yum-rpm)
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012, 2013 Etersoft # Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -27,7 +27,7 @@ epm_remove_low() ...@@ -27,7 +27,7 @@ epm_remove_low()
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm) apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
sudocmd rpm -ev $nodeps $@ sudocmd rpm -ev $nodeps $@
return ;; return ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
sudocmd dpkg -P $(subst_option nodeps --force-all) $@ sudocmd dpkg -P $(subst_option nodeps --force-all) $@
return ;; return ;;
pkgsrc) pkgsrc)
...@@ -54,6 +54,9 @@ epm_remove_names() ...@@ -54,6 +54,9 @@ epm_remove_names()
apt-dpkg) apt-dpkg)
sudocmd apt-get remove --purge $@ sudocmd apt-get remove --purge $@
return ;; return ;;
aptitude-dpkg)
sudocmd aptitude purge $@
return ;;
apt-rpm) apt-rpm)
sudocmd apt-get remove $@ sudocmd apt-get remove $@
return ;; return ;;
...@@ -97,6 +100,9 @@ epm_remove_names() ...@@ -97,6 +100,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 ;;
...@@ -122,6 +128,9 @@ epm_remove_nonint() ...@@ -122,6 +128,9 @@ epm_remove_nonint()
apt-dpkg) apt-dpkg)
sudocmd apt-get -y --force-yes remove --purge $@ sudocmd apt-get -y --force-yes remove --purge $@
return ;; return ;;
aptitude-dpkg)
sudocmd aptitude -y purge $@
return ;;
apt-rpm) apt-rpm)
sudocmd apt-get -y --force-yes remove $@ sudocmd apt-get -y --force-yes remove $@
return ;; return ;;
...@@ -153,7 +162,7 @@ epm_print_remove_command() ...@@ -153,7 +162,7 @@ epm_print_remove_command()
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm) apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@" echo "rpm -ev $nodeps $@"
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
echo "dpkg -P $@" echo "dpkg -P $@"
;; ;;
pkgsrc) pkgsrc)
......
...@@ -24,7 +24,7 @@ case $PMTYPE in ...@@ -24,7 +24,7 @@ case $PMTYPE in
assure_exists apt-repo assure_exists apt-repo
sudocmd apt-repo rm $pkg_filenames sudocmd apt-repo rm $pkg_filenames
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
echo "You need remove repo from /etc/apt/sources.list" echo "You need remove repo from /etc/apt/sources.list"
;; ;;
yum-rpm) yum-rpm)
......
...@@ -38,7 +38,7 @@ case $PMTYPE in ...@@ -38,7 +38,7 @@ case $PMTYPE in
deepsolver-rpm) deepsolver-rpm)
docmd ds-conf docmd ds-conf
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
showcmd cat /etc/apt/sources.list* showcmd cat /etc/apt/sources.list*
print_apt_sources_list /etc/apt/sources.list /etc/apt/sources.list.d/*.list print_apt_sources_list /etc/apt/sources.list /etc/apt/sources.list.d/*.list
;; ;;
......
...@@ -66,7 +66,7 @@ case $PMTYPE in ...@@ -66,7 +66,7 @@ case $PMTYPE in
pacman) pacman)
CMD="pactree" CMD="pactree"
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
# FIXME: need fix for a few names case # FIXME: need fix for a few names case
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
showcmd dpkg -s $pkg_names showcmd dpkg -s $pkg_names
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012 Etersoft # Copyright (C) 2012,2013 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012,2013 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
load_helper epm-check_updated_repo
__epm_search_output() __epm_search_output()
{ {
local CMD local CMD
...@@ -25,8 +27,15 @@ case $PMTYPE in ...@@ -25,8 +27,15 @@ case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
CMD="apt-cache search --" CMD="apt-cache search --"
;; ;;
aptitude-dpkg)
CMD="aptitude search --"
;;
deepsolver-rpm)
CMD="ds-require --"
;;
urpm-rpm) urpm-rpm)
CMD="urpmq -y --" # urpmq does not support --
CMD="urpmq -y"
;; ;;
pkgsrc) pkgsrc)
CMD="pkg_info -x --" CMD="pkg_info -x --"
...@@ -65,7 +74,7 @@ case $PMTYPE in ...@@ -65,7 +74,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"
...@@ -73,6 +82,9 @@ case $PMTYPE in ...@@ -73,6 +82,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"
;; ;;
...@@ -104,24 +116,31 @@ __epm_search_make_grep() ...@@ -104,24 +116,31 @@ __epm_search_make_grep()
#list=$(strip_spaces $list | sed -e "s/ /|/g") #list=$(strip_spaces $list | sed -e "s/ /|/g")
listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g") listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g")
[ -n "$listN" ] && echo -n " | egrep -i -v -- \"$listN\"" [ -n "$listN" ] && echon " | egrep -i -v -- \"$listN\""
# FIXME: The World has not idea how to do grep both string # FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1 # http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for i in $list ; do for i in $list ; do
# FIXME -n on MacOS? # FIXME -n on MacOS?
echo -n " | egrep -i -- \"$i\"" echon " | egrep -i -- \"$i\""
done done
if [ "$short" ] ; then
echon " | 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
[ -n "$COLO" ] && COLO="$COLO|" [ -n "$COLO" ] && COLO="$COLO|"
COLO="$COLO$i" COLO="$COLO$i"
done done
# FIXME -n on MacOS?
if [ -n "$list" ] ; then if [ -n "$list" ] ; then
echo -n " | egrep -i --color -- \"($COLO)\"" echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi fi
} }
...@@ -130,6 +149,10 @@ __epm_search_make_grep() ...@@ -130,6 +149,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"
# it is useful for first time running
update_repo_if_needed
# FIXME: do it better # FIXME: do it better
local MGS local MGS
MGS=$(eval __epm_search_make_grep $quoted_args) MGS=$(eval __epm_search_make_grep $quoted_args)
......
...@@ -49,7 +49,7 @@ case $PMTYPE in ...@@ -49,7 +49,7 @@ case $PMTYPE in
apt-rpm) apt-rpm)
local_content_search $pkg_filenames local_content_search $pkg_filenames
return ;; return ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
assure_exists apt-file assure_exists apt-file
sudocmd apt-file update sudocmd apt-file update
docmd apt-file search $pkg_filenames docmd apt-file search $pkg_filenames
......
...@@ -19,10 +19,11 @@ ...@@ -19,10 +19,11 @@
# copied from /etc/init.d/outformat (ALT Linux) # copied from /etc/init.d/outformat (ALT Linux)
# FIXME on Android: FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:366
inputisatty() inputisatty()
{ {
# check stdin # check stdin
tty -s tty -s 2>/dev/null
} }
isatty() isatty()
...@@ -45,6 +46,12 @@ check_tty() ...@@ -45,6 +46,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
...@@ -74,10 +81,18 @@ restore_color() ...@@ -74,10 +81,18 @@ restore_color()
echover() echover()
{ {
[ -n "$verbose" ] || return [ -z "$verbose" ] && return
echo "$*" >&2 echo "$*" >&2
} }
# echo string without EOL
echon()
{
# default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@"
}
# Used DISTRNAME # Used DISTRNAME
set_target_pkg_env() set_target_pkg_env()
{ {
...@@ -109,18 +124,19 @@ showcmd() ...@@ -109,18 +124,19 @@ showcmd()
docmd() docmd()
{ {
showcmd "$@$EXTRA_SHOWDOCMD" showcmd "$@$EXTRA_SHOWDOCMD"
"$@" #FIXME
$@
} }
# Run every arg with docmd # Run every arg with docmd
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
} }
...@@ -128,31 +144,31 @@ docmd_foreach() ...@@ -128,31 +144,31 @@ docmd_foreach()
sudocmd() sudocmd()
{ {
showcmd "$SUDO $@" showcmd "$SUDO $@"
$SUDO "$@" $SUDO $@
} }
# Run every arg with sudocmd # Run every arg with sudocmd
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"
} }
...@@ -182,7 +198,7 @@ store_output() ...@@ -182,7 +198,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
...@@ -194,7 +210,7 @@ clean_store_output() ...@@ -194,7 +210,7 @@ clean_store_output()
rm -f $RC_STDOUT $RC_STDOUT.pipestatus rm -f $RC_STDOUT $RC_STDOUT.pipestatus
} }
# run epm, possible from side repo
epm() epm()
{ {
$PROGDIR/epm $@ $PROGDIR/epm $@
...@@ -324,15 +340,16 @@ if [ -n "$FORCEPM" ] ; then ...@@ -324,15 +340,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"
...@@ -348,6 +365,7 @@ case $DISTRNAME in ...@@ -348,6 +365,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"
...@@ -370,6 +388,9 @@ case $DISTRNAME in ...@@ -370,6 +388,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"
;; ;;
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012-2013 Etersoft # Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -62,6 +62,9 @@ _epm_do_simulate() ...@@ -62,6 +62,9 @@ _epm_do_simulate()
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
CMD="apt-get --simulate install" CMD="apt-get --simulate install"
;; ;;
aptitude-dpkg)
CMD="aptitude -s install"
;;
yum-rpm) yum-rpm)
if __use_yum_assumeno ; then if __use_yum_assumeno ; then
LC_ALL=C store_output sudocmd yum --assumeno install $filenames LC_ALL=C store_output sudocmd yum --assumeno install $filenames
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012 Etersoft # Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -33,6 +33,9 @@ case $PMTYPE in ...@@ -33,6 +33,9 @@ case $PMTYPE in
#sudocmd apt-get -f install || exit #sudocmd apt-get -f install || exit
#sudocmd apt-get autoremove #sudocmd apt-get autoremove
;; ;;
aptitude-dpkg)
sudocmd aptitude update || exit
;;
yum-rpm) yum-rpm)
sudocmd yum check-update sudocmd yum check-update
;; ;;
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012 Etersoft # Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU Affero General Public License as published by
...@@ -17,9 +17,15 @@ ...@@ -17,9 +17,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
load_helper epm-check_updated_repo
epm_upgrade() epm_upgrade()
{ {
local CMD local CMD
# it is useful for first time running
update_repo_if_needed
echo "Run command for upgrade packages" echo "Run command for upgrade packages"
case $PMTYPE in case $PMTYPE in
...@@ -28,6 +34,9 @@ epm_upgrade() ...@@ -28,6 +34,9 @@ epm_upgrade()
# Функцию добавления параметра при условии # Функцию добавления параметра при условии
CMD="apt-get dist-upgrade" CMD="apt-get dist-upgrade"
;; ;;
aptitude-dpkg)
CMD="aptitude dist-upgrade"
;;
yum-rpm) yum-rpm)
# can do update repobase automagically # can do update repobase automagically
CMD="yum update" CMD="yum update"
......
...@@ -27,9 +27,12 @@ case $PMTYPE in ...@@ -27,9 +27,12 @@ case $PMTYPE in
apt-rpm) apt-rpm)
CMD="apt-cache whatdepends" CMD="apt-cache whatdepends"
;; ;;
apt-dpkg) apt-dpkg|aptitude-dpkg)
CMD="apt-cache rdepends" CMD="apt-cache rdepends"
;; ;;
aptitude-dpkg)
CMD="aptitude why"
;;
yum-rpm) yum-rpm)
CMD="repoquery --whatrequires" CMD="repoquery --whatrequires"
;; ;;
......
...@@ -27,7 +27,7 @@ case $PMTYPE in ...@@ -27,7 +27,7 @@ case $PMTYPE in
conary) conary)
CMD="conary repquery --what-provides" CMD="conary repquery --what-provides"
;; ;;
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg|aptitude-dpkg)
LANG=C docmd apt-get install --print-uris $pkg_filenames | grep "^Selecting" | cut -f2 -d" " LANG=C docmd apt-get install --print-uris $pkg_filenames | grep "^Selecting" | cut -f2 -d" "
return return
;; ;;
......
#!/bin/sh
# http://mywiki.wooledge.org/Bashism
# https://wiki.ubuntu.com/DashAsBinSh
checkbashisms -f bin/*
checkbashisms -f Makefile eepm.spec
# This spec is backported to ALTLinux p7 automatically by rpmbph script. Do not edit it. # This spec is backported to ALTLinux p7 automatically by rpmbph script. Do not edit it.
# #
Name: eepm Name: eepm
Version: 1.4.5 Version: 1.5.0
Release: alt0.M70P.1 Release: alt0.M70P.1
Summary: Etersoft EPM package manager Summary: Etersoft EPM package manager
...@@ -22,7 +22,10 @@ Conflicts: epm ...@@ -22,7 +22,10 @@ Conflicts: epm
Provides: upm Provides: upm
%if %_vendor == "alt"
# FIXHERE: Replace with target platform package manager
Requires: apt rpm Requires: apt rpm
%endif
%description %description
Etersoft EPM is the package manager for any platform Etersoft EPM is the package manager for any platform
...@@ -63,9 +66,26 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}* ...@@ -63,9 +66,26 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv %_sysconfdir/bash_completion.d/cerv
%changelog %changelog
* Tue Oct 29 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.5-alt0.M70P.1 * Wed Feb 26 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.0-alt0.M70P.1
- backport to ALTLinux p7 (by rpmbph script) - backport to ALTLinux p7 (by rpmbph script)
* Wed Feb 26 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.0-alt1
- distr_info: add Android detection
- add initial android support
- epm: use eatmydata on kernel update
- workaround for infinity wait in cat
- add aptitude support
- get repo info for first time
- add epm assure for check if command is exists
- epm: fix commands, helps, eatmydata using
* Tue Jan 28 2014 Vitaly Lipatov <lav@altlinux.ru> 1.4.6-alt1
- drop apt/rpm requires for non ALT distro
- epm-query_file: do search_file with full path if exists
- print about eatmydata only for u/i/r
- epm-search: add support --short option
- epm-search: remove unsupported --
* Tue Oct 29 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.5-alt1 * Tue Oct 29 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.5-alt1
- epm: check for -- after options - epm: check for -- after options
- fix bashisms - fix bashisms
......
...@@ -33,17 +33,39 @@ load_helper() ...@@ -33,17 +33,39 @@ load_helper()
# File bin/epm-sh-functions: # File bin/epm-sh-functions:
inputisatty()
{
# check stdin
tty -s 2>/dev/null
}
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
# 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
...@@ -73,10 +95,17 @@ restore_color() ...@@ -73,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"
...@@ -104,47 +133,47 @@ showcmd() ...@@ -104,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"
} }
...@@ -173,7 +202,7 @@ store_output() ...@@ -173,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
...@@ -185,7 +214,6 @@ clean_store_output() ...@@ -185,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 $@
...@@ -230,7 +258,8 @@ set_eatmydata() ...@@ -230,7 +258,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()
...@@ -304,15 +333,16 @@ if [ -n "$FORCEPM" ] ; then ...@@ -304,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"
...@@ -328,6 +358,7 @@ case $DISTRNAME in ...@@ -328,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"
...@@ -350,6 +381,9 @@ case $DISTRNAME in ...@@ -350,6 +381,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 +744,7 @@ pkgtype() ...@@ -710,6 +744,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 +942,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then ...@@ -907,6 +942,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 +1092,7 @@ $(get_help HELPOPT) ...@@ -1052,7 +1092,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.4.2" 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."
......
#!/bin/sh
run_command()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
RC_STDERR=$(mktemp)
$1 >$RC_STDOUT 2>$RC_STDERR
}
func()
{
echo STDERR >&2
echo STDOUT
}
run_command func
cat $RC_STDOUT
cat $RC_STDERR
rm -f $RC_STDOUT $RC_STDERR
#!/bin/sh
run_command()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
#RC_STDERR=$(mktemp)
$1 2>&1 | tee $RC_STDOUT
}
func()
{
echo STDERR >&2
echo STDOUT
}
run_command func
cat $RC_STDOUT
#cat $RC_STDERR
rm -f $RC_STDOUT $RC_STDERR
#!/bin/sh
store_output()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
local CMDSTATUS=$RC_STDOUT.pipestatus
echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp)
( "$@" 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
#return $PIPESTATUS
}
clean_store_output()
{
rm -f $RC_STDOUT $RC_STDOUT.pipestatus
}
store_output epmq mc
echo $?
cat $RC_STDOUT
ls -l $RC_STDOUT
store_output epmq mc1
echo $?
cat $RC_STDOUT
ls -l $RC_STDOUT
# param true false
subst_option()
{
eval "[ -n \"\$$1\" ]" && echo "$2" || echo "$3"
}
test1=1
test0=
echo $(subst_option test1 TRUE)
echo $(subst_option test1 TRUE FALSE)
echo $(subst_option test1 "" FALSE)
echo $(subst_option test0 "" FALSE)
echo $(subst_option test0 TRUE)
#!/bin/sh
SUDO=
#sudofunc
sudofunc()
{
echo "arg1: $1"
echo "arg2: $2"
echo "arg3: $3"
echo "arg4: $4"
}
# fake
showcmd()
{
echo "$@"
}
# Print command line and run command line with SUDO
sudocmd()
{
showcmd "$SUDO $@"
#FIXME
$SUDO $@
}
sudocmd "ls -l" "-a -a"
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