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. Дописать таблицу на вики на основании реализованных команд.
3. Доделать и проверить deplist|requires
......
......@@ -50,6 +50,7 @@ pkgtype()
archlinux) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;;
......@@ -237,6 +238,21 @@ 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)
# fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
# try use standart LSB info by default
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -58,7 +58,7 @@ print_version()
{
echo "EPM package manager version @VERSION@"
echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
echo "Copyright (c) Etersoft 2012-2013"
echo "Copyright (c) Etersoft 2012-2014"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
}
......@@ -97,6 +97,9 @@ case $progname in
epms)
epm_cmd=search
;;
epmsf)
epm_cmd=search_file
;;
epmq)
epm_cmd=query
;;
......@@ -133,80 +136,86 @@ 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
-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|-S|which|belongs) # HELPCMD: query package(s) owning file
epm_cmd=query_file
;;
# 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
;;
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
;;
-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
-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
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
requires|deplist|req) # HELPCMD: print package requires
epm_cmd=requires
;;
provides) # HELPCMD: print package provides
provides|prov) # HELPCMD: print package provides
epm_cmd=provides
;;
whatdepends) # HELPCMD: print packages dependences on that
whatdepends) # HELPCMD: print packages dependences on that
epm_cmd=whatdepends
;;
whatprovides) # HELPCMD: print packages provides that target
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: print list of installed package(s)
epm_cmd=packages
;;
programs) # HELPCMD: list of installed GUI program(s)
programs) # HELPCMD: print list of installed GUI program(s)
epm_cmd=programs
;;
assure) # HELPCMD: <command> [package]: install package if command does not exists
epm_cmd=assure
;;
# Repository control
update) # HELPCMD: update remote package repository databases
update) # HELPCMD: update remote package repository databases
epm_cmd=update
;;
addrepo|ar) # HELPCMD: add package repo
addrepo|ar) # HELPCMD: add package repo
epm_cmd=addrepo
;;
repolist|sl|rl|listrepo) # HELPCMD: print repo list
repolist|sl|rl|listrepo) # HELPCMD: print repo list
epm_cmd=repolist
;;
removerepo|rr) # HELPCMD: remove package repo
removerepo|rr) # HELPCMD: remove package repo
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
;;
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel) # HELPCMD: update system kernel to the last repo version
......@@ -214,22 +223,22 @@ check_command()
;;
# Other commands
clean) # HELPCMD: clean local package cache
clean) # HELPCMD: clean local package cache
epm_cmd=clean
;;
autoremove) # HELPCMD: auto remove unneeded package(s)
autoremove) # HELPCMD: auto remove unneeded package(s)
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
;;
Upgrade) # HELPCMD: performs update && upgrade command
Upgrade) # HELPCMD: force update package base, then run upgrade
epm_cmd=Upgrade
;;
simulate) # HELPCMD: simulate install (it does check requires, minimally)
simulate) # HELPCMD: simulate install with check requires
epm_cmd=simulate
;;
checkpkg|integrity) # HELPCMD: check package integrity
checkpkg|integrity) # HELPCMD: check package file integrity (checksum)
epm_cmd=checkpkg
;;
......@@ -254,7 +263,7 @@ check_option()
--verbose) # HELPOPT: verbose mode
verbose=1
;;
--skip-installed) # HELPOPT: skip already install during install
--skip-installed) # HELPOPT: skip already installed packages during install
skip_installed=1
;;
--show-command-only) # HELPOPT: show command only, do not any action (supports install and remove ONLY)
......@@ -285,18 +294,35 @@ check_option()
return 0
}
for opt in "$@" ; do
check_command $opt && continue
check_option $opt && continue
if [ -f "$opt" ] && echo $opt | grep -q "\." ; then
check_filenames()
{
local opt="$1"
# files can be with full path or have extension via .
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\""
}
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
# 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_names=$(strip_spaces "$pkg_names")
......@@ -314,6 +340,13 @@ if [ -z "$epm_cmd" ] ; then
fatal "Run $ $progname --help for get help"
fi
# Use eatmydata for write specific operations
case $epm_cmd in
update|upgrade|Upgrade|install|reinstall|Install|remove|autoremove|kernel_update|release_upgrade|check)
set_eatmydata
;;
esac
# Run helper for command
load_helper epm-$epm_cmd
epm_$epm_cmd
......
......@@ -26,7 +26,7 @@ epm_Install()
local names="$(echo $pkg_names | 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
case $PMTYPE in
......
......@@ -21,13 +21,14 @@ epm_addrepo()
{
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
sudocmd apt-repo add $pkg_filenames
;;
apt-dpkg)
echo "You need manually add repo to /etc/apt/sources.list"
apt-dpkg|aptitude-dpkg)
info "You need manually add repo to /etc/apt/sources.list"
;;
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)
sudocmd urpmi.addmedia $pkg_filenames
......@@ -39,7 +40,7 @@ case $PMTYPE in
sudocmd layman -a $pkg_filenames
;;
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:
#sudocmd repo-add $pkg_filenames
;;
......@@ -47,7 +48,7 @@ case $PMTYPE in
sudocmd npackdcl add-repo --url=$pkg_filenames
;;
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"
......
#!/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 @@
# 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()
{
case $PMTYPE in
apt-rpm)
assure_exists remove-old-kernels
# ALT Linux only
__epm_autoremove_altrpm
# ALT Linux only
sudocmd remove-old-kernels
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
sudocmd apt-get autoremove
;;
aura)
......@@ -45,7 +66,7 @@ case $PMTYPE in
;;
emerge)
sudocmd emerge --depclean
docmd epm --skip-installed install gentoolkit
assure_exists revdep-rebuild
sudocmd revdep-rebuild
;;
pacman)
......@@ -55,6 +76,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()
......@@ -45,13 +53,12 @@ __epm_changelog_local_names()
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm --changelog" $@ | less
;;
apt-dpkg)
# FIXME: only first pkg
apt-dpkg|aptitude-dpkg)
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"
;;
......@@ -93,7 +104,7 @@ __epm_changelog_unlocal_names()
epm_changelog()
{
[ -n "$pkg_filenames" ] || fatal "Run changelog without params"
[ -n "$pkg_filenames" ] || fatal "Changelog: Missing package(s) name"
__epm_changelog_files $pkg_files
......
......@@ -31,6 +31,10 @@ case $PMTYPE in
sudocmd apt-get -f install || exit
sudocmd apt-get autoremove
;;
aptitude-dpkg)
sudocmd aptitude -f install || exit
#sudocmd apt-get autoremove
;;
yum-rpm)
docmd yum check
docmd package-cleanup --problems
......@@ -52,6 +56,9 @@ case $PMTYPE in
conary)
sudocmd conary verify
;;
homebrew)
sudocmd brew doctor
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
#!/bin/sh
#
# Copyright (C) 2014 Etersoft
# Copyright (C) 2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__is_repo_info_download()
{
case $PMTYPE in
apt-*)
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 @@
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
;;
......@@ -38,9 +37,8 @@ check_pkg_integrity()
true
;;
*)
assure_exists erc
docmd erc test "$PKG" && return
which erc >/dev/null 2>/dev/null && fatal "Check failed"
fatal "Install erc package."
;;
esac
}
......@@ -54,6 +52,10 @@ case $PMTYPE in
*-dpkg)
docmd debsums $@
;;
emerge)
assure_exists equery
docmd equery check $@
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......@@ -65,12 +67,12 @@ esac
epm_checkpkg()
{
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
return
fi
[ -n "$pkg_files" ] || fatal "Run without names"
[ -n "$pkg_files" ] || fatal "Checkpkg: missing file or package name(s)"
local pkg
for pkg in $pkg_files ; do
check_pkg_integrity $pkg || fatal "Broken package $pkg"
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -23,6 +23,9 @@ case $PMTYPE in
apt-rpm|apt-dpkg)
sudocmd apt-get clean
;;
aptitude-dpkg)
sudocmd aptitude clean
;;
yum-rpm)
sudocmd yum clean all
#sudocmd yum makecache
......@@ -48,6 +51,6 @@ case $PMTYPE in
fatal "Have no suitable command for $PMTYPE"
;;
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
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -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"
;;
*)
......@@ -37,8 +78,7 @@ __epm_filelist_file()
;;
esac
# TODO: add less
docmd $CMD $@
docmd $CMD $@ | less
}
__epm_filelist_name()
......@@ -51,7 +91,7 @@ __epm_filelist_name()
apt-rpm)
CMD="rpm -ql"
;;
apt-dpkg)
*-dpkg)
CMD="dpkg -L"
;;
yum-rpm)
......@@ -63,16 +103,23 @@ __epm_filelist_name()
zypper-rpm)
CMD="rpm -ql"
;;
android)
CMD="pm list packages -f"
;;
conary)
CMD="conary query --ls"
;;
pacman)
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g"
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g" | less
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}*
docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* | less
return
;;
*)
......@@ -82,13 +129,13 @@ __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
}
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
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -28,8 +28,13 @@ __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()
{
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
case $PMTYPE in
apt-rpm)
__epm_info_rpm_low && return
......@@ -43,6 +48,13 @@ case $PMTYPE in
is_installed $pkg_names && docmd dpkg -p $pkg_names && return
docmd apt-cache show $pkg_names
;;
aptitude-dpkg)
if [ -n "$pkg_files" ] ; then
docmd dpkg -I $pkg_files
fi
[ -z "$pkg_names" ] && return
docmd aptitude show $pkg_names
;;
yum-rpm)
__epm_info_rpm_low && return
docmd yum info $pkg_names
......@@ -71,12 +83,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"
;;
......
......@@ -18,6 +18,7 @@
#
load_helper epm-query
load_helper epm-check_updated_repo
# TODO: use when run install with epm --skip-installed install
filter_out_installed_packages()
......@@ -93,6 +94,9 @@ epm_install_names()
apt-rpm|apt-dpkg)
sudocmd apt-get $APTOPTIONS install $@
return ;;
aptitude-dpkg)
sudocmd aptitude install $@
return ;;
deepsolver-rpm)
sudocmd ds-install $@
return ;;
......@@ -134,6 +138,7 @@ epm_install_names()
__separate_sudocmd_foreach "/usr/sbin/slackpkg install" "/usr/sbin/slackpkg upgrade" $@
return ;;
homebrew)
# FIXME: sudo and quote
__separate_sudocmd "brew install" "brew upgrade" $@
return ;;
ipkg)
......@@ -143,6 +148,12 @@ epm_install_names()
nix)
__separate_sudocmd "nix-env --install" "nix-env --upgrade" $@
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"
;;
......@@ -155,8 +166,12 @@ 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 ;;
aptitude-dpkg)
sudocmd aptitde -y install $@
return ;;
yum-rpm)
sudocmd yum -y $YUMOPTIONS install $@
return ;;
......@@ -192,6 +207,9 @@ epm_ni_install_names()
nix)
sudocmd nix-env --install $@
return ;;
#android)
# sudocmd pm install $@
# return ;;
slackpkg)
# FIXME: broken status when use batch and default answer
__separate_sudocmd_foreach "/usr/sbin/slackpkg -batch=on -default_answer=yes install" "/usr/sbin/slackpkg -batch=on -default_answer=yes upgrade" $@
......@@ -225,7 +243,7 @@ epm_install_files()
# use install_names
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
# the new version of the conf. file is installed with a .dpkg-dist suffix
if [ -n "$non_interactive" ] ; then
DPKGOPTIONS="--force-confdef --force-confold"
......@@ -281,6 +299,9 @@ epm_install_files()
pkgsrc)
sudocmd pkg_add $@
return ;;
android)
sudocmd pm install $@
return ;;
emerge)
load_helper epm-install-emerge
sudocmd epm_install_emerge $@
......@@ -309,7 +330,7 @@ epm_print_install_command()
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $@"
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
echo "dpkg -i $@"
;;
pkgsrc)
......@@ -331,6 +352,9 @@ epm_print_install_command()
ipkg)
echo "ipkg install $@"
;;
android)
echo "pm install $@"
;;
*)
fatal "Have no suitable appropriate install command for $PMTYPE"
;;
......@@ -345,12 +369,15 @@ epm_install()
return
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 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_files $files
......
......@@ -19,10 +19,11 @@
epm_kernel_update()
{
echo "Start update system kernel to the latest version"
info "Starting update system kernel to the latest version"
case $DISTRNAME in
ALTLinux)
assure_exists update-kernel
sudocmd update-kernel
return ;;
esac
......
......@@ -43,7 +43,7 @@ case $PMTYPE in
CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
;;
apt-dpkg)
*-dpkg)
#CMD="dpkg -l $pkg_filenames"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n $pkg_filenames"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n $pkg_filenames"
......@@ -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,19 @@ case $PMTYPE in
fi
;;
homebrew)
CMD="brew $pkg_filenames"
CMD="brew list $pkg_filenames"
;;
ipkg)
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"
;;
......
......@@ -25,7 +25,7 @@ epm_programs()
local DESKTOPDIR=/usr/share/applications
[ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system."
#find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u
showcmd "find /usr/share/applications -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u"
showcmd "find $DESKTOPDIR -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u"
find /usr/share/applications -type f -name "*.desktop" | \
xargs $0 -qf --quiet --short | sort -u
}
......@@ -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
case $(get_package_type $pkg_files) in
rpm)
docmd rpm -q --provides -p $pkg_files
;;
deb)
# FIXME: will we provide ourself?
docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
# by package file
case $PMTYPE in
*-rpm)
CMD="rpm -q --provides -p"
;;
# 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
[ -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,37 @@ 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
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"
;;
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 @@
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
......@@ -94,7 +107,7 @@ __epm_query_file()
CMD="rpm -qp"
[ -n "$short" ] && CMD="rpm -qp --queryformat %{name}\n"
;;
apt-dpkg)
*-dpkg)
CMD="dpkg-deb --show --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query --show --showformat=\${Package}\n"
;;
......@@ -117,7 +130,7 @@ __epm_query_name()
CMD="rpm -q"
[ -n "$short" ] && CMD="rpm -q --queryformat %{name}\n"
;;
apt-dpkg)
*-dpkg)
#docmd dpkg -l $@ | grep "^ii"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n"
......@@ -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
......@@ -162,7 +176,7 @@ separate_installed()
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
......
......@@ -33,7 +33,7 @@ __do_query_real_file()
else
TOFILE=`which $1 2>/dev/null || echo $1`
if [ "$TOFILE" != "$1" ] ; then
echo "Note: $1 is placed as $TOFILE"
info "Note: $1 is placed as $TOFILE"
fi
fi
......@@ -41,10 +41,11 @@ __do_query_real_file()
if [ -L "$TOFILE" ] ; then
__do_query $TOFILE
LINKTO=`readlink "$TOFILE"`
echo "Note: $TOFILE is link to $LINKTO"
info "Note: $TOFILE is link to $LINKTO"
__do_query_real_file "$LINKTO"
fi
FULLFILEPATH=`realpath $TOFILE`
FULLFILEPATH="$TOFILE"
}
dpkg_print_name_version()
......@@ -68,7 +69,7 @@ __do_query()
apt-rpm)
CMD="rpm -qf"
;;
apt-dpkg)
*-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")
return ;;
......@@ -79,6 +80,7 @@ __do_query()
CMD="rpm -qf"
;;
emerge)
assure_exists equery
CMD="equery belongs"
;;
pacman)
......@@ -116,6 +118,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)
......@@ -139,6 +142,7 @@ epm_query_file()
{
# in short mode print handle only real names and do short output
# TODO: move to separate command?
# FIXME: it is possible use query
if [ -n "$short" ] ; then
[ -n "$pkg_files" ] || fatal "Run query without file names (needed path to files)"
__do_short_query $pkg_files
......@@ -150,7 +154,7 @@ epm_query_file()
for pkg in $pkg_filenames ; do
__do_query_real_file "$pkg"
__do_query $FULLFILEPATH || pkg_filenames=$pkg epm_search_file
__do_query $FULLFILEPATH || pkg_filenames=$FULLFILEPATH epm_search_file
done
}
......@@ -22,9 +22,10 @@ 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)
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS
eval "pkg_filenames= epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS"
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -27,6 +27,9 @@ epm_reinstall_names()
apt-rpm|apt-dpkg)
sudocmd apt-get --reinstall install $@
return ;;
aptitude-dpkg)
sudocmd aptitude reinstall $@
return ;;
dnf-rpm)
sudocmd dnf reinstall $@
return ;;
......@@ -48,7 +51,7 @@ epm_reinstall_files()
sudocmd rpm -Uvh --force $@ && return
sudocmd apt-get --reinstall install $@
return ;;
apt-pkg)
apt-dpkg|aptitude-dpkg)
sudocmd dpkg -i $@
return ;;
slackpkg)
......@@ -63,7 +66,7 @@ epm_reinstall_files()
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_files $pkg_files
......
......@@ -19,8 +19,8 @@
epm_release_upgrade()
{
echo "Start upgrade whole system to the next release"
echo "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
info "Starting upgrade whole system to the next release"
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
case $PMTYPE in
apt-rpm)
......@@ -30,7 +30,7 @@ epm_release_upgrade()
docmd epm Upgrade
docmd epm update-kernel
;;
apt-dpkg)
*-dpkg)
sudocmd do-release-upgrade -d
;;
yum-rpm)
......@@ -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"
;;
......
#!/bin/sh
#
# Copyright (C) 2012, 2013 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -27,7 +27,7 @@ epm_remove_low()
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
sudocmd rpm -ev $nodeps $@
return ;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
sudocmd dpkg -P $(subst_option nodeps --force-all) $@
return ;;
pkgsrc)
......@@ -51,9 +51,15 @@ epm_remove_names()
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|apt-dpkg)
apt-dpkg)
sudocmd apt-get remove --purge $@
return ;;
aptitude-dpkg)
sudocmd aptitude purge $@
return ;;
apt-rpm)
sudocmd apt-get remove $@
return ;;
deepsolver-rpm)
sudocmd ds-remove $@
return ;;
......@@ -91,6 +97,12 @@ epm_remove_names()
nix)
sudocmd nix-env --uninstall $@
return ;;
guix)
sudocmd guix package -r $@
return ;;
android)
sudocmd pm uninstall $@
return ;;
chocolatey)
sudocmd chocolatey uninstall $@
return ;;
......@@ -113,9 +125,15 @@ epm_remove_names()
epm_remove_nonint()
{
case $PMTYPE in
apt-rpm|apt-dpkg)
apt-dpkg)
sudocmd apt-get -y --force-yes remove --purge $@
return ;;
aptitude-dpkg)
sudocmd aptitude -y purge $@
return ;;
apt-rpm)
sudocmd apt-get -y --force-yes remove $@
return ;;
urpm-rpm)
sudocmd urpme --auto $@
return ;;
......@@ -144,7 +162,7 @@ epm_print_remove_command()
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@"
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
echo "dpkg -P $@"
;;
pkgsrc)
......@@ -179,7 +197,7 @@ epm_remove()
# get full package name(s) from the package file(s)
[ -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
# get package name for hi level package management command (with version if supported and if possible)
......
......@@ -21,13 +21,14 @@ epm_removerepo()
{
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
sudocmd apt-repo rm $pkg_filenames
;;
apt-dpkg)
echo "You need remove repo from /etc/apt/sources.list"
apt-dpkg|aptitude-dpkg)
info "You need remove repo from /etc/apt/sources.list"
;;
yum-rpm)
echo "You need remove repo from /etc/yum.repos.d/"
info "You need remove repo from /etc/yum.repos.d/"
;;
urpm-rpm)
sudocmd urpmi.removemedia $pkg_filenames
......@@ -39,13 +40,13 @@ case $PMTYPE in
sudocmd layman -d$pkg_filenames
;;
pacman)
echo "You need remove repo from /etc/pacman.conf"
info "You need remove repo from /etc/pacman.conf"
;;
npackd)
sudocmd npackdcl remove-repo --url=$pkg_filenames
;;
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"
......
......@@ -32,12 +32,13 @@ epm_repolist()
{
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
docmd apt-repo list
;;
deepsolver-rpm)
docmd ds-conf
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
showcmd cat /etc/apt/sources.list*
print_apt_sources_list /etc/apt/sources.list /etc/apt/sources.list.d/*.list
;;
......@@ -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,48 @@
# 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"
;;
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
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
local PKGTYPE="$(case $(get_package_type $pkg_files))"
[ -n "$pkg_files" ] && docmd $CMD $pkg_files
case "$PKGTYPE" in
rpm)
docmd rpm -q --requires -p $pkg_files
;;
deb)
a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
;;
*)
fatal "Have no suitable command for $PKGTYPE"
;;
esac
}
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"
;;
......@@ -56,8 +68,19 @@ case $PMTYPE in
pacman)
CMD="pactree"
;;
apt-dpkg)
CMD="apt-cache depends"
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"
fi
;;
emerge)
assure_exists equery
CMD="equery depgraph"
;;
*)
fatal "Have no suitable command for $PMTYPE"
......@@ -65,6 +88,13 @@ case $PMTYPE in
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
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2013 Etersoft
# Copyright (C) 2012,2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
__epm_search_output()
{
local CMD
......@@ -25,8 +27,15 @@ case $PMTYPE in
apt-rpm|apt-dpkg)
CMD="apt-cache search --"
;;
aptitude-dpkg)
CMD="aptitude search --"
;;
deepsolver-rpm)
CMD="ds-require --"
;;
urpm-rpm)
CMD="urpmq -y --"
# urpmq does not support --
CMD="urpmq -y"
;;
pkgsrc)
CMD="pkg_info -x --"
......@@ -65,11 +74,17 @@ case $PMTYPE in
slackpkg)
# FIXME
echo "Note: case sensitive search"
CMD="/usr/sbin/slackpkg search --"
CMD="/usr/sbin/slackpkg search"
;;
homebrew)
CMD="brew search"
;;
guix)
CMD="guix package -A"
;;
android)
CMD="pm list packages"
;;
*)
fatal "Have no suitable search command for $PMTYPE"
;;
......@@ -87,29 +102,60 @@ __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\""
[ -n "$listN" ] && echon " | egrep -i -v -- \"$listN\""
# FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for i in $list ; do
echo -n " | egrep -i --color -- \"$i\""
# FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
# FIXME: move from it
#isatty || return
local COLO=""
# rule for colorife
for i in $list $listN; do
[ -n "$COLO" ] && COLO="$COLO|"
COLO="$COLO$i"
done
if [ -n "$list" ] ; then
echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi
}
# copied from korinf/tools/run-script/scripts/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
local MGS=$(eval __epm_search_make_grep $quoted_args)
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD="$MGS"
eval "__epm_search_output \"$(eval get_firstarg $quoted_args)\" $MGS"
}
......@@ -21,10 +21,12 @@
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
local_content_search()
{
# TODO: use global get_sysarch function
local SYSARCH
SYSARCH=$(uname -m)
[ "$SYSARCH" = "x86_64" ] || SYSARCH=i586
# FIXME: use config or/and web url
local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
local CI=$REPODIR/$SYSARCH/base/contents_index
local CINOA=$REPODIR/noarch/base/contents_index
......@@ -43,13 +45,14 @@ local_content_search()
epm_search_file()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Run search without names"
[ -n "$pkg_filenames" ] || fatal "Search file: missing file name(s)"
case $PMTYPE in
apt-rpm)
local_content_search $pkg_filenames
return ;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
assure_exists apt-file
sudocmd apt-file update
docmd apt-file search $pkg_filenames
return ;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2014 Etersoft
# Copyright (C) 2012, 2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -18,17 +18,40 @@
#
# 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()
{
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
# check stdout
test -t 1
}
isatty2()
{
# check stderr
test -t 2
}
check_tty()
{
isatty || return
isatty2 || return
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
# egrep from busybox may not --color
# egrep from MacOS print help to stderr
if egrep --help 2>&1 | grep -q -- "--color" ; then
EGREPCOLOR="--color"
fi
which tput >/dev/null 2>/dev/null || return
# FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return
......@@ -58,32 +81,34 @@ restore_color()
echover()
{
[ -n "$verbose" ] || return
[ -z "$verbose" ] && return
echo "$*" >&2
}
# echo string without EOL
echon()
{
# default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@"
}
# Used DISTRNAME
set_target_pkg_env()
{
[ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME"
[ -n "$DISTRNAME" ] || fatal "Missing DISTRNAME in set_target_pkg_env."
PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME")
PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME")
RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME")
}
# for systems without realpath command
realpath()
{
readlink -f "$@"
}
# Print command line and run command line
showcmd()
{
if [ -z "$quiet" ] ; then
set_boldcolor $GREEN
local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#"
[ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@"
restore_color
fi >&2
......@@ -93,18 +118,19 @@ showcmd()
docmd()
{
showcmd "$@$EXTRA_SHOWDOCMD"
"$@"
#FIXME
$@
}
# Run every arg with docmd
docmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
docmd $cmd $pkg
docmd "$cmd" $pkg
done
}
......@@ -112,31 +138,31 @@ docmd_foreach()
sudocmd()
{
showcmd "$SUDO $@"
$SUDO "$@"
$SUDO $@
}
# Run every arg with sudocmd
sudocmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
sudocmd $cmd $pkg
sudocmd "$cmd" $pkg
done
}
get_firstarg()
{
echo -n "$1"
echon "$1"
}
get_lastarg()
{
local lastarg
eval lastarg=\${$#}
echo -n "$lastarg"
echon "$lastarg"
}
......@@ -163,18 +189,22 @@ 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
}
# run epm, possible from side repo
epm()
{
$PROGDIR/epm $@
......@@ -201,17 +231,29 @@ warning()
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()
{
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 +261,59 @@ 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"
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
get_help()
{
......@@ -248,15 +343,16 @@ if [ -n "$FORCEPM" ] ; then
fi
case $DISTRNAME in
ALTLinux|PCLinux)
ALTLinux)
CMD="apt-rpm"
#which deepsolver 2>/dev/null >/dev/null && CMD=deepsolver-rpm
#which ds-install 2>/dev/null >/dev/null && CMD=deepsolver-rpm
;;
PCLinux)
CMD="apt-rpm"
;;
Ubuntu|Debian|Mint)
CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
;;
Mandriva|ROSA)
CMD="urpm-rpm"
......@@ -272,6 +368,7 @@ case $DISTRNAME in
;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific)
CMD="yum-rpm"
#which dnf 2>/dev/null >/dev/null && CMD=dnf-rpm
;;
Slackware)
CMD="slackpkg"
......@@ -291,6 +388,12 @@ case $DISTRNAME in
OpenWRT)
CMD="ipkg"
;;
GNU/Linux/Guix)
CMD="guix"
;;
Android)
CMD="android"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......
#!/bin/sh
#
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -62,6 +62,9 @@ _epm_do_simulate()
apt-rpm|apt-dpkg)
CMD="apt-get --simulate install"
;;
aptitude-dpkg)
CMD="aptitude -s install"
;;
yum-rpm)
if __use_yum_assumeno ; then
LC_ALL=C store_output sudocmd yum --assumeno install $filenames
......@@ -80,10 +83,9 @@ EOF
;;
zypper-rpm)
if ! __use_zypper_dry_run >/dev/null ; then
echo "zypper is too old: does not support --dry-run"
return
fatal "zypper is too old: does not support --dry-run"
fi
CMD="zypper --non-interactive install"
CMD="zypper --non-interactive install --dry-run"
;;
emerge)
local res=0
......@@ -114,7 +116,7 @@ EOF
pkg_filenames="$pkg-[0-9]" epm_search | grep -E "(installed|upgrade)" && continue
pkg_filenames="$pkg" epm_search | grep -E "(installed|upgrade)" && continue
res=1
echo "Does not found in repository."
info "Package '$pkg' does not found in repository."
done
return $res ;;
*)
......@@ -127,16 +129,16 @@ EOF
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)"
[ -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
local RES=$?
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
return $RES
}
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -21,7 +21,7 @@
epm_update()
{
echo "Run command for update remote package repository database"
info "Running command for update remote package repository database"
case $PMTYPE in
apt-rpm)
......@@ -33,6 +33,9 @@ case $PMTYPE in
#sudocmd apt-get -f install || exit
#sudocmd apt-get autoremove
;;
aptitude-dpkg)
sudocmd aptitude update || exit
;;
yum-rpm)
sudocmd yum check-update
;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -17,10 +17,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
epm_upgrade()
{
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
apt-rpm|apt-dpkg)
......@@ -28,6 +34,9 @@ epm_upgrade()
# Функцию добавления параметра при условии
CMD="apt-get dist-upgrade"
;;
aptitude-dpkg)
CMD="aptitude dist-upgrade"
;;
yum-rpm)
# can do update repobase automagically
CMD="yum update"
......@@ -61,7 +70,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 +80,9 @@ epm_upgrade()
slackpkg)
CMD="/usr/sbin/slackpkg upgrade-all"
;;
guix)
CMD="guix package -u"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -20,20 +20,24 @@
epm_whatdepends()
{
local CMD
[ -n "$pkg_names" ] || fatal "Run query without names"
[ -n "$pkg_filenames" ] || fatal "Whatdepends: missing package(s) name"
# by package name
case $PMTYPE in
apt-rpm)
CMD="apt-cache whatdepends"
;;
apt-dpkg)
apt-dpkg|aptitude-dpkg)
CMD="apt-cache rdepends"
;;
aptitude-dpkg)
CMD="aptitude why"
;;
yum-rpm)
CMD="repoquery --whatrequires"
;;
emerge)
assure_exists equery
CMD="equery depends -a"
;;
*)
......@@ -41,6 +45,6 @@ case $PMTYPE in
;;
esac
docmd $CMD $pkg_names
docmd $CMD $pkg_filenames
}
......@@ -20,14 +20,14 @@
epm_whatprovides()
{
local CMD
[ -n "$pkg_names" ] || fatal "Run query without names"
[ -n "$pkg_filenames" ] || fatal "Whatprovides: missing package(s) name"
# by package name
case $PMTYPE in
conary)
CMD="conary repquery --what-provides"
;;
apt-rpm|apt-dpkg)
apt-rpm|apt-dpkg|aptitude-dpkg)
LANG=C docmd apt-get install --print-uris $pkg_filenames | grep "^Selecting" | cut -f2 -d" "
return
;;
......@@ -42,6 +42,6 @@ case $PMTYPE in
;;
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.
#
Name: eepm
Version: 1.4.1
Version: 1.5.1
Release: alt0.M60P.1
Summary: Etersoft EPM package manager
......@@ -23,7 +23,8 @@ Conflicts: epm
Provides: upm
%if %_vendor == "alt"
Requires: apt rpm apt-repo
# FIXHERE: Replace with target platform package manager
Requires: apt rpm
%endif
%description
......@@ -65,9 +66,69 @@ 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.M60P.1
* Wed Mar 05 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.1-alt0.M60P.1
- 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
- add initial man page file
- epm-filelist: add todo for less
......
......@@ -33,17 +33,39 @@ load_helper()
# File bin/epm-sh-functions:
inputisatty()
{
# check stdin
tty -s 2>/dev/null
}
isatty()
{
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
# check stdout
test -t 1
}
isatty2()
{
# check stderr
test -t 2
}
check_tty()
{
isatty || return
isatty2 || return
# Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb
export TERM
# egrep from busybox may not --color
# egrep from MacOS print help to stderr
if egrep --help 2>&1 | grep -q -- "--color" ; then
EGREPCOLOR="--color"
fi
which tput >/dev/null 2>/dev/null || return
# FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return
......@@ -73,10 +95,17 @@ restore_color()
echover()
{
[ -n "$verbose" ] || return
[ -z "$verbose" ] && return
echo "$*" >&2
}
echon()
{
# default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@"
}
set_target_pkg_env()
{
[ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME"
......@@ -95,7 +124,7 @@ showcmd()
if [ -z "$quiet" ] ; then
set_boldcolor $GREEN
local PROMTSIG="\$"
[ "$UID" = 0 ] && PROMTSIG="#"
[ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@"
restore_color
fi >&2
......@@ -104,47 +133,47 @@ showcmd()
docmd()
{
showcmd "$@$EXTRA_SHOWDOCMD"
"$@"
$@
}
docmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
docmd $cmd $pkg
docmd "$cmd" $pkg
done
}
sudocmd()
{
showcmd "$SUDO $@"
$SUDO "$@"
$SUDO $@
}
sudocmd_foreach()
{
local cmd
local cmd pkg
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
sudocmd $cmd $pkg
sudocmd "$cmd" $pkg
done
}
get_firstarg()
{
echo -n "$1"
echon "$1"
}
get_lastarg()
{
local lastarg
eval lastarg=\${$#}
echo -n "$lastarg"
echon "$lastarg"
}
......@@ -170,18 +199,21 @@ 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
}
epm()
{
$PROGDIR/epm $@
......@@ -208,11 +240,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 +251,62 @@ 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"
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()
{
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do
......@@ -246,15 +333,16 @@ if [ -n "$FORCEPM" ] ; then
fi
case $DISTRNAME in
ALTLinux|PCLinux)
ALTLinux)
CMD="apt-rpm"
#which deepsolver 2>/dev/null >/dev/null && CMD=deepsolver-rpm
#which ds-install 2>/dev/null >/dev/null && CMD=deepsolver-rpm
;;
PCLinux)
CMD="apt-rpm"
;;
Ubuntu|Debian|Mint)
CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
;;
Mandriva|ROSA)
CMD="urpm-rpm"
......@@ -270,6 +358,7 @@ case $DISTRNAME in
;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific)
CMD="yum-rpm"
#which dnf 2>/dev/null >/dev/null && CMD=dnf-rpm
;;
Slackware)
CMD="slackpkg"
......@@ -289,6 +378,12 @@ case $DISTRNAME in
OpenWRT)
CMD="ipkg"
;;
GNU/Linux/Guix)
CMD="guix"
;;
Android)
CMD="android"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......@@ -649,6 +744,7 @@ pkgtype()
archlinux) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;;
......@@ -836,6 +932,21 @@ 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)
# fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
# try use standart LSB info by default
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB
......@@ -981,7 +1092,7 @@ $(get_help HELPOPT)
print_version()
{
echo "Service manager version 1.4.1"
echo "Service manager version 1.5.0"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
#!/bin/sh
run_command()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
RC_STDERR=$(mktemp)
$1 >$RC_STDOUT 2>$RC_STDERR
}
func()
{
echo STDERR >&2
echo STDOUT
}
run_command func
cat $RC_STDOUT
cat $RC_STDERR
rm -f $RC_STDOUT $RC_STDERR
#!/bin/sh
run_command()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
#RC_STDERR=$(mktemp)
$1 2>&1 | tee $RC_STDOUT
}
func()
{
echo STDERR >&2
echo STDOUT
}
run_command func
cat $RC_STDOUT
#cat $RC_STDERR
rm -f $RC_STDOUT $RC_STDERR
#!/bin/sh
store_output()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp)
local CMDSTATUS=$RC_STDOUT.pipestatus
echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp)
( "$@" 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
#return $PIPESTATUS
}
clean_store_output()
{
rm -f $RC_STDOUT $RC_STDOUT.pipestatus
}
store_output epmq mc
echo $?
cat $RC_STDOUT
ls -l $RC_STDOUT
store_output epmq mc1
echo $?
cat $RC_STDOUT
ls -l $RC_STDOUT
# param true false
subst_option()
{
eval "[ -n \"\$$1\" ]" && echo "$2" || echo "$3"
}
test1=1
test0=
echo $(subst_option test1 TRUE)
echo $(subst_option test1 TRUE FALSE)
echo $(subst_option test1 "" FALSE)
echo $(subst_option test0 "" FALSE)
echo $(subst_option test0 TRUE)
#!/bin/sh
SUDO=
#sudofunc
sudofunc()
{
echo "arg1: $1"
echo "arg2: $2"
echo "arg3: $3"
echo "arg4: $4"
}
# fake
showcmd()
{
echo "$@"
}
# Print command line and run command line with SUDO
sudocmd()
{
showcmd "$SUDO $@"
#FIXME
$SUDO $@
}
sudocmd "ls -l" "-a -a"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment