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. Дописать таблицу на вики на основании реализованных команд.
3. Доделать и проверить deplist|requires
https://wiki.archlinux.org/index.php/Pacman_Rosetta
......
......@@ -237,6 +237,16 @@ elif [ `uname` = "SunOS" ] ; then
DISTRIB_ID="SunOS"
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
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2013 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -37,6 +37,7 @@ load_helper epm-sh-functions
#PATH=$PATH:/sbin:/usr/sbin
set_sudo
set_eatmydata
check_tty
......@@ -97,6 +98,9 @@ case $progname in
epms)
epm_cmd=search
;;
epmsf)
epm_cmd=search_file
;;
epmq)
epm_cmd=query
;;
......@@ -133,19 +137,19 @@ check_command()
# Base commands
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
;;
-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
;;
-s|search) # HELPCMD: search in remote package repositories
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
;;
-qf|which|belongs) # HELPCMD: query package(s) owning file
-qf|qf|which|belongs) # HELPCMD: query package(s) owning file
epm_cmd=query_file
;;
......@@ -156,22 +160,22 @@ check_command()
Install) # HELPCMD: perform update package repo info and install package(s) via install command
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
;;
-sf|sf|filesearch) # HELPCMD: search in which package a file is included
epm_cmd=search_file
;;
-ql|filelist) # HELPCMD: print package file list
-ql|ql|filelist) # HELPCMD: print package file list
epm_cmd=filelist
;;
check|fix|verify) # HELPCMD: check local package base integrity and fix it
epm_cmd=check
;;
changelog|cl) # HELPCMD: show changelog for package
changelog|cl|-cl) # HELPCMD: show changelog for package
epm_cmd=changelog
;;
-qi|info|show) # HELPCMD: print package detail info
-qi|qi|info|show) # HELPCMD: print package detail info
epm_cmd=info
;;
requires|deplist) # HELPCMD: print package requires
......@@ -186,7 +190,10 @@ check_command()
whatprovides) # HELPCMD: print packages provides that target
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
;;
programs) # HELPCMD: list of installed GUI program(s)
......@@ -285,18 +292,30 @@ check_option()
return 0
}
for opt in "$@" ; do
check_command $opt && continue
check_option $opt && continue
check_filenames()
{
local opt="$1"
if [ -f "$opt" ] && echo $opt | grep -q "\." ; then
pkg_files="$pkg_files $opt"
else
pkg_names="$pkg_names $opt"
fi
quoted_args="$quoted_args \"$opt\""
}
for opt in "$@" ; do
check_command $opt && continue
check_option $opt && continue
check_filenames $opt
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_names=$(strip_spaces "$pkg_names")
......
......@@ -21,6 +21,7 @@ epm_addrepo()
{
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
sudocmd apt-repo add $pkg_filenames
;;
apt-dpkg)
......
......@@ -21,6 +21,7 @@ epm_autoremove()
{
case $PMTYPE in
apt-rpm)
assure_exists remove-old-kernels
# ALT Linux only
sudocmd remove-old-kernels
;;
......@@ -45,7 +46,7 @@ case $PMTYPE in
;;
emerge)
sudocmd emerge --depclean
docmd epm --skip-installed install gentoolkit
assure_exists revdep-rebuild
sudocmd revdep-rebuild
;;
pacman)
......@@ -55,6 +56,9 @@ case $PMTYPE in
# clean-system removes non official packages
#sudocmd slackpkg clean-system
;;
guix)
sudocmd guix gc
;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
......
......@@ -19,22 +19,30 @@
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()
{
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm)
# TODO: detect every file
case $(get_package_type $1) in
rpm)
docmd_foreach "rpm -p --changelog" $@ | less
;;
# apt-dpkg)
# deb)
#
# ;;
*)
fatal "Have no suitable command for $PMTYPE"
fatal "Have no suitable command for $1"
;;
esac
}
__epm_changelog_local_names()
......@@ -46,12 +54,11 @@ __epm_changelog_local_names()
docmd_foreach "rpm --changelog" $@ | less
;;
apt-dpkg)
# FIXME: only first pkg
docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
;;
emerge)
docmd view /usr/portage/category/$1/ChangeLog | less
# docmd equery changes -f $1 | less
assure_exists equery
docmd equery changes -f $1 | less
;;
pacman)
docmd pacman -Qc $1 | less
......@@ -67,9 +74,9 @@ __epm_changelog_unlocal_names()
[ -z "$*" ] && return
case $PMTYPE in
#apt-rpm)
# docmd_foreach "rpm --changelog" $@ | less
# ;;
apt-rpm)
__epm_changelog_apt $@ | less
;;
#apt-dpkg)
# # FIXME: only first pkg
# docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
......@@ -83,6 +90,10 @@ __epm_changelog_unlocal_names()
#zypper-rpm)
# sudocmd zypper clean
# ;;
emerge)
assure_exists equery
docmd equery changes -f $1 | less
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -19,11 +19,10 @@
check_pkg_integrity()
{
local EXT=`echo "$1" | sed -e "s|.*\.\([a-z0-9]*\)\$|\1|g"`
local PKG="$1"
local RET
case $EXT in
case $(get_package_type $PKG) in
rpm)
docmd rpm --checksig $PKG
;;
......@@ -39,8 +38,10 @@ check_pkg_integrity()
;;
*)
docmd erc test "$PKG" && return
which erc >/dev/null 2>/dev/null && fatal "Check failed"
fatal "Install erc package."
which erc >/dev/null 2>/dev/null && fatal "Check failed."
fatal "Install erc package for file package."
# TODO
epm install erc
;;
esac
}
......@@ -54,6 +55,10 @@ case $PMTYPE in
*-dpkg)
docmd debsums $@
;;
emerge)
assure_exists equery
docmd equery check $@
;;
*)
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
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -19,17 +19,58 @@
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()
{
local CMD
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
# TODO: allow a new packages
case $(get_package_type $1) in
rpm)
CMD="rpm -qlp"
;;
apt-dpkg)
deb)
CMD="dpkg --contents"
;;
*)
......@@ -70,6 +111,10 @@ __epm_filelist_name()
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g"
return
;;
emerge)
assure_exists equery
CMD="equery files"
;;
slackpkg)
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}*
......@@ -82,7 +127,7 @@ __epm_filelist_name()
# TODO: add less
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()
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()
{
case $PMTYPE in
......@@ -71,12 +73,22 @@ case $PMTYPE in
is_installed $pkg_names && docmd conary query $pkg_names --info && return
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)
docmd /usr/sbin/slackpkg info $pkg_names
;;
ipkg)
docmd ipkg info $pkg_names
;;
homebrew)
docmd brew info $pkg_names
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -143,6 +143,9 @@ epm_install_names()
nix)
__separate_sudocmd "nix-env --install" "nix-env --upgrade" $@
return ;;
guix)
__separate_sudocmd "guix package -i" "guix package -i" $@
return ;;
*)
fatal "Have no suitable install command for $PMTYPE"
;;
......@@ -155,6 +158,7 @@ epm_ni_install_names()
[ -z "$1" ] && return
case $PMTYPE in
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 $@
return ;;
yum-rpm)
......
......@@ -23,6 +23,7 @@ epm_kernel_update()
case $DISTRNAME in
ALTLinux)
assure_exists update-kernel
sudocmd update-kernel
return ;;
esac
......
......@@ -52,9 +52,10 @@ case $PMTYPE in
CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
;;
# Note: dnf has dnf list command
emerge)
CMD="qlist -I"
CMD="qlist -I -C"
# print with colors for console output
isatty && CMD="qlist -I"
;;
pkgsrc)
CMD="pkg_info"
......@@ -87,11 +88,14 @@ case $PMTYPE in
fi
;;
homebrew)
CMD="brew $pkg_filenames"
CMD="brew list $pkg_filenames"
;;
ipkg)
CMD="ipkg list"
;;
guix)
CMD="guix package -I"
;;
*)
fatal "Have no suitable query command for $PMTYPE"
;;
......
......@@ -19,35 +19,41 @@
load_helper epm-query
epm_provides()
epm_provides_files()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Run query without names"
[ -n "$pkg_files" ] || return
# by package file
case $PMTYPE in
*-rpm)
CMD="rpm -q --provides -p"
case $(get_package_type $pkg_files) in
rpm)
docmd "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"
;;
esac
esac
}
[ -n "$pkg_files" ] && docmd $CMD $pkg_files
epm_provides_names()
{
local CMD
[ -n "$pkg_names" ] || return
# by package name
case $PMTYPE in
apt-rpm)
# FIXME: need fix for a few names case
# TODO: separate this function to two section
if is_installed $pkg_names ; then
CMD="rpm -q --provides"
else
CMD="apt-cache depends"
EXTRA_SHOWDOCMD=' | grep "Provides:"'
docmd apt-cache show $pkg_names | grep "Provides:"
return
fi
;;
urpm-rpm|zypper-rpm|yum-rpm)
......@@ -58,19 +64,34 @@ case $PMTYPE in
fi
;;
emerge)
assure_exists equery
CMD="equery files"
;;
# yum-rpm)
# CMD="yum deplist"
# ;;
# apt-dpkg)
# CMD="apt-cache depends"
# ;;
apt-dpkg)
# 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"
;;
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 @@
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()
{
local res=0
local grepexp
local firstpkg=$1
shift
grepexp=$(_get_grep_exp $firstpkg)
# 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
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
return $res
......@@ -75,7 +88,7 @@ __epm_get_hilevel_name()
for i in $@ ; do
local 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
[ "$pkg" = "$i" ] && echo "$i" && continue
# try get long form or use short form
......@@ -129,7 +142,7 @@ __epm_query_name()
conary)
CMD="conary query"
;;
brew)
homebrew)
warning "fix query"
return 1
;;
......@@ -146,8 +159,9 @@ __epm_query_name()
# check if pkg is installed
is_installed()
{
#pkg_filenames="$@" epm_query >/dev/null
epm installed $@ >/dev/null 2>/dev/null
pkg_filenames="$@" pkg_names="$@" epm_query >/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
......
......@@ -79,6 +79,7 @@ __do_query()
CMD="rpm -qf"
;;
emerge)
assure_exists equery
CMD="equery belongs"
;;
pacman)
......@@ -116,6 +117,7 @@ __do_short_query()
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")
return ;;
NOemerge)
assure_exists equery
CMD="equery belongs"
;;
NOpacman)
......
......@@ -22,7 +22,7 @@ load_helper epm-search
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
local MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS
......
......@@ -63,6 +63,12 @@ epm_release_upgrade()
conary)
epm Upgrade
;;
emerge)
epm Upgrade
;;
guix)
sudocmd guix pull --verbose
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -51,9 +51,12 @@ epm_remove_names()
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|apt-dpkg)
apt-dpkg)
sudocmd apt-get remove --purge $@
return ;;
apt-rpm)
sudocmd apt-get remove $@
return ;;
deepsolver-rpm)
sudocmd ds-remove $@
return ;;
......@@ -91,6 +94,9 @@ epm_remove_names()
nix)
sudocmd nix-env --uninstall $@
return ;;
guix)
sudocmd guix package -r $@
return ;;
chocolatey)
sudocmd chocolatey uninstall $@
return ;;
......@@ -113,9 +119,12 @@ epm_remove_names()
epm_remove_nonint()
{
case $PMTYPE in
apt-rpm|apt-dpkg)
apt-dpkg)
sudocmd apt-get -y --force-yes remove --purge $@
return ;;
apt-rpm)
sudocmd apt-get -y --force-yes remove $@
return ;;
urpm-rpm)
sudocmd urpme --auto $@
return ;;
......
......@@ -21,6 +21,7 @@ epm_removerepo()
{
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
sudocmd apt-repo rm $pkg_filenames
;;
apt-dpkg)
......
......@@ -32,6 +32,7 @@ epm_repolist()
{
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
docmd apt-repo list
;;
deepsolver-rpm)
......@@ -54,6 +55,7 @@ case $PMTYPE in
docmd zypper sl -d
;;
emerge)
docmd eselect profile list
docmd layman -L
;;
pacman)
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -17,36 +17,46 @@
# 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_filenames" ] || fatal "Run query without names"
[ -n "$pkg_files" ] || return
# TODO: Здесь выбирать команду по расширению, а не по системному менеджеру
# В других таких случаях тоже
# В списке пакетов на установку проверять, что пакеты имеют соответствующее расширение
# by package file
case $PMTYPE in
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm)
CMD="rpm -q --requires -p"
case $(get_package_type $pkg_files) in
rpm)
docmd "rpm -q --requires -p"
;;
apt-dpkg)
# FIXME: need package base
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
deb)
a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
esac
}
[ -n "$pkg_files" ] && docmd $CMD $pkg_files
epm_requires_names()
{
local CMD
[ -n "$pkg_names" ] || return
# by package name
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
CMD="rpm -q --requires"
;;
......@@ -57,7 +67,18 @@ case $PMTYPE in
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 "^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"
......@@ -65,6 +86,13 @@ case $PMTYPE in
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
homebrew)
CMD="brew search"
;;
guix)
CMD="guix package -A"
;;
*)
fatal "Have no suitable search command for $PMTYPE"
;;
......@@ -87,20 +90,39 @@ __epm_search_make_grep()
local list=
local listN=
for i in $@ ; do
local NOR="${i/^/}"
[ "$NOR" = "$i" ] && list="$list $NOR" || listN="$listN $NOR"
case "$i" in
^*)
# 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
#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\""
# FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for i in $list ; do
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
# FIXME -n on MacOS?
if [ -n "$list" ] ; then
echo -n " | egrep -i --color -- \"($COLO)\""
fi
}
# copied from korinf/tools/run-script/scripts/search
......
......@@ -50,6 +50,7 @@ case $PMTYPE in
local_content_search $pkg_filenames
return ;;
apt-dpkg)
assure_exists apt-file
sudocmd apt-file update
docmd apt-file search $pkg_filenames
return ;;
......
......@@ -23,7 +23,8 @@ isatty()
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
test -t 1
# check stderr
test -t 2
}
check_tty()
......@@ -83,7 +84,7 @@ showcmd()
if [ -z "$quiet" ] ; then
set_boldcolor $GREEN
local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#"
[ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@"
restore_color
fi >&2
......@@ -163,15 +164,19 @@ 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 | tee $RC_STDOUT
( "$@" 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return $PIPESTATUS
#return $PIPESTATUS
}
clean_store_output()
{
rm -f $RC_STDOUT
rm -f $RC_STDOUT $RC_STDOUT.pipestatus
}
......@@ -207,11 +212,10 @@ set_sudo()
# skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return
# set SUDO not for root user
[ -n "$UID" ] || UID=`id -u`
EFFUID=`id -u`
# do not need sudo
[ $UID = "0" ] && return
[ $EFFUID = "0" ] && return
# use sudo if possible
which sudo >/dev/null 2>/dev/null && SUDO="sudo" && return
......@@ -219,6 +223,63 @@ set_sudo()
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
get_help()
{
......@@ -291,6 +352,9 @@ case $DISTRNAME in
OpenWRT)
CMD="ipkg"
;;
GNU/Linux/Guix)
CMD="guix"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......
......@@ -61,7 +61,9 @@ epm_upgrade()
CMD="chocolatey update all"
;;
homebrew)
CMD="brew upgrade"
#CMD="brew upgrade"
sudocmd "brew upgrade `brew outdated`"
return
;;
ipkg)
CMD="ipkg upgrade"
......@@ -69,6 +71,9 @@ epm_upgrade()
slackpkg)
CMD="/usr/sbin/slackpkg upgrade-all"
;;
guix)
CMD="guix package -u"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -20,7 +20,7 @@
epm_whatdepends()
{
local CMD
[ -n "$pkg_names" ] || fatal "Run query without names"
[ -n "$pkg_filenames" ] || fatal "Run query without names"
# by package name
case $PMTYPE in
......@@ -34,6 +34,7 @@ case $PMTYPE in
CMD="repoquery --whatrequires"
;;
emerge)
assure_exists equery
CMD="equery depends -a"
;;
*)
......@@ -41,6 +42,6 @@ case $PMTYPE in
;;
esac
docmd $CMD $pkg_names
docmd $CMD $pkg_filenames
}
......@@ -20,7 +20,7 @@
epm_whatprovides()
{
local CMD
[ -n "$pkg_names" ] || fatal "Run query without names"
[ -n "$pkg_filenames" ] || fatal "Run query without names"
# by package name
case $PMTYPE in
......@@ -42,6 +42,6 @@ case $PMTYPE in
;;
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.
#
Name: eepm
Version: 1.4.1
Version: 1.4.4
Release: alt0.M70P.1
Summary: Etersoft EPM package manager
......@@ -22,9 +22,7 @@ Conflicts: epm
Provides: upm
%if %_vendor == "alt"
Requires: apt rpm apt-repo
%endif
Requires: apt rpm
%description
Etersoft EPM is the package manager for any platform
......@@ -65,9 +63,38 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv
%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)
* 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
- add initial man page file
- epm-filelist: add todo for less
......
......@@ -95,7 +95,7 @@ showcmd()
if [ -z "$quiet" ] ; then
set_boldcolor $GREEN
local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#"
[ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@"
restore_color
fi >&2
......@@ -170,15 +170,19 @@ 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 | tee $RC_STDOUT
( "$@" 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return $PIPESTATUS
#return $PIPESTATUS
}
clean_store_output()
{
rm -f $RC_STDOUT
rm -f $RC_STDOUT $RC_STDOUT.pipestatus
}
......@@ -208,11 +212,10 @@ set_sudo()
# skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return
# set SUDO not for root user
[ -n "$UID" ] || UID=`id -u`
EFFUID=`id -u`
# do not need sudo
[ $UID = "0" ] && return
[ $EFFUID = "0" ] && return
# use sudo if possible
which sudo >/dev/null 2>/dev/null && SUDO="sudo" && return
......@@ -220,6 +223,61 @@ set_sudo()
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()
{
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do
......@@ -289,6 +347,9 @@ case $DISTRNAME in
OpenWRT)
CMD="ipkg"
;;
GNU/Linux/Guix)
CMD="guix"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......@@ -836,6 +897,16 @@ elif [ `uname` = "SunOS" ] ; then
DISTRIB_ID="SunOS"
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
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB
......@@ -981,7 +1052,7 @@ $(get_help HELPOPT)
print_version()
{
echo "Service manager version 1.4.1"
echo "Service manager version 1.4.2"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013"
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