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

backported to M60P as 1.5.1-alt0.M60P.1 (with rpmbph script)

parents e17a8887 fbe7c2f5
Загрузку конфига
Проверить всё с кавычками
Неверно передаёт кавычки:
__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" ;;
...@@ -237,6 +238,21 @@ elif [ `uname` = "SunOS" ] ; then ...@@ -237,6 +238,21 @@ elif [ `uname` = "SunOS" ] ; then
DISTRIB_ID="SunOS" DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: can we detect by some file?
elif [ `uname` = "Darwin" ] ; then
DISTRIB_ID="MacOS"
DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
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 # 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 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
...@@ -58,7 +58,7 @@ print_version() ...@@ -58,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."
} }
...@@ -97,6 +97,9 @@ case $progname in ...@@ -97,6 +97,9 @@ case $progname in
epms) epms)
epm_cmd=search epm_cmd=search
;; ;;
epmsf)
epm_cmd=search_file
;;
epmq) epmq)
epm_cmd=query epm_cmd=query
;; ;;
...@@ -133,19 +136,19 @@ check_command() ...@@ -133,19 +136,19 @@ check_command()
# Base commands # Base commands
case $1 in case $1 in
-i|install|add) # HELPCMD: install package(s) from remote repositories or from local file -i|install|add|i) # HELPCMD: install package(s) from remote repositories or from local file
epm_cmd=install epm_cmd=install
;; ;;
-e|-P|remove|delete|uninstall|erase) # HELPCMD: remove (delete) package(s) from the database and the system -e|-P|remove|delete|uninstall|erase|e) # HELPCMD: remove (delete) package(s) from the database and the system
epm_cmd=remove epm_cmd=remove
;; ;;
-s|search) # HELPCMD: search in remote package repositories -s|search) # HELPCMD: search in remote package repositories
epm_cmd=search epm_cmd=search
;; ;;
-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|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
;; ;;
...@@ -156,28 +159,28 @@ check_command() ...@@ -156,28 +159,28 @@ check_command()
Install) # HELPCMD: perform update package repo info and install package(s) via install command Install) # HELPCMD: perform update package repo info and install package(s) via install command
epm_cmd=Install epm_cmd=Install
;; ;;
-q|installed|query) # HELPCMD: check presence of package(s) and print this name (also --short is supported) -q|q|installed|query) # HELPCMD: check presence of package(s) and print this name (also --short is supported)
epm_cmd=query epm_cmd=query
;; ;;
-sf|sf|filesearch) # HELPCMD: search in which package a file is included -sf|sf|filesearch) # HELPCMD: search in which package a file is included
epm_cmd=search_file epm_cmd=search_file
;; ;;
-ql|filelist) # HELPCMD: print package file list -ql|ql|filelist) # HELPCMD: print package file list
epm_cmd=filelist epm_cmd=filelist
;; ;;
check|fix|verify) # HELPCMD: check local package base integrity and fix it check|fix|verify) # HELPCMD: check local package base integrity and fix it
epm_cmd=check epm_cmd=check
;; ;;
changelog|cl) # HELPCMD: show changelog for package changelog|cl|-cl) # HELPCMD: show changelog for package
epm_cmd=changelog epm_cmd=changelog
;; ;;
-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
...@@ -186,12 +189,18 @@ check_command() ...@@ -186,12 +189,18 @@ check_command()
whatprovides) # HELPCMD: print packages provides that target whatprovides) # HELPCMD: print packages provides that target
epm_cmd=whatprovides epm_cmd=whatprovides
;; ;;
-qa|list|packages|-l) # HELPCMD: list of installed package(s) conflicts) # HELPCMD: print package conflicts
epm_cmd=conflicts
;;
-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
...@@ -223,13 +232,13 @@ check_command() ...@@ -223,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
;; ;;
...@@ -254,7 +263,7 @@ check_option() ...@@ -254,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)
...@@ -285,18 +294,35 @@ check_option() ...@@ -285,18 +294,35 @@ check_option()
return 0 return 0
} }
for opt in "$@" ; do check_filenames()
check_command $opt && continue {
check_option $opt && continue local opt="$1"
# files can be with full path or have extension via .
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 $(timeout 1 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")
...@@ -314,6 +340,13 @@ if [ -z "$epm_cmd" ] ; then ...@@ -314,6 +340,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
......
...@@ -26,7 +26,7 @@ epm_Install() ...@@ -26,7 +26,7 @@ epm_Install()
local names="$(echo $pkg_names | filter_out_installed_packages)" local names="$(echo $pkg_names | filter_out_installed_packages)"
local files="$(echo $pkg_files | filter_out_installed_packages)" local files="$(echo $pkg_files | filter_out_installed_packages)"
[ -z "$files$names" ] && echo "Skip empty install list" && return 22 [ -z "$files$names" ] && info "Install: Skip empty install list." && return 22
# do update only if really need install something # do update only if really need install something
case $PMTYPE in case $PMTYPE in
......
...@@ -21,13 +21,14 @@ epm_addrepo() ...@@ -21,13 +21,14 @@ epm_addrepo()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
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" info "You need manually add repo to /etc/apt/sources.list"
;; ;;
yum-rpm) yum-rpm)
echo "You need manually add repo to /etc/yum.repos.d/" info "You need manually add repo to /etc/yum.repos.d/"
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi.addmedia $pkg_filenames sudocmd urpmi.addmedia $pkg_filenames
...@@ -39,7 +40,7 @@ case $PMTYPE in ...@@ -39,7 +40,7 @@ case $PMTYPE in
sudocmd layman -a $pkg_filenames sudocmd layman -a $pkg_filenames
;; ;;
pacman) pacman)
echo "You need manually add repo to /etc/pacman.conf" info "You need manually add repo to /etc/pacman.conf"
# Only for alone packages: # Only for alone packages:
#sudocmd repo-add $pkg_filenames #sudocmd repo-add $pkg_filenames
;; ;;
...@@ -47,7 +48,7 @@ case $PMTYPE in ...@@ -47,7 +48,7 @@ case $PMTYPE in
sudocmd npackdcl add-repo --url=$pkg_filenames sudocmd npackdcl add-repo --url=$pkg_filenames
;; ;;
slackpkg) slackpkg)
echo "You need manually add repo to /etc/slackpkg/mirrors" info "You need manually add repo to /etc/slackpkg/mirrors"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
......
#!/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")"
info "Command $1 is exists: $compath"
epm qf "$compath"
fi
return
fi
# TODO: use package name normalization
info "Installing 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 "Assure: Missing params. Check $0 --help for info."
# use helper func for extract separate params
__epm_assure $pkg_filenames
}
...@@ -17,14 +17,35 @@ ...@@ -17,14 +17,35 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
__epm_autoremove_altrpm()
{
local pkg
local flag=
load_helper epm-packages
info
info "Just removing 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
# ALT Linux only
__epm_autoremove_altrpm
# 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)
...@@ -45,7 +66,7 @@ case $PMTYPE in ...@@ -45,7 +66,7 @@ case $PMTYPE in
;; ;;
emerge) emerge)
sudocmd emerge --depclean sudocmd emerge --depclean
docmd epm --skip-installed install gentoolkit assure_exists revdep-rebuild
sudocmd revdep-rebuild sudocmd revdep-rebuild
;; ;;
pacman) pacman)
...@@ -55,6 +76,9 @@ case $PMTYPE in ...@@ -55,6 +76,9 @@ case $PMTYPE in
# clean-system removes non official packages # clean-system removes non official packages
#sudocmd slackpkg clean-system #sudocmd slackpkg clean-system
;; ;;
guix)
sudocmd guix gc
;;
#zypper-rpm) #zypper-rpm)
# sudocmd zypper clean # sudocmd zypper clean
# ;; # ;;
......
...@@ -19,22 +19,30 @@ ...@@ -19,22 +19,30 @@
load_helper epm-query load_helper epm-query
__epm_changelog_apt()
{
local i
for i in $@ ; do
docmd apt-cache show $i | grep -A 1000 "^Changelog:"
done
}
__epm_changelog_files() __epm_changelog_files()
{ {
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in # TODO: detect every file
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm) case $(get_package_type $1) in
rpm)
docmd_foreach "rpm -p --changelog" $@ | less docmd_foreach "rpm -p --changelog" $@ | less
;; ;;
# apt-dpkg) # deb)
# #
# ;; # ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $1"
;; ;;
esac esac
} }
__epm_changelog_local_names() __epm_changelog_local_names()
...@@ -45,13 +53,12 @@ __epm_changelog_local_names() ...@@ -45,13 +53,12 @@ __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)
# FIXME: only first pkg
docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
;; ;;
emerge) emerge)
docmd view /usr/portage/category/$1/ChangeLog | less assure_exists equery
# docmd equery changes -f $1 | less docmd equery changes -f $1 | less
;; ;;
pacman) pacman)
docmd pacman -Qc $1 | less docmd pacman -Qc $1 | less
...@@ -67,9 +74,9 @@ __epm_changelog_unlocal_names() ...@@ -67,9 +74,9 @@ __epm_changelog_unlocal_names()
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in case $PMTYPE in
#apt-rpm) apt-rpm)
# docmd_foreach "rpm --changelog" $@ | less __epm_changelog_apt $@ | less
# ;; ;;
#apt-dpkg) #apt-dpkg)
# # FIXME: only first pkg # # FIXME: only first pkg
# docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less # docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
...@@ -83,6 +90,10 @@ __epm_changelog_unlocal_names() ...@@ -83,6 +90,10 @@ __epm_changelog_unlocal_names()
#zypper-rpm) #zypper-rpm)
# sudocmd zypper clean # sudocmd zypper clean
# ;; # ;;
emerge)
assure_exists equery
docmd equery changes -f $1 | less
;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
...@@ -93,7 +104,7 @@ __epm_changelog_unlocal_names() ...@@ -93,7 +104,7 @@ __epm_changelog_unlocal_names()
epm_changelog() epm_changelog()
{ {
[ -n "$pkg_filenames" ] || fatal "Run changelog without params" [ -n "$pkg_filenames" ] || fatal "Changelog: Missing package(s) name"
__epm_changelog_files $pkg_files __epm_changelog_files $pkg_files
......
...@@ -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-*)
if [ -r /var/cache/apt ] ; then
# FIXME: only if root permissions
test -r /var/cache/apt/pkgcache.bin || return
fi
;;
*)
;;
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
}
...@@ -19,11 +19,10 @@ ...@@ -19,11 +19,10 @@
check_pkg_integrity() check_pkg_integrity()
{ {
local EXT=`echo "$1" | sed -e "s|.*\.\([a-z0-9]*\)\$|\1|g"`
local PKG="$1" local PKG="$1"
local RET local RET
case $EXT in case $(get_package_type $PKG) in
rpm) rpm)
docmd rpm --checksig $PKG docmd rpm --checksig $PKG
;; ;;
...@@ -38,9 +37,8 @@ check_pkg_integrity() ...@@ -38,9 +37,8 @@ check_pkg_integrity()
true true
;; ;;
*) *)
assure_exists erc
docmd erc test "$PKG" && return docmd erc test "$PKG" && return
which erc >/dev/null 2>/dev/null && fatal "Check failed"
fatal "Install erc package."
;; ;;
esac esac
} }
...@@ -54,6 +52,10 @@ case $PMTYPE in ...@@ -54,6 +52,10 @@ case $PMTYPE in
*-dpkg) *-dpkg)
docmd debsums $@ docmd debsums $@
;; ;;
emerge)
assure_exists equery
docmd equery check $@
;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
...@@ -65,12 +67,12 @@ esac ...@@ -65,12 +67,12 @@ esac
epm_checkpkg() epm_checkpkg()
{ {
if [ -n "$pkg_names" ] ; then if [ -n "$pkg_names" ] ; then
echo "Suggest $pkg_names are names of installed packages" info "Suggest $pkg_names are name(s) of installed packages"
__epm_check_installed_pkg $pkg_names __epm_check_installed_pkg $pkg_names
return return
fi fi
[ -n "$pkg_files" ] || fatal "Run without names" [ -n "$pkg_files" ] || fatal "Checkpkg: missing file or package name(s)"
local pkg local pkg
for pkg in $pkg_files ; do for pkg in $pkg_files ; do
check_pkg_integrity $pkg || fatal "Broken package $pkg" check_pkg_integrity $pkg || fatal "Broken package $pkg"
......
#!/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
...@@ -48,6 +51,6 @@ case $PMTYPE in ...@@ -48,6 +51,6 @@ case $PMTYPE in
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
echo "It is recommend to run 'epm autoremove' also" info "It is recommend to run 'epm autoremove' also"
} }
#!/bin/sh
#
# Copyright (C) 2013 Etersoft
# Copyright (C) 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
# 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-query
epm_conflicts_files()
{
[ -n "$pkg_files" ] || return
case $(get_package_type $pkg_files) in
rpm)
docmd "rpm -q --conflicts -p" $pkg_files
;;
#deb)
# a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
epm_conflicts_names()
{
local CMD
[ -n "$pkg_names" ] || return
# by package name
case $PMTYPE in
apt-rpm)
# FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so)
if is_installed $pkg_names ; then
CMD="rpm -q --conflicts"
else
EXTRA_SHOWDOCMD=' | grep "Conflicts:"'
docmd apt-cache show $pkg_names | grep "Conflicts:"
return
fi
;;
urpm-rpm|zypper-rpm)
# FIXME: use hi level commands
CMD="rpm -q --conflicts"
;;
#yum-rpm)
# CMD="yum deplist"
# ;;
#pacman)
# CMD="pactree"
# ;;
apt-dpkg)
# FIXME: need fix for a few names case
if is_installed $pkg_names ; then
showcmd dpkg -s $pkg_names
a= dpkg -s $pkg_names | grep "^Conflicts:" | sed "s|^Conflicts:||g"
return
else
EXTRA_SHOWDOCMD=' | grep "Conflicts:"'
docmd apt-cache show $pkg_names | grep "Conflicts:"
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"
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
docmd $CMD $pkg_names
}
epm_conflicts()
{
[ -n "$pkg_filenames" ] || fatal "Conflicts: Missing package(s) name"
epm_conflicts_files
epm_conflicts_names
}
#!/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
...@@ -19,17 +19,58 @@ ...@@ -19,17 +19,58 @@
load_helper epm-query load_helper epm-query
# TODO: port or rewrite apt-file
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
# see also epm-search-file
local_content_filelist()
{
local SYSARCH
SYSARCH=$(uname -m)
[ "$SYSARCH" = "x86_64" ] || SYSARCH=i586
local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
local CI=$REPODIR/$SYSARCH/base/contents_index
local CINOA=$REPODIR/noarch/base/contents_index
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD="cat"
test -r $CI && test -r $CINOA || fatal "Can't locate $CI or $CINOA"
{
[ -n "$USETTY" ] && echo "Search in $CI and $CINOA for $1..."
grep -h -- ".*$1$" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\1|g"
} | $OUTCMD
}
__epm_filelist_remote()
{
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm)
# TODO: use RESTful interface to prometeus? See ALT bug #29496
docmd_foreach local_content_filelist $@
;;
*)
fatal "Query filelist for non installed packages does not realized"
;;
esac
}
__epm_filelist_file() __epm_filelist_file()
{ {
local CMD local CMD
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in # TODO: allow a new packages
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm) case $(get_package_type $1) in
rpm)
CMD="rpm -qlp" CMD="rpm -qlp"
;; ;;
apt-dpkg) deb)
CMD="dpkg --contents" CMD="dpkg --contents"
;; ;;
*) *)
...@@ -37,8 +78,7 @@ __epm_filelist_file() ...@@ -37,8 +78,7 @@ __epm_filelist_file()
;; ;;
esac esac
# TODO: add less docmd $CMD $@ | less
docmd $CMD $@
} }
__epm_filelist_name() __epm_filelist_name()
...@@ -51,7 +91,7 @@ __epm_filelist_name() ...@@ -51,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)
...@@ -63,16 +103,23 @@ __epm_filelist_name() ...@@ -63,16 +103,23 @@ __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)
assure_exists equery
CMD="equery files"
;;
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
;; ;;
*) *)
...@@ -82,13 +129,13 @@ __epm_filelist_name() ...@@ -82,13 +129,13 @@ __epm_filelist_name()
# TODO: add less # TODO: add less
docmd $CMD $pkg_names && return docmd $CMD $pkg_names && return
is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized" is_installed $pkg_names || __epm_filelist_remote $pkg_names
} }
epm_filelist() epm_filelist()
{ {
[ -n "$pkg_filenames" ] || fatal "Run query without names" [ -n "$pkg_filenames" ] || fatal "Filelist: missing package(s) name"
__epm_filelist_file $pkg_files || return __epm_filelist_file $pkg_files || return
......
#!/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
...@@ -28,8 +28,13 @@ __epm_info_rpm_low() ...@@ -28,8 +28,13 @@ __epm_info_rpm_low()
is_installed $pkg_names && docmd rpm -qi $pkg_names && return is_installed $pkg_names && docmd rpm -qi $pkg_names && return
} }
# TODO: separate to _files and _names parts
# realize _files part per package, not by PMTYPE (see filelist)
epm_info() epm_info()
{ {
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_info_rpm_low && return __epm_info_rpm_low && return
...@@ -43,6 +48,13 @@ case $PMTYPE in ...@@ -43,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
...@@ -71,12 +83,22 @@ case $PMTYPE in ...@@ -71,12 +83,22 @@ case $PMTYPE in
is_installed $pkg_names && docmd conary query $pkg_names --info && return is_installed $pkg_names && docmd conary query $pkg_names --info && return
docmd conary repquery $pkg_names --info docmd conary repquery $pkg_names --info
;; ;;
emerge)
assure_exists equery
docmd equery meta $pkg_names
docmd equery which $pkg_names
docmd equery uses $pkg_names
docmd equery size $pkg_names
;;
slackpkg) slackpkg)
docmd /usr/sbin/slackpkg info $pkg_names docmd /usr/sbin/slackpkg info $pkg_names
;; ;;
ipkg) ipkg)
docmd ipkg info $pkg_names docmd ipkg info $pkg_names
;; ;;
homebrew)
docmd brew info $pkg_names
;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
......
...@@ -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)
...@@ -143,6 +148,12 @@ epm_install_names() ...@@ -143,6 +148,12 @@ epm_install_names()
nix) nix)
__separate_sudocmd "nix-env --install" "nix-env --upgrade" $@ __separate_sudocmd "nix-env --install" "nix-env --upgrade" $@
return ;; return ;;
guix)
__separate_sudocmd "guix package -i" "guix package -i" $@
return ;;
android)
fatal "We still 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"
;; ;;
...@@ -155,8 +166,12 @@ epm_ni_install_names() ...@@ -155,8 +166,12 @@ epm_ni_install_names()
[ -z "$1" ] && return [ -z "$1" ] && return
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
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 ;;
...@@ -192,6 +207,9 @@ epm_ni_install_names() ...@@ -192,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" $@
...@@ -225,7 +243,7 @@ epm_install_files() ...@@ -225,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"
...@@ -281,6 +299,9 @@ epm_install_files() ...@@ -281,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 $@
...@@ -309,7 +330,7 @@ epm_print_install_command() ...@@ -309,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)
...@@ -331,6 +352,9 @@ epm_print_install_command() ...@@ -331,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"
;; ;;
...@@ -345,12 +369,15 @@ epm_install() ...@@ -345,12 +369,15 @@ epm_install()
return return
fi fi
[ -n "$pkg_files$pkg_names" ] || { echo "Skip empty install list" ; return 22 ; } [ -z "$pkg_files$pkg_names" ] && info "Skip empty install list" && return 22
local names="$(echo $pkg_names | filter_out_installed_packages)" local names="$(echo $pkg_names | filter_out_installed_packages)"
local files="$(echo $pkg_files | filter_out_installed_packages)" local files="$(echo $pkg_files | filter_out_installed_packages)"
[ -z "$files$names" ] && echo "Skip empty install list" && return 22 [ -z "$files$names" ] && info "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
......
...@@ -19,10 +19,11 @@ ...@@ -19,10 +19,11 @@
epm_kernel_update() epm_kernel_update()
{ {
echo "Start update system kernel to the latest version" info "Starting update system kernel to the latest version"
case $DISTRNAME in case $DISTRNAME in
ALTLinux) ALTLinux)
assure_exists update-kernel
sudocmd update-kernel sudocmd update-kernel
return ;; return ;;
esac esac
......
...@@ -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"
...@@ -52,9 +52,10 @@ case $PMTYPE in ...@@ -52,9 +52,10 @@ 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"
;; ;;
# Note: dnf has dnf list command
emerge) emerge)
CMD="qlist -I" CMD="qlist -I -C"
# print with colors for console output
isatty && CMD="qlist -I"
;; ;;
pkgsrc) pkgsrc)
CMD="pkg_info" CMD="pkg_info"
...@@ -87,11 +88,19 @@ case $PMTYPE in ...@@ -87,11 +88,19 @@ case $PMTYPE in
fi fi
;; ;;
homebrew) homebrew)
CMD="brew $pkg_filenames" CMD="brew list $pkg_filenames"
;; ;;
ipkg) ipkg)
CMD="ipkg list" CMD="ipkg list"
;; ;;
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" 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
} }
...@@ -19,35 +19,41 @@ ...@@ -19,35 +19,41 @@
load_helper epm-query load_helper epm-query
epm_provides() epm_provides_files()
{ {
local CMD [ -n "$pkg_files" ] || return
[ -n "$pkg_filenames" ] || fatal "Run query without names"
# by package file case $(get_package_type $pkg_files) in
case $PMTYPE in rpm)
*-rpm) docmd rpm -q --provides -p $pkg_files
CMD="rpm -q --provides -p" ;;
deb)
# FIXME: will we provide ourself?
docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g"
;; ;;
# apt-dpkg)
# showcmd dpkg -s $pkg_files
# a= dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
# return
# ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
}
[ -n "$pkg_files" ] && docmd $CMD $pkg_files epm_provides_names()
{
local CMD
[ -n "$pkg_names" ] || return
# by package name # by package name
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# FIXME: need fix for a few names case
# TODO: separate this function to two section
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
CMD="rpm -q --provides" CMD="rpm -q --provides"
else else
CMD="apt-cache depends" EXTRA_SHOWDOCMD=' | grep "Provides:"'
docmd apt-cache show $pkg_names | grep "Provides:"
return
fi fi
;; ;;
urpm-rpm|zypper-rpm|yum-rpm) urpm-rpm|zypper-rpm|yum-rpm)
...@@ -58,19 +64,37 @@ case $PMTYPE in ...@@ -58,19 +64,37 @@ case $PMTYPE in
fi fi
;; ;;
emerge) emerge)
assure_exists equery
CMD="equery files" CMD="equery files"
;; ;;
# yum-rpm) # yum-rpm)
# CMD="yum deplist" # CMD="yum deplist"
# ;; # ;;
# apt-dpkg) apt-dpkg)
# CMD="apt-cache depends" # FIXME: need fix for a few names case
# ;; if is_installed $pkg_names ; then
info "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
;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
[ -n "$pkg_names" ] && docmd $CMD $pkg_names docmd $CMD $pkg_names
}
epm_provides()
{
[ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name"
epm_provides_files
epm_provides_names
} }
...@@ -19,19 +19,32 @@ ...@@ -19,19 +19,32 @@
load_helper epm-packages load_helper epm-packages
# TODO: combine with -qa (the difference only in return status now)
_get_grep_exp()
{
local def="^$1$"
[ "$PMTYPE" != "emerge" ] && echo "$def" && return
# Gentoo hack: support for short package form
echo "$1" | grep -q "/" && echo "$def" && return
echo "/$1$"
}
# TODO: combine with -qa (the difference only in return status now)
_query_via_packages_list() _query_via_packages_list()
{ {
local res=0 local res=0
local grepexp
local firstpkg=$1 local firstpkg=$1
shift shift
grepexp=$(_get_grep_exp $firstpkg)
# separate first line for print out command # separate first line for print out command
short=1 pkg_filenames=$firstpkg epm_packages | grep -- "^$firstpkg$" || res=1 short=1 pkg_filenames=$firstpkg epm_packages | grep -- "$grepexp" || res=1
for pkg in "$@" ; do for pkg in "$@" ; do
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -- "^$pkg$" || res=1 grepexp=$(_get_grep_exp $pkg)
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -- "$grepexp" || res=1
done done
return $res return $res
...@@ -75,7 +88,7 @@ __epm_get_hilevel_name() ...@@ -75,7 +88,7 @@ __epm_get_hilevel_name()
for i in $@ ; do for i in $@ ; do
local pkg local pkg
# get short form in pkg # get short form in pkg
quiet=1 short=1 pkg=$(__epm_query_name $i) quiet=1 short=1 pkg=$(__epm_query_name $i) || continue # drop not installed packages
# if already short form, skipped # if already short form, skipped
[ "$pkg" = "$i" ] && echo "$i" && continue [ "$pkg" = "$i" ] && echo "$i" && continue
# try get long form or use short form # try get long form or use short form
...@@ -94,7 +107,7 @@ __epm_query_file() ...@@ -94,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"
;; ;;
...@@ -117,7 +130,7 @@ __epm_query_name() ...@@ -117,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"
...@@ -129,7 +142,7 @@ __epm_query_name() ...@@ -129,7 +142,7 @@ __epm_query_name()
conary) conary)
CMD="conary query" CMD="conary query"
;; ;;
brew) homebrew)
warning "fix query" warning "fix query"
return 1 return 1
;; ;;
...@@ -146,8 +159,9 @@ __epm_query_name() ...@@ -146,8 +159,9 @@ __epm_query_name()
# check if pkg is installed # check if pkg is installed
is_installed() is_installed()
{ {
#pkg_filenames="$@" epm_query >/dev/null pkg_filenames="$@" pkg_names="$@" epm_query >/dev/null 2>/dev/null
epm installed $@ >/dev/null 2>/dev/null # broken way to recursive call here (overhead!)
#epm installed $@ >/dev/null 2>/dev/null
} }
# fill pkg_installed and pkg_noninstalled # fill pkg_installed and pkg_noninstalled
...@@ -162,7 +176,7 @@ separate_installed() ...@@ -162,7 +176,7 @@ separate_installed()
epm_query() epm_query()
{ {
[ -n "$pkg_filenames" ] || fatal "Run query without names" [ -n "$pkg_filenames" ] || fatal "Query: missing package(s) name"
__epm_query_file $pkg_files || return __epm_query_file $pkg_files || return
......
...@@ -33,7 +33,7 @@ __do_query_real_file() ...@@ -33,7 +33,7 @@ __do_query_real_file()
else else
TOFILE=`which $1 2>/dev/null || echo $1` TOFILE=`which $1 2>/dev/null || echo $1`
if [ "$TOFILE" != "$1" ] ; then if [ "$TOFILE" != "$1" ] ; then
echo "Note: $1 is placed as $TOFILE" info "Note: $1 is placed as $TOFILE"
fi fi
fi fi
...@@ -41,10 +41,11 @@ __do_query_real_file() ...@@ -41,10 +41,11 @@ __do_query_real_file()
if [ -L "$TOFILE" ] ; then if [ -L "$TOFILE" ] ; then
__do_query $TOFILE __do_query $TOFILE
LINKTO=`readlink "$TOFILE"` LINKTO=`readlink "$TOFILE"`
echo "Note: $TOFILE is link to $LINKTO" info "Note: $TOFILE is link to $LINKTO"
__do_query_real_file "$LINKTO" __do_query_real_file "$LINKTO"
fi fi
FULLFILEPATH=`realpath $TOFILE`
FULLFILEPATH="$TOFILE"
} }
dpkg_print_name_version() dpkg_print_name_version()
...@@ -68,7 +69,7 @@ __do_query() ...@@ -68,7 +69,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 ;;
...@@ -79,6 +80,7 @@ __do_query() ...@@ -79,6 +80,7 @@ __do_query()
CMD="rpm -qf" CMD="rpm -qf"
;; ;;
emerge) emerge)
assure_exists equery
CMD="equery belongs" CMD="equery belongs"
;; ;;
pacman) pacman)
...@@ -116,6 +118,7 @@ __do_short_query() ...@@ -116,6 +118,7 @@ __do_short_query()
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by") dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")
return ;; return ;;
NOemerge) NOemerge)
assure_exists equery
CMD="equery belongs" CMD="equery belongs"
;; ;;
NOpacman) NOpacman)
...@@ -139,6 +142,7 @@ epm_query_file() ...@@ -139,6 +142,7 @@ epm_query_file()
{ {
# in short mode print handle only real names and do short output # in short mode print handle only real names and do short output
# TODO: move to separate command? # TODO: move to separate command?
# FIXME: it is possible use query
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
[ -n "$pkg_files" ] || fatal "Run query without file names (needed path to files)" [ -n "$pkg_files" ] || fatal "Run query without file names (needed path to files)"
__do_short_query $pkg_files __do_short_query $pkg_files
...@@ -150,7 +154,7 @@ epm_query_file() ...@@ -150,7 +154,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
} }
...@@ -22,9 +22,10 @@ load_helper epm-search ...@@ -22,9 +22,10 @@ load_helper epm-search
epm_query_package() epm_query_package()
{ {
[ -n "$pkg_filenames" ] || fatal "Please, use search with some argument" [ -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"
} }
#!/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)
...@@ -63,7 +66,7 @@ epm_reinstall_files() ...@@ -63,7 +66,7 @@ epm_reinstall_files()
epm_reinstall() epm_reinstall()
{ {
[ -n "$pkg_filenames" ] || fatal "Run install without packages" [ -n "$pkg_filenames" ] || fatal "Reinstall: missing package(s) name."
epm_reinstall_names $pkg_names epm_reinstall_names $pkg_names
epm_reinstall_files $pkg_files epm_reinstall_files $pkg_files
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
epm_release_upgrade() epm_release_upgrade()
{ {
echo "Start upgrade whole system to the next release" info "Starting upgrade whole system to the next release"
echo "Check also http://wiki.etersoft.ru/Admin/UpdateLinux" info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
...@@ -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)
...@@ -63,6 +63,12 @@ epm_release_upgrade() ...@@ -63,6 +63,12 @@ epm_release_upgrade()
conary) conary)
epm Upgrade epm Upgrade
;; ;;
emerge)
epm Upgrade
;;
guix)
sudocmd guix pull --verbose
;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
......
#!/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)
...@@ -51,9 +51,15 @@ epm_remove_names() ...@@ -51,9 +51,15 @@ epm_remove_names()
[ -z "$1" ] && return [ -z "$1" ] && return
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-dpkg)
sudocmd apt-get remove --purge $@ sudocmd apt-get remove --purge $@
return ;; return ;;
aptitude-dpkg)
sudocmd aptitude purge $@
return ;;
apt-rpm)
sudocmd apt-get remove $@
return ;;
deepsolver-rpm) deepsolver-rpm)
sudocmd ds-remove $@ sudocmd ds-remove $@
return ;; return ;;
...@@ -91,6 +97,12 @@ epm_remove_names() ...@@ -91,6 +97,12 @@ epm_remove_names()
nix) nix)
sudocmd nix-env --uninstall $@ sudocmd nix-env --uninstall $@
return ;; return ;;
guix)
sudocmd guix package -r $@
return ;;
android)
sudocmd pm uninstall $@
return ;;
chocolatey) chocolatey)
sudocmd chocolatey uninstall $@ sudocmd chocolatey uninstall $@
return ;; return ;;
...@@ -113,9 +125,15 @@ epm_remove_names() ...@@ -113,9 +125,15 @@ epm_remove_names()
epm_remove_nonint() epm_remove_nonint()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm|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)
sudocmd apt-get -y --force-yes remove $@
return ;;
urpm-rpm) urpm-rpm)
sudocmd urpme --auto $@ sudocmd urpme --auto $@
return ;; return ;;
...@@ -144,7 +162,7 @@ epm_print_remove_command() ...@@ -144,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)
...@@ -179,7 +197,7 @@ epm_remove() ...@@ -179,7 +197,7 @@ epm_remove()
# get full package name(s) from the package file(s) # get full package name(s) from the package file(s)
[ -n "$pkg_files" ] && pkg_names="$pkg_names $(epm query $pkg_files)" [ -n "$pkg_files" ] && pkg_names="$pkg_names $(epm query $pkg_files)"
[ -n "$pkg_names" ] || fatal "Run remove without args" [ -n "$pkg_names" ] || fatal "Remove: missing package(s) name."
epm_remove_low $pkg_names && return epm_remove_low $pkg_names && return
# get package name for hi level package management command (with version if supported and if possible) # get package name for hi level package management command (with version if supported and if possible)
......
...@@ -21,13 +21,14 @@ epm_removerepo() ...@@ -21,13 +21,14 @@ epm_removerepo()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
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" info "You need remove repo from /etc/apt/sources.list"
;; ;;
yum-rpm) yum-rpm)
echo "You need remove repo from /etc/yum.repos.d/" info "You need remove repo from /etc/yum.repos.d/"
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi.removemedia $pkg_filenames sudocmd urpmi.removemedia $pkg_filenames
...@@ -39,13 +40,13 @@ case $PMTYPE in ...@@ -39,13 +40,13 @@ case $PMTYPE in
sudocmd layman -d$pkg_filenames sudocmd layman -d$pkg_filenames
;; ;;
pacman) pacman)
echo "You need remove repo from /etc/pacman.conf" info "You need remove repo from /etc/pacman.conf"
;; ;;
npackd) npackd)
sudocmd npackdcl remove-repo --url=$pkg_filenames sudocmd npackdcl remove-repo --url=$pkg_filenames
;; ;;
slackpkg) slackpkg)
echo "You need remove repo from /etc/slackpkg/mirrors" info "You need remove repo from /etc/slackpkg/mirrors"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
......
...@@ -32,12 +32,13 @@ epm_repolist() ...@@ -32,12 +32,13 @@ epm_repolist()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
assure_exists apt-repo
docmd apt-repo list docmd apt-repo list
;; ;;
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
;; ;;
...@@ -54,6 +55,7 @@ case $PMTYPE in ...@@ -54,6 +55,7 @@ case $PMTYPE in
docmd zypper sl -d docmd zypper sl -d
;; ;;
emerge) emerge)
docmd eselect profile list
docmd layman -L docmd layman -L
;; ;;
pacman) pacman)
......
#!/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,36 +17,48 @@ ...@@ -17,36 +17,48 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
epm_requires() load_helper epm-query
epm_requires_files()
{ {
local CMD [ -n "$pkg_files" ] || return
[ -n "$pkg_filenames" ] || fatal "Run query without names"
# TODO: Здесь выбирать команду по расширению, а не по системному менеджеру local PKGTYPE="$(case $(get_package_type $pkg_files))"
# В других таких случаях тоже
# В списке пакетов на установку проверять, что пакеты имеют соответствующее расширение case "$PKGTYPE" in
# by package file rpm)
case $PMTYPE in docmd rpm -q --requires -p $pkg_files
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm)
CMD="rpm -q --requires -p"
;; ;;
apt-dpkg) deb)
# FIXME: need package base a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
showcmd dpkg -s $pkg_files
a= dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
# FIXME: we need execute package name section too
return
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PKGTYPE"
;; ;;
esac esac
}
[ -n "$pkg_files" ] && docmd $CMD $pkg_files epm_requires_names()
{
local CMD
[ -n "$pkg_names" ] || return
# by package name # by package name
case $PMTYPE in case $PMTYPE in
apt-rpm|urpm-rpm|zypper-rpm) apt-rpm)
# FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so)
if is_installed $pkg_names ; then
CMD="rpm -q --requires"
else
#EXTRA_SHOWDOCMD=' | grep "Depends:"'
#docmd apt-cache show $pkg_names | grep "Depends:"
#return
CMD="apt-cache depends"
fi
;;
urpm-rpm|zypper-rpm)
# FIXME: use hi level commands # FIXME: use hi level commands
CMD="rpm -q --requires" CMD="rpm -q --requires"
;; ;;
...@@ -56,8 +68,19 @@ case $PMTYPE in ...@@ -56,8 +68,19 @@ case $PMTYPE in
pacman) pacman)
CMD="pactree" 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
a= dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
return
else
CMD="apt-cache depends" CMD="apt-cache depends"
fi
;;
emerge)
assure_exists equery
CMD="equery depgraph"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
...@@ -65,6 +88,13 @@ case $PMTYPE in ...@@ -65,6 +88,13 @@ case $PMTYPE in
esac esac
[ -n "$pkg_names" ] && docmd $CMD $pkg_names docmd $CMD $pkg_names
}
epm_requires()
{
[ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name"
epm_requires_files
epm_requires_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,11 +74,17 @@ case $PMTYPE in ...@@ -65,11 +74,17 @@ 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"
;; ;;
guix)
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"
;; ;;
...@@ -87,29 +102,60 @@ __epm_search_make_grep() ...@@ -87,29 +102,60 @@ __epm_search_make_grep()
local list= local list=
local listN= local listN=
for i in $@ ; do for i in $@ ; do
local NOR="${i/^/}" case "$i" in
[ "$NOR" = "$i" ] && list="$list $NOR" || listN="$listN $NOR" ^*)
# will clean from ^ later (and have the bug here with empty arg if run with one ^ only)
listN="$listN $i"
;;
*)
list="$list $i"
;;
esac
done done
#list=$(strip_spaces $list | sed -e "s/ /|/g") #list=$(strip_spaces $list | sed -e "s/ /|/g")
listN=$(strip_spaces $listN | 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
echo -n " | egrep -i --color -- \"$i\"" # FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done 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
if [ -n "$list" ] ; then
echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi
} }
# copied from korinf/tools/run-script/scripts/search # copied from korinf/tools/run-script/scripts/search
epm_search() epm_search()
{ {
[ -n "$pkg_filenames" ] || fatal "Please, use search with some argument" [ -n "$pkg_filenames" ] || fatal "Search: missing search argument(s)"
# it is useful for first time running
update_repo_if_needed
# 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"
} }
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449 # https://bugzilla.altlinux.org/show_bug.cgi?id=14449
local_content_search() local_content_search()
{ {
# TODO: use global get_sysarch function
local SYSARCH local SYSARCH
SYSARCH=$(uname -m) SYSARCH=$(uname -m)
[ "$SYSARCH" = "x86_64" ] || SYSARCH=i586 [ "$SYSARCH" = "x86_64" ] || SYSARCH=i586
# FIXME: use config or/and web url
local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
local CI=$REPODIR/$SYSARCH/base/contents_index local CI=$REPODIR/$SYSARCH/base/contents_index
local CINOA=$REPODIR/noarch/base/contents_index local CINOA=$REPODIR/noarch/base/contents_index
...@@ -43,13 +45,14 @@ local_content_search() ...@@ -43,13 +45,14 @@ local_content_search()
epm_search_file() epm_search_file()
{ {
local CMD local CMD
[ -n "$pkg_filenames" ] || fatal "Run search without names" [ -n "$pkg_filenames" ] || fatal "Search file: missing file name(s)"
case $PMTYPE in 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
sudocmd apt-file update sudocmd apt-file update
docmd apt-file search $pkg_filenames docmd apt-file search $pkg_filenames
return ;; return ;;
......
#!/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
...@@ -18,17 +18,40 @@ ...@@ -18,17 +18,40 @@
# #
# 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()
{
# 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
...@@ -58,32 +81,34 @@ restore_color() ...@@ -58,32 +81,34 @@ 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()
{ {
[ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME" [ -n "$DISTRNAME" ] || fatal "Missing DISTRNAME in set_target_pkg_env."
PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME") PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME")
PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME") PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME")
RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME") RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME")
} }
# for systems without realpath command
realpath()
{
readlink -f "$@"
}
# Print command line and run command line # Print command line and run command line
showcmd() showcmd()
{ {
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#" [ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@" echo " $PROMTSIG $@"
restore_color restore_color
fi >&2 fi >&2
...@@ -93,18 +118,19 @@ showcmd() ...@@ -93,18 +118,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
} }
...@@ -112,31 +138,31 @@ docmd_foreach() ...@@ -112,31 +138,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"
} }
...@@ -163,18 +189,22 @@ store_output() ...@@ -163,18 +189,22 @@ store_output()
{ {
# use make_temp_file from etersoft-build-utils # use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp) RC_STDOUT=$(mktemp)
local CMDSTATUS=$RC_STDOUT.pipestatus
echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp) #RC_STDERR=$(mktemp)
"$@" 2>&1 | tee $RC_STDOUT ( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return $PIPESTATUS #return $PIPESTATUS
} }
clean_store_output() clean_store_output()
{ {
rm -f $RC_STDOUT rm -f $RC_STDOUT $RC_STDOUT.pipestatus
} }
# run epm, possible from side repo
epm() epm()
{ {
$PROGDIR/epm $@ $PROGDIR/epm $@
...@@ -201,17 +231,29 @@ warning() ...@@ -201,17 +231,29 @@ warning()
fi fi
} }
info()
{
[ -n "$quiet" ] && return
# print message to stderr if stderr forwarded to (a file)
if isatty2 ; then
isatty || return 0
echo "$@"
else
echo "$@" >&2
fi
}
set_sudo() set_sudo()
{ {
SUDO="" SUDO=""
# skip SUDO if disabled # skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return [ -n "$EPMNOSUDO" ] && return
# set SUDO not for root user EFFUID=`id -u`
[ -n "$UID" ] || UID=`id -u`
# do not need sudo # do not need sudo
[ $UID = "0" ] && return [ $EFFUID = "0" ] && return
# use sudo if possible # use sudo if possible
which sudo >/dev/null 2>/dev/null && SUDO="sudo" && return which sudo >/dev/null 2>/dev/null && SUDO="sudo" && return
...@@ -219,6 +261,59 @@ set_sudo() ...@@ -219,6 +261,59 @@ set_sudo()
SUDO="fatal 'Can't find sudo. Please install sudo or run epm under root.'" SUDO="fatal 'Can't find sudo. Please install sudo or run epm under root.'"
} }
set_eatmydata()
{
# skip if disabled
[ -n "$EPMNOEATMYDATA" ] && return
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata"
info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
return 0
}
#
__get_package_for_command()
{
case "$1" in
equery|revdep-rebuild)
echo 'gentoolkit'
;;
update-kernel|remove-old-kernels)
echo 'update-kernel'
;;
esac
}
assure_exists()
{
load_helper epm-assure
__epm_assure "$1" $(__get_package_for_command "$1")
}
# improve
get_package_type()
{
local i
case $1 in
*.deb)
echo "deb"
return
;;
*.rpm)
echo "rpm"
return
;;
*)
#fatal "Don't know type of $1"
# return package name for info
echo "$1"
return 1
;;
esac
}
# print options description from HELPCMD/HELPOPT lines in the code # print options description from HELPCMD/HELPOPT lines in the code
get_help() get_help()
{ {
...@@ -248,15 +343,16 @@ if [ -n "$FORCEPM" ] ; then ...@@ -248,15 +343,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"
...@@ -272,6 +368,7 @@ case $DISTRNAME in ...@@ -272,6 +368,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"
...@@ -291,6 +388,12 @@ case $DISTRNAME in ...@@ -291,6 +388,12 @@ case $DISTRNAME in
OpenWRT) OpenWRT)
CMD="ipkg" CMD="ipkg"
;; ;;
GNU/Linux/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
...@@ -80,10 +83,9 @@ EOF ...@@ -80,10 +83,9 @@ EOF
;; ;;
zypper-rpm) zypper-rpm)
if ! __use_zypper_dry_run >/dev/null ; then if ! __use_zypper_dry_run >/dev/null ; then
echo "zypper is too old: does not support --dry-run" fatal "zypper is too old: does not support --dry-run"
return
fi fi
CMD="zypper --non-interactive install" CMD="zypper --non-interactive install --dry-run"
;; ;;
emerge) emerge)
local res=0 local res=0
...@@ -114,7 +116,7 @@ EOF ...@@ -114,7 +116,7 @@ EOF
pkg_filenames="$pkg-[0-9]" epm_search | grep -E "(installed|upgrade)" && continue pkg_filenames="$pkg-[0-9]" epm_search | grep -E "(installed|upgrade)" && continue
pkg_filenames="$pkg" epm_search | grep -E "(installed|upgrade)" && continue pkg_filenames="$pkg" epm_search | grep -E "(installed|upgrade)" && continue
res=1 res=1
echo "Does not found in repository." info "Package '$pkg' does not found in repository."
done done
return $res ;; return $res ;;
*) *)
...@@ -127,16 +129,16 @@ EOF ...@@ -127,16 +129,16 @@ EOF
epm_simulate() epm_simulate()
{ {
[ -z "$pkg_filenames" ] && echo "Skip empty list" && return 22 [ -z "$pkg_filenames" ] && info "Simulate: Skip empty list" && return 22
local filenames="$(echo $pkg_filenames | filter_out_installed_packages)" local filenames="$(echo $pkg_filenames | filter_out_installed_packages)"
[ -z "$filenames" ] && echo "All packages are already installed" && return 0 [ -z "$filenames" ] && info "Simulate: All packages are already installed" && return 0
_epm_do_simulate $filenames _epm_do_simulate $filenames
local RES=$? local RES=$?
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
[ "$RES" = 0 ] && echo "Result: $filenames package(s) CAN BE installed" || echo "Result: There are PROBLEMS with install some package(s)" [ "$RES" = 0 ] && info "Simulate result: $filenames package(s) CAN BE installed" || info "Simulate result: There are PROBLEMS with install some package(s)"
fi fi
return $RES return $RES
} }
......
#!/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
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
epm_update() epm_update()
{ {
echo "Run command for update remote package repository database" info "Running command for update remote package repository database"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
...@@ -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,10 +17,16 @@ ...@@ -17,10 +17,16 @@
# 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
echo "Run command for upgrade packages"
# it is useful for first time running
update_repo_if_needed
info "Running command for upgrade packages"
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
...@@ -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"
...@@ -61,7 +70,9 @@ epm_upgrade() ...@@ -61,7 +70,9 @@ epm_upgrade()
CMD="chocolatey update all" CMD="chocolatey update all"
;; ;;
homebrew) homebrew)
CMD="brew upgrade" #CMD="brew upgrade"
sudocmd "brew upgrade `brew outdated`"
return
;; ;;
ipkg) ipkg)
CMD="ipkg upgrade" CMD="ipkg upgrade"
...@@ -69,6 +80,9 @@ epm_upgrade() ...@@ -69,6 +80,9 @@ epm_upgrade()
slackpkg) slackpkg)
CMD="/usr/sbin/slackpkg upgrade-all" CMD="/usr/sbin/slackpkg upgrade-all"
;; ;;
guix)
CMD="guix package -u"
;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
......
...@@ -20,20 +20,24 @@ ...@@ -20,20 +20,24 @@
epm_whatdepends() epm_whatdepends()
{ {
local CMD local CMD
[ -n "$pkg_names" ] || fatal "Run query without names" [ -n "$pkg_filenames" ] || fatal "Whatdepends: missing package(s) name"
# by package name # by package name
case $PMTYPE in 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"
;; ;;
emerge) emerge)
assure_exists equery
CMD="equery depends -a" CMD="equery depends -a"
;; ;;
*) *)
...@@ -41,6 +45,6 @@ case $PMTYPE in ...@@ -41,6 +45,6 @@ case $PMTYPE in
;; ;;
esac esac
docmd $CMD $pkg_names docmd $CMD $pkg_filenames
} }
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
epm_whatprovides() epm_whatprovides()
{ {
local CMD local CMD
[ -n "$pkg_names" ] || fatal "Run query without names" [ -n "$pkg_filenames" ] || fatal "Whatprovides: missing package(s) name"
# by package name # by package name
case $PMTYPE in 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
;; ;;
...@@ -42,6 +42,6 @@ case $PMTYPE in ...@@ -42,6 +42,6 @@ case $PMTYPE in
;; ;;
esac esac
docmd $CMD $pkg_names docmd $CMD $pkg_filenames
} }
epm
\ No newline at end of file
#!/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 p6 automatically by rpmbph script. Do not edit it. # This spec is backported to ALTLinux p6 automatically by rpmbph script. Do not edit it.
# #
Name: eepm Name: eepm
Version: 1.4.1 Version: 1.5.1
Release: alt0.M60P.1 Release: alt0.M60P.1
Summary: Etersoft EPM package manager Summary: Etersoft EPM package manager
...@@ -23,7 +23,8 @@ Conflicts: epm ...@@ -23,7 +23,8 @@ Conflicts: epm
Provides: upm Provides: upm
%if %_vendor == "alt" %if %_vendor == "alt"
Requires: apt rpm apt-repo # FIXHERE: Replace with target platform package manager
Requires: apt rpm
%endif %endif
%description %description
...@@ -65,9 +66,69 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}* ...@@ -65,9 +66,69 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv %_sysconfdir/bash_completion.d/cerv
%changelog %changelog
* Thu Sep 05 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.1-alt0.M60P.1 * Wed Mar 05 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.1-alt0.M60P.1
- backport to ALTLinux p6 (by rpmbph script) - backport to ALTLinux p6 (by rpmbph script)
* Wed Mar 05 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.1-alt1
- epm: check real file detection
- checkpkg: use assure for erc
- simulate: add missed --dry-run for zypper
- epm-check_updated: fix if perms is unsufficient
* 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
- epm provides/requires: fix for rpm files
- separate check input and output
- epm-filelist: add less
- realize autoremove orphaned packages (unused libs*)
* Tue Oct 22 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.4-alt1
- epm: get package names from stdin if it is pipe
- fix stderr issues
* Mon Oct 21 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.3-alt1
- rewrite code without bashisms
- search colorifer: fix colorifing all args
- epm: use eatmydata if installed (set EPMNOEATMYDATA for skip)
- add initial support for epm conflicts
- whatdepends/whatprovides: all use exists files as goals
- add epmsf as link to epm sf command
- epm: normalize options
- epmql (epm-filelist): add support for list files of the remote packages
* Tue Oct 08 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.2-alt1
- add initial support for guix
- rewrite epm_requires and epm_provides
- remove mandatory requires to apt-repo
- fix epm query on Gentoo (disable colorifing for grep)
- epm-query: support for short form of package name on Gentoo
- epm-query: realize is_installed via internal function (for pkg names only), speed optimize
- improve MacOS support
- epm-query: fix for query non installed packages
- epm-filelist: allow list of foreign packages
- introduce get_package_type and use it
- epm-remove: do not use --purge on apt-rpm
- epm-changelog: add support for noninstalled packages on ALT
- install: do non interactive really non interactive
* Thu Sep 05 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.1-alt1 * Thu Sep 05 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.1-alt1
- add initial man page file - add initial man page file
- epm-filelist: add todo for less - epm-filelist: add todo for less
......
...@@ -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"
...@@ -95,7 +124,7 @@ showcmd() ...@@ -95,7 +124,7 @@ showcmd()
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#" [ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@" echo " $PROMTSIG $@"
restore_color restore_color
fi >&2 fi >&2
...@@ -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"
} }
...@@ -170,18 +199,21 @@ store_output() ...@@ -170,18 +199,21 @@ store_output()
{ {
# use make_temp_file from etersoft-build-utils # use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp) RC_STDOUT=$(mktemp)
local CMDSTATUS=$RC_STDOUT.pipestatus
echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp) #RC_STDERR=$(mktemp)
"$@" 2>&1 | tee $RC_STDOUT ( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return $PIPESTATUS #return $PIPESTATUS
} }
clean_store_output() clean_store_output()
{ {
rm -f $RC_STDOUT rm -f $RC_STDOUT $RC_STDOUT.pipestatus
} }
epm() epm()
{ {
$PROGDIR/epm $@ $PROGDIR/epm $@
...@@ -208,11 +240,10 @@ set_sudo() ...@@ -208,11 +240,10 @@ set_sudo()
# skip SUDO if disabled # skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return [ -n "$EPMNOSUDO" ] && return
# set SUDO not for root user EFFUID=`id -u`
[ -n "$UID" ] || UID=`id -u`
# do not need sudo # do not need sudo
[ $UID = "0" ] && return [ $EFFUID = "0" ] && return
# use sudo if possible # use sudo if possible
which sudo >/dev/null 2>/dev/null && SUDO="sudo" && return which sudo >/dev/null 2>/dev/null && SUDO="sudo" && return
...@@ -220,6 +251,62 @@ set_sudo() ...@@ -220,6 +251,62 @@ set_sudo()
SUDO="fatal 'Can't find sudo. Please install sudo or run epm under root.'" SUDO="fatal 'Can't find sudo. Please install sudo or run epm under root.'"
} }
set_eatmydata()
{
# skip if disabled
[ -n "$EPMNOEATMYDATA" ] && return
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata"
isatty && echo "Uwaga! eatmydata is installed, we will use it for disable all sync operations." >&2
return 0
}
assure_exists()
{
PATH=$PATH:/sbin:/usr/sbin which $1 2>/dev/null >/dev/null && return
echo "Install appropriate package for $1 command..."
case $1 in
equery|revdep-rebuild)
epm install gentoolkit
;;
apt-repo)
epm install apt-repo
;;
apt-file)
epm install apt-file
;;
update-kernel|remove-old-kernels)
epm install update-kernel
;;
*)
fatal "Internal error: Unknown binary $1 to check if exists"
;;
esac
}
get_package_type()
{
local i
case $1 in
*.deb)
echo "deb"
return
;;
*.rpm)
echo "rpm"
return
;;
*)
#fatal "Don't know type of $1"
# return package name for info
echo "$1"
return 1
;;
esac
}
get_help() get_help()
{ {
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do
...@@ -246,15 +333,16 @@ if [ -n "$FORCEPM" ] ; then ...@@ -246,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"
...@@ -270,6 +358,7 @@ case $DISTRNAME in ...@@ -270,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"
...@@ -289,6 +378,12 @@ case $DISTRNAME in ...@@ -289,6 +378,12 @@ case $DISTRNAME in
OpenWRT) OpenWRT)
CMD="ipkg" CMD="ipkg"
;; ;;
GNU/Linux/Guix)
CMD="guix"
;;
Android)
CMD="android"
;;
*) *)
fatal "Have no suitable DISTRNAME $DISTRNAME" fatal "Have no suitable DISTRNAME $DISTRNAME"
;; ;;
...@@ -649,6 +744,7 @@ pkgtype() ...@@ -649,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" ;;
...@@ -836,6 +932,21 @@ elif [ `uname` = "SunOS" ] ; then ...@@ -836,6 +932,21 @@ elif [ `uname` = "SunOS" ] ; then
DISTRIB_ID="SunOS" DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: can we detect by some file?
elif [ `uname` = "Darwin" ] ; then
DISTRIB_ID="MacOS"
DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
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 # 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
...@@ -981,7 +1092,7 @@ $(get_help HELPOPT) ...@@ -981,7 +1092,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.4.1" 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