Commit 3c521de8 authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to c7.1 as 2.5.8-alt0.M70C.1.1 (with rpmbph script)

parents a1107eb8 835a9dde
pkgdatadir=$(datadir)/eepm
# due using %makeinstallstd in spec
instpkgdatadir=/usr/share/eepm
instpkgdatadir=$(pkgdatadir)
install:
mkdir -p $(DESTDIR)$(bindir)/
# breaks link
#install -m 755 `ls -1 bin/* | grep -v "-"` $(DESTDIR)$(bindir)/
cp -a `ls -1 bin/* | grep -v "-"` $(DESTDIR)$(bindir)/
cp -a `ls -1 bin/* | grep -v "[-_]"` $(DESTDIR)$(bindir)/
cp -a bin/distr_info $(DESTDIR)$(bindir)/
chmod 0755 $(DESTDIR)$(bindir)/*
sed -e "s|SHAREDIR=.*|SHAREDIR=$(instpkgdatadir)|g" -e "s|@VERSION@|$(version)|g" <bin/epm >$(DESTDIR)$(bindir)/epm
sed -e "s|SHAREDIR=.*|SHAREDIR=$(instpkgdatadir)|g" \
-e "s|CONFIGDIR=.*|CONFIGDIR=$(sysconfdir)/eepm|g" \
-e "s|@VERSION@|$(version)|g" <bin/epm >$(DESTDIR)$(bindir)/epm
sed -e "s|SHAREDIR=.*|SHAREDIR=$(instpkgdatadir)|g" -e "s|@VERSION@|$(version)|g" <bin/serv >$(DESTDIR)$(bindir)/serv
mkdir -p $(DESTDIR)$(pkgdatadir)/
install -m 644 `ls -1 bin/* | grep "-"` $(DESTDIR)$(pkgdatadir)/
install -m 644 `ls -1 bin/* | grep "[-_]"` $(DESTDIR)$(pkgdatadir)/
rm -f $(DESTDIR)$(pkgdatadir)/distr_info
mkdir -p $(DESTDIR)$(mandir)/man1
cp -a `ls -1 man/*` $(DESTDIR)$(mandir)/man1/
......@@ -37,7 +37,17 @@ Note: epm is placed as /usr/bin/epm
$ rpm -qf /usr/bin/epm
eepm-1.1.0-alt2
== Install on any system ==
Just run under root user:
# curl -s https://raw.githubusercontent.com/Etersoft/eepm/master/packed/epm.sh | bash /dev/stdin ei --auto
== How to add new distro support ==
1. Fix detection with distr_info
2. Add distro support in set_pm_type function
3. Realize every command in epm-* files
4. Check epm packages and epm --short packages works correctly
(epm package 'awk' have to print packages with awk substring in their names)
See detailed description in russian at
http://wiki.etersoft.ru/Epm
......
Загрузку конфига
на p8, если в sources.list спереди стоит пробел
" rpm http://"
то имеем
# epm -sf /etc/fstab
Locate contents index file(s) ...
# apt-repo list
# eget -O /tmp/eepm/http:/10.10.19.99/altrepos/contents_index rpm/http://10.10.19.99/altrepos//base/contents_index
epm hs поиск с историей какой версией и changelog
https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks_(Русский)
systemctl edit юнит
аналог epm purge: запоминаем список файлов, удаляем пакеты и по возможности всё, от чего зависит (рекурсивно).
--interactive
встроить вычисление зависимость сюда rpmreqs
хочется видеть прямые зависимости, обратные, и рекурсивно.
выводить в цивилизованном виде (в прямом только с --direct)
Синхронизация списков файлов по пакетам:
rsync -av --inplace --progress --compress
Но лучше получать с сервиса
epm sf - скачивание через rsync -z для компактности?
epmqp uuid на x86_64/Ubuntu не различает архитектуру
get system checking
https://github.com/gwicke/mediawiki-containers
list перехватывается:
# serv openvpn
# service openvpn
Usage: openvpn {start|stop|reload|restart|reopen|condstop|condrestart|condreload|status|list|help}
[root@priv etc]# serv openvpn list
# chkconfig --list
# anyservice --quiet list
epmqf - если каталог есть, искать полный /usr/share/node
TODO: yaourt (pacman frontend), need we?
https://archlinux.fr/man/yaourt.8.html
/etc/eepm.conf конфиг
implement distr_info as inside tool and do access via epm command
Проверить всё с кавычками
[18:21:12] <danil> Вот так можно:
RED='\033[0;31m' ; NC='\033[0m' b="b" ; echo -e "aba" | sed -e "s|${b}|\\${RED}${b}\\${NC}|g" | xargs -0 printf
[18:23:40] <danil> > Ты знаешь способы?
Неверно передаёт кавычки:
__separate_sudocmd()
А другие?
colorise_word(){ //aba b
RED='\033[0;31m'
NC='\033[0m' b="b"
echo -e "$1" | sed -e "s|${2}|\\${RED}${2}\\${NC}|g" | xargs -0 printf
}
[18:24:18] <lav> Ну в общем-то да... Ещё можно попробовать готовый
readlink -f — что делать и нужен ли
Нужен realfullpath
yum list extras – имена тех пакетов, которые наличествуют в системе, но которыми в репозиториях и не пахло, то есть установленные “в лоб”, например, через
--dump-options for write simple bash completition
yum remove $(package-cleanup --orphans
https://github.com/biow0lf/prometheus-cli
$ ruby prometheus-cli.rb srpm openbox
Branch: Sisyphus
Name: openbox
Version: 3.5.0
Release: alt5
http://packages.altlinux.org/api_doc/
См. описание алгоритма установки с URL
строки в кавычках до rr (удаления репозитория) и добавления репозитория не доходят
dotty - через ссылки на реальные названия (epm req верхнего уровня)
менеджер пакетов из NetBSD — pkgsrc (команды для поиска нужных пакетов – pkgin update; pkgin avail; pkgin search).
Загрузку конфига
Использование | less теряет код возврата команды. Нужно сделать nobash решение, которое сохранит статус
Команда
......@@ -17,24 +100,21 @@ docmdmore
Установка (для отсутствующих файлов пакетов) и удаление (в любом случае) должны производиться с укороченными именами (которые воспримет верхний уровень)
Чтобы было легко выстраивать цепочки, нужно ввод не с консоли (если есть) воспринимать как параметры.
То же для EPM
Дописать таблицу на вики на основании реализованных команд.
2. Дописать таблицу на вики на основании реализованных команд.
3. Доделать и проверить deplist|requires
https://wiki.archlinux.org/index.php/Pacman_Rosetta
Вывернуть:
Было предложение вывернуть:
Не case по каждой системе, а в каталоге по каждой системе разместить файлы, выполняющие нужные действия.
apt-rpm/install
apt-rpm/remove
<<<<<<< HEAD
при упаковке лучше собирать в один файл.
Внесто общих функций тоже модули.
<<<<<<< HEAD
=======
=======
>>>>>>> 2.5.8-alt1
serv должен уметь показывать порядок загрузки?
>>>>>>> master
......@@ -33,7 +33,7 @@ epm_Install()
yum-rpm)
;;
*)
epm_update || return
pkg_filenames='' epm_update || return
;;
esac
......
......@@ -26,7 +26,7 @@ epm_Upgrade()
yum-rpm)
;;
*)
epm_update || return
pkg_filenames='' epm_update || return
;;
esac
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2017 Etersoft
# Copyright (C) 2012, 2017 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,27 +17,112 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-sh-altlinux
__epm_addrepo_altlinux()
{
local repo="$@"
case "$1" in
etersoft)
info "add Etersoft's addon repo"
load_helper epm-query
epm install --skip-installed apt-conf-etersoft-common apt-conf-etersoft-hold
# TODO: ignore only error code 22 (skipped) || fatal
local branch="$DISTRVERSION/branch"
[ "$DISTRVERSION" = "Sisyphus" ] && branch="$DISTRVERSION"
# FIXME
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
# TODO: func?
local arch=$(uname -m)
[ "$arch" = "i686" ] && arch="i586"
# TODO: use apt-repo add ?
echo "" | sudocmd tee -a /etc/apt/sources.list
echo "# added with eepm addrepo etersoft" | sudocmd tee -a /etc/apt/sources.list
echo "rpm [etersoft] http://download.etersoft.ru/pub/Etersoft LINUX@Etersoft/$branch/$arch addon" | sudocmd tee -a /etc/apt/sources.list
if [ "$arch" = "x86_64" ] ; then
echo "rpm [etersoft] http://download.etersoft.ru/pub/Etersoft LINUX@Etersoft/$branch/$arch-i586 addon" | sudocmd tee -a /etc/apt/sources.list
fi
echo "rpm [etersoft] http://download.etersoft.ru/pub/Etersoft LINUX@Etersoft/$branch/noarch addon" | sudocmd tee -a /etc/apt/sources.list
repo="$DISTRVERSION"
return 0
;;
autoimports)
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
;;
archive)
datestr="$2"
echo "$datestr" | grep -Eq "^20[0-2][0-9]/[01][0-9]/[0-3][0-9]$" || fatal "use follow date format: 2017/12/31"
# TODO: func?
local arch=$(uname -m)
[ "$arch" = "i686" ] && arch="i586"
echo "" | sudocmd tee -a /etc/apt/sources.list
local distrversion="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
local rpmsign='[alt]'
[ "$distrversion" != "sisyphus" ] && rpmsign="[$distrversion]"
echo "rpm $rpmsign http://ftp.altlinux.org/pub/distributions archive/$distrversion/date/$datestr/$arch classic" | sudocmd tee -a /etc/apt/sources.list
if [ "$arch" = "x86_64" ] ; then
echo "rpm $rpmsign http://ftp.altlinux.org/pub/distributions archive/$distrversion/date/$datestr/$arch-i586 classic" | sudocmd tee -a /etc/apt/sources.list
fi
echo "rpm $rpmsign http://ftp.altlinux.org/pub/distributions archive/$distrversion/date/$datestr/noarch classic" | sudocmd tee -a /etc/apt/sources.list
return 0
;;
esac
assure_exists apt-repo
if tasknumber "$repo" >/dev/null ; then
sudocmd apt-repo add $(tasknumber "$repo")
return
fi
if [ -z "$repo" ] ; then
info "Add branch repo. Use follow params:"
sudocmd apt-repo add branch
echo "etersoft (for LINUX@Etersoft repo)"
echo "archive 2018/02/09 (for archive from that date)"
return
fi
sudocmd apt-repo add "$repo"
}
epm_addrepo()
{
local repo="$(eval echo "$quoted_args")"
case $DISTRNAME in
ALTLinux)
__epm_addrepo_altlinux $repo
return
;;
esac
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
sudocmd apt-repo add $pkg_filenames
apt-dpkg)
assure_exists apt-add-repository software-properties-common
if echo "$repo" | grep -q "https://" ; then
assure_exists apt-transport-https
fi
sudocmd apt-add-repository "$repo"
info "Check file /etc/apt/sources.list if needed"
;;
apt-dpkg|aptitude-dpkg)
info "You need manually add repo to /etc/apt/sources.list"
aptitude-dpkg)
info "You need manually add repo to /etc/apt/sources.list (TODO)"
;;
yum-rpm)
info "You need manually add repo to /etc/yum.repos.d/"
assure_exists yum-utils
sudocmd yum-config-manager --add-repo "$repo"
;;
urpm-rpm)
sudocmd urpmi.addmedia $pkg_filenames
sudocmd urpmi.addmedia "$repo"
;;
zypper-rpm)
sudocmd zypper ar $pkg_filenames
sudocmd zypper ar "$repo"
;;
emerge)
sudocmd layman -a $pkg_filenames
sudocmd layman -a "$repo"
;;
pacman)
info "You need manually add repo to /etc/pacman.conf"
......@@ -45,7 +130,7 @@ case $PMTYPE in
#sudocmd repo-add $pkg_filenames
;;
npackd)
sudocmd npackdcl add-repo --url=$pkg_filenames
sudocmd npackdcl add-repo --url="$repo"
;;
slackpkg)
info "You need manually add repo to /etc/slackpkg/mirrors"
......
#!/bin/sh
#
# Copyright (C) 2013, 2014 Etersoft
# Copyright (C) 2013, 2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2013-2016 Etersoft
# Copyright (C) 2013-2016 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,42 +17,103 @@
# 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
# copied from strings
# CHECKME: the same like estrlist has ?
# Note: used egrep! write '[0-9]+(first|two)', not '[0-9]\+...'
rhas()
{
echo "$1" | grep -E -q -- "$2"
}
# $1 - command name
# $2 - package name
# copied from strings
is_dirpath()
{
[ "$1" = "." ] && return $?
rhas "$1" "/"
}
__epm_assure()
__epm_need_update()
{
local PACKAGE="$1"
local PACKAGEVERSION="$2"
[ -n "$PACKAGEVERSION" ] || return 0
load_helper epm-query
is_installed "$PACKAGE" || return 0
load_helper epm-print
# epm print version for package N
local INSTALLEDVERSION=$(query_package_field "version" "$PACKAGE")
# if needed >= installed, return 0
[ "$(compare_version "$PACKAGEVERSION" "$INSTALLEDVERSION")" -gt 0 ] && return 0
return 1
}
__epm_assure_checking()
{
if __check_command_in_path "$1" >/dev/null ; then
local CMD="$1"
local PACKAGE="$2"
local PACKAGEVERSION="$3"
[ -n "$PACKAGEVERSION" ] && return 1
if is_dirpath "$CMD" ; then
if [ -e "$CMD" ] ; then
if [ -n "$verbose" ] ; then
info "File or directory $CMD is already exists."
epm qf "$CMD"
fi
return 0
fi
[ -n "$PACKAGE" ] || fatal "You need run with package name param when use with absolute path"
return 1
fi
if __check_command_in_path "$CMD" >/dev/null ; then
if [ -n "$verbose" ] ; then
local compath="$(__check_command_in_path "$1")"
info "Command $1 is exists: $compath"
info "Command $CMD is exists: $compath"
epm qf "$compath"
fi
return
return 0
fi
# TODO: use package name normalization
info "Installing appropriate package for $1 command..."
return 1
}
# Do fast checking for command and install package if the command does not exist
# $1 - command name
# $2 - [package name]
# $3 - [needed package version]
__epm_assure()
{
local CMD="$1"
local PACKAGE="$2"
local PACKAGEVERSION="$3"
[ -n "$PACKAGE" ] || PACKAGE="$1"
#epm install $2
# copied from epm_install
local names="$(echo "$PACKAGE" | filter_out_installed_packages)"
__epm_assure_checking $CMD $PACKAGE $PACKAGEVERSION && return 0
info "Installing appropriate package for $CMD command..."
__epm_need_update $PACKAGE $PACKAGEVERSION || return 0
docmd epm --auto install $PACKAGE || return
non_interactive=1 epm_install_names $names
[ -n "$PACKAGEVERSION" ] || return 0
# check if we couldn't update and still need update
__epm_need_update $PACKAGE $PACKAGEVERSION && return 1
return 0
}
......@@ -61,5 +122,6 @@ 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
# shellcheck disable=SC2046
__epm_assure $(eval echo $quoted_args)
}
#!/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/>.
#
epm_audit()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
pkgng)
sudocmd pkg audit -F
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2015, 2017 Etersoft
# Copyright (C) 2015, 2017 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/>.
#
__epm_orphan_altrpm()
{
docmd "apt-cache list-extras"
}
epm_autoorphans()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm)
# ALT Linux only
assure_exists /etc/buildreqs/files/ignore.d/apt-scripts apt-scripts
if [ -z "$dryrun" ] ; then
echo "We will try remove all installed packages which are missed in repositories"
warning "Use with caution!"
fi
local PKGLIST=$(__epm_orphan_altrpm \
| sed -e "s/\.32bit//g" \
| grep -v -- "^eepm$" \
| grep -v -- "^kernel")
if [ -n "$quiet" ] ; then
echo "$PKGLIST"
else
docmd epm remove $dryrun $PKGLIST
fi
;;
apt-dpkg|aptitude-dpkg)
assure_exists deborphan
showcmd deborphan
a='' deborphan | docmd epm remove $dryrun
;;
#aura)
# sudocmd aura -Oj
# ;;
yum-rpm)
docmd epm upgrade
assure_exists package-cleanup yum-utils
showcmd package-cleanup --orphans
local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-")
docmd epm remove $dryrun $PKGLIST
;;
dnf-rpm)
# TODO: dnf list extras
docmd epm upgrade
assure_exists package-cleanup dnf-utils
showcmd package-cleanup --orphans
local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-")
docmd epm remove $dryrun $PKGLIST
;;
urpm-rpm)
if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet"
else
showcmd urpme --report-orphans
sudocmd urpme --auto-orphans
fi
;;
#emerge)
# sudocmd emerge --depclean
# assure_exists revdep-rebuild
# sudocmd revdep-rebuild
# ;;
pacman)
if [ -n "$dryrun" ] ; then
info "Autoorphans packages list:"
sudocmd pacman -Qdtq
else
sudocmd pacman -Qdtq | sudocmd pacman -Rs -
fi
;;
slackpkg)
# clean-system removes non official packages
sudocmd slackpkg clean-system
;;
#guix)
# sudocmd guix gc
# ;;
#pkgng)
# sudocmd pkg autoremove
# ;;
zypper-rpm)
# https://www.linux.org.ru/forum/desktop/11931830
assure_exists zypper zypper 1.9.2
# For zypper < 1.9.2: zypper se -si | grep 'System Packages'
sudocmd zypper packages --orphaned
# FIXME: x86_64/i586 are duplicated
local PKGLIST=$(zypper packages --orphaned | tail -n +5 | cut -d \| -f 3 | sort -u)
docmd epm remove $dryrun --clean-deps $PKGLIST
;;
xbps)
if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet"
else
sudocmd xbps-remove -o
fi
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2017, 2018 Etersoft
# Copyright (C) 2012, 2017, 2018 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,61 +17,219 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__epm_autoremove_altrpm()
load_helper epm-check_updated_repo
__epm_print_excluded()
{
local pkgs="$1"
local fullpkgs="$2"
local excluded
excluded="$(estrlist exclude "$pkgs" "$fullpkgs")"
if [ -n "$excluded" ] ; then
echo "Skipped manually installed:"
estrlist union $excluded
fi
}
__epm_autoremove_altrpm_pp()
{
local pkg
local pkgs fullpkgs
info "Removing unused python/perl modules..."
#[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force
local libexclude="$1"
local flag=
load_helper epm-packages
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
pkgs=$(skip_manually_installed $fullpkgs)
if [ -n "$dryrun" ] ; then
info "Packages for autoremoving:"
echo "$pkgs"
__epm_print_excluded "$pkgs" "$fullpkgs"
return 0
fi
__epm_print_excluded "$pkgs" "$fullpkgs"
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then
info ""
info "call again for next cycle until all modules will be removed"
__epm_autoremove_altrpm_pp "$libexclude"
fi
return 0
}
__epm_autoremove_altrpm_lib()
{
local pkgs fullpkgs
local nodevel="$1"
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
if [ "$nodevel" = "nodevel" ] ; then
info "Removing all non -devel/-debuginfo libs packages not need by anything..."
local develrule='-(devel|devel-static)$'
else
info "Removing all non -debuginfo libs packages (-devel too) not need by anything..."
local develrule='-(NONONO)$'
fi
#[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force
local flag=
local libgrep='^(lib|i586-lib|bzlib|zlib)'
[ -n "$force" ] || libexclude=$libgrep'[^-]*$'
# https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps
showcmd "apt-cache list-nodeps | grep -E -- \"$libgrep\""
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libgrep" \
| sed -e "s/[-\.]32bit$//g" \
| grep -E -v -- "$develrule" \
| grep -E -v -- "-(debuginfo)$" \
| grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \
| grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|eepm)" )
pkgs=$(skip_manually_installed $fullpkgs)
if [ -n "$dryrun" ] ; then
info "Packages for autoremoving:"
echo "$pkgs"
__epm_print_excluded "$pkgs" "$fullpkgs"
return 0
fi
__epm_print_excluded "$pkgs" "$fullpkgs"
# commented, with hi probability user install i586- manually
# workaround against missed i586- handling in apt-cache list-nodeps
if epmqp i586-lib >/dev/null ; then
info "You can try removing all i586- with follow command"
showcmd rpm -v -e $(epmqp i586-lib)
fi
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
# call again for next cycle until all libs will removed
[ -n "$flag" ] && __epm_autoremove_altrpm
if [ -n "$flag" ] ; then
info ""
info "call again for next cycle until all libs will be removed"
__epm_autoremove_altrpm_lib $nodevel
fi
return 0
}
__epm_autoremove_altrpm()
{
local i
load_helper epm-packages
assure_exists /etc/buildreqs/files/ignore.d/apt-scripts apt-scripts
if [ -z "$pkg_names" ] ; then
__epm_autoremove_altrpm_pp '^(python-module-|python3-module-|python-modules-|python3-modules|perl-)'
__epm_autoremove_altrpm_lib nodevel
return 0
fi
for i in $pkg_names ; do
case $i in
libs)
__epm_autoremove_altrpm_lib nodevel
;;
python)
__epm_autoremove_altrpm_pp '^(python-module-|python3-module-|python-modules-|python3-modules)'
;;
perl)
__epm_autoremove_altrpm_pp '^(perl-)'
;;
libs-devel)
__epm_autoremove_altrpm_lib
;;
*)
fatal "autoremove: unsupported '$i'. Use libs, python, perl, libs-devel."
;;
esac
done
return 0
}
# TODO: keep our eepm package
epm_autoremove()
{
case $PMTYPE in
apt-rpm)
assure_exists remove-old-kernels
# ALT Linux only
case $DISTRNAME in
ALTLinux)
__epm_autoremove_altrpm
# ALT Linux only
sudocmd remove-old-kernels
[ -n "$dryrun" ] && return
docmd epm remove-old-kernels
if which nvidia-clean-driver 2>/dev/null ; then
sudocmd nvidia-clean-driver
fi
return
;;
*)
;;
esac
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-dpkg|aptitude-dpkg)
sudocmd apt-get autoremove
sudocmd apt-get autoremove $dryrun
;;
aura)
if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet"
fi
sudocmd aura -Oj
;;
yum-rpm)
# cleanup orphanes?
while true ; do
# shellcheck disable=SC2046
docmd package-cleanup --leaves $(subst_option non_interactive --assumeyes)
# FIXME: package-cleanup have to use stderr for errors
local PKGLIST=$(package-cleanup --leaves | grep -v "Loaded plugins" | grep -v "Unable to")
local PKGLIST=$(package-cleanup -q --leaves | grep -v "^eepm-")
[ -n "$PKGLIST" ] || break
sudocmd yum remove $PKGLIST
showcmd epm remove $PKGLIST
done
;;
urpm-rpm)
sudocmd urpme --auto-orphans
dnf-rpm)
if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet"
fi
sudocmd dnf autoremove
;;
# see autoorhans
#urpm-rpm)
# sudocmd urpme --auto-orphans
# ;;
emerge)
if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet"
fi
sudocmd emerge --depclean
assure_exists revdep-rebuild
sudocmd revdep-rebuild
;;
pacman)
sudocmd pacman -Qdtq | sudocmd pacman -Rs -
;;
# see autoorhans
#pacman)
# sudocmd pacman -Qdtq | sudocmd pacman -Rs -
# ;;
slackpkg)
# clean-system removes non official packages
#sudocmd slackpkg clean-system
......@@ -79,9 +237,30 @@ case $PMTYPE in
guix)
sudocmd guix gc
;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
pkgng)
sudocmd pkg autoremove
;;
zypper-rpm)
# https://www.linux.org.ru/forum/desktop/11931830
assure_exists zypper zypper 1.9.3
sudocmd zypper packages --unneeded
# FIXME: x86_64/i586 are duplicated
local PKGLIST=$(zypper packages --unneeded | tail -n +5 | cut -d \| -f 3 | sort -u)
showcmd epm remove --clean-deps $PKGLIST
;;
xbps)
if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet"
fi
sudocmd xbps-remove -O
;;
opkg)
if [ -n "$dryrun" ] ; then
sudocmd opkg --noaction --autoremove
else
sudocmd opkg --autoremove
fi
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012, 2016 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
......@@ -34,7 +34,8 @@ __epm_changelog_files()
# TODO: detect every file
case $(get_package_type $1) in
rpm)
docmd_foreach "rpm -p --changelog" $@ | less
assure_exists rpm
docmd_foreach "rpm -q -p --changelog" $@ | less
;;
# deb)
#
......@@ -50,8 +51,8 @@ __epm_changelog_local_names()
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm --changelog" $@ | less
apt-rpm|yum-rpm|dnf-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm -q --changelog" $@ | less
;;
apt-dpkg|aptitude-dpkg)
docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
......@@ -84,9 +85,9 @@ __epm_changelog_unlocal_names()
#yum-rpm)
# sudocmd yum clean all
# ;;
#urpm-rpm)
# sudocmd urpmi --clean
# ;;
urpm-rpm)
docmd urpmq --changelog $@ | less
;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
......@@ -95,7 +96,7 @@ __epm_changelog_unlocal_names()
docmd equery changes -f $1 | less
;;
*)
fatal "Have no suitable command for $PMTYPE"
fatal "Have no suitable command for $PMTYPE. Try install the package firstly."
;;
esac
......
#!/bin/sh
#
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2019 Etersoft
# Copyright (C) 2012-2019 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,22 +17,56 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# remove duplicates
try_fix_apt_rpm_dupls()
{
info "Check for duplicates ..."
local TESTPKG="ignoreflock"
local has_testpkg=""
if epm --quiet installed $TESTPKG ; then
has_testpkg=1
sudocmd epm remove --auto $TESTPKG || return
fi
local PKGLIST
PKGLIST=$(LANG=C $SUDO apt-get install $TESTPKG 2>&1 | grep "W: There are multiple versions of" | \
sed -e 's|W: There are multiple versions of "\(.*\)" in your system.|\1|')
local TODEL
for i in $PKGLIST ; do
local pkg=${i/.32bit/}
local todel="$(rpm -q $pkg | head -n1)"
local todel2="$(rpm -q $pkg | head -n2 | tail -n1)"
if [ "$todel" = "$todel2" ] ; then
echo "Fix the same name duplicates for $pkg..."
sudocmd rpm -e "$todel" --allmatches --nodeps && epm install $pkg && continue
fi
sudocmd rpm -e "$todel" || TODEL="$TODEL $todel"
done
[ -n "$TODEL" ] && sudocmd rpm -e "$TODEL"
[ -n "$has_testpkg" ] && epm install $TESTPKG
}
epm_check()
{
case $PMTYPE in
apt-rpm|apt-dpkg)
apt-rpm)
#sudocmd apt-get check || exit
#sudocmd apt-get update || exit
sudocmd apt-get -f install || return
try_fix_apt_rpm_dupls
;;
apt-dpkg)
#sudocmd apt-get check || exit
#sudocmd apt-get update || exit
sudocmd apt-get -f install || exit
sudocmd apt-get -f install || return
;;
apt-dpkg)
#sudocmd apt-get update || exit
#sudocmd apt-get check || exit
sudocmd apt-get -f install || exit
sudocmd apt-get autoremove
sudocmd apt-get -f install || return
#sudocmd apt-get autoremove
;;
aptitude-dpkg)
sudocmd aptitude -f install || exit
sudocmd aptitude -f install || return
#sudocmd apt-get autoremove
;;
yum-rpm)
......@@ -44,6 +78,9 @@ case $PMTYPE in
docmd rpm -Va --nofiles --nodigest
;;
dnf-rpm)
sudocmd dnf check
;;
emerge)
sudocmd revdep-rebuild
;;
......@@ -56,8 +93,11 @@ case $PMTYPE in
conary)
sudocmd conary verify
;;
pkgng)
sudocmd pkg check -d -a
;;
homebrew)
sudocmd brew doctor
docmd brew doctor
;;
*)
fatal "Have no suitable command for $PMTYPE"
......
#!/bin/sh
#
# Copyright (C) 2014 Etersoft
# Copyright (C) 2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2014, 2015 Etersoft
# Copyright (C) 2014, 2015 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,13 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__is_repo_info_download()
__is_repo_info_downloaded()
{
case $PMTYPE in
apt-*)
if [ -r /var/cache/apt ] ; then
# FIXME: only if root permissions
test -r /var/cache/apt/pkgcache.bin || return
$SUDO test -r /var/cache/apt/pkgcache.bin || return
fi
;;
*)
......@@ -32,14 +31,60 @@ __is_repo_info_download()
return 0
}
__is_repo_info_uptodate()
{
case $PMTYPE in
apt-*)
# apt-deb do not update lock file date
#if $SUDO test -r /var/lib/apt/lists ; then
local LOCKFILE=/var/lib/apt/lists
$SUDO test -r $LOCKFILE || return
# if repo older than 1 day, return false
# find print string if file is obsoleted
test -z "$(find $LOCKFILE -maxdepth 0 -mtime +1)" || return
#fi
;;
*)
;;
esac
return 0
}
update_repo_if_needed()
{
if ! __is_repo_info_download ; then
# check if we need skip update checking
if [ "$1" = "soft" ] && [ -n "$SUDO" ] ; then
# if sudo requires a password, skip autoupdate
sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; }
fi
cd / || fatal
if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then
load_helper epm-update
epm_update
return
pkg_filenames='' epm_update
fi
cd - >/dev/null || fatal
}
# save manually installed packages
save_installed_packages()
{
[ -d /var/lib/rpm ] || return 0
estrlist list "$@" | $SUDO tee /var/lib/rpm/EPM-installed >/dev/null
}
# TODO: if repo info is very obsoleted (a few days?), we need run update
check_manually_installed()
{
[ -r /var/lib/rpm/EPM-installed ] || return 1
grep -q -- "^$1\$" /var/lib/rpm/EPM-installed
}
skip_manually_installed()
{
local i
for i in "$@" ; do
check_manually_installed "$i" && continue
echo "$i"
done
}
#!/bin/sh
#
# Copyright (C) 2009, 2012, 2013 Etersoft
# Copyright (C) 2009, 2012, 2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2009, 2012, 2013, 2014, 2016, 2018 Etersoft
# Copyright (C) 2009, 2012, 2013, 2014, 2016, 2018 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,21 +17,37 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# changed since rpm 4.0.4
__rpm_allows_nosignature()
{
a= rpm --help | grep -q -- "--nosignature"
}
check_pkg_integrity()
{
local PKG="$1"
local RET
local NOSIGNATURE
case $(get_package_type $PKG) in
rpm)
docmd rpm --checksig $PKG
assure_exists rpm
__rpm_allows_nosignature && NOSIGNATURE="--nosignature" || NOSIGNATURE="--nogpg"
docmd rpm --checksig $NOSIGNATURE $PKG
;;
deb)
assure_exists dpkg
# FIXME: debsums -ca package ?
docmd dpkg --contents $PKG >/dev/null && echo "Package $PKG is correct."
;;
exe)
true
file $PKG | grep -q "executable for MS Windows"
;;
msi)
# TODO: add to patool via cabextract
assure_exists cabextract
#file $PKG | grep -q "Microsoft Office Document"
docmd cabextract -t $PKG
;;
ebuild)
true
......@@ -50,6 +66,7 @@ case $PMTYPE in
docmd rpm -V $@
;;
*-dpkg)
assure_exists debsums
docmd debsums $@
;;
emerge)
......@@ -67,14 +84,31 @@ esac
epm_checkpkg()
{
if [ -n "$pkg_names" ] ; then
# TODO: если есть / или расширение, это отсутствующий файл
info "Suggest $pkg_names are name(s) of installed packages"
__epm_check_installed_pkg $pkg_names
return
fi
# if possible, it will put pkg_urls into pkg_files or pkg_names
if [ -n "$pkg_urls" ] ; then
load_helper epm-download
__handle_pkg_urls_to_checking
fi
[ -n "$pkg_files" ] || fatal "Checkpkg: missing file or package name(s)"
local RETVAL=0
local pkg
for pkg in $pkg_files ; do
check_pkg_integrity $pkg || fatal "Broken package $pkg"
check_pkg_integrity $pkg || RETVAL=1
done
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
#fatal "Broken package $pkg"
return $RETVAL
}
#!/bin/sh
#
# Copyright (C) 2015 Etersoft
# Copyright (C) 2015 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/>.
#
# TODO: rpm list from bash_completion in /var/log/rpmpkgs
epm_checksystem_ALTLinux()
{
local TDIR=$(mktemp -d)
assure_exists time
touch $TDIR/added
for ft in $(ls /usr/lib/rpm/*.filetrigger | sort) ; do
echo "Try run $ft ..."
echo $TDIR/added $TDIR/removed | a='' time $ft
done
rm -f $TDIR/added fatal
rmdir $TDIR || fatal
echo "Count lines:"
wc -l /var/lib/rpm/files-awaiting-filetriggers
}
epm_checksystem()
{
[ $EFFUID = "0" ] && fatal "Do not use checksystem under root"
case $DISTRNAME in
ALTLinux)
epm_checksystem_$DISTRNAME
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
# direct debug run
if [ "$1" = "--debug" ] ; then
shift
SUDO=sudo
DISTRNAME=ALTLinux
epm_checksystem
fi
#!/bin/sh
#
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014,2016 Etersoft
# Copyright (C) 2012,2014,2016 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,14 +17,41 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__remove_alt_apt_cache_file()
{
sudocmd rm -vf /var/cache/apt/*.bin
sudocmd rm -vf /var/cache/apt/partial/*
sudocmd rm -vf /var/lib/apt/lists/*pkglist*
sudocmd rm -vf /var/lib/apt/lists/*release*
}
__remove_deb_apt_cache_file()
{
sudocmd rm -vf /var/cache/apt/*.bin
sudocmd rm -vf /var/cache/apt/archives/partial/*
sudocmd rm -vf /var/lib/apt/lists/*Packages*
sudocmd rm -vf /var/lib/apt/lists/*Release*
sudocmd rm -vf /var/lib/apt/lists/*Translation*
}
epm_clean()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm|apt-dpkg)
apt-rpm)
sudocmd apt-get clean
[ -n "$force" ] && __remove_alt_apt_cache_file
;;
apt-dpkg)
sudocmd apt-get clean
[ -n "$force" ] && __remove_deb_apt_cache_file
;;
aptitude-dpkg)
sudocmd aptitude clean
[ -n "$force" ] && __remove_deb_apt_cache_file
;;
yum-rpm)
sudocmd yum clean all
......@@ -37,7 +64,7 @@ case $PMTYPE in
sudocmd urpmi --clean
;;
pacman)
sudocmd pacman -Sc
sudocmd pacman -Sc --noconfirm
;;
zypper-rpm)
sudocmd zypper clean
......@@ -47,6 +74,12 @@ case $PMTYPE in
;;
slackpkg)
;;
pkgng)
sudocmd pkg clean -a
;;
xbps)
sudocmd xbps-remove -O
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -25,6 +25,7 @@ epm_conflicts_files()
case $(get_package_type $pkg_files) in
rpm)
assure_exists rpm
docmd "rpm -q --conflicts -p" $pkg_files
;;
#deb)
......@@ -69,7 +70,7 @@ case $PMTYPE in
# 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"
a='' dpkg -s $pkg_names | grep "^Conflicts:" | sed "s|^Conflicts:||g"
return
else
EXTRA_SHOWDOCMD=' | grep "Conflicts:"'
......
#!/bin/sh
#
# Copyright (C) 2012,2014,2016 Etersoft
# Copyright (C) 2012,2014,2016 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-check_updated_repo
__epm_add_alt_apt_downgrade_preferences()
{
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
cat <<EOF | $SUDO tee /etc/apt/preferences
# main repo
Package: *
Pin: release c=classic
Pin-Priority: 1001
# overload with addon repo
Package: *
Pin: release c=addon
Pin-Priority: 1101
EOF
}
# See https://wiki.debian.org/ru/AptPreferences
__epm_add_deb_apt_downgrade_preferences()
{
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
info "Running with /etc/apt/preferences:"
cat <<EOF | $SUDO tee /etc/apt/preferences
Package: *
Pin: release a=stable
Pin-Priority: 1001
Package: *
Pin: release a=testing
Pin-Priority: 900
Package: *
Pin: release a=unstable
Pin-Priority: 800
EOF
}
__epm_remove_apt_downgrade_preferences()
{
sudocmd rm -f /etc/apt/preferences
}
epm_downgrade()
{
local CMD
# it is useful for first time running
update_repo_if_needed
info "Running command for downgrade packages"
case $PMTYPE in
apt-rpm)
local APTOPTIONS="$(subst_option non_interactive -y)"
__epm_add_alt_apt_downgrade_preferences || return
if [ -n "$pkg_filenames" ] ; then
sudocmd apt-get $APTOPTIONS install $pkg_filenames
else
sudocmd apt-get $APTOPTIONS dist-upgrade
fi
__epm_remove_apt_downgrade_preferences
;;
apt-dpkg)
local APTOPTIONS="$(subst_option non_interactive -y)"
__epm_add_deb_apt_downgrade_preferences || return
if [ -n "$pkg_filenames" ] ; then
sudocmd apt-get $APTOPTIONS install $pkg_filenames
else
sudocmd apt-get $APTOPTIONS dist-upgrade
fi
__epm_remove_apt_downgrade_preferences
;;
yum-rpm)
# can do update repobase automagically
if [ -n "$pkg_filenames" ] ; then
sudocmd yum downgrade $pkg_filenames
else
sudocmd yum distro-sync
fi
;;
dnf-rpm)
if [ -n "$pkg_filenames" ] ; then
sudocmd dnf downgrade $pkg_filenames
else
sudocmd dnf distro-sync
fi
;;
urpm-rpm)
assure_exists urpm-reposync urpm-tools
sudocmd urpm-reposync -v
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2016-2018 Etersoft
# Copyright (C) 2016-2018 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/>.
#
alt_base_dist_url="http://ftp.basealt.ru/pub/distributions"
__use_url_install()
{
case $DISTRNAME in
"ALTLinux")
# do not support https yet
echo "$pkg_urls" | grep -q "https://" && return 1
# force download if wildcard is used
echo "$pkg_urls" | grep -q "[?*]" && return 1
pkg_names="$pkg_names $pkg_urls"
return 0
;;
esac
case $PMTYPE in
#apt-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
#deepsolver-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
#urpm-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
pacman)
pkg_names="$pkg_names $pkg_urls"
;;
yum-rpm|dnf-rpm)
pkg_names="$pkg_names $pkg_urls"
;;
#zypper-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
*)
return 1
;;
esac
return 0
}
# for download before install / checking
__download_pkg_urls()
{
local url
[ -z "$pkg_urls" ] && return
for url in $pkg_urls ; do
local tmppkg=$(mktemp -d) || fatal "failed mktemp -d"
cd $tmppkg || fatal
if docmd eget "$url" ; then
local i
for i in $(basename $url) ; do
[ -s "$tmppkg/$i" ] || continue
pkg_files="$pkg_files $tmppkg/$i"
to_remove_pkg_files="$to_remove_pkg_files $tmppkg/$i"
done
else
warning "Failed to download $url, ignoring"
fi
cd - >/dev/null
done
# reconstruct
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
}
# NOTE: call __clean_downloaded_pkg_files after
__handle_pkg_urls_to_install()
{
#[ -n "$pkg_urls" ] || return
# TODO: do it correctly
to_remove_pkg_files=
# FIXME: check type of pkg_urls separately?
if [ "$(get_package_type "$pkg_urls")" != $PKGFORMAT ] || ! __use_url_install ; then
# use workaround with eget: download and put in pkg_files
__download_pkg_urls
fi
pkg_urls=
}
__handle_pkg_urls_to_checking()
{
#[ -n "$pkg_urls" ] || return
# TODO: do it correctly
to_remove_pkg_files=
# use workaround with eget: download and put in pkg_files
__download_pkg_urls
pkg_urls=
}
#__clean_downloaded_pkg_files()
#{
# [ -z "$to_remove_pkg_files" ] && return
# rm -fv $to_remove_pkg_files
#}
__epm_get_altpkg_url()
{
info "TODO: https://packages.altlinux.org/api/branches"
load_helper epm-site
local arch=$(paoapi packages/$1 | get_pao_var arch)
# FIXME: arch can be list
[ "$arch" = "noarch" ] || arch=$(arch)
# HACK: filename can be list
local filename=$(paoapi packages/$1 | get_pao_var filename | grep $arch)
[ -n "$filename" ] || fatal "Can't get filename"
# fixme: get from /branches
local dv=$DISTRNAME/$DISTRVERSION/branch
[ "$DISTRVERSION" = "Sisyphus" ] && dv=$DISTRNAME/$DISTRVERSION
echo "$alt_base_dist_url/$dv/$arch/RPMS.classic/$filename"
}
__epm_print_url_alt()
{
local url="$1"
echo "$url"
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://mirror.yandex.ru/altlinux|g"
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://download.etersoft.ru/pub/ALTLinux|g"
}
__epm_print_url_alt_check()
{
local pkg=$1
shift
local tm=$(mktemp)
epm assure curl
load_helper epm-site
quiet=1
local buildtime=$(paoapi packages/$pkg | get_pao_var buildtime)
echo
echo "Latest release: $(paoapi packages/$pkg | get_pao_var sourcepackage) $buildtime"
__epm_print_url_alt "$1" | while read url ; do
a='' curl -s --head $url >$tm || { echo "$url: missed" ; continue ; }
local http=$(cat $tm | grep "^HTTP" | sed -e "s|\r||g")
local lastdate=$(cat $tm | grep "^Last-Modified:" | sed -e "s|\r||g")
local size=$(cat $tm | grep "^Content-Length:" | sed -e "s|^Content-Length: ||g" | sed -e "s|\r||g")
echo "$url ($http $lastdate) Size: $size"
done
rm -f $tm
}
__epm_download_alt()
{
local pkg
if [ "$1" = "--check" ] ; then
local checkflag="$1"
shift
fi
for pkg in "$@" ; do
local url=$(__epm_get_altpkg_url $pkg)
[ -n "$url" ] || warning "Can't get URL for $pkg"
if [ -n "$checkflag" ] ; then
__epm_print_url_alt_check "$pkg" "$url"
else
docmd eget $url || return
fi
done
}
epm_download()
{
local CMD
case $DISTRNAME in
ALTLinux)
__epm_download_alt $pkg_filenames
return
;;
esac
case $PMTYPE in
dnf-rpm)
sudocmd dnf download $pkg_filenames
;;
aptcyg)
sudocmd apt-cyg download $pkg_filenames
;;
yum-rpm)
# TODO: check yum install --downloadonly --downloaddir=/tmp <package-name>
assure_exists yumdownloader yum-utils
sudocmd yumdownloader $pkg_filenames
;;
dnf-rpm)
sudocmd dnf download $pkg_filenames
;;
urpm-rpm)
sudocmd urpmi --no-install $URPMOPTIONS $@
;;
tce)
sudocmd tce-load -w $pkg_filenames
;;
opkg)
docmd opkg $pkg_filenames
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
# Copyright (C) 2016 Etersoft
# Copyright (C) 2016 Danil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2016 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
__epm_korinf_site() {
local archprefix=""
[ "$($DISTRVENDOR -a)" = "x86_64" ] && archprefix="x86_64/"
local aftername="-"
[ "$($DISTRVENDOR -p)" = "deb" ] && aftername="_"
echo "http://updates.etersoft.ru/pub/Korinf/$archprefix$($DISTRVENDOR -e)"
}
__epm_korinf_list() {
[ "$1" = "--list" ] && shift
local MASK="$1"
showcmd eget --list "$(__epm_korinf_site)/$MASK*.$($DISTRVENDOR -p)"
eget --list "$(__epm_korinf_site)/$MASK*.$($DISTRVENDOR -p)" | sort
}
__epm_korinf_install(){
local PACKAGE="$1"
# FIXME: some way to get latest package
local fn="$(__epm_korinf_list $PACKAGE$aftername | tail -n1)"
[ -n "$fn" ] || fatal "Can't find package file for $PACKAGE"
local download_link=$(__epm_korinf_site)/$fn
#info "Install $download_link ..."
pkg_names='' pkg_files='' pkg_urls="$download_link" epm_install
}
epm_epm_install(){
local i
local pkglist="$pkg_filenames"
# install epm by default
[ -n "$pkglist" ] || pkglist="eepm"
case "$pkglist" in
--list*)
__epm_korinf_list $pkglist
return
;;
esac
for i in $pkglist ; do
__epm_korinf_install $i
done
}
#!/bin/sh
#
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2018 Etersoft
# Copyright (C) 2012-2018 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,31 +18,36 @@
#
load_helper epm-query
load_helper epm-print
load_helper epm-sh-warmup
# TODO: port or rewrite apt-file
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
# see also epm-search-file
local_content_filelist()
__alt_local_content_filelist()
{
local SYSARCH
SYSARCH=$(uname -m)
[ "$SYSARCH" = "x86_64" ] || SYSARCH=i586
load_helper epm-sh-altlinux
local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
local CI=$REPODIR/$SYSARCH/base/contents_index
local CINOA=$REPODIR/noarch/base/contents_index
local CI="$(get_local_alt_contents_index)"
[ -n "$CI" ] || fatal "Have no local contents index"
# TODO: safe way to use less
#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"
[ -n "$USETTY" ] && info "Search in $CI for $1..."
__local_ercat $CI | grep -h -- ".*$1$" | sed -e "s|\(.*\)\t\(.*\)|\1|g"
} | $OUTCMD
}
__deb_local_content_filelist()
{
showcmd "apt-file list $1 | grep '^$1: ' | sed -e 's|$1: ||g'"
a='' apt-file list "$1" | grep "^$1: " | sed -e "s|$1: ||g"
}
__epm_filelist_remote()
{
......@@ -51,10 +56,27 @@ __epm_filelist_remote()
case $PMTYPE in
apt-rpm)
# TODO: use RESTful interface to prometeus? See ALT bug #29496
docmd_foreach local_content_filelist $@
docmd_foreach __alt_local_content_filelist "$@"
;;
apt-dpkg)
assure_exists apt-file || return
if sudo -n true 2>/dev/null ; then
sudocmd apt-file update
else
info "sudo requires a password, skip apt-file update"
fi
docmd_foreach __deb_local_content_filelist "$@"
;;
yum-rpm)
assure_exists yum-utils || return
docmd repoquery -q -l "$@"
;;
dnf-rpm)
assure_exists dnf-plugins-core || return
docmd dnf repoquery -l "$@"
;;
*)
fatal "Query filelist for non installed packages does not realized"
fatal "Query filelist for non installed packages is not implemented yet."
;;
esac
}
......@@ -68,9 +90,11 @@ __epm_filelist_file()
# TODO: allow a new packages
case $(get_package_type $1) in
rpm)
assure_exists rpm
CMD="rpm -qlp"
;;
deb)
assure_exists dpkg
CMD="dpkg --contents"
;;
*)
......@@ -87,22 +111,15 @@ __epm_filelist_name()
[ -z "$*" ] && return
warmup_lowbase
case $PMTYPE in
apt-rpm)
*-rpm)
CMD="rpm -ql"
;;
*-dpkg)
CMD="dpkg -L"
;;
yum-rpm)
CMD="rpm -ql"
;;
urpm-rpm)
CMD="rpm -ql"
;;
zypper-rpm)
CMD="rpm -ql"
;;
android)
CMD="pm list packages -f"
;;
......@@ -110,15 +127,31 @@ __epm_filelist_name()
CMD="conary query --ls"
;;
pacman)
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g" | less
docmd pacman -Ql $@ | sed -e "s|.* ||g" | less
return
;;
emerge)
assure_exists equery
CMD="equery files"
;;
homebrew)
CMD="brew list"
;;
pkgng)
CMD="pkg info -l"
;;
opkg)
CMD="opkg files"
;;
xbps)
CMD="xbps-query -f"
;;
aptcyg)
docmd apt-cyg listfiles $@ | sed -e "s|^|/|g"
return
;;
slackpkg)
is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized"
is_installed $@ || fatal "Query filelist for non installed packages is not implemented yet"
docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* | less
return
;;
......@@ -128,8 +161,9 @@ __epm_filelist_name()
esac
# TODO: add less
docmd $CMD $pkg_names && return
is_installed $pkg_names || __epm_filelist_remote $pkg_names
docmd $CMD $@ && return
# TODO: may be we need check is installed before prev. line?
is_installed $@ || __epm_filelist_remote $@
}
......@@ -139,6 +173,7 @@ epm_filelist()
__epm_filelist_file $pkg_files || return
__epm_filelist_name $pkg_names || return
# shellcheck disable=SC2046
__epm_filelist_name $(print_name $pkg_names) || return
}
#!/bin/sh
#
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2014, 2016 Etersoft
# Copyright (C) 2012, 2014, 2016 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,13 +28,25 @@ __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()
__epm_info_by_pkgtype()
{
[ -n "$pkg_files" ] || return 1
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
case $(get_package_type $pkg_files) in
rpm)
__epm_info_rpm_low && return
;;
deb)
docmd dpkg -I $pkg_files
;;
*)
return 1
;;
esac
}
__epm_info_by_pmtype()
{
case $PMTYPE in
apt-rpm)
__epm_info_rpm_low && return
......@@ -59,6 +71,10 @@ case $PMTYPE in
__epm_info_rpm_low && return
docmd yum info $pkg_names
;;
urpmi-rpm)
__epm_info_rpm_low && return
docmd urpmq -i $pkg_names
;;
dnf-rpm)
__epm_info_rpm_low && return
docmd dnf info $pkg_names
......@@ -93,15 +109,48 @@ case $PMTYPE in
slackpkg)
docmd /usr/sbin/slackpkg info $pkg_names
;;
ipkg)
docmd ipkg info $pkg_names
opkg)
docmd opkg info $pkg_names
;;
pkgng)
docmd pkg info $pkg_names
;;
xbps)
docmd xbps-query --show $pkg_names
;;
homebrew)
docmd brew info $pkg_names
;;
aptcyg)
docmd apt-cyg show $pkg_names
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
# TODO: separate to _files and _names parts
# implement _files part per package, not by PMTYPE (see filelist)
epm_info()
{
# if possible, it will put pkg_urls into pkg_files or pkg_names
if [ -n "$pkg_urls" ] ; then
load_helper epm-download
__handle_pkg_urls_to_checking
fi
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
__epm_info_by_pkgtype || __epm_info_by_pmtype
local RETVAL=$?
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
return $RETVAL
}
......@@ -55,6 +55,7 @@ __emerge_install_ebuild()
# copy tarballs
local DDIR=/usr/portage/distfiles
# FIXME: use independent dir
[ -d /var/calculate/remote/distfiles ] && DDIR=/var/calculate/remote/distfiles
docmd cp -f $TARBALLS $DDIR/ || return
......
#!/bin/sh
#
# Copyright (C) 2013 Etersoft
# Copyright (C) 2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2013, 2016, 2017 Etersoft
# Copyright (C) 2013, 2016, 2017 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,14 +17,26 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
load_helper epm-sh-warmup
epm_kernel_update()
{
info "Starting update system kernel to the latest version"
warmup_bases
info "Updating system kernel to the latest version..."
case $DISTRNAME in
ALTLinux)
assure_exists update-kernel
sudocmd update-kernel
load_helper epm-query_package
if ! __epm_query_package kernel-image >/dev/null ; then
info "No installed kernel packages, skipping update"
return
fi
assure_exists update-kernel update-kernel 0.9.9
update_repo_if_needed
sudocmd update-kernel $pkg_filenames || return
docmd epm remove-old-kernels $pkg_filenames || fatal
return ;;
esac
......
#!/bin/sh
#
# Copyright (C) 2015 Etersoft
# Copyright (C) 2015 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/>.
#
# TODO: is it different from rpm --rebuilddb?
__repack_rpm_base()
{
assure_exists db_dump || fatal
assure_exists db_load || fatal
cd /var/lib/rpm || fatal
mv Packages Packages.BACKUP || fatal
# mask dependencies with a=
a='' db_dump Packages.BACKUP | a='' db_load Packages || fatal
rm Packages.BACKUP
}
epm_optimize()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
*-rpm)
#__repack_rpm_base
#rm -f /var/lib/rpm/__db*
rpm --rebuilddb
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016, 2017 Etersoft
# Copyright (C) 2012, 2016, 2017 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,22 +17,40 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-sh-warmup
__epm_packages_sort()
{
# FIXME: sort depends on --sort value
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
docmd rpm -qa --queryformat "%{size} %{name}-%{version}-%{release}\n" $pkg_filenames | sort -n
# FIXME: space with quotes problems, use point instead
warmup_rpmbase
docmd rpm -qa --queryformat "%{size}@%{name}-%{version}-%{release}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1
;;
apt-dpkg)
docmd dpkg-query -W --showformat="\${Size} \${Package}-\${Version}\n" $pkg_filenames | sort -n
warmup_dpkgbase
docmd dpkg-query -W --showformat="\${Installed-Size}@\${Package}-\${Version}:\${Architecture}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1
;;
*)
fatal "Sorted package list are not realized for $PMTYPE"
fatal "Sorted package list function is not implemented for $PMTYPE"
;;
esac
}
__aptcyg_print_full()
{
#showcmd apt-cyg show
local VERSION=$(apt-cyg show "$1" | grep -m1 "^version: " | sed -e "s|^version: ||g")
echo "$1-$VERSION"
}
__fo_pfn()
{
grep -v "^$" | grep -- "$pkg_filenames"
}
# TODO: we have a problem with error status here
epm_packages()
{
local CMD
......@@ -40,18 +58,32 @@ epm_packages()
case $PMTYPE in
apt-rpm)
warmup_rpmbase
# FIXME: strong equal
CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
;;
docmd $CMD
return ;;
*-dpkg)
warmup_dpkgbase
# FIXME: strong equal
#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"
CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}-\${Version}:\${Architecture}\n $pkg_filenames"
# TODO: ${Architecture}
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}\n $pkg_filenames"
showcmd $CMD
$CMD | grep "^i" | sed -e "s|.* ||g" | __fo_pfn
return ;;
snappy)
CMD="snappy info"
;;
yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
warmup_rpmbase
# FIXME: strong equal
CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
;;
docmd $CMD
return ;;
emerge)
CMD="qlist -I -C"
# print with colors for console output
......@@ -59,11 +91,27 @@ case $PMTYPE in
;;
pkgsrc)
CMD="pkg_info"
;;
showcmd $CMD
$CMD | sed -e "s| .*||g" | __fo_pfn
return ;;
pkgng)
if [ -n "$pkg_filenames" ] ; then
CMD="pkg info -E $pkg_filenames"
else
CMD="pkg info"
fi
showcmd $CMD
if [ -n "$short" ] ; then
$CMD | sed -e "s| .*||g" | sed -e "s|-[0-9].*||g" | __fo_pfn
else
$CMD | sed -e "s| .*||g" | __fo_pfn
fi
return ;;
pacman)
CMD="pacman -Qs $pkg_filenames"
showcmd $CMD
if [ -n "$short" ] ; then
docmd $CMD | sed -e "s| .*||g" -e "s|.*/||g" | grep -v "^$"
$CMD | sed -e "s| .*||g" -e "s|.*/||g" | __fo_pfn
return
fi
;;
......@@ -74,38 +122,67 @@ case $PMTYPE in
conary)
CMD="conary query"
;;
# chocolatey)
# CMD="chocolatey list"
# ;;
chocolatey)
CMD="chocolatey list"
;;
slackpkg)
CMD="ls -1 /var/log/packages/"
if [ -n "$short" ] ; then
# FIXME: does not work for libjpeg-v8a
# TODO: remove last 3 elements (if arch is second from the last?)
# FIXME this hack
docmd ls -1 /var/log/packages/ | sed -e "s|-[0-9].*||g" | sed -e "s|libjpeg-v8a.*|libjpeg|g"
docmd ls -1 /var/log/packages/ | sed -e "s|-[0-9].*||g" | sed -e "s|libjpeg-v8a.*|libjpeg|g" | __fo_pfn
return
fi
;;
homebrew)
CMD="brew list $pkg_filenames"
docmd brew list | xargs -n1 echo
;;
ipkg)
CMD="ipkg list"
opkg)
CMD="opkg list-installed"
;;
apk)
CMD="apk info"
;;
tce)
CMD="ls -1 /usr/local/tce.installed"
;;
guix)
CMD="guix package -I"
;;
xbps)
CMD="xbps-query -l"
showcmd $CMD
if [ -n "$short" ] ; then
$CMD | sed -e "s|^ii ||g" -e "s| .*||g" -e "s|\(.*\)-.*|\1|g" | __fo_pfn
else
$CMD | sed -e "s|^ii ||g" -e "s| .*||g" | __fo_pfn
fi
return 0
;;
android)
CMD="pm list packages"
docmd $CMD | sed -e "s|^package:||g"
showcmd $CMD
$CMD | sed -e "s|^package:||g" | __fo_pfn
return
;;
aptcyg)
CMD="apt-cyg list $pkg_filenames"
if [ -z "$short" ] ; then
showcmd $CMD
# TODO: fix this slow way
for i in $($CMD) ; do
__aptcyg_print_full $i
done
return
fi
;;
*)
fatal "Have no suitable query command for $PMTYPE"
;;
esac
docmd $CMD
docmd $CMD | __fo_pfn
# FIXME: we print empty lines, but will lost error status
}
#!/bin/sh
#
# Copyright (C) 2015, 2017 Etersoft
# Copyright (C) 2015, 2017 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
load_helper epm-sh-warmup
epm_policy()
{
[ -n "$pkg_names" ] || fatal "Info: missing package(s) name"
warmup_bases
# get package name for hi level package management command (with version if supported and if possible)
pkg_names=$(__epm_get_hilevel_name $pkg_names)
case $PMTYPE in
apt-rpm)
docmd apt-cache policy $pkg_names
;;
apt-dpkg)
docmd apt-cache policy $pkg_names
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2015, 2016, 2018 Etersoft
# Copyright (C) 2008, 2015, 2016, 2018 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/>.
#
# Query variables from rpm package
# TODO: rpm only
query_package_field()
{
local FORMAT="%{$1}\n"
shift
local INSTALLED="-p"
# if not file, drop -p for get from rpm base
[ -e "$1" ] || INSTALLED=""
rpmquery $INSTALLED --queryformat "$FORMAT" "$@"
}
# build binary package list (1st - repo dir, 2st - pkgname)
# algorithm: list all files in PKGDIR, print packages with our source pkg name
print_binpkgfilelist()
{
local PKGDIR=$1
local PKGNAME=$(basename $2)
find "$PKGDIR" ! -name '*\.src\.rpm' -name '*\.rpm' -execdir \
rpmquery -p --qf='%{sourcerpm}\t%{name}-%{version}-%{release}.%{arch}.rpm\n' "{}" \; \
| grep "^$PKGNAME[[:space:]].*" \
| cut -f2 \
| xargs -n1 -I "{}" echo -n "$PKGDIR/{} "
}
# TODO: need try detect more strict
# TODO: package name mask for every system
#PKGNAMEMASK1="\(.*\)-\([^0-9].*[^0-9]\)-\(.*[0-9].*\)"
# mask to parse package name
PKGNAMEMASK="\(.*\)-\([0-9].*\)-\(.*[0-9].*\)\.\(.*\)\.\(.*\)"
print_name()
{
echo "$@" | xargs -n1 echo | sed -e "s|$PKGNAMEMASK|\1|g"
}
print_version()
{
echo "$1" | xargs -n1 echo | sed -e "s|$PKGNAMEMASK|\2|g"
}
print_release()
{
echo "$1" | xargs -n1 echo | sed -e "s|$PKGNAMEMASK|\3|g"
}
print_version_release()
{
echo "$1" | xargs -n1 echo | sed -e "s|$PKGNAMEMASK|\2-\3|g"
}
print_pkgname()
{
local i
for i in $@ ; do
# TODO: deb and other, arch string
echo "$(basename "$i") " | sed -e "s|\.[a-z_0-9]*\.rpm||g" -e "s|\(.*\)_\(.*\)_[a-z_0-9]*\.deb|\1-\2|g"
done
}
print_srcname()
{
print_name "$(print_srcpkgname "$@")"
}
print_specname()
{
# CHECKME: it is possible to have two or more specs in one package?
rpm -qlp "$@" | grep "\.spec\$"
}
print_srcpkgname()
{
query_package_field sourcerpm "$@"
}
compare_version()
{
which rpmevrcmp 2>/dev/null >/dev/null || fatal "rpmevrcmp exists in ALT Linux only"
rpmevrcmp "$@"
}
__epm_print()
{
local WHAT="$1"
shift
local FNFLAG=
local PKFLAG=
[ "$1" = "from" ] && shift
[ "$1" = "for" ] && shift
[ "$1" = "in" ] && shift
if [ "$1" = "filename" ] ; then
FNFLAG="$1"
shift
fi
if [ "$1" = "package" ] ; then
PKFLAG="$1"
shift
fi
case "$WHAT" in
"")
fatal "Use epm print help for get help."
;;
"-h"|"--help"|"help")
cat <<EOF
Examples:
epm print name [from filename|for package] NN print only name of package name or package file
epm print version [from filename|for package] NN print only version of package name or package file
epm print release [from filename|for package] NN print only release of package name or package file
epm print version-release [from filename|for package] NN print only release-release of package name or package file
epm print field FF for package NN print field of the package
epm print pkgname from filename NN print package name for the package file
epm print srcname from filename NN print source name for the package file
epm print srcpkgname from [filename|package] NN print source package name for the binary package file
epm print specname from filename NN print spec filename for the source package file
epm print binpkgfilelist in DIR for NN list binary package(s) filename(s) from DIR for the source package file
epm print compare [package] version N1 N2 compare (package) versions and print -1, 0, 1
EOF
;;
"name")
[ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then
print_name "$(print_pkgname "$@")"
elif [ -n "$PKFLAG" ] ; then
query_package_field "name" "$@"
else
print_name "$@"
fi
;;
"version")
[ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then
print_version "$(print_pkgname "$@")"
elif [ -n "$PKFLAG" ] ; then
query_package_field "version" "$@"
else
print_version "$@"
fi
;;
"release")
[ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then
print_release "$(print_pkgname "$@")"
elif [ -n "$PKFLAG" ] ; then
query_package_field "release" "$@"
else
print_release "$@"
fi
;;
"version-release")
[ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then
print_version_release "$(print_pkgname "$@")"
elif [ -n "$PKFLAG" ] ; then
echo "$(query_package_field "version" "$@")-$(query_package_field "release" "$@")"
else
print_version_release "$@"
fi
;;
"field")
[ -n "$1" ] || fatal "Arg is missed"
local FIELD="$1"
shift
[ "$1" = "for" ] && shift
query_package_field "$FIELD" "$@"
;;
"pkgname")
[ -n "$FNFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
# TODO: drop_pkg_extensions
print_pkgname "$@"
;;
"srcname")
[ -n "$FNFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
print_srcname "$@"
;;
"srcpkgname")
[ -n "$FNFLAG" ] || [ -n "$PKFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
print_srcpkgname "$@"
;;
"specname")
[ -n "$FNFLAG" ] || [ -n "$PKFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
print_specname "$@"
;;
"binpkgfilelist")
# TODO: rpm only
# TODO: replace get_binpkg_list
local DIR="$1"
shift
[ "$1" = "for" ] && shift
[ -n "$DIR" ] || fatal "DIR arg is missed"
[ -n "$1" ] || fatal "source package filename is missed"
print_binpkgfilelist "$DIR" "$1"
;;
"compare")
[ "$1" = "version" ] && shift
[ -n "$1" ] || fatal "Arg is missed"
#if [ -n "$PKFLAG" ] ; then
# query_package_field "name" "$@"
#else
compare_version "$1" "$2"
#fi
;;
*)
fatal "Unknown command $ epm print $WHAT. Use epm print help for get help."
;;
esac
}
epm_print()
{
[ -n "$pkg_filenames" ] || fatal "Missed args. Use epm print help for get help."
# Note! do not quote args below (see eterbug #11863)
# shellcheck disable=SC2046
__epm_print $(eval echo $quoted_args)
}
......@@ -22,10 +22,18 @@ load_helper epm-query_file
# Inspired by http://www.altlinux.org/Tips
epm_programs()
{
local DESKTOPDIR=/usr/share/applications
case $DISTRNAME in
FreeBSD|NetBSD|OpenBSD|Solaris)
local DESKTOPDIR=/usr/local/share/applications
;;
*)
local DESKTOPDIR=/usr/share/applications
;;
esac
[ -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 $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
showcmd "find $DESKTOPDIR -type f -print0 -name "*.desktop" | xargs -0 $0 -qf --quiet --short | sort -u"
find $DESKTOPDIR -type f -print0 -name "*.desktop" | \
xargs -0 $0 -qf --quiet --short | sort -u
}
......@@ -18,16 +18,22 @@
#
load_helper epm-query
load_helper epm-print
epm_provides_files()
{
local pkg_files="$*"
[ -n "$pkg_files" ] || return
case $(get_package_type $pkg_files) in
local PKGTYPE="$(get_package_type $pkg_files)"
case $PKGTYPE in
rpm)
assure_exists rpm
docmd rpm -q --provides -p $pkg_files
;;
deb)
assure_exists dpkg
# FIXME: will we provide ourself?
docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g"
;;
......@@ -40,6 +46,7 @@ epm_provides_files()
epm_provides_names()
{
local pkg_names="$*"
local CMD
[ -n "$pkg_names" ] || return
......@@ -56,7 +63,7 @@ case $PMTYPE in
return
fi
;;
urpm-rpm|zypper-rpm|yum-rpm)
urpm-rpm|zypper-rpm|yum-rpm|dnf-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --provides"
else
......@@ -70,6 +77,9 @@ case $PMTYPE in
# yum-rpm)
# CMD="yum deplist"
# ;;
pkgng)
CMD="pkg info -b"
;;
apt-dpkg)
# FIXME: need fix for a few names case
if is_installed $pkg_names ; then
......@@ -95,6 +105,7 @@ epm_provides()
{
[ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name"
epm_provides_files
epm_provides_names
epm_provides_files $pkg_files
# shellcheck disable=SC2046
epm_provides_names $(print_name $pkg_names)
}
#!/bin/sh
#
# Copyright (C) 2012, 2013 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2013, 2015-2017 Etersoft
# Copyright (C) 2012, 2013, 2015-2017 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,6 +18,51 @@
#
load_helper epm-packages
load_helper epm-print
# pkg suffix
__print_with_arch_suffix()
{
local pkg="$1"
local suffix="$2"
[ -n "$pkg" ] || return 1
# do not change if some suffix already exists
echo "$pkg" | grep -q "(x86-32)$" && echo "$pkg" | sed -e "s|(x86-32)$|.i686|" && return 1
echo "$pkg" | grep "\.x86_64$" && return 1
echo "$pkg" | grep "\.noarch$" && return 1
echo "$pkg" | grep "\.i[56]86$" && return 1
echo "$pkg$suffix"
}
# add suffix .x86_64 if we have 64 arch
exp_with_arch_suffix()
{
local suffix
[ "$($DISTRVENDOR -a)" = "x86_64" ] || { cat ; return ; }
# TODO: it is ok for ALT rpm to remove with this suffix
# TODO: separate install and remove?
case $PMTYPE in
yum-rpm|dnf-rpm)
suffix=".x86_64"
;;
*)
cat
return
;;
esac
# TODO: use estrlist or some function to do it
local pkg
for pkg in $(cat) ; do
local p
# check only packages without arch
p="$(__print_with_arch_suffix "$pkg" .i686)" || { echo "$pkg" ; continue ; }
# add arch suffix only if arch package already installed (otherwise we don't know package arch)
is_installed "$p" || { echo "$pkg" ; continue ; }
echo "$pkg.x86_64"
done
}
_get_grep_exp()
......@@ -30,23 +75,55 @@ _get_grep_exp()
}
# TODO: combine with -qa (the difference only in return status now)
_query_via_packages_list()
_shortquery_via_packages_list()
{
local res=0
local res=1
local grepexp
local firstpkg=$1
shift
grepexp=$(_get_grep_exp $firstpkg)
# TODO: we miss status due grep
# Note: double call due stderr redirect
# Note: we use short=1 here due grep by ^name$
# separate first line for print out command
short=1 pkg_filenames=$firstpkg epm_packages | grep -- "$grepexp" || res=1
short=1 pkg_filenames=$firstpkg epm_packages | grep -- "$grepexp" && res=0 || res=1
local pkg
for pkg in "$@" ; do
grepexp=$(_get_grep_exp $pkg)
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -- "$grepexp" || res=1
done
# TODO: print in query (for user): 'warning: package $pkg is not installed'
return $res
}
# Note: modified from _shortquery_via_packages_list
# TODO: non optimal double epm packages call
_query_via_packages_list()
{
local res=1
local grepexp
local firstpkg=$1
shift
grepexp=$(_get_grep_exp $firstpkg)
# TODO: we miss status due grep
# TODO: grep correctly
# Note: double call due stderr redirect
# Note: we use short=1 here due grep by ^name$
# separate first line for print out command
short=1 pkg_filenames=$firstpkg epm_packages | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$firstpkg epm_packages && res=0 || res=1
local pkg
for pkg in "$@" ; do
grepexp=$(_get_grep_exp $pkg)
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$pkg epm_packages || res=1
done
return $res
}
......@@ -66,11 +143,11 @@ __epm_get_hilevel_nameform()
echo $pkg
return
;;
yum-rpm)
yum-rpm|dnf-rpm)
# just use strict version with Epoch and Serial
local pkg
pkg=$(rpm -q --queryformat "%{EPOCH}:%{NAME}%{VERSION}-%{RELEASE}.${ARCH}\n" $1)
echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.${ARCH}\n" $1)
pkg=$(rpm -q --queryformat "%{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" $1)
echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" $1)
echo $pkg
return
;;
......@@ -88,11 +165,12 @@ __epm_get_hilevel_name()
for i in $@ ; do
local pkg
# get short form in pkg
quiet=1 short=1 pkg=$(__epm_query_name $i) || continue # drop not installed packages
# FIXME: where we use it? continue or pkg=$i?
quiet=1 pkg=$(__epm_query_shortname "$i") || pkg="$i" #continue # drop not installed packages
# if already short form, skipped
[ "$pkg" = "$i" ] && echo "$i" && continue
# try get long form or use short form
__epm_get_hilevel_nameform $i || echo $pkg
__epm_get_hilevel_nameform "$i" || echo $pkg
done
}
......@@ -119,6 +197,16 @@ __epm_query_file()
docmd $CMD $@
}
# hack: dpkg -W will print names for removed packages too (until newest Ubuntu)
__epm_query_dpkg_check()
{
local i
for i in $@ ; do
a='' dpkg -s $i >/dev/null 2>/dev/null || return
done
return 0
}
__epm_query_name()
{
local CMD
......@@ -128,26 +216,36 @@ __epm_query_name()
case $PMTYPE in
*-rpm)
CMD="rpm -q"
[ -n "$short" ] && CMD="rpm -q --queryformat %{name}\n"
;;
*-dpkg)
#docmd dpkg -l $@ | grep "^ii"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n"
#CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
docmd dpkg-query -W "--showformat=\${Package}-\${Version}\n" $@ || return
__epm_query_dpkg_check $@ || return
return
;;
npackd)
docmd "npackdcl path --package=$@"
docmd "npackdcl path --package=$1"
return
;;
conary)
CMD="conary query"
;;
homebrew)
warning "fix query"
docmd brew info "$1" >/dev/null 2>/dev/null && echo "$1" && return
return 1
;;
pacman)
docmd pacman -Q $@
return
;;
# TODO: need to print name if exists
#pkgng)
# CMD="pkg info -e"
# ;;
# Note: slackpkg info pkgname
*)
# default slow workaround
_query_via_packages_list $@
return
;;
......@@ -156,10 +254,58 @@ __epm_query_name()
docmd $CMD $@
}
__epm_query_shortname()
{
local CMD
[ -z "$*" ] && return
case $PMTYPE in
*-rpm)
CMD="rpm -q --queryformat %{name}\n"
;;
*-dpkg)
#CMD="dpkg-query -W --showformat=\${Package}\n"
docmd dpkg-query -W "--showformat=\${Package}\n" $@ || return
__epm_query_dpkg_check $@ || return
return
;;
npackd)
docmd "npackdcl path --package=$1"
return
;;
conary)
CMD="conary query"
;;
homebrew)
docmd brew info "$1" >/dev/null 2>/dev/null && echo "$1" && return
return 1
;;
# TODO: check status
#pacman)
# docmd pacman -Q $@ | sed -e "s| .*||g"
# return
# ;;
# TODO: need to print name if exists
#pkgng)
# CMD="pkg info -e"
# ;;
# Note: slackpkg info pkgname
*)
# default slow workaround
_shortquery_via_packages_list $@
return
;;
esac
docmd $CMD $@
}
# check if pkg is installed
is_installed()
{
pkg_filenames="$@" pkg_names="$@" epm_query >/dev/null 2>/dev/null
__epm_query_shortname "$@" >/dev/null 2>/dev/null
# broken way to recursive call here (overhead!)
#epm installed $@ >/dev/null 2>/dev/null
}
......@@ -169,7 +315,7 @@ separate_installed()
{
pkg_installed=
pkg_noninstalled=
for i in $* ; do
for i in "$@" ; do
is_installed $i && pkg_installed="$pkg_installed $i" || pkg_noninstalled="$pkg_noninstalled $i"
done
}
......@@ -180,5 +326,11 @@ epm_query()
__epm_query_file $pkg_files || return
__epm_query_name $pkg_names || return
if [ -n "$short" ] ; then
# shellcheck disable=SC2046
__epm_query_shortname $(print_name $pkg_names) || return
else
# shellcheck disable=SC2046
__epm_query_name $(print_name $pkg_names) || return
fi
}
#!/bin/sh
#
# Copyright (C) 2009, 2012 Etersoft
# Copyright (C) 2009, 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2009, 2012, 2016 Etersoft
# Copyright (C) 2009, 2012, 2016 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,21 +17,31 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-search_file
# copied from etersoft-build-utils/bin/rpmqf
# use and modify TOFILE recursively
# TODO: check for lib64/name situations
__abs_filename()
{
if echo "$1" | grep -q "/" ; then
echo "$1"
return
fi
if [ -e "$1" ] ; then
echo "$(pwd)/$1"
return
fi
echo "$1"
}
__do_query_real_file()
{
local LINKTO1 LINKTO
local TOFILE
# get canonical path
if [ -e "$1" ] ; then
TOFILE=$1
TOFILE="$(__abs_filename "$1")"
else
TOFILE=`which $1 2>/dev/null || echo $1`
TOFILE=$(which "$1" 2>/dev/null || echo "$1")
if [ "$TOFILE" != "$1" ] ; then
info "Note: $1 is placed as $TOFILE"
fi
......@@ -39,10 +49,12 @@ __do_query_real_file()
# get value of symbolic link
if [ -L "$TOFILE" ] ; then
__do_query $TOFILE
LINKTO=`readlink "$TOFILE"`
local LINKTO
__do_query "$TOFILE"
LINKTO=$(readlink -f "$TOFILE")
info "Note: $TOFILE is link to $LINKTO"
__do_query_real_file "$LINKTO"
return
fi
FULLFILEPATH="$TOFILE"
......@@ -51,7 +63,7 @@ __do_query_real_file()
dpkg_print_name_version()
{
local ver i
for i in $* ; do
for i in "$@" ; do
ver=$(dpkg -s $i 2>/dev/null | grep "Version:" | sed -e "s|Version: ||g")
if [ -z "$ver" ] ; then
echo "$i"
......@@ -70,10 +82,10 @@ __do_query()
CMD="rpm -qf"
;;
*-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")
showcmd dpkg -S "$1"
dpkg_print_name_version "$(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")"
return ;;
yum-rpm|urpm-rpm)
yum-rpm|dnf-rpm|urpm-rpm)
CMD="rpm -qf"
;;
zypper-rpm)
......@@ -86,6 +98,9 @@ __do_query()
pacman)
CMD="pacman -Qo"
;;
pkgng)
CMD="pkg which"
;;
conary)
CMD="conary query --path"
;;
......@@ -94,8 +109,17 @@ __do_query()
docmd grep -R -- "$(echo $@ | sed -e 's|^/\+||g')" /var/log/packages | sed -e "s|/var/log/packages/||g"
return
;;
ipkg)
CMD="ipkg files"
opkg)
CMD="opkg search"
;;
xbps)
# FIXME: maybe it is search file?
CMD="xbps-query -o"
;;
aptcyg)
#CMD="apt-cyg packageof"
# is not implemented locally
return 1
;;
*)
fatal "Have no suitable query command for $PMTYPE"
......@@ -114,8 +138,8 @@ __do_short_query()
CMD="rpm -qf --queryformat %{NAME}\n"
;;
NOapt-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")
showcmd dpkg -S "$1"
dpkg_print_name_version "$(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")"
return ;;
NOemerge)
assure_exists equery
......@@ -140,21 +164,25 @@ __do_short_query()
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
[ -n "$pkg_files$pkg_dirs" ] || fatal "Run query without file names (needed path to files)"
__do_short_query $pkg_files $pkg_dirs
return
fi
# file can exists or not
[ -n "$pkg_filenames" ] || fatal "Run query without file names"
#load_helper epm-search_file
for pkg in $pkg_filenames ; do
__do_query_real_file "$pkg"
__do_query $FULLFILEPATH || pkg_filenames=$FULLFILEPATH epm_search_file
__do_query "$FULLFILEPATH" || info "Try epm sf for search file in all packages in repository" #|| pkg_filenames="$FULLFILEPATH" epm_search_file
done
}
......@@ -20,6 +20,11 @@
load_helper epm-packages
load_helper epm-search
__epm_query_package()
{
(pkg_filenames="$*" quoted_args="$*" quiet=1 epm_query_package)
}
epm_query_package()
{
[ -n "$pkg_filenames" ] || fatal "Please, use search with some argument or run epmqa for get all packages."
......@@ -27,5 +32,6 @@ epm_query_package()
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS
eval "pkg_filenames= epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS"
# Note: get all packages list and do grep
(eval "pkg_filenames='' epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS")
}
#!/bin/sh
#
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014,2016,2017 Etersoft
# Copyright (C) 2012,2014,2016,2017 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,21 +18,33 @@
#
load_helper epm-install
load_helper epm-sh-warmup
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_reinstall_names()
{
[ -n "$1" ] || return
case $PMTYPE in
apt-rpm|apt-dpkg)
sudocmd apt-get --reinstall install $@
local APTOPTIONS="$(subst_option non_interactive -y)"
sudocmd apt-get --reinstall $APTOPTIONS install $@
return ;;
aptitude-dpkg)
sudocmd aptitude reinstall $@
return ;;
yum-rpm)
sudocmd yum reinstall $@
return ;;
dnf-rpm)
sudocmd dnf reinstall $@
return ;;
pkgng)
sudocmd pkg install -f $@
return ;;
opkg)
sudocmd opkg --force-reinstall install $@
return ;;
slackpkg)
sudocmd_foreach "/usr/sbin/slackpkg reinstall" $@
return ;;
......@@ -68,6 +80,13 @@ epm_reinstall()
{
[ -n "$pkg_filenames" ] || fatal "Reinstall: missing package(s) name."
warmup_lowbase
# get package name for hi level package management command (with version if supported and if possible)
pkg_names=$(__epm_get_hilevel_name $pkg_names)
warmup_hibase
epm_reinstall_names $pkg_names
epm_reinstall_files $pkg_files
}
......
#!/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/>.
#
epm_release_upgrade()
{
info "Starting upgrade whole system to the next release"
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
case $PMTYPE in
apt-rpm)
docmd epm update
docmd epm install apt rpm
showcmd "TODO: change repo"
docmd epm Upgrade
docmd epm update-kernel
;;
*-dpkg)
sudocmd do-release-upgrade -d
;;
yum-rpm)
docmd epm install rpm yum
sudocmd yum clean all
# TODO
showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
docmd epm Upgrade
;;
urpm-rpm)
sudocmd urpmi.removemedia -av
# TODO
showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
sudocmd urpmi --auto-update --replacefiles
;;
zypper-rpm)
docmd epm repolist
# TODO
# sudocmd zypper rr <номер_репозитория>
showcmd rr N
showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
showcmd zypper ref
docmd epm update
docmd epm install rpm zypper
docmd epm upgrade
;;
pacman)
epm Upgrade
;;
conary)
epm Upgrade
;;
emerge)
epm Upgrade
;;
guix)
sudocmd guix pull --verbose
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
sudocmd $CMD $pkg_filenames
}
#!/bin/sh
#
# Copyright (C) 2013, 2016, 2017 Etersoft
# Copyright (C) 2013, 2016, 2017 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
confirm_info()
{
info "$*"
if [ -z "$non_interactive" ] ; then
confirm "Are you sure? [y/N]" || fatal "Exiting"
fi
}
__replace_text_in_alt_repo()
{
local i
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
[ -s "$i" ] || continue
regexp_subst "$1" "$i"
done
}
__wcount()
{
echo "$*" | wc -w
}
__detect_alt_release_by_repo()
{
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
| grep -v "^#" \
| grep "[tp][5-9]/branch/" \
| sed -e "s|.*\([tp][5-9]\)/branch.*|\1|g" \
| sort -u )
if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD"
return
fi
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
| grep -v "^#" \
| grep "Sisyphus/" \
| sed -e "s|.*\(Sisyphus\).*|\1|g" \
| sort -u )
if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD"
return
fi
return 1
}
__replace_alt_version_in_repo()
{
local i
assure_exists apt-repo
#echo "Upgrading $DISTRNAME from $1 to $2 ..."
docmd apt-repo list | sed -e "s|\($1\)|{\1}->{$2}|g" | grep -E --color -- "$1"
# ask and replace only we will have changes
if a='' apt-repo list | grep -E -q -- "$1" ; then
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
fi
docmd apt-repo list
}
__alt_repofix()
{
load_helper epm-repofix
showcmd epm repofix
quiet=1 pkg_filenames='' epm_repofix >/dev/null
__replace_text_in_alt_repo "/^ *#/! s!\[[tpc][6-9]\]![updates]!g"
}
__get_conflict_release_pkg()
{
epmqf --quiet --short /etc/fedora-release | head -n1
}
get_fix_release_pkg()
{
local TOINSTALL=''
local FORCE=''
if [ "$1" == "--force" ] ; then
FORCE="$1"
shift
fi
local TO="$1"
if [ "$TO" = "Sisyphus" ] ; then
TO="sisyphus"
echo "apt-conf-$TO"
else
echo "apt-conf-branch"
fi
if [ "$FORCE" == "--force" ] ; then
# assure we have set needed release
TOINSTALL="altlinux-release-$TO"
else
# just assure we have /etc/altlinux-release and switched from sisyphus
if [ ! -s /etc/altlinux-release ] || epmqf /etc/altlinux-release | grep -q sisyphus ; then
TOINSTALL="altlinux-release-$TO"
fi
fi
# workaround against obsoleted altlinux-release-sisyphus package from 2008 year
[ "$TOINSTALL" = "altlinux-release-sisyphus" ] && TOINSTALL="branding-alt-sisyphus-release"
if [ -n "$TOINSTALL" ] ; then
echo "$TOINSTALL"
# workaround against
# file /etc/fedora-release from install of altlinux-release-p8-20160414-alt1 conflicts with file from package branding-simply-linux-release-8.2.0-alt1
# problem
if __get_conflict_release_pkg | grep -q -v "^altlinux-release" && [ "$TOINSTALL" != "$(__get_conflict_release_pkg)" ] ; then
echo $(__get_conflict_release_pkg)-
fi
fi
}
__update_to_the_distro()
{
local TO="$1"
__alt_repofix
case "$TO" in
p7)
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;;
p8)
docmd epm update || fatal
docmd epm install rpm apt "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal
# sure we have systemd if systemd is running
if is_installed systemd && is_active_systemd systemd ; then
docmd epm install systemd || fatal
fi
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;;
Sisyphus)
docmd epm update || fatal
local ADDPKG
ADDPKG=$(epm -q --short make-initrd sssd-ad 2>/dev/null)
docmd epm install librpm7 librpm rpm apt $ADDPKG "$(get_fix_release_pkg --force "$TO")" ConsoleKit2- || fatal "Check an error and run again"
#docmd apt-get upgrade || fatal "Check an error and run epm release-upgrade or just epm upgrade again"
docmd epm upgrade || fatal "Check an error and run epm release-upgrade or just epm upgrade again"
;;
*)
esac
}
__update_alt_to_next_distro()
{
local TO="$2"
local FROM="$1"
[ -n "$TO" ] || TO="$FROM"
info
case "$*" in
"p6"|"p6 p7"|"t6 p7"|"c6 c7")
TO="p7"
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "$FROM/branch/" "$TO/branch/"
__update_to_the_distro "$TO"
docmd epm update-kernel
info "Done."
info "Run epm release-upgrade again for update to p8"
;;
"p7"|"p7 p8"|"t7 p8"|"c7 c8"|"p8 p8")
TO="p8"
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo $FROM/branch/ $TO/branch/
__update_to_the_distro $TO
docmd epm update-kernel || fatal
info "Done."
;;
"Sisyphus p8")
TO="p8"
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "$FROM/" "$TO/branch/"
__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__update_to_the_distro $TO
docmd epm downgrade || fatal
info "Done."
;;
"p8 Sisyphus"|"Sisyphus Sisyphus")
TO="Sisyphus"
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt "$(get_fix_release_pkg "$FROM")" || fatal
docmd epm upgrade || fatal
__replace_alt_version_in_repo "$FROM/branch/" "$TO/"
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![alt]!g"
__update_to_the_distro $TO
docmd epm update-kernel || fatal
info "Done."
;;
*)
if [ "$FROM" = "$TO" ] ; then
info "It seems your system is already updated to newest $DISTRNAME $TO"
else
warning "Have no idea how to update from $DISTRNAME $FROM to $DISTRNAME $TO."
fi
info "Try run f.i. # epm release-upgrade p8 or # epm release-upgrade Sisyphus"
info "Also possible you need install altlinux-release-p? package for correct distro version detecting"
return 1
esac
}
epm_release_upgrade()
{
assure_root
info "Starting upgrade whole system to the next release"
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
# TODO: it is possible eatmydata does not do his work
export EPMNOEATMYDATA=1
case $DISTRNAME in
ALTLinux)
docmd epm update || fatal
# try to detect current release by repo
if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then
local dv
dv="$(__detect_alt_release_by_repo)"
if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then
DISTRVERSION="$dv"
info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)"
fi
fi
__alt_repofix
# check forced target
if [ -n "$pkg_filenames" ] ; then
[ "$(__wcount $pkg_filenames)" = "1" ] || fatal "Too many args: $pkg_filenames"
fi
# TODO: ask before upgrade
__update_alt_to_next_distro $DISTRVERSION $pkg_filenames
return
;;
*)
;;
esac
case $PMTYPE in
apt-rpm)
#docmd epm update
info "Have no idea how to upgrade $DISTRNAME"
;;
*-dpkg)
assure_exists do-release-upgrade update-manager-core
sudocmd do-release-upgrade
;;
yum-rpm)
docmd epm install rpm yum
sudocmd yum clean all
# TODO
showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
docmd epm Upgrade
;;
dnf-rpm)
info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info"
docmd epm install dnf
sudocmd dnf --refresh upgrade
sudocmd dnf clean all
assure_exists dnf-plugin-system-upgrade
sudocmd dnf upgrade --refresh
local RELEASEVER="$pkg_filenames"
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
#[ -n "$RELEASEVER" ] || fatal "Run me with new version"
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER
# TODO: from docs:
# dnf system-upgrade reboot
# FIXME: download all packages again
sudocmd dnf distro-sync --releasever=$RELEASEVER
info "Run epm autoorphans to remove orphaned packages"
;;
urpm-rpm)
sudocmd urpmi.removemedia -av
# TODO
showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
sudocmd urpmi --auto-update --replacefiles
;;
zypper-rpm)
docmd epm repolist
# TODO
# sudocmd zypper rr <номер_репозитория>
showcmd rr N
showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
showcmd zypper ref
docmd epm update
docmd epm install rpm zypper
docmd epm upgrade
;;
pacman)
epm Upgrade
;;
conary)
epm Upgrade
;;
emerge)
epm Upgrade
;;
guix)
sudocmd guix pull --verbose
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2012-2014 Etersoft
# Copyright (C) 2012-2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2014, 2016, 2017 Etersoft
# Copyright (C) 2012-2014, 2016, 2017 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,22 +17,32 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-sh-altlinux
load_helper epm-query
load_helper epm-print
load_helper epm-sh-warmup
# Try remove with low level removing
epm_remove_low()
{
[ -z "$1" ] && return
warmup_lowbase
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
sudocmd rpm -ev $nodeps $@
return ;;
apt-dpkg|aptitude-dpkg)
sudocmd dpkg -P $(subst_option nodeps --force-all) $@
# shellcheck disable=SC2046
sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@")
return ;;
pkgsrc)
sudocmd pkg_delete -r $@
return ;;
pkgng)
sudocmd pkg delete -R $@
return ;;
emerge)
sudocmd emerge --unmerge $@
return ;;
......@@ -50,15 +60,17 @@ epm_remove_names()
{
[ -z "$1" ] && return
warmup_bases
case $PMTYPE in
apt-dpkg)
sudocmd apt-get remove --purge $@
sudocmd apt-get remove --purge $APTOPTIONS $@
return ;;
aptitude-dpkg)
sudocmd aptitude purge $@
return ;;
apt-rpm)
sudocmd apt-get remove $@
sudocmd apt-get remove $APTOPTIONS $@
return ;;
deepsolver-rpm)
sudocmd ds-remove $@
......@@ -69,6 +81,9 @@ epm_remove_names()
pkgsrc) # without dependencies
sudocmd pkg_delete $@
return ;;
pkgng)
sudocmd pkg delete -R $@
return ;;
emerge)
#sudocmd emerge --unmerge $@
sudocmd emerge -aC $@
......@@ -82,8 +97,11 @@ epm_remove_names()
dnf-rpm)
sudocmd dnf remove $@
return ;;
snappy)
sudocmd snappy uninstall $@
return ;;
zypper-rpm)
sudocmd zypper remove $@
sudocmd zypper remove --clean-deps $@
return ;;
mpkg)
sudocmd mpkg remove $@
......@@ -92,11 +110,14 @@ epm_remove_names()
sudocmd conary erase $@
return ;;
npackd)
sudocmd npackdcl remove --package=$@
sudocmd npackdcl remove --package=$1
return ;;
nix)
sudocmd nix-env --uninstall $@
return ;;
apk)
sudocmd apk del $@
return ;;
guix)
sudocmd guix package -r $@
return ;;
......@@ -110,10 +131,17 @@ epm_remove_names()
sudocmd /usr/sbin/slackpkg remove $@
return ;;
homebrew)
sudocmd brew remove $@
docmd brew remove $@
return ;;
ipkg)
sudocmd ipkg $(subst_option force -force-depends) remove $@
aptcyg)
sudocmd apt-cyg remove $@
return ;;
xbps)
sudocmd xbps remove -R $@
return ;;
opkg)
# shellcheck disable=SC2046
sudocmd opkg $(subst_option force -force-depends) remove $@
return ;;
*)
fatal "Have no suitable command for $PMTYPE"
......@@ -124,6 +152,8 @@ epm_remove_names()
# TODO
epm_remove_nonint()
{
warmup_bases
case $PMTYPE in
apt-dpkg)
sudocmd apt-get -y --force-yes remove --purge $@
......@@ -143,14 +173,23 @@ epm_remove_nonint()
yum-rpm)
sudocmd yum -y remove $@
return ;;
dnf-rpm)
sudocmd dnf remove --assumeyes $@
return ;;
zypper-rpm)
sudocmd zypper --non-interactive remove $@
sudocmd zypper --non-interactive remove --clean-deps $@
return ;;
slackpkg)
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes remove $@
return ;;
ipkg)
sudocmd ipkg -force-defaults remove $@
pkgng)
sudocmd pkg delete -y -R $@
return ;;
opkg)
sudocmd opkg -force-defaults remove $@
return ;;
xbps)
sudocmd xbps remove -y $@
return ;;
esac
return 5
......@@ -160,25 +199,34 @@ epm_print_remove_command()
{
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@"
echo "rpm -ev $nodeps $*"
;;
apt-dpkg|aptitude-dpkg)
echo "dpkg -P $@"
echo "dpkg -P $*"
;;
pkgsrc)
echo "pkg_delete -r $@"
echo "pkg_delete -r $*"
;;
pkgng)
echo "pkg delete -R $*"
;;
pacman)
echo "pacman -R $@"
echo "pacman -R $*"
;;
emerge)
echo "emerge --unmerge $@"
echo "emerge --unmerge $*"
;;
slackpkg)
echo "/sbin/removepkg $@"
echo "/sbin/removepkg $*"
;;
opkg)
echo "opkg remove $*"
;;
ipkg)
echo "ipkg remove $@"
aptcyg)
echo "apt-cyg remove $*"
;;
xbps)
echo "xbps remove -y $*"
;;
*)
fatal "Have no suitable appropriate remove command for $PMTYPE"
......@@ -194,11 +242,45 @@ epm_remove()
return
fi
local tn=$(tasknumber "$pkg_names")
if [ -n "$tn" ] ; then
assure_distr ALTLinux "remove with task number"
assure_exists apt-repo
pkg_names=$(showcmd apt-repo list $tn)
#docmd epm remove $dryrun
return
fi
# TODO: fix pkg_names override
# get full package name(s) from the package file(s)
[ -n "$pkg_files" ] && pkg_names="$pkg_names $(epm query $pkg_files)"
pkg_files=''
[ -n "$pkg_names" ] || fatal "Remove: missing package(s) name."
# remove according current arch (if x86_64) by default
pkg_names="$(echo $pkg_names | exp_with_arch_suffix)"
if [ -n "$dryrun" ] ; then
info "Packages for removing:"
echo "$pkg_names"
case $PMTYPE in
apt-rpm)
nodeps="--test"
APTOPTIONS="--simulate"
;;
*)
return
;;
esac
fi
epm_remove_low $pkg_names && return
local STATUS=$?
# TODO: check if we need continue with hi level
if [ -n "$direct" ] ; then
return $STATUS
fi
# get package name for hi level package management command (with version if supported and if possible)
pkg_names=$(__epm_get_hilevel_name $pkg_names)
......
#!/bin/sh
#
# Copyright (C) 2016-2017 Etersoft
# Copyright (C) 2016-2017 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-sh-warmup
epm_remove_old_kernels()
{
warmup_bases
case $DISTRNAME in
ALTLinux)
load_helper epm-query_package
if ! __epm_query_package kernel-image >/dev/null ; then
info "No installed kernel packages, skipping cleaning"
return
fi
assure_exists update-kernel update-kernel 0.9.9
sudocmd remove-old-kernels $pkg_filenames
return ;;
Ubuntu)
load_helper epm-query_package
if ! __epm_query_package linux-image >/dev/null ; then
info "No installed kernel packages, skipping cleaning"
return
fi
info "Note: it is enough to use eepm autoremove for old kernel removing..."
info "Check also http://ubuntuhandbook.org/index.php/2016/05/remove-old-kernels-ubuntu-16-04/"
# http://www.opennet.ru/tips/2980_ubuntu_apt_clean_kernel_packet.shtml
case $DISTRVERSION in
10.04|12.04|14.04|15.04|15.10)
assure_exists purge-old-kernels bikeshed
;;
*)
# since Ubuntu 16.04
assure_exists purge-old-kernels byobu
;;
esac
sudocmd purge-old-kernels $pkg_filenames
return ;;
Gentoo)
sudocmd emerge -P gentoo-sources
return ;;
VoidLinux)
sudocmd vkpurge rm all
return ;;
esac
case $PMTYPE in
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2017 Etersoft
# Copyright (C) 2012, 2017 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,33 +17,78 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-sh-altlinux
epm_removerepo()
{
case $PMTYPE in
apt-rpm)
local repo="$(eval echo $quoted_args)"
case $DISTRNAME in
ALTLinux)
case "$repo" in
autoimports)
info "remove autoimports repo"
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
;;
archive)
info "remove archive repos"
assure_exists apt-repo
epm repolist | grep "archive/" | while read repo ; do
sudocmd apt-repo rm "$repo"
done
return 0
;;
tasks)
info "remove task repos"
assure_exists apt-repo
epm repolist | grep "/repo/" | while read repo ; do
sudocmd apt-repo rm "$repo"
done
return 0
;;
*)
if tasknumber "$repo" >/dev/null ; then
repo="$(epm repolist | grep "repo/$(tasknumber "$repo")" | line)"
# "
fi
;;
esac
[ -n "$repo" ] || fatal "No such repo or task. Use epm remove repo [autoimports|archive|TASK]"
assure_exists apt-repo
sudocmd apt-repo rm $pkg_filenames
sudocmd apt-repo rm "$repo"
return
;;
esac;
case $PMTYPE in
apt-dpkg)
assure_exists apt-add-repository software-properties-common
sudocmd apt-add-repository --remove "$repo"
info "Check file /etc/apt/sources.list if needed"
;;
apt-dpkg|aptitude-dpkg)
aptitude-dpkg)
info "You need remove repo from /etc/apt/sources.list"
;;
yum-rpm)
info "You need remove repo from /etc/yum.repos.d/"
assure_exists yum-utils
sudocmd yum-config-manager --disable "$repo"
;;
urpm-rpm)
sudocmd urpmi.removemedia $pkg_filenames
sudocmd urpmi.removemedia "$repo"
;;
zypper-rpm)
sudocmd zypper removerepo $pkg_filenames
sudocmd zypper removerepo "$repo"
;;
emerge)
sudocmd layman -d$pkg_filenames
sudocmd layman "-d$repo"
;;
pacman)
info "You need remove repo from /etc/pacman.conf"
;;
npackd)
sudocmd npackdcl remove-repo --url=$pkg_filenames
sudocmd npackdcl remove-repo --url="$repo"
;;
slackpkg)
info "You need remove repo from /etc/slackpkg/mirrors"
......
#!/bin/sh
#
# Copyright (C) 2017-2018 Etersoft
# Copyright (C) 2017-2018 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-sh-altlinux
load_helper epm-assure
# arg: rpm or deb
# fills split_replaced_pkgs with packages of that type
__epm_split_by_pkg_type()
{
local type="$1"
shift
split_replaced_pkgs=''
for pkg in "$@" ; do
[ "$(get_package_type "$pkg")" = "$type" ] || return 1
[ -e "$pkg" ] || fatal "Can't read $pkg"
split_replaced_pkgs="$split_target_pkgs $(realpath "$pkg")"
done
[ -n "$split_replaced_pkgs" ]
}
# fills repacked_rpms
__epm_repack_deb_to_rpm()
{
local pkg
assure_exists alien
assure_exists dpkg
# TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен
# assure_exists debconf
repacked_rpms=''
local TDIR=$(mktemp -d)
cd $TDIR || fatal
for pkg in "$@" ; do
# TODO: fakeroot for non ALT?
showcmd_store_output alien -r -k $scripts "$pkg" || fatal
local RPMCONVERTED=$(grep "rpm generated" $RC_STDOUT | sed -e "s| generated||g")
repacked_rpms="$repacked_rpms $(realpath $RPMCONVERTED)"
to_remove_pkg_files="$to_remove_pkg_files $(realpath $RPMCONVERTED)"
clean_store_output
done
cd - >/dev/null
return 0
}
__epm_check_if_try_install_deb()
{
__epm_split_by_pkg_type deb "$@" || return 1
__epm_repack_deb_to_rpm "$@"
# TODO: move to install
docmd epm install $force $nodeps $repacked_rpms
return 0
}
# fills repacked_debs
__epm_repack_rpm_to_deb()
{
local pkg
assure_exists alien
assure_exists fakeroot
assure_exists rpm
repacked_debs=''
local TDIR=$(mktemp -d)
cd $TDIR || fatal
for pkg in $rpmpkgs ; do
showcmd_store_output fakeroot alien -d -k $scripts "$pkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
repacked_debs="$repacked_rpms $(realpath $DEBCONVERTED)"
to_remove_pkg_files="$to_remove_pkg_files $(realpath $DEBCONVERTED)"
clean_store_output
done
cd - >/dev/null
return 0
}
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_rpm()
{
__epm_split_by_pkg_type rpm "$@" || return 1
__epm_repack_rpm_to_deb "$@"
# TODO: move to install
docmd epm install $force $nodeps $repacked_debs
return 0
}
# args: buildroot spec
__fix_spec()
{
local buildroot="$1"
local spec="$2"
local i
for i in $(grep '^"/' $spec | sed -e 's|^"\(.*\)"$|\1|') ; do
#' hack for highlight
# add %dir to dir in list
if [ -d "$buildroot$i" ] ; then
subst 's|^\("'$i'"\)$|%dir \1|' $spec
fi
done
subst "s|^Release: |Release: alt1.repacked.with.epm.|" $spec
subst "s|^\((Converted from a rpm package.*\)|(Repacked from binary rpm with epm $EPMVERSION)\n\1|" $spec
#" hack for highlight
}
__apply_fix_code()
{
local repackcode="$CONFIGDIR/repack.d/$1.sh"
[ -x "$repackcode" ] || return
shift
docmd $repackcode "$1" "$2" || warning "There was errors with $repackcode script"
}
__create_rpmmacros()
{
cat <<EOF >$HOME/.rpmmacros
%_topdir $HOME/RPM
%_tmppath $TMPDIR
%packager EPM <support@etersoft.ru>
%_gpg_name support@etersoft.ru
EOF
}
# will fill repacked_rpms var
__epm_repack_rpm()
{
assure_distr ALTLinux "install --repack"
assure_exists fakeroot || fatal
assure_exists alien || fatal
assure_exists rpmbuild rpm-build || fatal
local pkg
export HOME=$(mktemp -d)
local tmpbuilddir=$HOME/repack
mkdir $tmpbuilddir
__create_rpmmacros
local abspkg
repacked_rpms=''
for pkg in $* ; do
abspkg=$(realpath $pkg)
info "Repacking $abspkg to local rpm format ..."
cd $tmpbuilddir || fatal
docmd fakeroot alien --generate --to-rpm $verbose $scripts $abspkg || fatal
local subdir="$(echo *)"
[ -d "$subdir" ] || fatal "can't find subdir"
# detect spec and move to prev dir
local spec="$(echo $tmpbuilddir/$subdir/*.spec)"
[ -s "$spec" ] || fatal "can't find spec"
mv $spec $tmpbuilddir || fatal
spec="$tmpbuilddir/$(basename "$spec")"
__fix_spec $tmpbuilddir/$subdir $spec
local pkgname="$(grep "^Name: " $spec | sed -e "s|Name: ||g" | head -n1)"
__apply_fix_code $pkgname $tmpbuilddir/$subdir $spec
showcmd fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec
if [ -n "$verbose" ] ; then
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec || fatal
else
a='' fakeroot rpmbuild --buildroot $tmpbuilddir/$subdir --define='_allow_root_build 1' -bb $spec >/dev/null || fatal
fi
local repacked_rpm="$(realpath $tmpbuilddir/../*.rpm)"
if [ -s "$repacked_rpm" ] ; then
repacked_rpms="$repacked_rpms $repacked_rpm"
to_remove_pkg_files="$to_remove_pkg_files $repacked_rpm"
else
warning "Can't find converted rpm for source binary $pkg package"
fi
cd - >/dev/null
rm -rf $tmpbuilddir/$subdir/
#rm -rf $tmpbuilddir/../*.rpm
rm -rf $spec
done
rmdir $tmpbuilddir
#rmdir $tmpbuilddir/..
true
}
epm_repack()
{
# if possible, it will put pkg_urls into pkg_files and reconstruct pkg_filenames
if [ -n "$pkg_urls" ] ; then
load_helper epm-download
__handle_pkg_urls_to_install
fi
[ -z "$pkg_files" ] && info "Skip empty repack list" && return 22
# TODO: если у нас rpm, а пакет - deb и наоборот
case $PKGFORMAT in
rpm)
if __epm_split_by_pkg_type deb $pkg_files ; then
__epm_repack_deb_to_rpm $split_replaced_pkgs
cp -v $repacked_rpms .
pkg_files="$(estrlist exclude $split_replaced_pkgs $pkg_files)"
fi
if [ -n "$pkg_files" ] ; then
__epm_repack_rpm $pkg_files || fatal
cp -v $repacked_rpms .
fi
;;
deb)
if __epm_split_by_pkg_type rpm $pkg_files ; then
__epm_repack_rpm_to_deb $split_replaced_pkgs
cp -v $repacked_debs .
pkg_files="$(estrlist exclude $split_replaced_pkgs $pkg_files)"
fi
;;
*)
fatal "$PKGFORMAT is not supported for repack yet"
;;
esac
# TODO: move it to exit handler
if [ -z "$DEBUG" ] ; then
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
fi
}
#!/bin/sh
#
# Copyright (C) 2015-2016 Etersoft
# Copyright (C) 2015-2016 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
__repofix_check_vendor()
{
local i
for i in /etc/apt/vendors.list.d/*.list; do
[ -e "$i" ] || continue
grep -q "^simple-key \"$1\"" $i && return
done
return 1
}
# source-list vendor path
# example: /etc/apt/source.list p7 ALTLinux\/Sisyphus
__try_fix_apt_source_list()
{
local list="$1"
local br="$2"
local path="$3"
if grep -q -e "^[^#].*$path" $list ; then
if __repofix_check_vendor $br ; then
regexp_subst "/$path/s/^rpm[[:space:]]*([fhr])/rpm [$br] \1/" $list
else
warning "Skip set $br vendor key (it misssed) for $list"
regexp_subst "/$path/s/^rpm[[:space:]]*\[$br\][[:space:]]*([fhr])/rpm \1/" $list
fi
fi
}
__fix_apt_sources_list()
{
# for beauty spaces
local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus|p8[/ ]branch|p7[/ ]branch|t7[/ ]branch|c7[/ ]branch|p6[/ ]branch|t6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local i
assure_root
for i in "$@" ; do
[ -s "$i" ] || continue
#perl -i.bak -pe "$SUBST_ALT_RULE" $i
# TODO: only for uncommented strings
#sed -i -r -e "$SUBST_ALT_RULE" $i
regexp_subst "/^ *#/! $SUBST_ALT_RULE" $i
# Sisyphus uses 'alt' vendor key
__try_fix_apt_source_list $i alt "ALTLinux\/Sisyphus"
__try_fix_apt_source_list $i etersoft "Etersoft\/Sisyphus"
# skip branch replacement for ALT Linux Sisyphus
[ "$DISTRVERSION" = "Sisyphus" ] && continue
# add signs for branches
__try_fix_apt_source_list $i $DISTRVERSION "ALTLinux\/$DISTRVERSION\/branch"
__try_fix_apt_source_list $i etersoft "Etersoft\/$DISTRVERSION\/branch"
done
}
epm_repofix()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
[ -n "$quiet" ] || docmd apt-repo list
__fix_apt_sources_list /etc/apt/sources.list
__fix_apt_sources_list /etc/apt/sources.list.d/*.list
docmd apt-repo list
# FIXME: what the best place?
# rebuild rpm database
#sudocmd rm -fv /var/lib/rpm/__db*
#sudocmd rpm --rebuilddb
;;
yum-rpm|dnf-rpm)
# FIXME: what the best place?
#sudocmd rm -fv /var/lib/rpm/__db*
#sudocmd rpm --rebuilddb
;;
xbps)
sudocmd xbps-pkgdb -a
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012, 2016 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
......@@ -39,11 +39,11 @@ case $PMTYPE in
docmd ds-conf
;;
apt-dpkg|aptitude-dpkg)
showcmd cat /etc/apt/sources.list*
showcmd cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list
print_apt_sources_list /etc/apt/sources.list /etc/apt/sources.list.d/*.list
;;
yum-rpm)
docmd yum repolist
docmd yum repolist -v
;;
dnf-rpm)
docmd dnf repolist -v
......@@ -58,6 +58,9 @@ case $PMTYPE in
docmd eselect profile list
docmd layman -L
;;
xbps)
docmd xbps-query -L
;;
pacman)
docmd grep -v -- "^#\|^$" /etc/pacman.conf
;;
......
#!/bin/sh
#
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2013, 2016, 2018 Etersoft
# Copyright (C) 2012-2013, 2016, 2018 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,19 +18,23 @@
#
load_helper epm-query
load_helper epm-print
epm_requires_files()
{
local pkg_files="$*"
[ -n "$pkg_files" ] || return
local PKGTYPE="$(case $(get_package_type $pkg_files))"
local PKGTYPE="$(get_package_type $pkg_files)"
case "$PKGTYPE" in
rpm)
assure_exists rpm
docmd rpm -q --requires -p $pkg_files
;;
deb)
a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
assure_exists dpkg
a='' docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
;;
*)
fatal "Have no suitable command for $PKGTYPE"
......@@ -40,6 +44,7 @@ epm_requires_files()
epm_requires_names()
{
local pkg_names="$*"
local CMD
[ -n "$pkg_names" ] || return
......@@ -58,12 +63,26 @@ case $PMTYPE in
fi
;;
urpm-rpm|zypper-rpm)
# FIXME: use hi level commands
CMD="rpm -q --requires"
#zypper-rpm)
# # FIXME: use hi level commands
# CMD="rpm -q --requires"
# ;;
urpm-rpm)
CMD="urpmq --requires"
;;
yum-rpm)
CMD="yum deplist"
if is_installed $pkg_names ; then
CMD="rpm -q --requires"
else
CMD="yum deplist"
fi
;;
dnf-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --requires"
else
CMD="dnf repoquery --requires"
fi
;;
pacman)
CMD="pactree"
......@@ -72,7 +91,7 @@ case $PMTYPE in
# 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"
a='' dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
return
else
CMD="apt-cache depends"
......@@ -82,6 +101,22 @@ case $PMTYPE in
assure_exists equery
CMD="equery depgraph"
;;
pkgng)
#CMD="pkg rquery '%dn-%dv'"
CMD="pkg info -d"
;;
opkg)
CMD="opkg depends"
;;
xbps)
CMD="xbps-query -x"
;;
aptcyg)
#CMD="apt-cyg depends"
# print show version
docmd apt-cyg show $pkg_names | grep "^requires: " | sed "s|^requires: ||g"
return
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......@@ -95,6 +130,7 @@ docmd $CMD $pkg_names
epm_requires()
{
[ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name"
epm_requires_files
epm_requires_names
epm_requires_files $pkg_files
# shellcheck disable=SC2046
epm_requires_names $(print_name $pkg_names)
}
#!/bin/sh
#
# Copyright (C) 2012,2013 Etersoft
# Copyright (C) 2012,2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2013, 2016-2018 Etersoft
# Copyright (C) 2012, 2013, 2016-2018 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,6 +18,7 @@
#
load_helper epm-check_updated_repo
load_helper epm-sh-warmup
__epm_search_output()
{
......@@ -40,6 +41,9 @@ case $PMTYPE in
pkgsrc)
CMD="pkg_info -x --"
;;
pkgng)
CMD="pkg search -i --"
;;
emerge)
CMD="emerge --search --"
;;
......@@ -61,6 +65,12 @@ case $PMTYPE in
mpkg)
CMD="mpkg search"
;;
apk)
CMD="apk search"
;;
tce)
CMD="tce-ab"
;;
conary)
CMD="conary repquery"
;;
......@@ -74,7 +84,15 @@ case $PMTYPE in
slackpkg)
# FIXME
echo "Note: case sensitive search"
CMD="/usr/sbin/slackpkg search"
if [ -n "$verbose" ] ; then
CMD="/usr/sbin/slackpkg search"
else
LANG=C docmd /usr/sbin/slackpkg search $string | grep " - " | sed -e 's|.* - ||g'
return
fi
;;
opkg)
CMD="opkg find"
;;
homebrew)
CMD="brew search"
......@@ -85,12 +103,18 @@ case $PMTYPE in
android)
CMD="pm list packages"
;;
aptcyg)
CMD="apt-cyg searchall"
;;
xbps)
CMD="xbps-query -s"
;;
*)
fatal "Have no suitable search command for $PMTYPE"
;;
esac
docmd $CMD $string
LANG=C docmd $CMD $string
}
# produce grep sequence
......@@ -103,8 +127,8 @@ __epm_search_make_grep()
local listN=
for i in $@ ; do
case "$i" in
^*)
# will clean from ^ later (and have the bug here with empty arg if run with one ^ only)
~*)
# will clean from ~ later (and have the bug here with empty arg if run with one ~ only)
listN="$listN $i"
;;
*)
......@@ -114,24 +138,30 @@ __epm_search_make_grep()
done
#list=$(strip_spaces $list | sed -e "s/ /|/g")
listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g")
listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/~//g")
if [ -n "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
[ -n "$listN" ] && echon " | egrep -i -v -- \"$listN\""
# FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for i in $list ; do
# FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
# Need only if we have more than one word (with one word we will grep for colorify)
if [ "$(echo "$list" | wc -w)" -gt 1 ] ; then
for i in $list ; do
# FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done
fi
# FIXME: move from it
#isatty || return
# TODO: sorts word by length from large to short
local COLO=""
# rule for colorife
for i in $list $listN; do
......@@ -139,11 +169,24 @@ __epm_search_make_grep()
COLO="$COLO$i"
done
# TODO: use some colorifer instead grep (check grep adove too)
if [ -n "$list" ] ; then
echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi
}
__epm_search_internal()
{
[ -n "$pkg_filenames" ] || fatal "Search: missing search argument(s)"
# it is useful for first time running
update_repo_if_needed soft
warmup_bases
__epm_search_output $(get_firstarg $pkg_filenames) | grep "$pkg_filenames"
}
# copied from korinf/tools/run-script/scripts/search
epm_search()
......@@ -151,7 +194,9 @@ epm_search()
[ -n "$pkg_filenames" ] || fatal "Search: missing search argument(s)"
# it is useful for first time running
update_repo_if_needed
update_repo_if_needed soft
warmup_bases
# FIXME: do it better
local MGS
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016, 2017 Etersoft
# Copyright (C) 2012, 2016, 2017 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,29 +17,34 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# TODO: port or rewrite apt-file
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
local_content_search()
# TODO: see epm-search (colorify for all distro)
# args: index_lists word grep_string
__alt_search_file_output()
{
# grep only on left part (filename), then revert order and grep with color
__local_ercat $1 | grep -h -- ".*$2.*[[:space:]]" | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g" $3
}
__alt_local_content_search()
{
# TODO: use global get_sysarch function
local SYSARCH
SYSARCH=$(uname -m)
[ "$SYSARCH" = "x86_64" ] || SYSARCH=i586
load_helper epm-sh-altlinux
load_helper epm-search
# 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
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD="cat"
info "Locate contents index file(s) ..."
local CI="$(get_local_alt_contents_index)"
# TODO use something like
[ -n "$CI" ] || fatal "Have no local contents index"
test -r $CI && test -r $CINOA || fatal "Can't locate $CI or $CINOA"
info "Searching in"
echo "$CI"
echo "for $1... "
{
[ -n "$USETTY" ] && echo "Search in $CI and $CINOA for $1..."
grep -h -- ".*$1.*\t" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
} | $OUTCMD
# FIXME: do it better
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
showcmd "$ cat contents_index $MGS"
eval "__alt_search_file_output \"$CI\" \"$(eval get_firstarg $quoted_args)\" $MGS"
}
epm_search_file()
......@@ -49,7 +54,7 @@ epm_search_file()
case $PMTYPE in
apt-rpm)
local_content_search $pkg_filenames
__alt_local_content_search $pkg_filenames
return ;;
apt-dpkg|aptitude-dpkg)
assure_exists apt-file
......@@ -57,9 +62,13 @@ case $PMTYPE in
docmd apt-file search $pkg_filenames
return ;;
yum-rpm)
# TODO
info "Search by full packages list is not implemented yet"
CMD="yum provides"
;;
dnf-rpm)
# TODO
info "Search by full packages list is not implemented yet"
CMD="dnf provides"
;;
urpm-rpm)
......@@ -74,8 +83,15 @@ case $PMTYPE in
slackpkg)
CMD="/usr/sbin/slackpkg file-search"
;;
ipkg)
CMD="ipkg search"
opkg)
CMD="opkg -A search"
;;
xbps)
CMD="xbps-query -Ro"
;;
aptcyg)
docmd apt-cyg searchall "$(echo " $pkg_filenames" | sed -e "s| /| |g")"
return
;;
*)
fatal "Have no suitable search file command for $PMTYPE"
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
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