Commit efc1a899 authored by Vitaly Lipatov's avatar Vitaly Lipatov

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

parents 9bc1e7ad f136d576
Чтобы было легко выстраивать цепочки, нужно ввод не с консоли (если есть) воспринимать как параметры.
2. Дописать таблицу на вики на основании реализованных команд. 2. Дописать таблицу на вики на основании реализованных команд.
3. Доделать и проверить deplist|requires 3. Доделать и проверить deplist|requires
https://wiki.archlinux.org/index.php/Pacman_Rosetta https://wiki.archlinux.org/index.php/Pacman_Rosetta
......
...@@ -237,6 +237,16 @@ elif [ `uname` = "SunOS" ] ; then ...@@ -237,6 +237,16 @@ 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)
# 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, 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
...@@ -37,6 +37,7 @@ load_helper epm-sh-functions ...@@ -37,6 +37,7 @@ load_helper epm-sh-functions
#PATH=$PATH:/sbin:/usr/sbin #PATH=$PATH:/sbin:/usr/sbin
set_sudo set_sudo
set_eatmydata
check_tty check_tty
...@@ -97,6 +98,9 @@ case $progname in ...@@ -97,6 +98,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,80 +137,83 @@ check_command() ...@@ -133,80 +137,83 @@ 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|which|belongs) # HELPCMD: query package(s) owning file
epm_cmd=query_file epm_cmd=query_file
;; ;;
# Useful commands # Useful commands
reinstall) # HELPCMD: reinstall package(s) from remote repositories or from local file reinstall) # HELPCMD: reinstall package(s) from remote repositories or from local file
epm_cmd=reinstall epm_cmd=reinstall
;; ;;
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) # HELPCMD: print package requires
epm_cmd=requires epm_cmd=requires
;; ;;
provides) # HELPCMD: print package provides provides) # HELPCMD: print package provides
epm_cmd=provides epm_cmd=provides
;; ;;
whatdepends) # HELPCMD: print packages dependences on that whatdepends) # HELPCMD: print packages dependences on that
epm_cmd=whatdepends epm_cmd=whatdepends
;; ;;
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: list of installed package(s)
epm_cmd=packages epm_cmd=packages
;; ;;
programs) # HELPCMD: list of installed GUI program(s) programs) # HELPCMD: list of installed GUI program(s)
epm_cmd=programs epm_cmd=programs
;; ;;
# Repository control # Repository control
update) # HELPCMD: update remote package repository databases update) # HELPCMD: update remote package repository databases
epm_cmd=update epm_cmd=update
;; ;;
addrepo|ar) # HELPCMD: add package repo addrepo|ar) # HELPCMD: add package repo
epm_cmd=addrepo epm_cmd=addrepo
;; ;;
repolist|sl|rl|listrepo) # HELPCMD: print repo list repolist|sl|rl|listrepo) # HELPCMD: print repo list
epm_cmd=repolist epm_cmd=repolist
;; ;;
removerepo|rr) # HELPCMD: remove package repo removerepo|rr) # HELPCMD: remove package repo
epm_cmd=removerepo epm_cmd=removerepo
;; ;;
release-upgrade) # HELPCMD: update whole system to the next release release-upgrade) # HELPCMD: update whole system to the next release
epm_cmd=release_upgrade epm_cmd=release_upgrade
;; ;;
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel) # HELPCMD: update system kernel to the last repo version kernel-update|kernel-upgrade|update-kernel|upgrade-kernel) # HELPCMD: update system kernel to the last repo version
...@@ -214,22 +221,22 @@ check_command() ...@@ -214,22 +221,22 @@ check_command()
;; ;;
# Other commands # Other commands
clean) # HELPCMD: clean local package cache clean) # HELPCMD: clean local package cache
epm_cmd=clean epm_cmd=clean
;; ;;
autoremove) # HELPCMD: auto remove unneeded package(s) autoremove) # HELPCMD: auto remove unneeded package(s)
epm_cmd=autoremove epm_cmd=autoremove
;; ;;
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: performs update && upgrade command
epm_cmd=Upgrade epm_cmd=Upgrade
;; ;;
simulate) # HELPCMD: simulate install (it does check requires, minimally) simulate) # HELPCMD: simulate install (it does check requires, minimally)
epm_cmd=simulate epm_cmd=simulate
;; ;;
checkpkg|integrity) # HELPCMD: check package integrity checkpkg|integrity) # HELPCMD: check package integrity
epm_cmd=checkpkg epm_cmd=checkpkg
;; ;;
...@@ -285,18 +292,30 @@ check_option() ...@@ -285,18 +292,30 @@ check_option()
return 0 return 0
} }
for opt in "$@" ; do check_filenames()
check_command $opt && continue {
check_option $opt && continue local opt="$1"
if [ -f "$opt" ] && echo $opt | grep -q "\." ; then if [ -f "$opt" ] && echo $opt | grep -q "\." ; then
pkg_files="$pkg_files $opt" pkg_files="$pkg_files $opt"
else else
pkg_names="$pkg_names $opt" pkg_names="$pkg_names $opt"
fi fi
quoted_args="$quoted_args \"$opt\"" quoted_args="$quoted_args \"$opt\""
}
for opt in "$@" ; do
check_command $opt && continue
check_option $opt && continue
check_filenames $opt
done done
# if input is not console, get pkg from it too
if ! tty -s ; then
for opt in $(cat) ; do
check_filenames $opt
done
fi
pkg_files=$(strip_spaces "$pkg_files") pkg_files=$(strip_spaces "$pkg_files")
pkg_names=$(strip_spaces "$pkg_names") pkg_names=$(strip_spaces "$pkg_names")
......
...@@ -21,6 +21,7 @@ epm_addrepo() ...@@ -21,6 +21,7 @@ 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)
......
...@@ -21,6 +21,7 @@ epm_autoremove() ...@@ -21,6 +21,7 @@ epm_autoremove()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
assure_exists remove-old-kernels
# ALT Linux only # ALT Linux only
sudocmd remove-old-kernels sudocmd remove-old-kernels
;; ;;
...@@ -45,7 +46,7 @@ case $PMTYPE in ...@@ -45,7 +46,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 +56,9 @@ case $PMTYPE in ...@@ -55,6 +56,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()
...@@ -46,12 +54,11 @@ __epm_changelog_local_names() ...@@ -46,12 +54,11 @@ __epm_changelog_local_names()
docmd_foreach "rpm --changelog" $@ | less docmd_foreach "rpm --changelog" $@ | less
;; ;;
apt-dpkg) apt-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"
;; ;;
......
...@@ -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
;; ;;
...@@ -39,8 +38,10 @@ check_pkg_integrity() ...@@ -39,8 +38,10 @@ check_pkg_integrity()
;; ;;
*) *)
docmd erc test "$PKG" && return docmd erc test "$PKG" && return
which erc >/dev/null 2>/dev/null && fatal "Check failed" which erc >/dev/null 2>/dev/null && fatal "Check failed."
fatal "Install erc package." fatal "Install erc package for file package."
# TODO
epm install erc
;; ;;
esac esac
} }
...@@ -54,6 +55,10 @@ case $PMTYPE in ...@@ -54,6 +55,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"
;; ;;
......
#!/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"
;;
#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
;;
#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 "Run query without names"
epm_conflicts_files
epm_conflicts_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
...@@ -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"
;; ;;
*) *)
...@@ -70,6 +111,10 @@ __epm_filelist_name() ...@@ -70,6 +111,10 @@ __epm_filelist_name()
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g" docmd pacman -Ql $pkg_names | sed -e "s|.* ||g"
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}*
...@@ -82,7 +127,7 @@ __epm_filelist_name() ...@@ -82,7 +127,7 @@ __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
} }
......
...@@ -28,6 +28,8 @@ __epm_info_rpm_low() ...@@ -28,6 +28,8 @@ __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()
{ {
case $PMTYPE in case $PMTYPE in
...@@ -71,12 +73,22 @@ case $PMTYPE in ...@@ -71,12 +73,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"
;; ;;
......
...@@ -143,6 +143,9 @@ epm_install_names() ...@@ -143,6 +143,9 @@ 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 ;;
*) *)
fatal "Have no suitable install command for $PMTYPE" fatal "Have no suitable install command for $PMTYPE"
;; ;;
...@@ -155,6 +158,7 @@ epm_ni_install_names() ...@@ -155,6 +158,7 @@ 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 ;;
yum-rpm) yum-rpm)
......
...@@ -23,6 +23,7 @@ epm_kernel_update() ...@@ -23,6 +23,7 @@ epm_kernel_update()
case $DISTRNAME in case $DISTRNAME in
ALTLinux) ALTLinux)
assure_exists update-kernel
sudocmd update-kernel sudocmd update-kernel
return ;; return ;;
esac esac
......
...@@ -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,14 @@ case $PMTYPE in ...@@ -87,11 +88,14 @@ 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"
;;
*) *)
fatal "Have no suitable query command for $PMTYPE" fatal "Have no suitable query command for $PMTYPE"
;; ;;
......
...@@ -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"
CMD="rpm -q --provides -p" ;;
;; deb)
# apt-dpkg) # FIXME: will we provide ourself?
# showcmd dpkg -s $pkg_files docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g"
# 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,34 @@ case $PMTYPE in ...@@ -58,19 +64,34 @@ 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
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 "Run query without names"
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
...@@ -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
......
...@@ -79,6 +79,7 @@ __do_query() ...@@ -79,6 +79,7 @@ __do_query()
CMD="rpm -qf" CMD="rpm -qf"
;; ;;
emerge) emerge)
assure_exists equery
CMD="equery belongs" CMD="equery belongs"
;; ;;
pacman) pacman)
...@@ -116,6 +117,7 @@ __do_short_query() ...@@ -116,6 +117,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)
......
...@@ -22,7 +22,7 @@ load_helper epm-search ...@@ -22,7 +22,7 @@ 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=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS EXTRA_SHOWDOCMD=$MGS
......
...@@ -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"
;; ;;
......
...@@ -51,9 +51,12 @@ epm_remove_names() ...@@ -51,9 +51,12 @@ 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 ;;
apt-rpm)
sudocmd apt-get remove $@
return ;;
deepsolver-rpm) deepsolver-rpm)
sudocmd ds-remove $@ sudocmd ds-remove $@
return ;; return ;;
...@@ -91,6 +94,9 @@ epm_remove_names() ...@@ -91,6 +94,9 @@ epm_remove_names()
nix) nix)
sudocmd nix-env --uninstall $@ sudocmd nix-env --uninstall $@
return ;; return ;;
guix)
sudocmd guix package -r $@
return ;;
chocolatey) chocolatey)
sudocmd chocolatey uninstall $@ sudocmd chocolatey uninstall $@
return ;; return ;;
...@@ -113,9 +119,12 @@ epm_remove_names() ...@@ -113,9 +119,12 @@ 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 ;;
apt-rpm)
sudocmd apt-get -y --force-yes remove $@
return ;;
urpm-rpm) urpm-rpm)
sudocmd urpme --auto $@ sudocmd urpme --auto $@
return ;; return ;;
......
...@@ -21,6 +21,7 @@ epm_removerepo() ...@@ -21,6 +21,7 @@ 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)
......
...@@ -32,6 +32,7 @@ epm_repolist() ...@@ -32,6 +32,7 @@ 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)
...@@ -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,46 @@ ...@@ -17,36 +17,46 @@
# 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: Здесь выбирать команду по расширению, а не по системному менеджеру case $(get_package_type $pkg_files) in
# В других таких случаях тоже rpm)
# В списке пакетов на установку проверять, что пакеты имеют соответствующее расширение docmd "rpm -q --requires -p"
# by package file ;;
case $PMTYPE in deb)
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm) a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
CMD="rpm -q --requires -p" ;;
;; *)
apt-dpkg) fatal "Have no suitable command for $PMTYPE"
# FIXME: need package base ;;
showcmd dpkg -s $pkg_files esac
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"
;;
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"
;; ;;
...@@ -57,7 +67,18 @@ case $PMTYPE in ...@@ -57,7 +67,18 @@ case $PMTYPE in
CMD="pactree" CMD="pactree"
;; ;;
apt-dpkg) apt-dpkg)
CMD="apt-cache depends" # 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"
fi
;;
emerge)
assure_exists equery
CMD="equery depgraph"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
...@@ -65,6 +86,13 @@ case $PMTYPE in ...@@ -65,6 +86,13 @@ case $PMTYPE in
esac esac
[ -n "$pkg_names" ] && docmd $CMD $pkg_names docmd $CMD $pkg_names
} }
epm_requires()
{
[ -n "$pkg_filenames" ] || fatal "Run query without names"
epm_requires_files
epm_requires_names
}
...@@ -70,6 +70,9 @@ case $PMTYPE in ...@@ -70,6 +70,9 @@ case $PMTYPE in
homebrew) homebrew)
CMD="brew search" CMD="brew search"
;; ;;
guix)
CMD="guix package -A"
;;
*) *)
fatal "Have no suitable search command for $PMTYPE" fatal "Have no suitable search command for $PMTYPE"
;; ;;
...@@ -87,20 +90,39 @@ __epm_search_make_grep() ...@@ -87,20 +90,39 @@ __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" ] && echo -n " | 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?
echo -n " | egrep -i -- \"$i\""
done
local COLO=""
# rule for colorife
for i in $list $listN; do
[ -n "$COLO" ] && COLO="$COLO|"
COLO="$COLO$i"
done done
# FIXME -n on MacOS?
if [ -n "$list" ] ; then
echo -n " | egrep -i --color -- \"($COLO)\""
fi
} }
# copied from korinf/tools/run-script/scripts/search # copied from korinf/tools/run-script/scripts/search
......
...@@ -50,6 +50,7 @@ case $PMTYPE in ...@@ -50,6 +50,7 @@ case $PMTYPE in
local_content_search $pkg_filenames local_content_search $pkg_filenames
return ;; return ;;
apt-dpkg) apt-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 ;;
......
...@@ -23,7 +23,8 @@ isatty() ...@@ -23,7 +23,8 @@ isatty()
# Set a sane TERM required for tput # Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb [ -n "$TERM" ] || TERM=dumb
export TERM export TERM
test -t 1 # check stderr
test -t 2
} }
check_tty() check_tty()
...@@ -83,7 +84,7 @@ showcmd() ...@@ -83,7 +84,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
...@@ -163,15 +164,19 @@ store_output() ...@@ -163,15 +164,19 @@ 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
} }
...@@ -207,11 +212,10 @@ set_sudo() ...@@ -207,11 +212,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
...@@ -219,6 +223,63 @@ set_sudo() ...@@ -219,6 +223,63 @@ 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"
tty -s && 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
}
# 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()
{ {
...@@ -291,6 +352,9 @@ case $DISTRNAME in ...@@ -291,6 +352,9 @@ case $DISTRNAME in
OpenWRT) OpenWRT)
CMD="ipkg" CMD="ipkg"
;; ;;
GNU/Linux/Guix)
CMD="guix"
;;
*) *)
fatal "Have no suitable DISTRNAME $DISTRNAME" fatal "Have no suitable DISTRNAME $DISTRNAME"
;; ;;
......
...@@ -61,7 +61,9 @@ epm_upgrade() ...@@ -61,7 +61,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 +71,9 @@ epm_upgrade() ...@@ -69,6 +71,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,7 +20,7 @@ ...@@ -20,7 +20,7 @@
epm_whatdepends() epm_whatdepends()
{ {
local CMD local CMD
[ -n "$pkg_names" ] || fatal "Run query without names" [ -n "$pkg_filenames" ] || fatal "Run query without names"
# by package name # by package name
case $PMTYPE in case $PMTYPE in
...@@ -34,6 +34,7 @@ case $PMTYPE in ...@@ -34,6 +34,7 @@ case $PMTYPE in
CMD="repoquery --whatrequires" CMD="repoquery --whatrequires"
;; ;;
emerge) emerge)
assure_exists equery
CMD="equery depends -a" CMD="equery depends -a"
;; ;;
*) *)
...@@ -41,6 +42,6 @@ case $PMTYPE in ...@@ -41,6 +42,6 @@ case $PMTYPE in
;; ;;
esac esac
docmd $CMD $pkg_names docmd $CMD $pkg_filenames
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
epm_whatprovides() epm_whatprovides()
{ {
local CMD local CMD
[ -n "$pkg_names" ] || fatal "Run query without names" [ -n "$pkg_filenames" ] || fatal "Run query without names"
# by package name # by package name
case $PMTYPE in case $PMTYPE in
...@@ -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
# This spec is backported to ALTLinux p7 automatically by rpmbph script. Do not edit it. # This spec is backported to ALTLinux p7 automatically by rpmbph script. Do not edit it.
# #
Name: eepm Name: eepm
Version: 1.4.1 Version: 1.4.4
Release: alt0.M70P.1 Release: alt0.M70P.1
Summary: Etersoft EPM package manager Summary: Etersoft EPM package manager
...@@ -22,9 +22,7 @@ Conflicts: epm ...@@ -22,9 +22,7 @@ Conflicts: epm
Provides: upm Provides: upm
%if %_vendor == "alt" Requires: apt rpm
Requires: apt rpm apt-repo
%endif
%description %description
Etersoft EPM is the package manager for any platform Etersoft EPM is the package manager for any platform
...@@ -65,9 +63,38 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}* ...@@ -65,9 +63,38 @@ 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.M70P.1 * Tue Oct 22 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.4-alt0.M70P.1
- backport to ALTLinux p7 (by rpmbph script) - backport to ALTLinux p7 (by rpmbph script)
* 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
......
...@@ -95,7 +95,7 @@ showcmd() ...@@ -95,7 +95,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
...@@ -170,15 +170,19 @@ store_output() ...@@ -170,15 +170,19 @@ 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
} }
...@@ -208,11 +212,10 @@ set_sudo() ...@@ -208,11 +212,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 +223,61 @@ set_sudo() ...@@ -220,6 +223,61 @@ 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"
echo "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
}
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
...@@ -289,6 +347,9 @@ case $DISTRNAME in ...@@ -289,6 +347,9 @@ case $DISTRNAME in
OpenWRT) OpenWRT)
CMD="ipkg" CMD="ipkg"
;; ;;
GNU/Linux/Guix)
CMD="guix"
;;
*) *)
fatal "Have no suitable DISTRNAME $DISTRNAME" fatal "Have no suitable DISTRNAME $DISTRNAME"
;; ;;
...@@ -836,6 +897,16 @@ elif [ `uname` = "SunOS" ] ; then ...@@ -836,6 +897,16 @@ 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)
# 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 +1052,7 @@ $(get_help HELPOPT) ...@@ -981,7 +1052,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.4.1" echo "Service manager version 1.4.2"
echo "Running on $($DISTRVENDOR)" echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013" echo "Copyright (c) Etersoft 2012, 2013"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment