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. Дописать таблицу на вики на основании реализованных команд.
3. Доделать и проверить deplist|requires
......
......@@ -50,6 +50,7 @@ pkgtype()
archlinux) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;;
......@@ -247,6 +248,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix"
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
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB
......
#!/bin/sh
#
# Copyright (C) 2012, 2013 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-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
......@@ -37,7 +37,6 @@ load_helper epm-sh-functions
#PATH=$PATH:/sbin:/usr/sbin
set_sudo
set_eatmydata
check_tty
......@@ -59,7 +58,7 @@ print_version()
{
echo "EPM package manager version @VERSION@"
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."
}
......@@ -149,7 +148,7 @@ check_command()
-qp|qp|query_package) # HELPCMD: search in the list of installed packages
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
;;
......@@ -178,10 +177,10 @@ check_command()
-qi|qi|info|show) # HELPCMD: print package detail info
epm_cmd=info
;;
requires|deplist) # HELPCMD: print package requires
requires|deplist|req) # HELPCMD: print package requires
epm_cmd=requires
;;
provides) # HELPCMD: print package provides
provides|prov) # HELPCMD: print package provides
epm_cmd=provides
;;
whatdepends) # HELPCMD: print packages dependences on that
......@@ -193,12 +192,15 @@ check_command()
conflicts) # HELPCMD: print package 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
;;
programs) # HELPCMD: list of installed GUI program(s)
programs) # HELPCMD: print list of installed GUI program(s)
epm_cmd=programs
;;
assure) # HELPCMD: <command> [package]: install package if command does not exists
epm_cmd=assure
;;
# Repository control
update) # HELPCMD: update remote package repository databases
......@@ -230,13 +232,13 @@ check_command()
upgrade|dist-upgrade) # HELPCMD: performs upgrades of package software distributions
epm_cmd=upgrade
;;
Upgrade) # HELPCMD: performs update && upgrade command
Upgrade) # HELPCMD: force update package base, then run upgrade
epm_cmd=Upgrade
;;
simulate) # HELPCMD: simulate install (it does check requires, minimally)
simulate) # HELPCMD: simulate install with check requires
epm_cmd=simulate
;;
checkpkg|integrity) # HELPCMD: check package integrity
checkpkg|integrity) # HELPCMD: check package file integrity (checksum)
epm_cmd=checkpkg
;;
......@@ -261,7 +263,7 @@ check_option()
--verbose) # HELPOPT: verbose mode
verbose=1
;;
--skip-installed) # HELPOPT: skip already install during install
--skip-installed) # HELPOPT: skip already installed packages during install
skip_installed=1
;;
--show-command-only) # HELPOPT: show command only, do not any action (supports install and remove ONLY)
......@@ -315,7 +317,7 @@ done
# if input is not console, get pkg from it too
if ! inputisatty ; then
for opt in $(cat) ; do
for opt in $(timeout 1 cat) ; do
check_filenames $opt
done
fi
......@@ -337,6 +339,13 @@ if [ -z "$epm_cmd" ] ; then
fatal "Run $ $progname --help for get help"
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
load_helper epm-$epm_cmd
epm_$epm_cmd
......
......@@ -24,7 +24,7 @@ case $PMTYPE in
assure_exists apt-repo
sudocmd apt-repo add $pkg_filenames
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
echo "You need manually add repo to /etc/apt/sources.list"
;;
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
# ALT Linux only
sudocmd remove-old-kernels
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
sudocmd apt-get autoremove
;;
aura)
......
......@@ -53,7 +53,7 @@ __epm_changelog_local_names()
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm --changelog" $@ | less
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
;;
emerge)
......
......@@ -31,6 +31,10 @@ case $PMTYPE in
sudocmd apt-get -f install || exit
sudocmd apt-get autoremove
;;
aptitude-dpkg)
sudocmd aptitude -f install || exit
#sudocmd apt-get autoremove
;;
yum-rpm)
docmd yum check
docmd package-cleanup --problems
......@@ -52,6 +56,9 @@ case $PMTYPE in
conary)
sudocmd conary verify
;;
homebrew)
sudocmd brew doctor
;;
*)
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
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,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
......@@ -23,6 +23,9 @@ case $PMTYPE in
apt-rpm|apt-dpkg)
sudocmd apt-get clean
;;
aptitude-dpkg)
sudocmd aptitude clean
;;
yum-rpm)
sudocmd yum clean all
#sudocmd yum makecache
......
......@@ -25,7 +25,7 @@ epm_conflicts_files()
case $(get_package_type $pkg_files) in
rpm)
docmd "rpm -q --conflicts -p"
docmd "rpm -q --conflicts -p" $pkg_files
;;
#deb)
# a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
......@@ -77,6 +77,11 @@ case $PMTYPE in
return
fi
;;
# TODO: why-not show who conflicts with us
#aptitude-dpkg)
# docmd aptitude why-not $pkg_names
# ;;
#emerge)
# assure_exists equery
# CMD="equery depgraph"
......
#!/bin/sh
#
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-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
......@@ -91,7 +91,7 @@ __epm_filelist_name()
apt-rpm)
CMD="rpm -ql"
;;
apt-dpkg)
*-dpkg)
CMD="dpkg -L"
;;
yum-rpm)
......@@ -103,6 +103,9 @@ __epm_filelist_name()
zypper-rpm)
CMD="rpm -ql"
;;
android)
CMD="pm list packages -f"
;;
conary)
CMD="conary query --ls"
;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,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
......@@ -32,6 +32,9 @@ __epm_info_rpm_low()
# realize _files part per package, not by PMTYPE (see filelist)
epm_info()
{
[ -n "$pkg_filenames" ] || fatal "Run info without names"
case $PMTYPE in
apt-rpm)
__epm_info_rpm_low && return
......@@ -45,6 +48,13 @@ case $PMTYPE in
is_installed $pkg_names && docmd dpkg -p $pkg_names && return
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)
__epm_info_rpm_low && return
docmd yum info $pkg_names
......
......@@ -18,6 +18,7 @@
#
load_helper epm-query
load_helper epm-check_updated_repo
# TODO: use when run install with epm --skip-installed install
filter_out_installed_packages()
......@@ -93,6 +94,9 @@ epm_install_names()
apt-rpm|apt-dpkg)
sudocmd apt-get $APTOPTIONS install $@
return ;;
aptitude-dpkg)
sudocmd aptitude install $@
return ;;
deepsolver-rpm)
sudocmd ds-install $@
return ;;
......@@ -134,6 +138,7 @@ epm_install_names()
__separate_sudocmd_foreach "/usr/sbin/slackpkg install" "/usr/sbin/slackpkg upgrade" $@
return ;;
homebrew)
# FIXME: sudo and quote
__separate_sudocmd "brew install" "brew upgrade" $@
return ;;
ipkg)
......@@ -146,6 +151,9 @@ epm_install_names()
guix)
__separate_sudocmd "guix package -i" "guix package -i" $@
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"
;;
......@@ -161,6 +169,9 @@ epm_ni_install_names()
export DEBIAN_FRONTEND=noninteractive
sudocmd apt-get -y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@
return ;;
aptitude-dpkg)
sudocmd aptitde -y install $@
return ;;
yum-rpm)
sudocmd yum -y $YUMOPTIONS install $@
return ;;
......@@ -196,6 +207,9 @@ epm_ni_install_names()
nix)
sudocmd nix-env --install $@
return ;;
#android)
# sudocmd pm install $@
# return ;;
slackpkg)
# 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" $@
......@@ -229,7 +243,7 @@ epm_install_files()
# use install_names
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
# the new version of the conf. file is installed with a .dpkg-dist suffix
if [ -n "$non_interactive" ] ; then
DPKGOPTIONS="--force-confdef --force-confold"
......@@ -285,6 +299,9 @@ epm_install_files()
pkgsrc)
sudocmd pkg_add $@
return ;;
android)
sudocmd pm install $@
return ;;
emerge)
load_helper epm-install-emerge
sudocmd epm_install_emerge $@
......@@ -313,7 +330,7 @@ epm_print_install_command()
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $@"
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
echo "dpkg -i $@"
;;
pkgsrc)
......@@ -335,6 +352,9 @@ epm_print_install_command()
ipkg)
echo "ipkg install $@"
;;
android)
echo "pm install $@"
;;
*)
fatal "Have no suitable appropriate install command for $PMTYPE"
;;
......@@ -356,6 +376,9 @@ epm_install()
[ -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_files $files
}
......@@ -43,7 +43,7 @@ case $PMTYPE in
CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
;;
apt-dpkg)
*-dpkg)
#CMD="dpkg -l $pkg_filenames"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n $pkg_filenames"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n $pkg_filenames"
......@@ -96,6 +96,11 @@ case $PMTYPE in
guix)
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"
;;
......
......@@ -25,7 +25,7 @@ epm_programs()
local DESKTOPDIR=/usr/share/applications
[ -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
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" | \
xargs $0 -qf --quiet --short | sort -u
}
......@@ -73,12 +73,14 @@ case $PMTYPE in
apt-dpkg)
# FIXME: need fix for a few names case
if is_installed $pkg_names ; then
CMD="rpm -q --provides"
else
echo "Please inform the author how to get provides from dpkg"
fi
# CMD="rpm -q --provides"
#else
EXTRA_SHOWDOCMD=' | grep "Provides:"'
docmd apt-cache show $pkg_names | grep "Provides:"
return
fi
#fi
;;
*)
fatal "Have no suitable command for $PMTYPE"
......
......@@ -107,7 +107,7 @@ __epm_query_file()
CMD="rpm -qp"
[ -n "$short" ] && CMD="rpm -qp --queryformat %{name}\n"
;;
apt-dpkg)
*-dpkg)
CMD="dpkg-deb --show --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query --show --showformat=\${Package}\n"
;;
......@@ -130,7 +130,7 @@ __epm_query_name()
CMD="rpm -q"
[ -n "$short" ] && CMD="rpm -q --queryformat %{name}\n"
;;
apt-dpkg)
*-dpkg)
#docmd dpkg -l $@ | grep "^ii"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n"
......
......@@ -68,7 +68,7 @@ __do_query()
apt-rpm)
CMD="rpm -qf"
;;
apt-dpkg)
*-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")
return ;;
......@@ -152,7 +152,7 @@ epm_query_file()
for pkg in $pkg_filenames ; do
__do_query_real_file "$pkg"
__do_query $FULLFILEPATH || pkg_filenames=$pkg epm_search_file
__do_query $FULLFILEPATH || pkg_filenames=$FULLFILEPATH epm_search_file
done
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,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
......@@ -27,6 +27,9 @@ epm_reinstall_names()
apt-rpm|apt-dpkg)
sudocmd apt-get --reinstall install $@
return ;;
aptitude-dpkg)
sudocmd aptitude reinstall $@
return ;;
dnf-rpm)
sudocmd dnf reinstall $@
return ;;
......@@ -48,7 +51,7 @@ epm_reinstall_files()
sudocmd rpm -Uvh --force $@ && return
sudocmd apt-get --reinstall install $@
return ;;
apt-pkg)
apt-dpkg|aptitude-dpkg)
sudocmd dpkg -i $@
return ;;
slackpkg)
......
......@@ -30,7 +30,7 @@ epm_release_upgrade()
docmd epm Upgrade
docmd epm update-kernel
;;
apt-dpkg)
*-dpkg)
sudocmd do-release-upgrade -d
;;
yum-rpm)
......
#!/bin/sh
#
# Copyright (C) 2012, 2013 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-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
......@@ -27,7 +27,7 @@ epm_remove_low()
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
sudocmd rpm -ev $nodeps $@
return ;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
sudocmd dpkg -P $(subst_option nodeps --force-all) $@
return ;;
pkgsrc)
......@@ -54,6 +54,9 @@ epm_remove_names()
apt-dpkg)
sudocmd apt-get remove --purge $@
return ;;
aptitude-dpkg)
sudocmd aptitude purge $@
return ;;
apt-rpm)
sudocmd apt-get remove $@
return ;;
......@@ -97,6 +100,9 @@ epm_remove_names()
guix)
sudocmd guix package -r $@
return ;;
android)
sudocmd pm uninstall $@
return ;;
chocolatey)
sudocmd chocolatey uninstall $@
return ;;
......@@ -122,6 +128,9 @@ epm_remove_nonint()
apt-dpkg)
sudocmd apt-get -y --force-yes remove --purge $@
return ;;
aptitude-dpkg)
sudocmd aptitude -y purge $@
return ;;
apt-rpm)
sudocmd apt-get -y --force-yes remove $@
return ;;
......@@ -153,7 +162,7 @@ epm_print_remove_command()
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@"
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
echo "dpkg -P $@"
;;
pkgsrc)
......
......@@ -24,7 +24,7 @@ case $PMTYPE in
assure_exists apt-repo
sudocmd apt-repo rm $pkg_filenames
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
echo "You need remove repo from /etc/apt/sources.list"
;;
yum-rpm)
......
......@@ -38,7 +38,7 @@ case $PMTYPE in
deepsolver-rpm)
docmd ds-conf
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
showcmd cat /etc/apt/sources.list*
print_apt_sources_list /etc/apt/sources.list /etc/apt/sources.list.d/*.list
;;
......
......@@ -66,7 +66,7 @@ case $PMTYPE in
pacman)
CMD="pactree"
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
# FIXME: need fix for a few names case
if is_installed $pkg_names ; then
showcmd dpkg -s $pkg_names
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2013 Etersoft
# Copyright (C) 2012,2013 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
......@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
__epm_search_output()
{
local CMD
......@@ -25,8 +27,15 @@ case $PMTYPE in
apt-rpm|apt-dpkg)
CMD="apt-cache search --"
;;
aptitude-dpkg)
CMD="aptitude search --"
;;
deepsolver-rpm)
CMD="ds-require --"
;;
urpm-rpm)
CMD="urpmq -y --"
# urpmq does not support --
CMD="urpmq -y"
;;
pkgsrc)
CMD="pkg_info -x --"
......@@ -65,7 +74,7 @@ case $PMTYPE in
slackpkg)
# FIXME
echo "Note: case sensitive search"
CMD="/usr/sbin/slackpkg search --"
CMD="/usr/sbin/slackpkg search"
;;
homebrew)
CMD="brew search"
......@@ -73,6 +82,9 @@ case $PMTYPE in
guix)
CMD="guix package -A"
;;
android)
CMD="pm list packages"
;;
*)
fatal "Have no suitable search command for $PMTYPE"
;;
......@@ -104,24 +116,31 @@ __epm_search_make_grep()
#list=$(strip_spaces $list | 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
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for i in $list ; do
# FIXME -n on MacOS?
echo -n " | egrep -i -- \"$i\""
echon " | egrep -i -- \"$i\""
done
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
# FIXME: move from it
#isatty || return
local COLO=""
# rule for colorife
for i in $list $listN; do
[ -n "$COLO" ] && COLO="$COLO|"
COLO="$COLO$i"
done
# FIXME -n on MacOS?
if [ -n "$list" ] ; then
echo -n " | egrep -i --color -- \"($COLO)\""
echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi
}
......@@ -130,6 +149,10 @@ __epm_search_make_grep()
epm_search()
{
[ -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
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
......
......@@ -49,7 +49,7 @@ case $PMTYPE in
apt-rpm)
local_content_search $pkg_filenames
return ;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
assure_exists apt-file
sudocmd apt-file update
docmd apt-file search $pkg_filenames
......
......@@ -19,10 +19,11 @@
# copied from /etc/init.d/outformat (ALT Linux)
# FIXME on Android: FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:366
inputisatty()
{
# check stdin
tty -s
tty -s 2>/dev/null
}
isatty()
......@@ -45,6 +46,12 @@ check_tty()
[ -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
# FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return
......@@ -74,10 +81,18 @@ restore_color()
echover()
{
[ -n "$verbose" ] || return
[ -z "$verbose" ] && return
echo "$*" >&2
}
# echo string without EOL
echon()
{
# default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@"
}
# Used DISTRNAME
set_target_pkg_env()
{
......@@ -109,18 +124,19 @@ showcmd()
docmd()
{
showcmd "$@$EXTRA_SHOWDOCMD"
"$@"
#FIXME
$@
}
# Run every arg with docmd
docmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
docmd $cmd $pkg
docmd "$cmd" $pkg
done
}
......@@ -128,31 +144,31 @@ docmd_foreach()
sudocmd()
{
showcmd "$SUDO $@"
$SUDO "$@"
$SUDO $@
}
# Run every arg with sudocmd
sudocmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
sudocmd $cmd $pkg
sudocmd "$cmd" $pkg
done
}
get_firstarg()
{
echo -n "$1"
echon "$1"
}
get_lastarg()
{
local lastarg
eval lastarg=\${$#}
echo -n "$lastarg"
echon "$lastarg"
}
......@@ -182,7 +198,7 @@ store_output()
local CMDSTATUS=$RC_STDOUT.pipestatus
echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp)
( "$@" 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
......@@ -194,7 +210,7 @@ clean_store_output()
rm -f $RC_STDOUT $RC_STDOUT.pipestatus
}
# run epm, possible from side repo
epm()
{
$PROGDIR/epm $@
......@@ -324,15 +340,16 @@ if [ -n "$FORCEPM" ] ; then
fi
case $DISTRNAME in
ALTLinux|PCLinux)
ALTLinux)
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)
CMD="apt-rpm"
;;
Ubuntu|Debian|Mint)
CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
;;
Mandriva|ROSA)
CMD="urpm-rpm"
......@@ -348,6 +365,7 @@ case $DISTRNAME in
;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific)
CMD="yum-rpm"
#which dnf 2>/dev/null >/dev/null && CMD=dnf-rpm
;;
Slackware)
CMD="slackpkg"
......@@ -370,6 +388,9 @@ case $DISTRNAME in
GNU/Linux/Guix)
CMD="guix"
;;
Android)
CMD="android"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......
#!/bin/sh
#
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-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
......@@ -62,6 +62,9 @@ _epm_do_simulate()
apt-rpm|apt-dpkg)
CMD="apt-get --simulate install"
;;
aptitude-dpkg)
CMD="aptitude -s install"
;;
yum-rpm)
if __use_yum_assumeno ; then
LC_ALL=C store_output sudocmd yum --assumeno install $filenames
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,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
......@@ -33,6 +33,9 @@ case $PMTYPE in
#sudocmd apt-get -f install || exit
#sudocmd apt-get autoremove
;;
aptitude-dpkg)
sudocmd aptitude update || exit
;;
yum-rpm)
sudocmd yum check-update
;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,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
......@@ -17,9 +17,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
epm_upgrade()
{
local CMD
# it is useful for first time running
update_repo_if_needed
echo "Run command for upgrade packages"
case $PMTYPE in
......@@ -28,6 +34,9 @@ epm_upgrade()
# Функцию добавления параметра при условии
CMD="apt-get dist-upgrade"
;;
aptitude-dpkg)
CMD="aptitude dist-upgrade"
;;
yum-rpm)
# can do update repobase automagically
CMD="yum update"
......
......@@ -27,9 +27,12 @@ case $PMTYPE in
apt-rpm)
CMD="apt-cache whatdepends"
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
CMD="apt-cache rdepends"
;;
aptitude-dpkg)
CMD="aptitude why"
;;
yum-rpm)
CMD="repoquery --whatrequires"
;;
......
......@@ -27,7 +27,7 @@ case $PMTYPE in
conary)
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" "
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.
#
Name: eepm
Version: 1.4.5
Version: 1.5.0
Release: alt0.M70P.1
Summary: Etersoft EPM package manager
......@@ -22,7 +22,10 @@ Conflicts: epm
Provides: upm
%if %_vendor == "alt"
# FIXHERE: Replace with target platform package manager
Requires: apt rpm
%endif
%description
Etersoft EPM is the package manager for any platform
......@@ -63,9 +66,26 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv
%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)
* 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
- epm: check for -- after options
- fix bashisms
......
......@@ -33,17 +33,39 @@ load_helper()
# File bin/epm-sh-functions:
inputisatty()
{
# check stdin
tty -s 2>/dev/null
}
isatty()
{
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
# check stdout
test -t 1
}
isatty2()
{
# check stderr
test -t 2
}
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
# FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return
......@@ -73,10 +95,17 @@ restore_color()
echover()
{
[ -n "$verbose" ] || return
[ -z "$verbose" ] && return
echo "$*" >&2
}
echon()
{
# default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@"
}
set_target_pkg_env()
{
[ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME"
......@@ -104,47 +133,47 @@ showcmd()
docmd()
{
showcmd "$@$EXTRA_SHOWDOCMD"
"$@"
$@
}
docmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
docmd $cmd $pkg
docmd "$cmd" $pkg
done
}
sudocmd()
{
showcmd "$SUDO $@"
$SUDO "$@"
$SUDO $@
}
sudocmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
sudocmd $cmd $pkg
sudocmd "$cmd" $pkg
done
}
get_firstarg()
{
echo -n "$1"
echon "$1"
}
get_lastarg()
{
local lastarg
eval lastarg=\${$#}
echo -n "$lastarg"
echon "$lastarg"
}
......@@ -173,7 +202,7 @@ store_output()
local CMDSTATUS=$RC_STDOUT.pipestatus
echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp)
( "$@" 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
......@@ -185,7 +214,6 @@ clean_store_output()
rm -f $RC_STDOUT $RC_STDOUT.pipestatus
}
epm()
{
$PROGDIR/epm $@
......@@ -230,7 +258,8 @@ set_eatmydata()
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
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()
......@@ -304,15 +333,16 @@ if [ -n "$FORCEPM" ] ; then
fi
case $DISTRNAME in
ALTLinux|PCLinux)
ALTLinux)
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)
CMD="apt-rpm"
;;
Ubuntu|Debian|Mint)
CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
;;
Mandriva|ROSA)
CMD="urpm-rpm"
......@@ -328,6 +358,7 @@ case $DISTRNAME in
;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific)
CMD="yum-rpm"
#which dnf 2>/dev/null >/dev/null && CMD=dnf-rpm
;;
Slackware)
CMD="slackpkg"
......@@ -350,6 +381,9 @@ case $DISTRNAME in
GNU/Linux/Guix)
CMD="guix"
;;
Android)
CMD="android"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......@@ -710,6 +744,7 @@ pkgtype()
archlinux) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;;
......@@ -907,6 +942,11 @@ elif [ `uname` = "Linux" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix"
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
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB
......@@ -1052,7 +1092,7 @@ $(get_help HELPOPT)
print_version()
{
echo "Service manager version 1.4.2"
echo "Service manager version 1.5.0"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013"
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