Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
eepm
Commits
efc1a899
Commit
efc1a899
authored
Oct 22, 2013
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Plain Diff
backported to p7 as 1.4.4-alt0.M70P.1 (with rpmbph script)
parents
9bc1e7ad
f136d576
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
1126 additions
and
267 deletions
+1126
-267
TODO
TODO
+2
-0
distr_info
bin/distr_info
+10
-0
epm
bin/epm
+55
-36
epm-addrepo
bin/epm-addrepo
+1
-0
epm-autoremove
bin/epm-autoremove
+5
-1
epm-changelog
bin/epm-changelog
+22
-11
epm-checkpkg
bin/epm-checkpkg
+9
-4
epm-conflicts
bin/epm-conflicts
+99
-0
epm-filelist
bin/epm-filelist
+51
-6
epm-info
bin/epm-info
+12
-0
epm-install
bin/epm-install
+4
-0
epm-kernel_update
bin/epm-kernel_update
+1
-0
epm-packages
bin/epm-packages
+7
-3
epm-provides
bin/epm-provides
+44
-23
epm-query
bin/epm-query
+21
-7
epm-query_file
bin/epm-query_file
+2
-0
epm-query_package
bin/epm-query_package
+1
-1
epm-release-upgrade
bin/epm-release-upgrade
+6
-0
epm-remove
bin/epm-remove
+11
-2
epm-removerepo
bin/epm-removerepo
+1
-0
epm-repolist
bin/epm-repolist
+2
-0
epm-requires
bin/epm-requires
+56
-28
epm-search
bin/epm-search
+26
-4
epm-search_file
bin/epm-search_file
+1
-0
epm-sh-functions
bin/epm-sh-functions
+72
-8
epm-upgrade
bin/epm-upgrade
+6
-1
epm-whatdepends
bin/epm-whatdepends
+3
-2
epm-whatprovides
bin/epm-whatprovides
+2
-2
epmsf
bin/epmsf
+2
-0
eepm.spec
eepm.spec
+32
-5
epm.sh
packed/epm.sh
+481
-115
serv.sh
packed/serv.sh
+79
-8
No files found.
TODO
View file @
efc1a899
Чтобы было легко выстраивать цепочки, нужно ввод не с консоли (если есть) воспринимать как параметры.
2. Дописать таблицу на вики на основании реализованных команд.
3. Доделать и проверить deplist|requires
https://wiki.archlinux.org/index.php/Pacman_Rosetta
...
...
bin/distr_info
View file @
efc1a899
...
...
@@ -237,6 +237,16 @@ elif [ `uname` = "SunOS" ] ; then
DISTRIB_ID
=
"SunOS"
DISTRIB_RELEASE
=
$(
uname
-r
)
# fixme: can we detect by some file?
elif
[
`
uname
`
=
"Darwin"
]
;
then
DISTRIB_ID
=
"MacOS"
DISTRIB_RELEASE
=
$(
uname
-r
)
# fixme: move to up
elif
[
`
uname
`
=
"Linux"
]
&&
which guix 2>/dev/null
>
/dev/null
;
then
DISTRIB_ID
=
"GNU/Linux/Guix"
DISTRIB_RELEASE
=
$(
uname
-r
)
# try use standart LSB info by default
elif
distro lsb-release
&&
[
-n
"
$DISTRIB_RELEASE
"
]
;
then
# use LSB
...
...
bin/epm
View file @
efc1a899
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2013
Etersoft
# Copyright (C) 2012
, 2013
Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -37,6 +37,7 @@ load_helper epm-sh-functions
#PATH=$PATH:/sbin:/usr/sbin
set_sudo
set_eatmydata
check_tty
...
...
@@ -97,6 +98,9 @@ case $progname in
epms
)
epm_cmd
=
search
;;
epmsf
)
epm_cmd
=
search_file
;;
epmq
)
epm_cmd
=
query
;;
...
...
@@ -133,80 +137,83 @@ check_command()
# Base commands
case
$1
in
-i
|
install
|
add
)
# HELPCMD: install package(s) from remote repositories or from local file
-i
|
install
|
add
|i
)
# HELPCMD: install package(s) from remote repositories or from local file
epm_cmd
=
install
;;
-e
|
-P
|
remove|delete|uninstall|erase
)
# HELPCMD: remove (delete) package(s) from the database and the system
-e
|
-P
|
remove|delete|uninstall|erase
|e
)
# HELPCMD: remove (delete) package(s) from the database and the system
epm_cmd
=
remove
;;
-s
|
search
)
# HELPCMD: search in remote package repositories
-s
|
search
)
# HELPCMD: search in remote package repositories
epm_cmd
=
search
;;
-qp
|
q
uery_package
)
# HELPCMD: search in the list of installed packages
-qp
|
q
p|query_package
)
# HELPCMD: search in the list of installed packages
epm_cmd
=
query_package
;;
-qf
|
which|belongs
)
# HELPCMD: query package(s) owning file
-qf
|
qf|which|belongs
)
# HELPCMD: query package(s) owning file
epm_cmd
=
query_file
;;
# Useful commands
reinstall
)
# HELPCMD: reinstall package(s) from remote repositories or from local file
reinstall
)
# HELPCMD: reinstall package(s) from remote repositories or from local file
epm_cmd
=
reinstall
;;
Install
)
# HELPCMD: perform update package repo info and install package(s) via install command
Install
)
# HELPCMD: perform update package repo info and install package(s) via install command
epm_cmd
=
Install
;;
-q
|
installed|query
)
# HELPCMD: check presence of package(s) and print this name (also --short is supported)
-q
|
q|installed|query
)
# HELPCMD: check presence of package(s) and print this name (also --short is supported)
epm_cmd
=
query
;;
-sf
|
sf|filesearch
)
# HELPCMD: search in which package a file is included
-sf
|
sf|filesearch
)
# HELPCMD: search in which package a file is included
epm_cmd
=
search_file
;;
-ql
|
filelist
)
# HELPCMD: print package file list
-ql
|
ql|filelist
)
# HELPCMD: print package file list
epm_cmd
=
filelist
;;
check|fix|verify
)
# HELPCMD: check local package base integrity and fix it
check|fix|verify
)
# HELPCMD: check local package base integrity and fix it
epm_cmd
=
check
;;
changelog|cl
)
# HELPCMD: show changelog for package
changelog|cl
|-cl
)
# HELPCMD: show changelog for package
epm_cmd
=
changelog
;;
-qi
|
info|show
)
# HELPCMD: print package detail info
-qi
|
qi|info|show
)
# HELPCMD: print package detail info
epm_cmd
=
info
;;
requires|deplist
)
# HELPCMD: print package requires
requires|deplist
)
# HELPCMD: print package requires
epm_cmd
=
requires
;;
provides
)
# HELPCMD: print package provides
provides
)
# HELPCMD: print package provides
epm_cmd
=
provides
;;
whatdepends
)
# HELPCMD: print packages dependences on that
whatdepends
)
# HELPCMD: print packages dependences on that
epm_cmd
=
whatdepends
;;
whatprovides
)
# HELPCMD: print packages provides that target
whatprovides
)
# HELPCMD: print packages provides that target
epm_cmd
=
whatprovides
;;
-qa
|
list|packages|-l
)
# HELPCMD: list of installed package(s)
conflicts
)
# HELPCMD: print package conflicts
epm_cmd
=
conflicts
;;
-qa
|
list|packages|-l|qa
)
# HELPCMD: list of installed package(s)
epm_cmd
=
packages
;;
programs
)
# HELPCMD: list of installed GUI program(s)
programs
)
# HELPCMD: list of installed GUI program(s)
epm_cmd
=
programs
;;
# Repository control
update
)
# HELPCMD: update remote package repository databases
update
)
# HELPCMD: update remote package repository databases
epm_cmd
=
update
;;
addrepo|ar
)
# HELPCMD: add package repo
addrepo|ar
)
# HELPCMD: add package repo
epm_cmd
=
addrepo
;;
repolist|sl|rl|listrepo
)
# HELPCMD: print repo list
repolist|sl|rl|listrepo
)
# HELPCMD: print repo list
epm_cmd
=
repolist
;;
removerepo|rr
)
# HELPCMD: remove package repo
removerepo|rr
)
# HELPCMD: remove package repo
epm_cmd
=
removerepo
;;
release-upgrade
)
# HELPCMD: update whole system to the next release
release-upgrade
)
# HELPCMD: update whole system to the next release
epm_cmd
=
release_upgrade
;;
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel
)
# HELPCMD: update system kernel to the last repo version
...
...
@@ -214,22 +221,22 @@ check_command()
;;
# Other commands
clean
)
# HELPCMD: clean local package cache
clean
)
# HELPCMD: clean local package cache
epm_cmd
=
clean
;;
autoremove
)
# HELPCMD: auto remove unneeded package(s)
autoremove
)
# HELPCMD: auto remove unneeded package(s)
epm_cmd
=
autoremove
;;
upgrade|dist-upgrade
)
# HELPCMD: performs upgrades of package software distributions
upgrade|dist-upgrade
)
# HELPCMD: performs upgrades of package software distributions
epm_cmd
=
upgrade
;;
Upgrade
)
# HELPCMD: performs update && upgrade command
Upgrade
)
# HELPCMD: performs update && upgrade command
epm_cmd
=
Upgrade
;;
simulate
)
# HELPCMD: simulate install (it does check requires, minimally)
simulate
)
# HELPCMD: simulate install (it does check requires, minimally)
epm_cmd
=
simulate
;;
checkpkg|integrity
)
# HELPCMD: check package integrity
checkpkg|integrity
)
# HELPCMD: check package integrity
epm_cmd
=
checkpkg
;;
...
...
@@ -285,18 +292,30 @@ check_option()
return
0
}
for
opt
in
"
$@
"
;
do
check_command
$opt
&&
continue
check_option
$opt
&&
continue
check_filenames
()
{
local
opt
=
"
$1
"
if
[
-f
"
$opt
"
]
&&
echo
$opt
|
grep
-q
"
\.
"
;
then
pkg_files
=
"
$pkg_files
$opt
"
else
pkg_names
=
"
$pkg_names
$opt
"
fi
quoted_args
=
"
$quoted_args
\"
$opt
\"
"
}
for
opt
in
"
$@
"
;
do
check_command
$opt
&&
continue
check_option
$opt
&&
continue
check_filenames
$opt
done
# if input is not console, get pkg from it too
if
!
tty
-s
;
then
for
opt
in
$(
cat
)
;
do
check_filenames
$opt
done
fi
pkg_files
=
$(
strip_spaces
"
$pkg_files
"
)
pkg_names
=
$(
strip_spaces
"
$pkg_names
"
)
...
...
bin/epm-addrepo
View file @
efc1a899
...
...
@@ -21,6 +21,7 @@ epm_addrepo()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists apt-repo
sudocmd apt-repo add
$pkg_filenames
;;
apt-dpkg
)
...
...
bin/epm-autoremove
View file @
efc1a899
...
...
@@ -21,6 +21,7 @@ epm_autoremove()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists remove-old-kernels
# ALT Linux only
sudocmd remove-old-kernels
;;
...
...
@@ -45,7 +46,7 @@ case $PMTYPE in
;;
emerge
)
sudocmd emerge
--depclean
docmd epm
--skip-installed
install
gentoolkit
assure_exists revdep-rebuild
sudocmd revdep-rebuild
;;
pacman
)
...
...
@@ -55,6 +56,9 @@ case $PMTYPE in
# clean-system removes non official packages
#sudocmd slackpkg clean-system
;;
guix
)
sudocmd guix gc
;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
...
...
bin/epm-changelog
View file @
efc1a899
...
...
@@ -19,22 +19,30 @@
load_helper epm-query
__epm_changelog_apt
()
{
local
i
for
i
in
$@
;
do
docmd apt-cache show
$i
|
grep
-A
1000
"^Changelog:"
done
}
__epm_changelog_files
()
{
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm
)
# TODO: detect every file
case
$(
get_package_type
$1
)
in
rpm
)
docmd_foreach
"rpm -p --changelog"
$@
| less
;;
#
apt-dpkg
)
#
deb
)
#
# ;;
*
)
fatal
"Have no suitable command for
$
PMTYPE
"
fatal
"Have no suitable command for
$
1
"
;;
esac
}
__epm_changelog_local_names
()
...
...
@@ -46,12 +54,11 @@ __epm_changelog_local_names()
docmd_foreach
"rpm --changelog"
$@
| less
;;
apt-dpkg
)
# FIXME: only first pkg
docmd zcat /usr/share/doc/
$1
/changelog.Debian.gz | less
;;
emerge
)
docmd view /usr/portage/category/
$1
/ChangeLog | less
#
docmd equery changes -f $1 | less
assure_exists equery
docmd equery changes
-f
$1
| less
;;
pacman
)
docmd pacman
-Qc
$1
| less
...
...
@@ -67,9 +74,9 @@ __epm_changelog_unlocal_names()
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
#
apt-rpm)
# docmd_foreach "rpm --changelog"
$@ | less
#
;;
apt-rpm
)
__epm_changelog_apt
$@
| less
;;
#apt-dpkg)
# # FIXME: only first pkg
# docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
...
...
@@ -83,6 +90,10 @@ __epm_changelog_unlocal_names()
#zypper-rpm)
# sudocmd zypper clean
# ;;
emerge
)
assure_exists equery
docmd equery changes
-f
$1
| less
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
bin/epm-checkpkg
View file @
efc1a899
...
...
@@ -19,11 +19,10 @@
check_pkg_integrity
()
{
local
EXT
=
`
echo
"
$1
"
|
sed
-e
"s|.*
\.\(
[a-z0-9]*
\)\$
|
\1
|g"
`
local
PKG
=
"
$1
"
local
RET
case
$
EXT
in
case
$
(
get_package_type
$PKG
)
in
rpm
)
docmd rpm
--checksig
$PKG
;;
...
...
@@ -39,8 +38,10 @@ check_pkg_integrity()
;;
*
)
docmd erc
test
"
$PKG
"
&&
return
which erc
>
/dev/null 2>/dev/null
&&
fatal
"Check failed"
fatal
"Install erc package."
which erc
>
/dev/null 2>/dev/null
&&
fatal
"Check failed."
fatal
"Install erc package for file package."
# TODO
epm
install
erc
;;
esac
}
...
...
@@ -54,6 +55,10 @@ case $PMTYPE in
*
-dpkg
)
docmd debsums
$@
;;
emerge
)
assure_exists equery
docmd equery check
$@
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
bin/epm-conflicts
0 → 100644
View file @
efc1a899
#!/bin/sh
#
# Copyright (C) 2013 Etersoft
# Copyright (C) 2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-query
epm_conflicts_files
()
{
[
-n
"
$pkg_files
"
]
||
return
case
$(
get_package_type
$pkg_files
)
in
rpm
)
docmd
"rpm -q --conflicts -p"
;;
#deb)
# a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
# ;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
epm_conflicts_names
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
return
# by package name
case
$PMTYPE
in
apt-rpm
)
# FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so)
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --conflicts"
else
EXTRA_SHOWDOCMD
=
' | grep "Conflicts:"'
docmd apt-cache show
$pkg_names
|
grep
"Conflicts:"
return
fi
;;
urpm-rpm|zypper-rpm
)
# FIXME: use hi level commands
CMD
=
"rpm -q --conflicts"
;;
#yum-rpm)
# CMD="yum deplist"
# ;;
#pacman)
# CMD="pactree"
# ;;
apt-dpkg
)
# FIXME: need fix for a few names case
if
is_installed
$pkg_names
;
then
showcmd dpkg
-s
$pkg_names
a
=
dpkg
-s
$pkg_names
|
grep
"^Conflicts:"
|
sed
"s|^Conflicts:||g"
return
else
EXTRA_SHOWDOCMD
=
' | grep "Conflicts:"'
docmd apt-cache show
$pkg_names
|
grep
"Conflicts:"
return
fi
;;
#emerge)
# assure_exists equery
# CMD="equery depgraph"
# ;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
docmd
$CMD
$pkg_names
}
epm_conflicts
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
epm_conflicts_files
epm_conflicts_names
}
bin/epm-filelist
View file @
efc1a899
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
-2013
Etersoft
# Copyright (C) 2012
-2013
Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -19,17 +19,58 @@
load_helper epm-query
# TODO: port or rewrite apt-file
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
# see also epm-search-file
local_content_filelist
()
{
local
SYSARCH
SYSARCH
=
$(
uname
-m
)
[
"
$SYSARCH
"
=
"x86_64"
]
||
SYSARCH
=
i586
local
REPODIR
=
/var/ftp/pub/ALTLinux/Sisyphus
local
CI
=
$REPODIR
/
$SYSARCH
/base/contents_index
local
CINOA
=
$REPODIR
/noarch/base/contents_index
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD
=
"cat"
test
-r
$CI
&&
test
-r
$CINOA
||
fatal
"Can't locate
$CI
or
$CINOA
"
{
[
-n
"
$USETTY
"
]
&&
echo
"Search in
$CI
and
$CINOA
for
$1
..."
grep
-h
--
".*
$1
$"
$CI
$CINOA
|
sed
-e
"s|
\(
.*
\)\t\(
.*
\)
|
\1
|g"
}
|
$OUTCMD
}
__epm_filelist_remote
()
{
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
apt-rpm
)
# TODO: use RESTful interface to prometeus? See ALT bug #29496
docmd_foreach local_content_filelist
$@
;;
*
)
fatal
"Query filelist for non installed packages does not realized"
;;
esac
}
__epm_filelist_file
()
{
local
CMD
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm
)
# TODO: allow a new packages
case
$(
get_package_type
$1
)
in
rpm
)
CMD
=
"rpm -qlp"
;;
apt-dpkg
)
deb
)
CMD
=
"dpkg --contents"
;;
*
)
...
...
@@ -70,6 +111,10 @@ __epm_filelist_name()
docmd pacman
-Ql
$pkg_names
|
sed
-e
"s|.* ||g"
return
;;
emerge
)
assure_exists equery
CMD
=
"equery files"
;;
slackpkg
)
is_installed
$pkg_names
||
fatal
"Query filelist for non installed packages does not realized"
docmd
awk
'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}'
/var/log/packages/
${
pkg_filenames
}*
...
...
@@ -82,7 +127,7 @@ __epm_filelist_name()
# TODO: add less
docmd
$CMD
$pkg_names
&&
return
is_installed
$pkg_names
||
fatal
"Query filelist for non installed packages does not realized"
is_installed
$pkg_names
||
__epm_filelist_remote
$pkg_names
}
...
...
bin/epm-info
View file @
efc1a899
...
...
@@ -28,6 +28,8 @@ __epm_info_rpm_low()
is_installed
$pkg_names
&&
docmd rpm
-qi
$pkg_names
&&
return
}
# TODO: separate to _files and _names parts
# realize _files part per package, not by PMTYPE (see filelist)
epm_info
()
{
case
$PMTYPE
in
...
...
@@ -71,12 +73,22 @@ case $PMTYPE in
is_installed
$pkg_names
&&
docmd conary query
$pkg_names
--info
&&
return
docmd conary repquery
$pkg_names
--info
;;
emerge
)
assure_exists equery
docmd equery meta
$pkg_names
docmd equery which
$pkg_names
docmd equery uses
$pkg_names
docmd equery size
$pkg_names
;;
slackpkg
)
docmd /usr/sbin/slackpkg info
$pkg_names
;;
ipkg
)
docmd ipkg info
$pkg_names
;;
homebrew
)
docmd brew info
$pkg_names
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
bin/epm-install
View file @
efc1a899
...
...
@@ -143,6 +143,9 @@ epm_install_names()
nix
)
__separate_sudocmd
"nix-env --install"
"nix-env --upgrade"
$@
return
;;
guix
)
__separate_sudocmd
"guix package -i"
"guix package -i"
$@
return
;;
*
)
fatal
"Have no suitable install command for
$PMTYPE
"
;;
...
...
@@ -155,6 +158,7 @@ epm_ni_install_names()
[
-z
"
$1
"
]
&&
return
case
$PMTYPE
in
apt-rpm|apt-dpkg
)
export
DEBIAN_FRONTEND
=
noninteractive
sudocmd apt-get
-y
--force-yes
-o
Dpkg::Options::
=
"--force-confdef"
-o
Dpkg::Options::
=
"--force-confold"
$APTOPTIONS
install
$@
return
;;
yum-rpm
)
...
...
bin/epm-kernel_update
View file @
efc1a899
...
...
@@ -23,6 +23,7 @@ epm_kernel_update()
case
$DISTRNAME
in
ALTLinux
)
assure_exists update-kernel
sudocmd update-kernel
return
;;
esac
...
...
bin/epm-packages
View file @
efc1a899
...
...
@@ -52,9 +52,10 @@ case $PMTYPE in
CMD
=
"rpm -qa
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
;;
# Note: dnf has dnf list command
emerge
)
CMD
=
"qlist -I"
CMD
=
"qlist -I -C"
# print with colors for console output
isatty
&&
CMD
=
"qlist -I"
;;
pkgsrc
)
CMD
=
"pkg_info"
...
...
@@ -87,11 +88,14 @@ case $PMTYPE in
fi
;;
homebrew
)
CMD
=
"brew
$pkg_filenames
"
CMD
=
"brew
list
$pkg_filenames
"
;;
ipkg
)
CMD
=
"ipkg list"
;;
guix
)
CMD
=
"guix package -I"
;;
*
)
fatal
"Have no suitable query command for
$PMTYPE
"
;;
...
...
bin/epm-provides
View file @
efc1a899
...
...
@@ -19,35 +19,41 @@
load_helper epm-query
epm_provides
()
epm_provides
_files
()
{
local
CMD
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_files
"
]
||
return
# by package file
case
$PMTYPE
in
*
-rpm
)
CMD
=
"rpm -q --provides -p"
;;
# apt-dpkg)
# showcmd dpkg -s $pkg_files
# a= dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
# return
# ;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
case
$(
get_package_type
$pkg_files
)
in
rpm
)
docmd
"rpm -q --provides -p"
;;
deb
)
# FIXME: will we provide ourself?
docmd dpkg
-I
$pkg_files
|
grep
"^ *Provides:"
|
sed
"s|^ *Provides:||g"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
[
-n
"
$pkg_files
"
]
&&
docmd
$CMD
$pkg_files
epm_provides_names
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
return
# by package name
case
$PMTYPE
in
apt-rpm
)
# FIXME: need fix for a few names case
# TODO: separate this function to two section
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --provides"
else
CMD
=
"apt-cache depends"
EXTRA_SHOWDOCMD
=
' | grep "Provides:"'
docmd apt-cache show
$pkg_names
|
grep
"Provides:"
return
fi
;;
urpm-rpm|zypper-rpm|yum-rpm
)
...
...
@@ -58,19 +64,34 @@ case $PMTYPE in
fi
;;
emerge
)
assure_exists equery
CMD
=
"equery files"
;;
# yum-rpm)
# CMD="yum deplist"
# ;;
# apt-dpkg)
# CMD="apt-cache depends"
# ;;
apt-dpkg
)
# FIXME: need fix for a few names case
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --provides"
else
EXTRA_SHOWDOCMD
=
' | grep "Provides:"'
docmd apt-cache show
$pkg_names
|
grep
"Provides:"
return
fi
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
[
-n
"
$pkg_names
"
]
&&
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_names
}
epm_provides
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
epm_provides_files
epm_provides_names
}
bin/epm-query
View file @
efc1a899
...
...
@@ -19,19 +19,32 @@
load_helper epm-packages
# TODO: combine with -qa (the difference only in return status now)
_get_grep_exp
()
{
local
def
=
"^
$1
$"
[
"
$PMTYPE
"
!=
"emerge"
]
&&
echo
"
$def
"
&&
return
# Gentoo hack: support for short package form
echo
"
$1
"
|
grep
-q
"/"
&&
echo
"
$def
"
&&
return
echo
"/
$1
$"
}
# TODO: combine with -qa (the difference only in return status now)
_query_via_packages_list
()
{
local
res
=
0
local
grepexp
local
firstpkg
=
$1
shift
grepexp
=
$(
_get_grep_exp
$firstpkg
)
# separate first line for print out command
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"
^
$firstpkg
$
"
||
res
=
1
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"
$grepexp
"
||
res
=
1
for
pkg
in
"
$@
"
;
do
short
=
1
pkg_filenames
=
$pkg
epm_packages 2>/dev/null |
grep
--
"^
$pkg
$"
||
res
=
1
grepexp
=
$(
_get_grep_exp
$pkg
)
short
=
1
pkg_filenames
=
$pkg
epm_packages 2>/dev/null |
grep
--
"
$grepexp
"
||
res
=
1
done
return
$res
...
...
@@ -75,7 +88,7 @@ __epm_get_hilevel_name()
for
i
in
$@
;
do
local
pkg
# get short form in pkg
quiet
=
1
short
=
1
pkg
=
$(
__epm_query_name
$i
)
quiet
=
1
short
=
1
pkg
=
$(
__epm_query_name
$i
)
||
continue
# drop not installed packages
# if already short form, skipped
[
"
$pkg
"
=
"
$i
"
]
&&
echo
"
$i
"
&&
continue
# try get long form or use short form
...
...
@@ -129,7 +142,7 @@ __epm_query_name()
conary
)
CMD
=
"conary query"
;;
brew
)
home
brew
)
warning
"fix query"
return
1
;;
...
...
@@ -146,8 +159,9 @@ __epm_query_name()
# check if pkg is installed
is_installed
()
{
#pkg_filenames="$@" epm_query >/dev/null
epm installed
$@
>
/dev/null 2>/dev/null
pkg_filenames
=
"
$@
"
pkg_names
=
"
$@
"
epm_query
>
/dev/null 2>/dev/null
# broken way to recursive call here (overhead!)
#epm installed $@ >/dev/null 2>/dev/null
}
# fill pkg_installed and pkg_noninstalled
...
...
bin/epm-query_file
View file @
efc1a899
...
...
@@ -79,6 +79,7 @@ __do_query()
CMD
=
"rpm -qf"
;;
emerge
)
assure_exists equery
CMD
=
"equery belongs"
;;
pacman
)
...
...
@@ -116,6 +117,7 @@ __do_short_query()
dpkg_print_name_version
$(
dpkg
-S
$1
|
sed
-e
"s|:.*||"
|
grep
-v
"^diversion by"
)
return
;;
NOemerge
)
assure_exists equery
CMD
=
"equery belongs"
;;
NOpacman
)
...
...
bin/epm-query_package
View file @
efc1a899
...
...
@@ -22,7 +22,7 @@ load_helper epm-search
epm_query_package
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Please, use search with some argument"
[
-n
"
$pkg_filenames
"
]
||
fatal
"Please, use search with some argument
or run epmqa for get all packages.
"
# FIXME: do it better
local
MGS
=
$(
eval
__epm_search_make_grep
$quoted_args
)
EXTRA_SHOWDOCMD
=
$MGS
...
...
bin/epm-release-upgrade
View file @
efc1a899
...
...
@@ -63,6 +63,12 @@ epm_release_upgrade()
conary
)
epm Upgrade
;;
emerge
)
epm Upgrade
;;
guix
)
sudocmd guix pull
--verbose
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
bin/epm-remove
View file @
efc1a899
...
...
@@ -51,9 +51,12 @@ epm_remove_names()
[
-z
"
$1
"
]
&&
return
case
$PMTYPE
in
apt-
rpm|apt-
dpkg
)
apt-dpkg
)
sudocmd apt-get remove
--purge
$@
return
;;
apt-rpm
)
sudocmd apt-get remove
$@
return
;;
deepsolver-rpm
)
sudocmd ds-remove
$@
return
;;
...
...
@@ -91,6 +94,9 @@ epm_remove_names()
nix
)
sudocmd nix-env
--uninstall
$@
return
;;
guix
)
sudocmd guix package
-r
$@
return
;;
chocolatey
)
sudocmd chocolatey uninstall
$@
return
;;
...
...
@@ -113,9 +119,12 @@ epm_remove_names()
epm_remove_nonint
()
{
case
$PMTYPE
in
apt-
rpm|apt-
dpkg
)
apt-dpkg
)
sudocmd apt-get
-y
--force-yes
remove
--purge
$@
return
;;
apt-rpm
)
sudocmd apt-get
-y
--force-yes
remove
$@
return
;;
urpm-rpm
)
sudocmd urpme
--auto
$@
return
;;
...
...
bin/epm-removerepo
View file @
efc1a899
...
...
@@ -21,6 +21,7 @@ epm_removerepo()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists apt-repo
sudocmd apt-repo
rm
$pkg_filenames
;;
apt-dpkg
)
...
...
bin/epm-repolist
View file @
efc1a899
...
...
@@ -32,6 +32,7 @@ epm_repolist()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists apt-repo
docmd apt-repo list
;;
deepsolver-rpm
)
...
...
@@ -54,6 +55,7 @@ case $PMTYPE in
docmd zypper sl
-d
;;
emerge
)
docmd eselect profile list
docmd layman
-L
;;
pacman
)
...
...
bin/epm-requires
View file @
efc1a899
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
-2013
Etersoft
# Copyright (C) 2012
-2013
Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -17,36 +17,46 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
epm_requires
()
load_helper epm-query
epm_requires_files
()
{
local
CMD
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_files
"
]
||
return
# TODO: Здесь выбирать команду по расширению, а не по системному менеджеру
# В других таких случаях тоже
# В списке пакетов на установку проверять, что пакеты имеют соответствующее расширение
# by package file
case
$PMTYPE
in
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm
)
CMD
=
"rpm -q --requires -p"
;;
apt-dpkg
)
# FIXME: need package base
showcmd dpkg
-s
$pkg_files
a
=
dpkg
-s
$pkg_names
|
grep
"^Depends:"
|
sed
"s|^Depends:||g"
# FIXME: we need execute package name section too
return
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
case
$(
get_package_type
$pkg_files
)
in
rpm
)
docmd
"rpm -q --requires -p"
;;
deb
)
a
=
docmd dpkg
-I
$pkg_files
|
grep
"^ *Depends:"
|
sed
"s|^ *Depends:||g"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
[
-n
"
$pkg_files
"
]
&&
docmd
$CMD
$pkg_files
epm_requires_names
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
return
# by package name
case
$PMTYPE
in
apt-rpm|urpm-rpm|zypper-rpm
)
apt-rpm
)
# FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so)
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --requires"
else
#EXTRA_SHOWDOCMD=' | grep "Depends:"'
#docmd apt-cache show $pkg_names | grep "Depends:"
#return
CMD
=
"apt-cache depends"
fi
;;
urpm-rpm|zypper-rpm
)
# FIXME: use hi level commands
CMD
=
"rpm -q --requires"
;;
...
...
@@ -57,7 +67,18 @@ case $PMTYPE in
CMD
=
"pactree"
;;
apt-dpkg
)
CMD
=
"apt-cache depends"
# FIXME: need fix for a few names case
if
is_installed
$pkg_names
;
then
showcmd dpkg
-s
$pkg_names
a
=
dpkg
-s
$pkg_names
|
grep
"^Depends:"
|
sed
"s|^Depends:||g"
return
else
CMD
=
"apt-cache depends"
fi
;;
emerge
)
assure_exists equery
CMD
=
"equery depgraph"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
...
...
@@ -65,6 +86,13 @@ case $PMTYPE in
esac
[
-n
"
$pkg_names
"
]
&&
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_names
}
epm_requires
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
epm_requires_files
epm_requires_names
}
bin/epm-search
View file @
efc1a899
...
...
@@ -70,6 +70,9 @@ case $PMTYPE in
homebrew
)
CMD
=
"brew search"
;;
guix
)
CMD
=
"guix package -A"
;;
*
)
fatal
"Have no suitable search command for
$PMTYPE
"
;;
...
...
@@ -87,20 +90,39 @@ __epm_search_make_grep()
local
list
=
local
listN
=
for
i
in
$@
;
do
local
NOR
=
"
${
i
/^/
}
"
[
"
$NOR
"
=
"
$i
"
]
&&
list
=
"
$list
$NOR
"
||
listN
=
"
$listN
$NOR
"
case
"
$i
"
in
^
*
)
# will clean from ^ later (and have the bug here with empty arg if run with one ^ only)
listN
=
"
$listN
$i
"
;;
*
)
list
=
"
$list
$i
"
;;
esac
done
#list=$(strip_spaces $list | sed -e "s/ /|/g")
listN
=
$(
strip_spaces
$listN
|
sed
-e
"s/ /|/g"
)
listN
=
$(
strip_spaces
$listN
|
sed
-e
"s/ /|/g"
|
sed
-e
"s/
\^
//g"
)
[
-n
"
$listN
"
]
&&
echo
-n
" | egrep -i -v --
\"
$listN
\"
"
# FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for
i
in
$list
;
do
echo
-n
" | egrep -i --color --
\"
$i
\"
"
# FIXME -n on MacOS?
echo
-n
" | egrep -i --
\"
$i
\"
"
done
local
COLO
=
""
# rule for colorife
for
i
in
$list
$listN
;
do
[
-n
"
$COLO
"
]
&&
COLO
=
"
$COLO
|"
COLO
=
"
$COLO$i
"
done
# FIXME -n on MacOS?
if
[
-n
"
$list
"
]
;
then
echo
-n
" | egrep -i --color --
\"
(
$COLO
)
\"
"
fi
}
# copied from korinf/tools/run-script/scripts/search
...
...
bin/epm-search_file
View file @
efc1a899
...
...
@@ -50,6 +50,7 @@ case $PMTYPE in
local_content_search
$pkg_filenames
return
;;
apt-dpkg
)
assure_exists apt-file
sudocmd apt-file update
docmd apt-file search
$pkg_filenames
return
;;
...
...
bin/epm-sh-functions
View file @
efc1a899
...
...
@@ -23,7 +23,8 @@ isatty()
# Set a sane TERM required for tput
[
-n
"
$TERM
"
]
||
TERM
=
dumb
export
TERM
test
-t
1
# check stderr
test
-t
2
}
check_tty
()
...
...
@@ -83,7 +84,7 @@ showcmd()
if
[
-z
"
$quiet
"
]
;
then
set_boldcolor
$GREEN
local
PROMTSIG
=
"
\$
"
[
"
$UID
"
=
0
]
&&
PROMTSIG
=
"#"
[
"
$
EFF
UID
"
=
0
]
&&
PROMTSIG
=
"#"
echo
"
$PROMTSIG
$@
"
restore_color
fi
>
&2
...
...
@@ -163,15 +164,19 @@ store_output()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT
=
$(
mktemp
)
local
CMDSTATUS
=
$RC_STDOUT
.pipestatus
echo
1
>
$CMDSTATUS
#RC_STDERR=$(mktemp)
"
$@
"
2>&1 |
tee
$RC_STDOUT
(
"
$@
"
2>&1
;
echo
$?
>
$CMDSTATUS
)
|
tee
$RC_STDOUT
return
$(
cat
$CMDSTATUS
)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return
$PIPESTATUS
#
return $PIPESTATUS
}
clean_store_output
()
{
rm
-f
$RC_STDOUT
rm
-f
$RC_STDOUT
$RC_STDOUT
.pipestatus
}
...
...
@@ -207,11 +212,10 @@ set_sudo()
# skip SUDO if disabled
[
-n
"
$EPMNOSUDO
"
]
&&
return
# set SUDO not for root user
[
-n
"
$UID
"
]
||
UID
=
`
id
-u
`
EFFUID
=
`
id
-u
`
# do not need sudo
[
$UID
=
"0"
]
&&
return
[
$
EFF
UID
=
"0"
]
&&
return
# use sudo if possible
which
sudo
>
/dev/null 2>/dev/null
&&
SUDO
=
"sudo"
&&
return
...
...
@@ -219,6 +223,63 @@ set_sudo()
SUDO
=
"fatal 'Can't find sudo. Please install sudo or run epm under root.'"
}
set_eatmydata
()
{
# skip if disabled
[
-n
"
$EPMNOEATMYDATA
"
]
&&
return
# use if possible
which eatmydata
>
/dev/null 2>/dev/null
||
return
SUDO
=
"
$SUDO
eatmydata"
tty
-s
&&
echo
"Uwaga! eatmydata is installed, we will use it for disable all sync operations."
>
&2
return
0
}
assure_exists
()
{
PATH
=
$PATH
:/sbin:/usr/sbin which
$1
2>/dev/null
>
/dev/null
&&
return
echo
"Install appropriate package for
$1
command..."
case
$1
in
equery|revdep-rebuild
)
epm
install
gentoolkit
;;
apt-repo
)
epm
install
apt-repo
;;
apt-file
)
epm
install
apt-file
;;
update-kernel|remove-old-kernels
)
epm
install
update-kernel
;;
*
)
fatal
"Internal error: Unknown binary
$1
to check if exists"
;;
esac
}
# improve
get_package_type
()
{
local
i
case
$1
in
*
.deb
)
echo
"deb"
return
;;
*
.rpm
)
echo
"rpm"
return
;;
*
)
#fatal "Don't know type of $1"
# return package name for info
echo
"
$1
"
return
1
;;
esac
}
# print options description from HELPCMD/HELPOPT lines in the code
get_help
()
{
...
...
@@ -291,6 +352,9 @@ case $DISTRNAME in
OpenWRT
)
CMD
=
"ipkg"
;;
GNU/Linux/Guix
)
CMD
=
"guix"
;;
*
)
fatal
"Have no suitable DISTRNAME
$DISTRNAME
"
;;
...
...
bin/epm-upgrade
View file @
efc1a899
...
...
@@ -61,7 +61,9 @@ epm_upgrade()
CMD
=
"chocolatey update all"
;;
homebrew
)
CMD
=
"brew upgrade"
#CMD="brew upgrade"
sudocmd
"brew upgrade
`
brew outdated
`
"
return
;;
ipkg
)
CMD
=
"ipkg upgrade"
...
...
@@ -69,6 +71,9 @@ epm_upgrade()
slackpkg
)
CMD
=
"/usr/sbin/slackpkg upgrade-all"
;;
guix
)
CMD
=
"guix package -u"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
bin/epm-whatdepends
View file @
efc1a899
...
...
@@ -20,7 +20,7 @@
epm_whatdepends
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_
file
names
"
]
||
fatal
"Run query without names"
# by package name
case
$PMTYPE
in
...
...
@@ -34,6 +34,7 @@ case $PMTYPE in
CMD
=
"repoquery --whatrequires"
;;
emerge
)
assure_exists equery
CMD
=
"equery depends -a"
;;
*
)
...
...
@@ -41,6 +42,6 @@ case $PMTYPE in
;;
esac
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_
file
names
}
bin/epm-whatprovides
View file @
efc1a899
...
...
@@ -20,7 +20,7 @@
epm_whatprovides
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_
file
names
"
]
||
fatal
"Run query without names"
# by package name
case
$PMTYPE
in
...
...
@@ -42,6 +42,6 @@ case $PMTYPE in
;;
esac
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_
file
names
}
bin/epmsf
0 → 120000
View file @
efc1a899
epm
\ No newline at end of file
eepm.spec
View file @
efc1a899
# This spec is backported to ALTLinux p7 automatically by rpmbph script. Do not edit it.
#
Name: eepm
Version: 1.4.
1
Version: 1.4.
4
Release: alt0.M70P.1
Summary: Etersoft EPM package manager
...
...
@@ -22,9 +22,7 @@ Conflicts: epm
Provides: upm
%if %_vendor == "alt"
Requires: apt rpm apt-repo
%endif
Requires: apt rpm
%description
Etersoft EPM is the package manager for any platform
...
...
@@ -65,9 +63,38 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv
%changelog
* T
hu Sep 05 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.1
-alt0.M70P.1
* T
ue Oct 22 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.4
-alt0.M70P.1
- backport to ALTLinux p7 (by rpmbph script)
* Tue Oct 22 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.4-alt1
- epm: get package names from stdin if it is pipe
- fix stderr issues
* Mon Oct 21 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.3-alt1
- rewrite code without bashisms
- search colorifer: fix colorifing all args
- epm: use eatmydata if installed (set EPMNOEATMYDATA for skip)
- add initial support for epm conflicts
- whatdepends/whatprovides: all use exists files as goals
- add epmsf as link to epm sf command
- epm: normalize options
- epmql (epm-filelist): add support for list files of the remote packages
* Tue Oct 08 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.2-alt1
- add initial support for guix
- rewrite epm_requires and epm_provides
- remove mandatory requires to apt-repo
- fix epm query on Gentoo (disable colorifing for grep)
- epm-query: support for short form of package name on Gentoo
- epm-query: realize is_installed via internal function (for pkg names only), speed optimize
- improve MacOS support
- epm-query: fix for query non installed packages
- epm-filelist: allow list of foreign packages
- introduce get_package_type and use it
- epm-remove: do not use --purge on apt-rpm
- epm-changelog: add support for noninstalled packages on ALT
- install: do non interactive really non interactive
* Thu Sep 05 2013 Vitaly Lipatov <lav@altlinux.ru> 1.4.1-alt1
- add initial man page file
- epm-filelist: add todo for less
...
...
packed/epm.sh
View file @
efc1a899
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2013
Etersoft
# Copyright (C) 2012
, 2013
Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -97,7 +97,7 @@ showcmd()
if
[
-z
"
$quiet
"
]
;
then
set_boldcolor
$GREEN
local
PROMTSIG
=
"
\$
"
[
"
$UID
"
=
0
]
&&
PROMTSIG
=
"#"
[
"
$
EFF
UID
"
=
0
]
&&
PROMTSIG
=
"#"
echo
"
$PROMTSIG
$@
"
restore_color
fi
>
&2
...
...
@@ -172,15 +172,19 @@ store_output()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT
=
$(
mktemp
)
local
CMDSTATUS
=
$RC_STDOUT
.pipestatus
echo
1
>
$CMDSTATUS
#RC_STDERR=$(mktemp)
"
$@
"
2>&1 |
tee
$RC_STDOUT
(
"
$@
"
2>&1
;
echo
$?
>
$CMDSTATUS
)
|
tee
$RC_STDOUT
return
$(
cat
$CMDSTATUS
)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return
$PIPESTATUS
#
return $PIPESTATUS
}
clean_store_output
()
{
rm
-f
$RC_STDOUT
rm
-f
$RC_STDOUT
$RC_STDOUT
.pipestatus
}
...
...
@@ -210,11 +214,10 @@ set_sudo()
# skip SUDO if disabled
[
-n
"
$EPMNOSUDO
"
]
&&
return
# set SUDO not for root user
[
-n
"
$UID
"
]
||
UID
=
`
id
-u
`
EFFUID
=
`
id
-u
`
# do not need sudo
[
$UID
=
"0"
]
&&
return
[
$
EFF
UID
=
"0"
]
&&
return
# use sudo if possible
which
sudo
>
/dev/null 2>/dev/null
&&
SUDO
=
"sudo"
&&
return
...
...
@@ -222,6 +225,61 @@ set_sudo()
SUDO
=
"fatal 'Can't find sudo. Please install sudo or run epm under root.'"
}
set_eatmydata
()
{
# skip if disabled
[
-n
"
$EPMNOEATMYDATA
"
]
&&
return
# use if possible
which eatmydata
>
/dev/null 2>/dev/null
||
return
SUDO
=
"
$SUDO
eatmydata"
echo
"Uwaga! eatmydata is installed, we will use it for disable all sync operations."
}
assure_exists
()
{
PATH
=
$PATH
:/sbin:/usr/sbin which
$1
2>/dev/null
>
/dev/null
&&
return
echo
"Install appropriate package for
$1
command..."
case
$1
in
equery|revdep-rebuild
)
epm
install
gentoolkit
;;
apt-repo
)
epm
install
apt-repo
;;
apt-file
)
epm
install
apt-file
;;
update-kernel|remove-old-kernels
)
epm
install
update-kernel
;;
*
)
fatal
"Internal error: Unknown binary
$1
to check if exists"
;;
esac
}
get_package_type
()
{
local
i
case
$1
in
*
.deb
)
echo
"deb"
return
;;
*
.rpm
)
echo
"rpm"
return
;;
*
)
#fatal "Don't know type of $1"
# return package name for info
echo
"
$1
"
return
1
;;
esac
}
get_help
()
{
grep
-v
--
"^#"
$0
|
grep
--
"#
$1
"
|
while
read
n
;
do
...
...
@@ -291,6 +349,9 @@ case $DISTRNAME in
OpenWRT
)
CMD
=
"ipkg"
;;
GNU/Linux/Guix
)
CMD
=
"guix"
;;
*
)
fatal
"Have no suitable DISTRNAME
$DISTRNAME
"
;;
...
...
@@ -305,6 +366,7 @@ epm_addrepo()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists apt-repo
sudocmd apt-repo add
$pkg_filenames
;;
apt-dpkg
)
...
...
@@ -346,6 +408,7 @@ epm_autoremove()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists remove-old-kernels
# ALT Linux only
sudocmd remove-old-kernels
;;
...
...
@@ -370,7 +433,7 @@ case $PMTYPE in
;;
emerge
)
sudocmd emerge
--depclean
docmd epm
--skip-installed
install
gentoolkit
assure_exists revdep-rebuild
sudocmd revdep-rebuild
;;
pacman
)
...
...
@@ -380,6 +443,9 @@ case $PMTYPE in
# clean-system removes non official packages
#sudocmd slackpkg clean-system
;;
guix
)
sudocmd guix gc
;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
...
...
@@ -393,19 +459,27 @@ esac
# File bin/epm-changelog:
__epm_changelog_apt
()
{
local
i
for
i
in
$@
;
do
docmd apt-cache show
$i
|
grep
-A
1000
"^Changelog:"
done
}
__epm_changelog_files
()
{
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm
)
# TODO: detect every file
case
$(
get_package_type
$1
)
in
rpm
)
docmd_foreach
"rpm -p --changelog"
$@
| less
;;
*
)
fatal
"Have no suitable command for
$
PMTYPE
"
fatal
"Have no suitable command for
$
1
"
;;
esac
}
__epm_changelog_local_names
()
...
...
@@ -417,12 +491,11 @@ __epm_changelog_local_names()
docmd_foreach
"rpm --changelog"
$@
| less
;;
apt-dpkg
)
# FIXME: only first pkg
docmd zcat /usr/share/doc/
$1
/changelog.Debian.gz | less
;;
emerge
)
docmd view /usr/portage/category/
$1
/ChangeLog | less
#
docmd equery changes -f $1 | less
assure_exists equery
docmd equery changes
-f
$1
| less
;;
pacman
)
docmd pacman
-Qc
$1
| less
...
...
@@ -438,9 +511,9 @@ __epm_changelog_unlocal_names()
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
#
apt-rpm)
# docmd_foreach "rpm --changelog"
$@ | less
#
;;
apt-rpm
)
__epm_changelog_apt
$@
| less
;;
#apt-dpkg)
# # FIXME: only first pkg
# docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
...
...
@@ -454,6 +527,10 @@ __epm_changelog_unlocal_names()
#zypper-rpm)
# sudocmd zypper clean
# ;;
emerge
)
assure_exists equery
docmd equery changes
-f
$1
| less
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
@@ -526,11 +603,10 @@ esac
check_pkg_integrity
()
{
local
EXT
=
`
echo
"
$1
"
|
sed
-e
"s|.*
\.\(
[a-z0-9]*
\)\$
|
\1
|g"
`
local
PKG
=
"
$1
"
local
RET
case
$
EXT
in
case
$
(
get_package_type
$PKG
)
in
rpm
)
docmd rpm
--checksig
$PKG
;;
...
...
@@ -546,8 +622,10 @@ check_pkg_integrity()
;;
*
)
docmd erc
test
"
$PKG
"
&&
return
which erc
>
/dev/null 2>/dev/null
&&
fatal
"Check failed"
fatal
"Install erc package."
which erc
>
/dev/null 2>/dev/null
&&
fatal
"Check failed."
fatal
"Install erc package for file package."
# TODO
epm
install
erc
;;
esac
}
...
...
@@ -561,6 +639,10 @@ case $PMTYPE in
*
-dpkg
)
docmd debsums
$@
;;
emerge
)
assure_exists equery
docmd equery check
$@
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
@@ -621,20 +703,139 @@ esac
}
# File bin/epm-conflicts:
epm_conflicts_files
()
{
[
-n
"
$pkg_files
"
]
||
return
case
$(
get_package_type
$pkg_files
)
in
rpm
)
docmd
"rpm -q --conflicts -p"
;;
#deb)
# a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
# ;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
epm_conflicts_names
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
return
case
$PMTYPE
in
apt-rpm
)
# FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so)
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --conflicts"
else
EXTRA_SHOWDOCMD
=
' | grep "Conflicts:"'
docmd apt-cache show
$pkg_names
|
grep
"Conflicts:"
return
fi
;;
urpm-rpm|zypper-rpm
)
# FIXME: use hi level commands
CMD
=
"rpm -q --conflicts"
;;
#yum-rpm)
# CMD="yum deplist"
# ;;
#pacman)
# CMD="pactree"
# ;;
apt-dpkg
)
# FIXME: need fix for a few names case
if
is_installed
$pkg_names
;
then
showcmd dpkg
-s
$pkg_names
a
=
dpkg
-s
$pkg_names
|
grep
"^Conflicts:"
|
sed
"s|^Conflicts:||g"
return
else
EXTRA_SHOWDOCMD
=
' | grep "Conflicts:"'
docmd apt-cache show
$pkg_names
|
grep
"Conflicts:"
return
fi
;;
#emerge)
# assure_exists equery
# CMD="equery depgraph"
# ;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
docmd
$CMD
$pkg_names
}
epm_conflicts
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
epm_conflicts_files
epm_conflicts_names
}
# File bin/epm-filelist:
local_content_filelist
()
{
local
SYSARCH
SYSARCH
=
$(
uname
-m
)
[
"
$SYSARCH
"
=
"x86_64"
]
||
SYSARCH
=
i586
local
REPODIR
=
/var/ftp/pub/ALTLinux/Sisyphus
local
CI
=
$REPODIR
/
$SYSARCH
/base/contents_index
local
CINOA
=
$REPODIR
/noarch/base/contents_index
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD
=
"cat"
test
-r
$CI
&&
test
-r
$CINOA
||
fatal
"Can't locate
$CI
or
$CINOA
"
{
[
-n
"
$USETTY
"
]
&&
echo
"Search in
$CI
and
$CINOA
for
$1
..."
grep
-h
--
".*
$1
$"
$CI
$CINOA
|
sed
-e
"s|
\(
.*
\)\t\(
.*
\)
|
\1
|g"
}
|
$OUTCMD
}
__epm_filelist_remote
()
{
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
apt-rpm
)
# TODO: use RESTful interface to prometeus? See ALT bug #29496
docmd_foreach local_content_filelist
$@
;;
*
)
fatal
"Query filelist for non installed packages does not realized"
;;
esac
}
__epm_filelist_file
()
{
local
CMD
[
-z
"
$*
"
]
&&
return
case
$PMTYPE
in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm
)
# TODO: allow a new packages
case
$(
get_package_type
$1
)
in
rpm
)
CMD
=
"rpm -qlp"
;;
apt-dpkg
)
deb
)
CMD
=
"dpkg --contents"
;;
*
)
...
...
@@ -675,6 +876,10 @@ __epm_filelist_name()
docmd pacman
-Ql
$pkg_names
|
sed
-e
"s|.* ||g"
return
;;
emerge
)
assure_exists equery
CMD
=
"equery files"
;;
slackpkg
)
is_installed
$pkg_names
||
fatal
"Query filelist for non installed packages does not realized"
docmd
awk
'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}'
/var/log/packages/
${
pkg_filenames
}*
...
...
@@ -687,7 +892,7 @@ __epm_filelist_name()
# TODO: add less
docmd
$CMD
$pkg_names
&&
return
is_installed
$pkg_names
||
fatal
"Query filelist for non installed packages does not realized"
is_installed
$pkg_names
||
__epm_filelist_remote
$pkg_names
}
...
...
@@ -756,12 +961,22 @@ case $PMTYPE in
is_installed
$pkg_names
&&
docmd conary query
$pkg_names
--info
&&
return
docmd conary repquery
$pkg_names
--info
;;
emerge
)
assure_exists equery
docmd equery meta
$pkg_names
docmd equery which
$pkg_names
docmd equery uses
$pkg_names
docmd equery size
$pkg_names
;;
slackpkg
)
docmd /usr/sbin/slackpkg info
$pkg_names
;;
ipkg
)
docmd ipkg info
$pkg_names
;;
homebrew
)
docmd brew info
$pkg_names
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
@@ -891,6 +1106,9 @@ epm_install_names()
nix
)
__separate_sudocmd
"nix-env --install"
"nix-env --upgrade"
$@
return
;;
guix
)
__separate_sudocmd
"guix package -i"
"guix package -i"
$@
return
;;
*
)
fatal
"Have no suitable install command for
$PMTYPE
"
;;
...
...
@@ -902,6 +1120,7 @@ epm_ni_install_names()
[
-z
"
$1
"
]
&&
return
case
$PMTYPE
in
apt-rpm|apt-dpkg
)
export
DEBIAN_FRONTEND
=
noninteractive
sudocmd apt-get
-y
--force-yes
-o
Dpkg::Options::
=
"--force-confdef"
-o
Dpkg::Options::
=
"--force-confold"
$APTOPTIONS
install
$@
return
;;
yum-rpm
)
...
...
@@ -1210,6 +1429,7 @@ epm_kernel_update()
case
$DISTRNAME
in
ALTLinux
)
assure_exists update-kernel
sudocmd update-kernel
return
;;
esac
...
...
@@ -1258,7 +1478,9 @@ case $PMTYPE in
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
;;
emerge
)
CMD
=
"qlist -I"
CMD
=
"qlist -I -C"
# print with colors for console output
isatty
&&
CMD
=
"qlist -I"
;;
pkgsrc
)
CMD
=
"pkg_info"
...
...
@@ -1288,11 +1510,14 @@ case $PMTYPE in
fi
;;
homebrew
)
CMD
=
"brew
$pkg_filenames
"
CMD
=
"brew
list
$pkg_filenames
"
;;
ipkg
)
CMD
=
"ipkg list"
;;
guix
)
CMD
=
"guix package -I"
;;
*
)
fatal
"Have no suitable query command for
$PMTYPE
"
;;
...
...
@@ -1318,28 +1543,40 @@ epm_programs()
# File bin/epm-provides:
epm_provides
()
epm_provides
_files
()
{
local
CMD
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_files
"
]
||
return
case
$(
get_package_type
$pkg_files
)
in
rpm
)
docmd
"rpm -q --provides -p"
;;
deb
)
# FIXME: will we provide ourself?
docmd dpkg
-I
$pkg_files
|
grep
"^ *Provides:"
|
sed
"s|^ *Provides:||g"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
case
$PMTYPE
in
*
-rpm
)
CMD
=
"rpm -q --provides -p"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
[
-n
"
$pkg_files
"
]
&&
docmd
$CMD
$pkg_files
epm_provides_names
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
return
case
$PMTYPE
in
apt-rpm
)
# FIXME: need fix for a few names case
# TODO: separate this function to two section
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --provides"
else
CMD
=
"apt-cache depends"
EXTRA_SHOWDOCMD
=
' | grep "Provides:"'
docmd apt-cache show
$pkg_names
|
grep
"Provides:"
return
fi
;;
urpm-rpm|zypper-rpm|yum-rpm
)
...
...
@@ -1350,32 +1587,63 @@ case $PMTYPE in
fi
;;
emerge
)
assure_exists equery
CMD
=
"equery files"
;;
apt-dpkg
)
# FIXME: need fix for a few names case
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --provides"
else
EXTRA_SHOWDOCMD
=
' | grep "Provides:"'
docmd apt-cache show
$pkg_names
|
grep
"Provides:"
return
fi
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
[
-n
"
$pkg_names
"
]
&&
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_names
}
epm_provides
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
epm_provides_files
epm_provides_names
}
# File bin/epm-query:
_get_grep_exp
()
{
local
def
=
"^
$1
$"
[
"
$PMTYPE
"
!=
"emerge"
]
&&
echo
"
$def
"
&&
return
# Gentoo hack: support for short package form
echo
"
$1
"
|
grep
-q
"/"
&&
echo
"
$def
"
&&
return
echo
"/
$1
$"
}
_query_via_packages_list
()
{
local
res
=
0
local
grepexp
local
firstpkg
=
$1
shift
grepexp
=
$(
_get_grep_exp
$firstpkg
)
# separate first line for print out command
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"
^
$firstpkg
$
"
||
res
=
1
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"
$grepexp
"
||
res
=
1
for
pkg
in
"
$@
"
;
do
short
=
1
pkg_filenames
=
$pkg
epm_packages 2>/dev/null |
grep
--
"^
$pkg
$"
||
res
=
1
grepexp
=
$(
_get_grep_exp
$pkg
)
short
=
1
pkg_filenames
=
$pkg
epm_packages 2>/dev/null |
grep
--
"
$grepexp
"
||
res
=
1
done
return
$res
...
...
@@ -1416,7 +1684,7 @@ __epm_get_hilevel_name()
for
i
in
$@
;
do
local
pkg
# get short form in pkg
quiet
=
1
short
=
1
pkg
=
$(
__epm_query_name
$i
)
quiet
=
1
short
=
1
pkg
=
$(
__epm_query_name
$i
)
||
continue
# drop not installed packages
# if already short form, skipped
[
"
$pkg
"
=
"
$i
"
]
&&
echo
"
$i
"
&&
continue
# try get long form or use short form
...
...
@@ -1470,7 +1738,7 @@ __epm_query_name()
conary
)
CMD
=
"conary query"
;;
brew
)
home
brew
)
warning
"fix query"
return
1
;;
...
...
@@ -1486,8 +1754,9 @@ __epm_query_name()
is_installed
()
{
#pkg_filenames="$@" epm_query >/dev/null
epm installed
$@
>
/dev/null 2>/dev/null
pkg_filenames
=
"
$@
"
pkg_names
=
"
$@
"
epm_query
>
/dev/null 2>/dev/null
# broken way to recursive call here (overhead!)
#epm installed $@ >/dev/null 2>/dev/null
}
separate_installed
()
...
...
@@ -1569,6 +1838,7 @@ __do_query()
CMD
=
"rpm -qf"
;;
emerge
)
assure_exists equery
CMD
=
"equery belongs"
;;
pacman
)
...
...
@@ -1606,6 +1876,7 @@ __do_short_query()
dpkg_print_name_version
$(
dpkg
-S
$1
|
sed
-e
"s|:.*||"
|
grep
-v
"^diversion by"
)
return
;;
NOemerge
)
assure_exists equery
CMD
=
"equery belongs"
;;
NOpacman
)
...
...
@@ -1650,7 +1921,7 @@ epm_query_file()
epm_query_package
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Please, use search with some argument"
[
-n
"
$pkg_filenames
"
]
||
fatal
"Please, use search with some argument
or run epmqa for get all packages.
"
# FIXME: do it better
local
MGS
=
$(
eval
__epm_search_make_grep
$quoted_args
)
EXTRA_SHOWDOCMD
=
$MGS
...
...
@@ -1758,6 +2029,12 @@ epm_release_upgrade()
conary
)
epm Upgrade
;;
emerge
)
epm Upgrade
;;
guix
)
sudocmd guix pull
--verbose
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
@@ -1800,9 +2077,12 @@ epm_remove_names()
[
-z
"
$1
"
]
&&
return
case
$PMTYPE
in
apt-
rpm|apt-
dpkg
)
apt-dpkg
)
sudocmd apt-get remove
--purge
$@
return
;;
apt-rpm
)
sudocmd apt-get remove
$@
return
;;
deepsolver-rpm
)
sudocmd ds-remove
$@
return
;;
...
...
@@ -1840,6 +2120,9 @@ epm_remove_names()
nix
)
sudocmd nix-env
--uninstall
$@
return
;;
guix
)
sudocmd guix package
-r
$@
return
;;
chocolatey
)
sudocmd chocolatey uninstall
$@
return
;;
...
...
@@ -1861,9 +2144,12 @@ epm_remove_names()
epm_remove_nonint
()
{
case
$PMTYPE
in
apt-
rpm|apt-
dpkg
)
apt-dpkg
)
sudocmd apt-get
-y
--force-yes
remove
--purge
$@
return
;;
apt-rpm
)
sudocmd apt-get
-y
--force-yes
remove
$@
return
;;
urpm-rpm
)
sudocmd urpme
--auto
$@
return
;;
...
...
@@ -1950,6 +2236,7 @@ epm_removerepo()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists apt-repo
sudocmd apt-repo
rm
$pkg_filenames
;;
apt-dpkg
)
...
...
@@ -2000,6 +2287,7 @@ epm_repolist()
{
case
$PMTYPE
in
apt-rpm
)
assure_exists apt-repo
docmd apt-repo list
;;
deepsolver-rpm
)
...
...
@@ -2022,6 +2310,7 @@ case $PMTYPE in
docmd zypper sl
-d
;;
emerge
)
docmd eselect profile list
docmd layman
-L
;;
pacman
)
...
...
@@ -2039,31 +2328,44 @@ esac
# File bin/epm-requires:
epm_requires
()
epm_requires_files
()
{
local
CMD
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_files
"
]
||
return
case
$PMTYPE
in
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm
)
CMD
=
"rpm -q --requires -p"
;;
apt-dpkg
)
# FIXME: need package base
showcmd dpkg
-s
$pkg_files
a
=
dpkg
-s
$pkg_names
|
grep
"^Depends:"
|
sed
"s|^Depends:||g"
# FIXME: we need execute package name section too
return
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
case
$(
get_package_type
$pkg_files
)
in
rpm
)
docmd
"rpm -q --requires -p"
;;
deb
)
a
=
docmd dpkg
-I
$pkg_files
|
grep
"^ *Depends:"
|
sed
"s|^ *Depends:||g"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
esac
}
[
-n
"
$pkg_files
"
]
&&
docmd
$CMD
$pkg_files
epm_requires_names
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
return
case
$PMTYPE
in
apt-rpm|urpm-rpm|zypper-rpm
)
apt-rpm
)
# FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so)
if
is_installed
$pkg_names
;
then
CMD
=
"rpm -q --requires"
else
#EXTRA_SHOWDOCMD=' | grep "Depends:"'
#docmd apt-cache show $pkg_names | grep "Depends:"
#return
CMD
=
"apt-cache depends"
fi
;;
urpm-rpm|zypper-rpm
)
# FIXME: use hi level commands
CMD
=
"rpm -q --requires"
;;
...
...
@@ -2074,7 +2376,18 @@ case $PMTYPE in
CMD
=
"pactree"
;;
apt-dpkg
)
CMD
=
"apt-cache depends"
# FIXME: need fix for a few names case
if
is_installed
$pkg_names
;
then
showcmd dpkg
-s
$pkg_names
a
=
dpkg
-s
$pkg_names
|
grep
"^Depends:"
|
sed
"s|^Depends:||g"
return
else
CMD
=
"apt-cache depends"
fi
;;
emerge
)
assure_exists equery
CMD
=
"equery depgraph"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
...
...
@@ -2082,8 +2395,15 @@ case $PMTYPE in
esac
[
-n
"
$pkg_names
"
]
&&
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_names
}
epm_requires
()
{
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
epm_requires_files
epm_requires_names
}
# File bin/epm-search:
...
...
@@ -2141,6 +2461,9 @@ case $PMTYPE in
homebrew
)
CMD
=
"brew search"
;;
guix
)
CMD
=
"guix package -A"
;;
*
)
fatal
"Have no suitable search command for
$PMTYPE
"
;;
...
...
@@ -2157,20 +2480,39 @@ __epm_search_make_grep()
local
list
=
local
listN
=
for
i
in
$@
;
do
local
NOR
=
"
${
i
/^/
}
"
[
"
$NOR
"
=
"
$i
"
]
&&
list
=
"
$list
$NOR
"
||
listN
=
"
$listN
$NOR
"
case
"
$i
"
in
^
*
)
# will clean from ^ later (and have the bug here with empty arg if run with one ^ only)
listN
=
"
$listN
$i
"
;;
*
)
list
=
"
$list
$i
"
;;
esac
done
#list=$(strip_spaces $list | sed -e "s/ /|/g")
listN
=
$(
strip_spaces
$listN
|
sed
-e
"s/ /|/g"
)
listN
=
$(
strip_spaces
$listN
|
sed
-e
"s/ /|/g"
|
sed
-e
"s/
\^
//g"
)
[
-n
"
$listN
"
]
&&
echo
-n
" | egrep -i -v --
\"
$listN
\"
"
# FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
for
i
in
$list
;
do
echo
-n
" | egrep -i --color --
\"
$i
\"
"
# FIXME -n on MacOS?
echo
-n
" | egrep -i --
\"
$i
\"
"
done
local
COLO
=
""
# rule for colorife
for
i
in
$list
$listN
;
do
[
-n
"
$COLO
"
]
&&
COLO
=
"
$COLO
|"
COLO
=
"
$COLO$i
"
done
# FIXME -n on MacOS?
if
[
-n
"
$list
"
]
;
then
echo
-n
" | egrep -i --color --
\"
(
$COLO
)
\"
"
fi
}
...
...
@@ -2216,6 +2558,7 @@ case $PMTYPE in
local_content_search
$pkg_filenames
return
;;
apt-dpkg
)
assure_exists apt-file
sudocmd apt-file update
docmd apt-file search
$pkg_filenames
return
;;
...
...
@@ -2476,7 +2819,9 @@ epm_upgrade()
CMD
=
"chocolatey update all"
;;
homebrew
)
CMD
=
"brew upgrade"
#CMD="brew upgrade"
sudocmd
"brew upgrade
`
brew outdated
`
"
return
;;
ipkg
)
CMD
=
"ipkg upgrade"
...
...
@@ -2484,6 +2829,9 @@ epm_upgrade()
slackpkg
)
CMD
=
"/usr/sbin/slackpkg upgrade-all"
;;
guix
)
CMD
=
"guix package -u"
;;
*
)
fatal
"Have no suitable command for
$PMTYPE
"
;;
...
...
@@ -2513,7 +2861,7 @@ epm_Upgrade()
epm_whatdepends
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_
file
names
"
]
||
fatal
"Run query without names"
case
$PMTYPE
in
apt-rpm
)
...
...
@@ -2526,6 +2874,7 @@ case $PMTYPE in
CMD
=
"repoquery --whatrequires"
;;
emerge
)
assure_exists equery
CMD
=
"equery depends -a"
;;
*
)
...
...
@@ -2533,7 +2882,7 @@ case $PMTYPE in
;;
esac
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_
file
names
}
...
...
@@ -2542,7 +2891,7 @@ docmd $CMD $pkg_names
epm_whatprovides
()
{
local
CMD
[
-n
"
$pkg_names
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_
file
names
"
]
||
fatal
"Run query without names"
case
$PMTYPE
in
conary
)
...
...
@@ -2563,7 +2912,7 @@ case $PMTYPE in
;;
esac
docmd
$CMD
$pkg_names
docmd
$CMD
$pkg_
file
names
}
internal_distr_info
()
...
...
@@ -2807,6 +3156,16 @@ elif [ `uname` = "SunOS" ] ; then
DISTRIB_ID
=
"SunOS"
DISTRIB_RELEASE
=
$(
uname
-r
)
# fixme: can we detect by some file?
elif
[
`
uname
`
=
"Darwin"
]
;
then
DISTRIB_ID
=
"MacOS"
DISTRIB_RELEASE
=
$(
uname
-r
)
# fixme: move to up
elif
[
`
uname
`
=
"Linux"
]
&&
which guix 2>/dev/null
>
/dev/null
;
then
DISTRIB_ID
=
"GNU/Linux/Guix"
DISTRIB_RELEASE
=
$(
uname
-r
)
# try use standart LSB info by default
elif
distro lsb-release
&&
[
-n
"
$DISTRIB_RELEASE
"
]
;
then
# use LSB
...
...
@@ -2866,6 +3225,7 @@ esac
#PATH=$PATH:/sbin:/usr/sbin
set_sudo
set_eatmydata
check_tty
...
...
@@ -2885,7 +3245,7 @@ $(get_help HELPOPT)
print_version
()
{
echo
"EPM package manager version 1.4.
1
"
echo
"EPM package manager version 1.4.
2
"
echo
"Running on
$(
$DISTRVENDOR
)
('
$PMTYPE
' package manager uses '
$PKGFORMAT
' package format)"
echo
"Copyright (c) Etersoft 2012-2013"
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
...
...
@@ -2926,6 +3286,9 @@ case $progname in
epms
)
epm_cmd
=
search
;;
epmsf
)
epm_cmd
=
search_file
;;
epmq
)
epm_cmd
=
query
;;
...
...
@@ -2962,80 +3325,83 @@ check_command()
# Base commands
case
$1
in
-i
|
install
|
add
)
# HELPCMD: install package(s) from remote repositories or from local file
-i
|
install
|
add
|i
)
# HELPCMD: install package(s) from remote repositories or from local file
epm_cmd
=
install
;;
-e
|
-P
|
remove|delete|uninstall|erase
)
# HELPCMD: remove (delete) package(s) from the database and the system
-e
|
-P
|
remove|delete|uninstall|erase
|e
)
# HELPCMD: remove (delete) package(s) from the database and the system
epm_cmd
=
remove
;;
-s
|
search
)
# HELPCMD: search in remote package repositories
-s
|
search
)
# HELPCMD: search in remote package repositories
epm_cmd
=
search
;;
-qp
|
q
uery_package
)
# HELPCMD: search in the list of installed packages
-qp
|
q
p|query_package
)
# HELPCMD: search in the list of installed packages
epm_cmd
=
query_package
;;
-qf
|
which|belongs
)
# HELPCMD: query package(s) owning file
-qf
|
qf|which|belongs
)
# HELPCMD: query package(s) owning file
epm_cmd
=
query_file
;;
# Useful commands
reinstall
)
# HELPCMD: reinstall package(s) from remote repositories or from local file
reinstall
)
# HELPCMD: reinstall package(s) from remote repositories or from local file
epm_cmd
=
reinstall
;;
Install
)
# HELPCMD: perform update package repo info and install package(s) via install command
Install
)
# HELPCMD: perform update package repo info and install package(s) via install command
epm_cmd
=
Install
;;
-q
|
installed|query
)
# HELPCMD: check presence of package(s) and print this name (also --short is supported)
-q
|
q|installed|query
)
# HELPCMD: check presence of package(s) and print this name (also --short is supported)
epm_cmd
=
query
;;
-sf
|
sf|filesearch
)
# HELPCMD: search in which package a file is included
-sf
|
sf|filesearch
)
# HELPCMD: search in which package a file is included
epm_cmd
=
search_file
;;
-ql
|
filelist
)
# HELPCMD: print package file list
-ql
|
ql|filelist
)
# HELPCMD: print package file list
epm_cmd
=
filelist
;;
check|fix|verify
)
# HELPCMD: check local package base integrity and fix it
check|fix|verify
)
# HELPCMD: check local package base integrity and fix it
epm_cmd
=
check
;;
changelog|cl
)
# HELPCMD: show changelog for package
changelog|cl
|-cl
)
# HELPCMD: show changelog for package
epm_cmd
=
changelog
;;
-qi
|
info|show
)
# HELPCMD: print package detail info
-qi
|
qi|info|show
)
# HELPCMD: print package detail info
epm_cmd
=
info
;;
requires|deplist
)
# HELPCMD: print package requires
requires|deplist
)
# HELPCMD: print package requires
epm_cmd
=
requires
;;
provides
)
# HELPCMD: print package provides
provides
)
# HELPCMD: print package provides
epm_cmd
=
provides
;;
whatdepends
)
# HELPCMD: print packages dependences on that
whatdepends
)
# HELPCMD: print packages dependences on that
epm_cmd
=
whatdepends
;;
whatprovides
)
# HELPCMD: print packages provides that target
whatprovides
)
# HELPCMD: print packages provides that target
epm_cmd
=
whatprovides
;;
-qa
|
list|packages|-l
)
# HELPCMD: list of installed package(s)
conflicts
)
# HELPCMD: print package conflicts
epm_cmd
=
conflicts
;;
-qa
|
list|packages|-l|qa
)
# HELPCMD: list of installed package(s)
epm_cmd
=
packages
;;
programs
)
# HELPCMD: list of installed GUI program(s)
programs
)
# HELPCMD: list of installed GUI program(s)
epm_cmd
=
programs
;;
# Repository control
update
)
# HELPCMD: update remote package repository databases
update
)
# HELPCMD: update remote package repository databases
epm_cmd
=
update
;;
addrepo|ar
)
# HELPCMD: add package repo
addrepo|ar
)
# HELPCMD: add package repo
epm_cmd
=
addrepo
;;
repolist|sl|rl|listrepo
)
# HELPCMD: print repo list
repolist|sl|rl|listrepo
)
# HELPCMD: print repo list
epm_cmd
=
repolist
;;
removerepo|rr
)
# HELPCMD: remove package repo
removerepo|rr
)
# HELPCMD: remove package repo
epm_cmd
=
removerepo
;;
release-upgrade
)
# HELPCMD: update whole system to the next release
release-upgrade
)
# HELPCMD: update whole system to the next release
epm_cmd
=
release_upgrade
;;
kernel-update|kernel-upgrade|update-kernel|upgrade-kernel
)
# HELPCMD: update system kernel to the last repo version
...
...
@@ -3043,22 +3409,22 @@ check_command()
;;
# Other commands
clean
)
# HELPCMD: clean local package cache
clean
)
# HELPCMD: clean local package cache
epm_cmd
=
clean
;;
autoremove
)
# HELPCMD: auto remove unneeded package(s)
autoremove
)
# HELPCMD: auto remove unneeded package(s)
epm_cmd
=
autoremove
;;
upgrade|dist-upgrade
)
# HELPCMD: performs upgrades of package software distributions
upgrade|dist-upgrade
)
# HELPCMD: performs upgrades of package software distributions
epm_cmd
=
upgrade
;;
Upgrade
)
# HELPCMD: performs update && upgrade command
Upgrade
)
# HELPCMD: performs update && upgrade command
epm_cmd
=
Upgrade
;;
simulate
)
# HELPCMD: simulate install (it does check requires, minimally)
simulate
)
# HELPCMD: simulate install (it does check requires, minimally)
epm_cmd
=
simulate
;;
checkpkg|integrity
)
# HELPCMD: check package integrity
checkpkg|integrity
)
# HELPCMD: check package integrity
epm_cmd
=
checkpkg
;;
...
...
packed/serv.sh
View file @
efc1a899
...
...
@@ -95,7 +95,7 @@ showcmd()
if
[
-z
"
$quiet
"
]
;
then
set_boldcolor
$GREEN
local
PROMTSIG
=
"
\$
"
[
"
$UID
"
=
0
]
&&
PROMTSIG
=
"#"
[
"
$
EFF
UID
"
=
0
]
&&
PROMTSIG
=
"#"
echo
"
$PROMTSIG
$@
"
restore_color
fi
>
&2
...
...
@@ -170,15 +170,19 @@ store_output()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT
=
$(
mktemp
)
local
CMDSTATUS
=
$RC_STDOUT
.pipestatus
echo
1
>
$CMDSTATUS
#RC_STDERR=$(mktemp)
"
$@
"
2>&1 |
tee
$RC_STDOUT
(
"
$@
"
2>&1
;
echo
$?
>
$CMDSTATUS
)
|
tee
$RC_STDOUT
return
$(
cat
$CMDSTATUS
)
# bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return
$PIPESTATUS
#
return $PIPESTATUS
}
clean_store_output
()
{
rm
-f
$RC_STDOUT
rm
-f
$RC_STDOUT
$RC_STDOUT
.pipestatus
}
...
...
@@ -208,11 +212,10 @@ set_sudo()
# skip SUDO if disabled
[
-n
"
$EPMNOSUDO
"
]
&&
return
# set SUDO not for root user
[
-n
"
$UID
"
]
||
UID
=
`
id
-u
`
EFFUID
=
`
id
-u
`
# do not need sudo
[
$UID
=
"0"
]
&&
return
[
$
EFF
UID
=
"0"
]
&&
return
# use sudo if possible
which
sudo
>
/dev/null 2>/dev/null
&&
SUDO
=
"sudo"
&&
return
...
...
@@ -220,6 +223,61 @@ set_sudo()
SUDO
=
"fatal 'Can't find sudo. Please install sudo or run epm under root.'"
}
set_eatmydata
()
{
# skip if disabled
[
-n
"
$EPMNOEATMYDATA
"
]
&&
return
# use if possible
which eatmydata
>
/dev/null 2>/dev/null
||
return
SUDO
=
"
$SUDO
eatmydata"
echo
"Uwaga! eatmydata is installed, we will use it for disable all sync operations."
}
assure_exists
()
{
PATH
=
$PATH
:/sbin:/usr/sbin which
$1
2>/dev/null
>
/dev/null
&&
return
echo
"Install appropriate package for
$1
command..."
case
$1
in
equery|revdep-rebuild
)
epm
install
gentoolkit
;;
apt-repo
)
epm
install
apt-repo
;;
apt-file
)
epm
install
apt-file
;;
update-kernel|remove-old-kernels
)
epm
install
update-kernel
;;
*
)
fatal
"Internal error: Unknown binary
$1
to check if exists"
;;
esac
}
get_package_type
()
{
local
i
case
$1
in
*
.deb
)
echo
"deb"
return
;;
*
.rpm
)
echo
"rpm"
return
;;
*
)
#fatal "Don't know type of $1"
# return package name for info
echo
"
$1
"
return
1
;;
esac
}
get_help
()
{
grep
-v
--
"^#"
$0
|
grep
--
"#
$1
"
|
while
read
n
;
do
...
...
@@ -289,6 +347,9 @@ case $DISTRNAME in
OpenWRT
)
CMD
=
"ipkg"
;;
GNU/Linux/Guix
)
CMD
=
"guix"
;;
*
)
fatal
"Have no suitable DISTRNAME
$DISTRNAME
"
;;
...
...
@@ -836,6 +897,16 @@ elif [ `uname` = "SunOS" ] ; then
DISTRIB_ID
=
"SunOS"
DISTRIB_RELEASE
=
$(
uname
-r
)
# fixme: can we detect by some file?
elif
[
`
uname
`
=
"Darwin"
]
;
then
DISTRIB_ID
=
"MacOS"
DISTRIB_RELEASE
=
$(
uname
-r
)
# fixme: move to up
elif
[
`
uname
`
=
"Linux"
]
&&
which guix 2>/dev/null
>
/dev/null
;
then
DISTRIB_ID
=
"GNU/Linux/Guix"
DISTRIB_RELEASE
=
$(
uname
-r
)
# try use standart LSB info by default
elif
distro lsb-release
&&
[
-n
"
$DISTRIB_RELEASE
"
]
;
then
# use LSB
...
...
@@ -981,7 +1052,7 @@ $(get_help HELPOPT)
print_version
()
{
echo
"Service manager version 1.4.
1
"
echo
"Service manager version 1.4.
2
"
echo
"Running on
$(
$DISTRVENDOR
)
"
echo
"Copyright (c) Etersoft 2012, 2013"
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment