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
etersoft
eepm
Commits
2d72a762
Commit
2d72a762
authored
Jul 25, 2013
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Plain Diff
backported to M60P as 1.3.1-alt0.M60P.1 (with rpmbph script)
parents
6e2b73b3
ff699790
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
445 additions
and
128 deletions
+445
-128
TODO
TODO
+12
-0
epm
bin/epm
+14
-4
epm-autoremove
bin/epm-autoremove
+6
-5
epm-check
bin/epm-check
+3
-3
epm-checkpkg
bin/epm-checkpkg
+2
-0
epm-install
bin/epm-install
+75
-26
epm-install-emerge
bin/epm-install-emerge
+1
-1
epm-packages
bin/epm-packages
+23
-2
epm-provides
bin/epm-provides
+2
-0
epm-query
bin/epm-query
+59
-13
epm-reinstall
bin/epm-reinstall
+1
-1
epm-remove
bin/epm-remove
+15
-11
epm-requires
bin/epm-requires
+5
-0
epm-sh-functions
bin/epm-sh-functions
+47
-2
epm-simulate
bin/epm-simulate
+40
-15
epm-update
bin/epm-update
+1
-1
epm-upgrade
bin/epm-upgrade
+2
-1
epmql
bin/epmql
+2
-0
epmu
bin/epmu
+2
-0
serv
bin/serv
+6
-2
serv-list
bin/serv-list
+2
-2
serv-list_all
bin/serv-list_all
+1
-1
serv-list_startup
bin/serv-list_startup
+6
-1
serv-status
bin/serv-status
+6
-7
eepm.spec
eepm.spec
+35
-3
epm.sh
packed/epm.sh
+0
-0
serv.sh
packed/serv.sh
+77
-27
No files found.
TODO
View file @
2d72a762
...
@@ -2,3 +2,15 @@
...
@@ -2,3 +2,15 @@
3. Доделать и проверить deplist|requires
3. Доделать и проверить deplist|requires
https://wiki.archlinux.org/index.php/Pacman_Rosetta
https://wiki.archlinux.org/index.php/Pacman_Rosetta
Вывернуть:
Не case по каждой системе, а в каталоге по каждой системе разместить файлы, выполняющие нужные действия.
apt-rpm/install
apt-rpm/remove
при упаковке лучше собирать в один файл.
Внесто общих функций тоже модули.
serv должен уметь показывать порядок загрузки?
bin/epm
View file @
2d72a762
...
@@ -73,6 +73,7 @@ quiet=
...
@@ -73,6 +73,7 @@ quiet=
nodeps
=
nodeps
=
force
=
force
=
short
=
short
=
sort
=
non_interactive
=
non_interactive
=
skip_installed
=
skip_installed
=
show_command_only
=
show_command_only
=
...
@@ -110,6 +111,12 @@ case $progname in
...
@@ -110,6 +111,12 @@ case $progname in
epmqp
)
epmqp
)
epm_cmd
=
query_package
epm_cmd
=
query_package
;;
;;
epmql
)
epm_cmd
=
filelist
;;
epmu
)
epm_cmd
=
update
;;
epm|upm|eepm
)
epm|upm|eepm
)
;;
;;
*
)
*
)
...
@@ -148,7 +155,7 @@ check_command()
...
@@ -148,7 +155,7 @@ check_command()
Install
)
# HELPCMD: perform update package repo info and install package(s) via install command
Install
)
# HELPCMD: perform update package repo info and install package(s) via install command
epm_cmd
=
Install
epm_cmd
=
Install
;;
;;
-q
|
installed
)
# HELPCMD: check presence of package(s
)
-q
|
installed
|query
)
# HELPCMD: check presence of package(s) and print this name (also --short is supported
)
epm_cmd
=
query
epm_cmd
=
query
;;
;;
-sf
|
sf|filesearch
)
# HELPCMD: search in which package a file is included
-sf
|
sf|filesearch
)
# HELPCMD: search in which package a file is included
...
@@ -178,7 +185,7 @@ check_command()
...
@@ -178,7 +185,7 @@ check_command()
-qa
|
list|packages|-l
)
# HELPCMD: list of installed package(s)
-qa
|
list|packages|-l
)
# HELPCMD: list of installed package(s)
epm_cmd
=
packages
epm_cmd
=
packages
;;
;;
programs
)
# HELPCMD: list of installed program(s)
programs
)
# HELPCMD: list of installed
GUI
program(s)
epm_cmd
=
programs
epm_cmd
=
programs
;;
;;
...
@@ -198,7 +205,7 @@ check_command()
...
@@ -198,7 +205,7 @@ check_command()
release-upgrade
)
# HELPCMD: update whole system to the next release
release-upgrade
)
# HELPCMD: update whole system to the next release
epm_cmd
=
release_upgrade
epm_cmd
=
release_upgrade
;;
;;
kernel-update|kernel-upgrade|update-kernel
)
# HELPCMD: update system kernel to the last repo version
kernel-update|kernel-upgrade|update-kernel
|upgrade-kernel
)
# HELPCMD: update system kernel to the last repo version
epm_cmd
=
kernel_update
epm_cmd
=
kernel_update
;;
;;
...
@@ -258,9 +265,12 @@ check_option()
...
@@ -258,9 +265,12 @@ check_option()
--force
)
# HELPOPT: force install/remove package (f.i., override)
--force
)
# HELPOPT: force install/remove package (f.i., override)
force
=
"--force"
force
=
"--force"
;;
;;
--short
)
# HELPOPT: short output (
package instead package-version-release
)
--short
)
# HELPOPT: short output (
just 'package' instead 'package-version-release'
)
short
=
"--short"
short
=
"--short"
;;
;;
--sort
)
# HELPOPT: sort output, f.i. --sort=size (supported only for packages command)
sort
=
"
$1
"
;;
--auto
)
# HELPOPT: non interactive mode
--auto
)
# HELPOPT: non interactive mode
non_interactive
=
1
non_interactive
=
1
;;
;;
...
...
bin/epm-autoremove
View file @
2d72a762
...
@@ -20,9 +20,10 @@
...
@@ -20,9 +20,10 @@
epm_autoremove
()
epm_autoremove
()
{
{
case
$PMTYPE
in
case
$PMTYPE
in
#apt-rpm)
apt-rpm
)
# sudocmd apt-get autoclean
# ALT Linux only
# ;;
sudocmd remove-old-kernels
;;
apt-dpkg
)
apt-dpkg
)
sudocmd apt-get autoremove
sudocmd apt-get autoremove
;;
;;
...
@@ -32,7 +33,7 @@ case $PMTYPE in
...
@@ -32,7 +33,7 @@ case $PMTYPE in
yum-rpm
)
yum-rpm
)
# cleanup orphanes?
# cleanup orphanes?
while
true
;
do
while
true
;
do
docmd package-cleanup
--leaves
docmd package-cleanup
--leaves
$(
subst_option non_interactive
--assumeyes
)
# FIXME: package-cleanup have to use stderr for errors
# 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
--leaves
|
grep
-v
"Loaded plugins"
|
grep
-v
"Unable to"
)
[
-n
"
$PKGLIST
"
]
||
break
[
-n
"
$PKGLIST
"
]
||
break
...
@@ -48,7 +49,7 @@ case $PMTYPE in
...
@@ -48,7 +49,7 @@ case $PMTYPE in
sudocmd revdep-rebuild
sudocmd revdep-rebuild
;;
;;
pacman
)
pacman
)
sudocmd pacman
-Qdtq
| pacman
-Rs
-
sudocmd pacman
-Qdtq
|
sudocmd
pacman
-Rs
-
;;
;;
slackpkg
)
slackpkg
)
# clean-system removes non official packages
# clean-system removes non official packages
...
...
bin/epm-check
View file @
2d72a762
...
@@ -43,9 +43,9 @@ case $PMTYPE in
...
@@ -43,9 +43,9 @@ case $PMTYPE in
emerge
)
emerge
)
sudocmd revdep-rebuild
sudocmd revdep-rebuild
;;
;;
urpm-rpm
)
#
urpm-rpm)
#
sudocmd urpme --auto-orphans
#
sudocmd urpme --auto-orphans
;;
#
;;
zypper-rpm
)
zypper-rpm
)
sudocmd zypper verify
||
exit
sudocmd zypper verify
||
exit
;;
;;
...
...
bin/epm-checkpkg
View file @
2d72a762
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# TODO: move zip,rar,7z to arc project, and pack all to check_pkg_integrity
# also use arc project if installed
check_rpm_integrity
()
check_rpm_integrity
()
{
{
docmd rpm
--checksig
$@
docmd rpm
--checksig
$@
...
...
bin/epm-install
View file @
2d72a762
...
@@ -48,6 +48,38 @@ __use_zypper_no_gpg_checks()
...
@@ -48,6 +48,38 @@ __use_zypper_no_gpg_checks()
a
=
zypper
install
--help
2>&1 |
grep
-q
--
"--no-gpg-checks"
&&
echo
"--no-gpg-checks"
a
=
zypper
install
--help
2>&1 |
grep
-q
--
"--no-gpg-checks"
&&
echo
"--no-gpg-checks"
}
}
# args: cmd_reinstall, cmd_install, packages
__separate_sudocmd_foreach
()
{
local
cmd_re
=
$1
local
cmd_in
=
$2
shift
2
separate_installed
$@
if
[
-n
"
$pkg_noninstalled
"
]
;
then
sudocmd_foreach
"
$cmd_re
"
$pkg_noninstalled
||
return
fi
if
[
-n
"
$pkg_installed
"
]
;
then
sudocmd_foreach
"
$cmd_in
"
$pkg_installed
||
return
fi
return
0
}
# args: cmd_reinstall, cmd_install, packages
__separate_sudocmd
()
{
local
cmd_re
=
$1
local
cmd_in
=
$2
shift
2
separate_installed
$@
if
[
-n
"
$pkg_noninstalled
"
]
;
then
sudocmd
"
$cmd_re
"
$pkg_noninstalled
||
return
fi
if
[
-n
"
$pkg_installed
"
]
;
then
sudocmd
"
$cmd_in
"
$pkg_installed
||
return
fi
return
0
}
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_install_names
()
epm_install_names
()
{
{
...
@@ -92,31 +124,21 @@ epm_install_names()
...
@@ -92,31 +124,21 @@ epm_install_names()
sudocmd mpkg
install
$@
sudocmd mpkg
install
$@
return
;;
return
;;
npackd
)
npackd
)
separate_installed
$@
# FIXME: correct arg
# FIXME: fix return status
__separate_sudocmd_foreach
"npackdcl add --package="
"npackdcl update --package="
$@
# TODO: use upgrade if package is already installed
[
-n
"
$pkg_noninstalled
"
]
&&
sudocmd npackdcl add
--package
=
$@
$pkg_noninstalled
[
-n
"
$pkg_installed
"
]
&&
sudocmd npackdcl update
--package
=
$@
$pkg_installed
return
;;
return
;;
slackpkg
)
slackpkg
)
separate_installed
$@
__separate_sudocmd_foreach
"/usr/sbin/slackpkg install"
"/usr/sbin/slackpkg upgrade"
$@
# TODO: use upgrade if package is already installed
[
-n
"
$pkg_noninstalled
"
]
&&
sudocmd /usr/sbin/slackpkg
install
$pkg_noninstalled
[
-n
"
$pkg_installed
"
]
&&
sudocmd /usr/sbin/slackpkg upgrade
$pkg_installed
return
;;
return
;;
homebrew
)
homebrew
)
separate_installed
$@
__separate_sudocmd
"brew install"
"brew upgrade"
$@
[
-n
"
$pkg_noninstalled
"
]
&&
sudocmd brew
install
$pkg_noninstalled
[
-n
"
$pkg_installed
"
]
&&
sudocmd brew upgrade
$pkg_installed
return
;;
return
;;
ipkg
)
ipkg
)
[
-n
"
$force
"
]
&&
force
=
-force-depends
[
-n
"
$force
"
]
&&
force
=
-force-depends
sudocmd ipkg
$force
install
$@
sudocmd ipkg
$force
install
$@
return
;;
return
;;
nix
)
nix
)
separate_installed
$@
__separate_sudocmd
"nix-env --install"
"nix-env --upgrade"
$@
[
-n
"
$pkg_noninstalled
"
]
&&
sudocmd nix-env
--install
$pkg_noninstalled
[
-n
"
$pkg_installed
"
]
&&
sudocmd nix-env
--upgrade
$pkg_installed
return
;;
return
;;
*
)
*
)
fatal
"Have no suitable install command for
$PMTYPE
"
fatal
"Have no suitable install command for
$PMTYPE
"
...
@@ -168,10 +190,8 @@ epm_ni_install_names()
...
@@ -168,10 +190,8 @@ epm_ni_install_names()
sudocmd nix-env
--install
$@
sudocmd nix-env
--install
$@
return
;;
return
;;
slackpkg
)
slackpkg
)
separate_installed
$@
# FIXME: broken status when use batch and default answer
# FIXME: broken status when use batch and default answrt
__separate_sudocmd_foreach
"/usr/sbin/slackpkg -batch=on -default_answer=yes install"
"/usr/sbin/slackpkg -batch=on -default_answer=yes upgrade"
$@
[
-n
"
$pkg_noninstalled
"
]
&&
sudocmd /usr/sbin/slackpkg
-batch
=
on
-default_answer
=
yes install
$pkg_noninstalled
[
-n
"
$pkg_installed
"
]
&&
sudocmd /usr/sbin/slackpkg
-batch
=
on
-default_answer
=
yes
upgrade
$pkg_installed
return
;;
return
;;
*
)
*
)
fatal
"Have no suitable appropriate install command for
$PMTYPE
"
fatal
"Have no suitable appropriate install command for
$PMTYPE
"
...
@@ -179,6 +199,13 @@ epm_ni_install_names()
...
@@ -179,6 +199,13 @@ epm_ni_install_names()
esac
esac
}
}
__epm_check_if_rpm_already_installed
()
{
# Not: we can make optimize if just check version?
LANG
=
C
$SUDO
rpm
-Uvh
$force
$nodeps
$@
2>&1 |
grep
-q
"is already installed"
}
epm_install_files
()
epm_install_files
()
{
{
[
-z
"
$1
"
]
&&
return
[
-z
"
$1
"
]
&&
return
...
@@ -186,9 +213,12 @@ epm_install_files()
...
@@ -186,9 +213,12 @@ epm_install_files()
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm
)
apt-rpm
)
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
# TODO: check for "is already installed"
local
RES
=
$?
__epm_check_if_rpm_already_installed
$@
&&
return
# if run with --nodeps, do not fallback on hi level
# if run with --nodeps, do not fallback on hi level
[
-n
"
$nodeps
"
]
&&
return
[
-n
"
$nodeps
"
]
&&
return
$RES
# use install_names
# use install_names
;;
;;
...
@@ -197,35 +227,50 @@ epm_install_files()
...
@@ -197,35 +227,50 @@ epm_install_files()
if
[
-n
"
$non_interactive
"
]
;
then
if
[
-n
"
$non_interactive
"
]
;
then
DPKGOPTIONS
=
"--force-confdef --force-confold"
DPKGOPTIONS
=
"--force-confdef --force-confold"
fi
fi
# FIXME: return false in case no install and in case install with broken deps
sudocmd dpkg
$DPKGOPTIONS
-i
$@
sudocmd dpkg
$DPKGOPTIONS
-i
$@
local
RES
=
$?
# if run with --nodeps, do not fallback on hi level
# if run with --nodeps, do not fallback on hi level
[
-n
"
$nodeps
"
]
&&
return
[
-n
"
$nodeps
"
]
&&
return
$RES
# fall to apt-get -f install for fix deps
# fall to apt-get -f install for fix deps
# can't use APTOPTIONS with empty install args
# can't use APTOPTIONS with empty install args
epm_install_names
-f
epm_install_names
-f
# repeat install for get correct status
sudocmd dpkg
$DPKGOPTIONS
-i
$@
return
return
;;
;;
yum-rpm|dnf-rpm
)
yum-rpm|dnf-rpm
)
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
# if run with --nodeps, do not fallback on hi level
# if run with --nodeps, do not fallback on hi level
__epm_check_if_rpm_already_installed
$@
&&
return
[
-n
"
$nodeps
"
]
&&
return
[
-n
"
$nodeps
"
]
&&
return
YUMOPTIONS
=
--nogpgcheck
YUMOPTIONS
=
--nogpgcheck
# use install_names
# use install_names
;;
;;
zypper-rpm
)
zypper-rpm
)
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
local
RES
=
$?
__epm_check_if_rpm_already_installed
$@
&&
return
# if run with --nodeps, do not fallback on hi level
# if run with --nodeps, do not fallback on hi level
[
-n
"
$nodeps
"
]
&&
return
[
-n
"
$nodeps
"
]
&&
return
$RES
ZYPPEROPTIONS
=
$(
__use_zypper_no_gpg_checks
)
ZYPPEROPTIONS
=
$(
__use_zypper_no_gpg_checks
)
# use install_names
# use install_names
;;
;;
urpm-rpm
)
urpm-rpm
)
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
sudocmd rpm
-Uvh
$force
$nodeps
$@
&&
return
local
RES
=
$?
__epm_check_if_rpm_already_installed
$@
&&
return
# if run with --nodeps, do not fallback on hi level
# if run with --nodeps, do not fallback on hi level
[
-n
"
$nodeps
"
]
&&
return
[
-n
"
$nodeps
"
]
&&
return
$RES
URPMOPTIONS
=
--no-verify-rpm
URPMOPTIONS
=
--no-verify-rpm
# use install_names
# use install_names
...
@@ -239,11 +284,15 @@ epm_install_files()
...
@@ -239,11 +284,15 @@ epm_install_files()
return
;;
return
;;
pacman
)
pacman
)
sudocmd pacman
-U
--noconfirm
$force
$nodeps
$@
&&
return
sudocmd pacman
-U
--noconfirm
$force
$nodeps
$@
&&
return
[
-n
"
$nodeps
"
]
&&
return
local
RES
=
$?
[
-n
"
$nodeps
"
]
&&
return
$RES
sudocmd pacman
-U
$force
$@
sudocmd pacman
-U
$force
$@
return
;;
return
;;
slackpkg
)
slackpkg
)
sudocmd /sbin/installpkg
$@
# FIXME: check for full package name
# FIXME: broken status when use batch and default answer
__separate_sudocmd_foreach
"/sbin/installpkg"
"/sbin/upgradepkg"
$@
return
;;
return
;;
esac
esac
...
...
bin/epm-install-emerge
View file @
2d72a762
...
@@ -69,7 +69,7 @@ __emerge_install_ebuild()
...
@@ -69,7 +69,7 @@ __emerge_install_ebuild()
}
}
# install one ebuild
# install one ebuild
__emerge_install_tb
g
z2
()
__emerge_install_tbz2
()
{
{
local
TGDIR
=
/usr/portage/packages/app-arch
local
TGDIR
=
/usr/portage/packages/app-arch
mkdir
-p
$TGDIR
mkdir
-p
$TGDIR
...
...
bin/epm-packages
View file @
2d72a762
...
@@ -17,9 +17,26 @@
...
@@ -17,9 +17,26 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
__epm_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
;;
apt-dpkg
)
docmd dpkg-query
-W
--showformat
=
"
\$
{Size}
\$
{Package}-
\$
{Version}
\n
"
$pkg_filenames
|
sort
-n
;;
*
)
fatal
"Sorted package list are not realized for
$PMTYPE
"
;;
esac
}
epm_packages
()
epm_packages
()
{
{
local
CMD
local
CMD
[
-n
"
$sort
"
]
&&
__epm_packages_sort
&&
return
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm
)
apt-rpm
)
...
@@ -27,7 +44,8 @@ case $PMTYPE in
...
@@ -27,7 +44,8 @@ case $PMTYPE in
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qa --queryformat %{name}
\n
$pkg_filenames
"
;;
;;
apt-dpkg
)
apt-dpkg
)
CMD
=
"dpkg -l
$pkg_filenames
"
#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
"
[
-n
"
$short
"
]
&&
CMD
=
"dpkg-query -W --showformat=
\$
{Package}
\n
$pkg_filenames
"
;;
;;
yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm
)
yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm
)
...
@@ -58,7 +76,10 @@ case $PMTYPE in
...
@@ -58,7 +76,10 @@ case $PMTYPE in
slackpkg
)
slackpkg
)
CMD
=
"ls -1 /var/log/packages/"
CMD
=
"ls -1 /var/log/packages/"
if
[
-n
"
$short
"
]
;
then
if
[
-n
"
$short
"
]
;
then
docmd
ls
-1
/var/log/packages/ |
sed
-e
"s|-[0-9].*||g"
# 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"
return
return
fi
fi
;;
;;
...
...
bin/epm-provides
View file @
2d72a762
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
load_helper epm-query
epm_provides
()
epm_provides
()
{
{
local
CMD
local
CMD
...
...
bin/epm-query
View file @
2d72a762
#!/bin/sh
#!/bin/sh
#
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012
, 2013
Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2013
Vitaly Lipatov <lav@etersoft.ru>
#
#
# This program is free software: you can redistribute it and/or modify
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# it under the terms of the GNU Affero General Public License as published by
...
@@ -26,14 +26,63 @@ _query_via_packages_list()
...
@@ -26,14 +26,63 @@ _query_via_packages_list()
local
res
=
0
local
res
=
0
local
firstpkg
=
$1
local
firstpkg
=
$1
shift
shift
# separate first line for print out command
# separate first line for print out command
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"^
$firstpkg
$"
||
res
=
1
short
=
1
pkg_filenames
=
$firstpkg
epm_packages |
grep
--
"^
$firstpkg
$"
||
res
=
1
for
pkg
in
"
$@
"
;
do
for
pkg
in
"
$@
"
;
do
short
=
1
pkg_filenames
=
$pkg
epm_packages 2>/dev/null |
grep
--
"^
$pkg
$"
||
res
=
1
short
=
1
pkg_filenames
=
$pkg
epm_packages 2>/dev/null |
grep
--
"^
$pkg
$"
||
res
=
1
done
done
return
$res
return
$res
}
}
# internal use only
__epm_get_hilevel_nameform
()
{
[
-n
"
$*
"
]
||
return
case
$PMTYPE
in
apt-rpm
)
# use # as delimeter for apt
local
pkg
pkg
=
$(
rpm
-q
--queryformat
"%{NAME}#%{SERIAL}:%{VERSION}-%{RELEASE}
\n
"
$1
)
echo
$pkg
|
grep
-q
"(none)"
&&
pkg
=
$(
rpm
-q
--queryformat
"%{NAME}#%{VERSION}-%{RELEASE}
\n
"
$1
)
# HACK: can use only for multiple install packages like kernel
echo
$pkg
|
grep
-q
kernel
||
return
1
echo
$pkg
return
;;
yum-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
)
echo
$pkg
return
;;
*
)
return
1
;;
esac
}
# for local installed packages only
# used from epm remove
__epm_get_hilevel_name
()
{
local
i
for
i
in
$@
;
do
local
pkg
# get short form in pkg
quiet
=
1
short
=
1
pkg
=
$(
__epm_query_name
$i
)
# 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
done
}
__epm_query_file
()
__epm_query_file
()
{
{
local
CMD
local
CMD
...
@@ -43,13 +92,11 @@ __epm_query_file()
...
@@ -43,13 +92,11 @@ __epm_query_file()
case
$PMTYPE
in
case
$PMTYPE
in
*
-rpm
)
*
-rpm
)
CMD
=
"rpm -qp"
CMD
=
"rpm -qp"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -qp --queryformat %{name}
\n
"
;;
;;
apt-dpkg
)
apt-dpkg
)
CMD
=
"dpkg-deb --show"
CMD
=
"dpkg-deb --show --showformat=
\$
{Package}-
\$
{Version}
\n
"
# TODO: make rpm-like output
[
-n
"
$short
"
]
&&
CMD
=
"dpkg-query --show --showformat=
\$
{Package}
\n
"
#showcmd dpkg -l $pkg_filenames
#dpkg -l $pkg_filenames | grep "^ii"
#return
;;
;;
*
)
*
)
fatal
"Do not know command for query file package"
fatal
"Do not know command for query file package"
...
@@ -68,14 +115,12 @@ __epm_query_name()
...
@@ -68,14 +115,12 @@ __epm_query_name()
case
$PMTYPE
in
case
$PMTYPE
in
*
-rpm
)
*
-rpm
)
CMD
=
"rpm -q"
CMD
=
"rpm -q"
[
-n
"
$short
"
]
&&
CMD
=
"rpm -q --queryformat %{name}
\n
"
;;
;;
apt-dpkg
)
apt-dpkg
)
#docmd dpkg -l $@
#docmd dpkg -l $@ | grep "^ii"
docmd dpkg
-l
$@
|
grep
"^ii"
CMD
=
"dpkg-query -W --showformat=
\$
{Package}-
\$
{Version}
\n
"
# TODO: make rpm-like output
[
-n
"
$short
"
]
&&
CMD
=
"dpkg-query -W --showformat=
\$
{Package}
\n
"
#showcmd dpkg -l $pkg_filenames
#dpkg -l $pkg_filenames | grep "^ii"
return
;;
;;
npackd
)
npackd
)
CMD
=
"npackdcl path --package=
$@
"
CMD
=
"npackdcl path --package=
$@
"
...
@@ -84,6 +129,7 @@ __epm_query_name()
...
@@ -84,6 +129,7 @@ __epm_query_name()
warning
"fix query"
warning
"fix query"
return
1
return
1
;;
;;
# Note: slackpkg info pkgname
*
)
*
)
_query_via_packages_list
$@
_query_via_packages_list
$@
return
return
...
...
bin/epm-reinstall
View file @
2d72a762
...
@@ -36,7 +36,7 @@ epm_reinstall_names()
...
@@ -36,7 +36,7 @@ epm_reinstall_names()
esac
esac
# fallback to generic install
# fallback to generic install
epm_install_names
epm_install_names
$@
}
}
epm_reinstall_files
()
epm_reinstall_files
()
...
...
bin/epm-remove
View file @
2d72a762
#!/bin/sh
#!/bin/sh
#
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012
, 2013
Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2013
Vitaly Lipatov <lav@etersoft.ru>
#
#
# This program is free software: you can redistribute it and/or modify
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# it under the terms of the GNU Affero General Public License as published by
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
load_helper epm-query
# Try remove with low level removing
# Try remove with low level removing
epm_remove_low
()
epm_remove_low
()
{
{
...
@@ -26,8 +28,7 @@ epm_remove_low()
...
@@ -26,8 +28,7 @@ epm_remove_low()
sudocmd rpm
-ev
$nodeps
$@
sudocmd rpm
-ev
$nodeps
$@
return
;;
return
;;
apt-dpkg
)
apt-dpkg
)
[
-n
"
$nodeps
"
]
&&
nodeps
=
"--force-all"
sudocmd dpkg
-P
$(
subst_option nodeps
--force-all
)
$@
sudocmd dpkg
-P
$nodeps
$@
return
;;
return
;;
pkgsrc
)
pkgsrc
)
sudocmd pkg_delete
-r
$@
sudocmd pkg_delete
-r
$@
...
@@ -97,8 +98,7 @@ epm_remove_names()
...
@@ -97,8 +98,7 @@ epm_remove_names()
sudocmd brew remove
$@
sudocmd brew remove
$@
return
;;
return
;;
ipkg
)
ipkg
)
[
-n
"
$force
"
]
&&
force
=
-force-depends
sudocmd ipkg
$(
subst_option force
-force-depends
)
remove
$@
sudocmd ipkg
$force
remove
$@
return
;;
return
;;
*
)
*
)
fatal
"Have no suitable command for
$PMTYPE
"
fatal
"Have no suitable command for
$PMTYPE
"
...
@@ -173,18 +173,22 @@ epm_remove()
...
@@ -173,18 +173,22 @@ epm_remove()
return
return
fi
fi
[
-n
"
$pkg_files
"
]
&&
fatal
"FIXME: remove by package file is not supported yet"
# get full package name(s) from the package file(s)
[
-n
"
$pkg_files
"
]
&&
pkg_names
=
"
$pkg_names
$(
epm query
$pkg_files
)
"
[
-n
"
$pkg_names
"
]
||
fatal
"Run remove without args"
epm_remove_low
$pkg_names
&&
return
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run remove without args"
# get package name for hi level package management command (with version if supported and if possible)
epm_remove_low
$pkg_filenames
&&
return
pkg_names
=
$(
__epm_get_hilevel_name
$pkg_names
)
if
[
-n
"
$non_interactive
"
]
;
then
if
[
-n
"
$non_interactive
"
]
;
then
epm_remove_nonint
$pkg_
file
names
epm_remove_nonint
$pkg_names
local
RET
=
$?
local
RET
=
$?
# if not separate command, use usual command
# if not separate command, use usual command
[
"
$RET
"
=
"5"
]
||
return
$RET
[
"
$RET
"
=
"5"
]
||
return
$RET
fi
fi
epm_remove_names
$pkg_
file
names
epm_remove_names
$pkg_names
}
}
bin/epm-requires
View file @
2d72a762
...
@@ -22,14 +22,19 @@ epm_requires()
...
@@ -22,14 +22,19 @@ epm_requires()
local
CMD
local
CMD
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
[
-n
"
$pkg_filenames
"
]
||
fatal
"Run query without names"
# TODO: Здесь выбирать команду по расширению, а не по системному менеджеру
# В других таких случаях тоже
# В списке пакетов на установку проверять, что пакеты имеют соответствующее расширение
# by package file
# by package file
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm
)
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm
)
CMD
=
"rpm -q --requires -p"
CMD
=
"rpm -q --requires -p"
;;
;;
apt-dpkg
)
apt-dpkg
)
# FIXME: need package base
showcmd dpkg
-s
$pkg_files
showcmd dpkg
-s
$pkg_files
a
=
dpkg
-s
$pkg_names
|
grep
"^Depends:"
|
sed
"s|^Depends:||g"
a
=
dpkg
-s
$pkg_names
|
grep
"^Depends:"
|
sed
"s|^Depends:||g"
# FIXME: we need execute package name section too
return
return
;;
;;
*
)
*
)
...
...
bin/epm-sh-functions
View file @
2d72a762
...
@@ -96,7 +96,7 @@ docmd()
...
@@ -96,7 +96,7 @@ docmd()
"
$@
"
"
$@
"
}
}
#
Print command line and run command line
#
Run every arg with docmd
docmd_foreach
()
docmd_foreach
()
{
{
local
cmd
local
cmd
...
@@ -115,6 +115,19 @@ sudocmd()
...
@@ -115,6 +115,19 @@ sudocmd()
$SUDO
"
$@
"
$SUDO
"
$@
"
}
}
# Run every arg with sudocmd
sudocmd_foreach
()
{
local
cmd
cmd
=
"
$1
"
#showcmd "$@"
shift
for
pkg
in
"
$@
"
;
do
sudocmd
$cmd
$pkg
done
}
filter_strip_spaces
()
filter_strip_spaces
()
{
{
# possible use just
# possible use just
...
@@ -128,6 +141,28 @@ strip_spaces()
...
@@ -128,6 +141,28 @@ strip_spaces()
echo
"
$*
"
| filter_strip_spaces
echo
"
$*
"
| filter_strip_spaces
}
}
# param true false
subst_option
()
{
eval
"[ -n
\"\$
$1
\"
]"
&&
echo
"
$2
"
||
echo
"
$3
"
}
store_output
()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT
=
$(
mktemp
)
#RC_STDERR=$(mktemp)
"
$@
"
2>&1 |
tee
$RC_STDOUT
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return
$PIPESTATUS
}
clean_store_output
()
{
rm
-f
$RC_STDOUT
}
epm
()
epm
()
{
{
$PROGDIR
/epm
$@
$PROGDIR
/epm
$@
...
@@ -144,6 +179,16 @@ fatal()
...
@@ -144,6 +179,16 @@ fatal()
exit
1
exit
1
}
}
# Print warning message
warning
()
{
if
[
-z
"
$TEXTDOMAIN
"
]
;
then
echo
"Warning:
$@
"
>
&2
# else
# echog "Error in $0: $@" >&2
fi
}
set_sudo
()
set_sudo
()
{
{
SUDO
=
""
SUDO
=
""
...
@@ -165,7 +210,7 @@ set_sudo()
...
@@ -165,7 +210,7 @@ set_sudo()
# print options description from HELPCMD/HELPOPT lines in the code
# print options description from HELPCMD/HELPOPT lines in the code
get_help
()
get_help
()
{
{
grep
-
-
"#
$1
"
$0
|
while
read
n
;
do
grep
-
v
--
"^#"
$0
|
grep
--
"#
$1
"
|
while
read
n
;
do
opt
=
$(
echo
$n
|
sed
-e
"s|) #
$1
:.*||g"
)
opt
=
$(
echo
$n
|
sed
-e
"s|) #
$1
:.*||g"
)
desc
=
$(
echo
$n
|
sed
-e
"s|.*) #
$1
:||g"
)
desc
=
$(
echo
$n
|
sed
-e
"s|.*) #
$1
:||g"
)
printf
" %-20s %s
\n
"
$opt
"
$desc
"
printf
" %-20s %s
\n
"
$opt
"
$desc
"
...
...
bin/epm-simulate
View file @
2d72a762
...
@@ -31,9 +31,31 @@ __use_yum_assumeno()
...
@@ -31,9 +31,31 @@ __use_yum_assumeno()
a
=
yum
--help
2>&1 |
grep
-q
--
"--assumeno"
a
=
yum
--help
2>&1 |
grep
-q
--
"--assumeno"
}
}
__check_yum_result
()
{
grep
"^No package"
$1
&&
return
1
grep
"^Complete!"
$1
&&
return
0
grep
"^Exiting on user Command"
$1
&&
return
0
grep
"^Exiting on user command"
$1
&&
return
0
# return default result by default
return
$2
}
__check_pacman_result
()
{
grep
"^error: target not found:"
$1
&&
return
1
grep
"^Total Installed Size:"
$1
&&
return
0
grep
"^Total Download Size:"
$1
&&
return
0
# return default result by default
return
$2
}
_epm_do_simulate
()
_epm_do_simulate
()
{
{
local
CMD
local
CMD
local
RES
=
0
local
filenames
=
"
$*
"
local
filenames
=
"
$*
"
case
$PMTYPE
in
case
$PMTYPE
in
...
@@ -42,20 +64,17 @@ _epm_do_simulate()
...
@@ -42,20 +64,17 @@ _epm_do_simulate()
;;
;;
yum-rpm
)
yum-rpm
)
if
__use_yum_assumeno
;
then
if
__use_yum_assumeno
;
then
LC_ALL
=
C sudocmd yum
--assumeno
install
$filenames
LC_ALL
=
C store_output sudocmd yum
--assumeno
install
$filenames
# FIXME: check only error output
__check_yum_result
$RC_STDOUT
$?
LC_ALL
=
C sudocmd yum
--assumeno
install
$filenames
2>&1 |
grep
"^No package"
&&
return
1
LC_ALL
=
C sudocmd yum
--assumeno
install
$filenames
2>&1 |
grep
"^Complete!"
&&
return
0
LC_ALL
=
C sudocmd yum
--assumeno
install
$filenames
2>&1 |
grep
"^Exiting on user Command"
&&
return
0
LC_ALL
=
C sudocmd yum
--assumeno
install
$filenames
>
/dev/null 2>&1
||
return
else
else
LC_ALL
=
C
echo
n | sudocmd yum
install
$filenames
LC_ALL
=
C store_output sudocmd yum
install
$filenames
<<
EOF
# FIXME: check only error output
n
LC_ALL
=
C
echo
n | sudocmd yum
install
$filenames
2>&1 |
grep
"^No package"
&&
return
1
EOF
LC_ALL
=
C
echo
n | sudocmd yum
install
$filenames
2>&1 |
grep
"^Complete!"
&&
return
0
__check_yum_result
$RC_STDOUT
$?
LC_ALL
=
C
echo
n | sudocmd yum
install
$filenames
>
/dev/null 2>&1
||
return
fi
fi
return
0
;;
RES
=
$?
clean_store_output
return
$RES
;;
urpm-rpm
)
urpm-rpm
)
CMD
=
"urpmi --test --auto"
CMD
=
"urpmi --test --auto"
;;
;;
...
@@ -76,9 +95,13 @@ _epm_do_simulate()
...
@@ -76,9 +95,13 @@ _epm_do_simulate()
done
done
return
$res
;;
return
$res
;;
pacman
)
pacman
)
showcmd
$SUDO
pacman
-v
-S
$filenames
LC_ALL
=
C store_output sudocmd pacman
-v
-S
$filenames
<<
EOF
echo
no |
$SUDO
pacman
-v
-S
$filenames
no
return
;;
EOF
__check_pacman_result
$RC_STDOUT
$?
RES
=
$?
clean_store_output
return
$RES
;;
slackpkg
)
slackpkg
)
#docmd /usr/sbin/slackpkg -batch=on -default_answer=yes download
#docmd /usr/sbin/slackpkg -batch=on -default_answer=yes download
# just try search every package
# just try search every package
...
@@ -86,6 +109,8 @@ _epm_do_simulate()
...
@@ -86,6 +109,8 @@ _epm_do_simulate()
local
pkg res
local
pkg res
res
=
0
res
=
0
for
pkg
in
$filenames
;
do
for
pkg
in
$filenames
;
do
# FIXME: -[0-0] does not work in search!
# FIXME: we need strict search here (not find gst-plugins-base if search for gst-plugins
pkg_filenames
=
"
$pkg
-[0-9]"
epm_search |
grep
-E
"(installed|upgrade)"
&&
continue
pkg_filenames
=
"
$pkg
-[0-9]"
epm_search |
grep
-E
"(installed|upgrade)"
&&
continue
pkg_filenames
=
"
$pkg
"
epm_search |
grep
-E
"(installed|upgrade)"
&&
continue
pkg_filenames
=
"
$pkg
"
epm_search |
grep
-E
"(installed|upgrade)"
&&
continue
res
=
1
res
=
1
...
...
bin/epm-update
View file @
2d72a762
...
@@ -52,7 +52,7 @@ case $PMTYPE in
...
@@ -52,7 +52,7 @@ case $PMTYPE in
sudocmd emerge
--sync
sudocmd emerge
--sync
;;
;;
slackpkg
)
slackpkg
)
sudocmd /usr/sbin/slackpkg update
sudocmd /usr/sbin/slackpkg
-batch
=
on
update
;;
;;
deepsolver-rpm
)
deepsolver-rpm
)
sudocmd ds-update
sudocmd ds-update
...
...
bin/epm-upgrade
View file @
2d72a762
...
@@ -24,7 +24,8 @@ epm_upgrade()
...
@@ -24,7 +24,8 @@ epm_upgrade()
case
$PMTYPE
in
case
$PMTYPE
in
apt-rpm|apt-dpkg
)
apt-rpm|apt-dpkg
)
# FIXME: apt-get update before
# non_interactive
# Функцию добавления параметра при условии
CMD
=
"apt-get dist-upgrade"
CMD
=
"apt-get dist-upgrade"
;;
;;
yum-rpm
)
yum-rpm
)
...
...
bin/epmql
0 → 120000
View file @
2d72a762
epm
\ No newline at end of file
bin/epmu
0 → 120000
View file @
2d72a762
epm
\ No newline at end of file
bin/serv
View file @
2d72a762
...
@@ -141,7 +141,7 @@ show_command_only=
...
@@ -141,7 +141,7 @@ show_command_only=
serv_cmd
=
serv_cmd
=
service_name
=
service_name
=
params
=
params
=
withoutservicename
=
check_command
()
check_command
()
{
{
...
@@ -154,6 +154,7 @@ check_command()
...
@@ -154,6 +154,7 @@ check_command()
;;
;;
usage
)
# HELPCMD: print out usage of the service
usage
)
# HELPCMD: print out usage of the service
serv_cmd
=
usage
serv_cmd
=
usage
withoutservicename
=
1
;;
;;
#restart) # HELPCMD: restart service
#restart) # HELPCMD: restart service
#reload) # HELPCMD: reload service
#reload) # HELPCMD: reload service
...
@@ -168,12 +169,15 @@ check_command()
...
@@ -168,12 +169,15 @@ check_command()
;;
;;
list
)
# HELPCMD: list running services
list
)
# HELPCMD: list running services
serv_cmd
=
list
serv_cmd
=
list
withoutservicename
=
1
;;
;;
list-all
)
# HELPCMD: list all available services
list-all
)
# HELPCMD: list all available services
serv_cmd
=
list_all
serv_cmd
=
list_all
withoutservicename
=
1
;;
;;
list-startup
)
# HELPCMD: list all services to run on startup
list-startup
)
# HELPCMD: list all services to run on startup
serv_cmd
=
list_startup
serv_cmd
=
list_startup
withoutservicename
=
1
;;
;;
on|enable
)
# HELPCMD: add service to run on startup and start it now
on|enable
)
# HELPCMD: add service to run on startup and start it now
serv_cmd
=
enable
serv_cmd
=
enable
...
@@ -229,7 +233,7 @@ echover "service: $service_name"
...
@@ -229,7 +233,7 @@ echover "service: $service_name"
echover
"command:
$serv_cmd
"
echover
"command:
$serv_cmd
"
# Just printout help if run without args
# Just printout help if run without args
if
[
"
$serv_cmd
"
!=
"list"
]
&&
[
"
$serv_cmd
"
!=
"list_all
"
]
&&
[
-z
"
$service_name
"
]
;
then
if
[
-z
"
$withoutservicename
"
]
&&
[
-z
"
$service_name
"
]
;
then
print_version
print_version
echo
echo
fatal
"Run
$ $progname
--help for get help"
fatal
"Run
$ $progname
--help for get help"
...
...
bin/serv-list
View file @
2d72a762
...
@@ -30,13 +30,13 @@ serv_list()
...
@@ -30,13 +30,13 @@ serv_list()
sudocmd service
--status-all
sudocmd service
--status-all
;;
;;
systemd
)
systemd
)
sudocmd systemctl list-units
sudocmd systemctl list-units
$@
;;
;;
*
)
*
)
load_helper serv-list_all
load_helper serv-list_all
load_helper serv-status
load_helper serv-status
for
i
in
$(
serv_list_all
)
;
do
for
i
in
$(
serv_list_all
)
;
do
is_service_running
$i
&&
echo
$i
is_service_running
$i
>
/dev/null
&&
echo
$i
done
done
;;
;;
esac
esac
...
...
bin/serv-list_all
View file @
2d72a762
...
@@ -29,7 +29,7 @@ serv_list_all()
...
@@ -29,7 +29,7 @@ serv_list_all()
sudocmd
ls
-1
/etc/init.d/
*
|
sed
-e
"s|/etc/init.d/||g"
|
grep
-v
README
sudocmd
ls
-1
/etc/init.d/
*
|
sed
-e
"s|/etc/init.d/||g"
|
grep
-v
README
;;
;;
systemd
)
systemd
)
sudocmd systemctl list-unit-files
sudocmd systemctl list-unit-files
$@
;;
;;
*
)
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
fatal
"Have no suitable command for
$SERVICETYPE
"
...
...
bin/serv-list_startup
View file @
2d72a762
...
@@ -31,7 +31,12 @@ serv_list_startup()
...
@@ -31,7 +31,12 @@ serv_list_startup()
# sudocmd systemctl list-unit-files
# sudocmd systemctl list-unit-files
# ;;
# ;;
*
)
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
load_helper serv-list_all
load_helper serv-status
for
i
in
$(
serv_list_all |
cut
-f
1
-d
" "
|
grep
"
\.
service$"
)
;
do
is_service_autostart
>
/dev/null
$i
&&
echo
$i
done
;;
;;
esac
esac
}
}
bin/serv-status
View file @
2d72a762
#!/bin/sh
#!/bin/sh
#
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012
, 2013
Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2013
Vitaly Lipatov <lav@etersoft.ru>
#
#
# This program is free software: you can redistribute it and/or modify
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# it under the terms of the GNU Affero General Public License as published by
...
@@ -28,8 +28,7 @@ is_service_running()
...
@@ -28,8 +28,7 @@ is_service_running()
$SUDO
/etc/init.d/
$1
status
>
/dev/null
$SUDO
/etc/init.d/
$1
status
>
/dev/null
;;
;;
systemd
)
systemd
)
#sudocmd systemctl is-enabled $1
$SUDO
systemctl status
$1
>
/dev/null
fatal
"FIXME: don't know how detect current startup state"
;;
;;
*
)
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
fatal
"Have no suitable command for
$SERVICETYPE
"
...
@@ -48,7 +47,7 @@ is_service_autostart()
...
@@ -48,7 +47,7 @@ is_service_autostart()
fatal
"FIXME: don't know how detect current startup state"
fatal
"FIXME: don't know how detect current startup state"
;;
;;
systemd
)
systemd
)
sudocmd systemctl is-enabled
$1
.service
$SUDO
systemctl is-enabled
$1
;;
;;
*
)
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
fatal
"Have no suitable command for
$SERVICETYPE
"
...
@@ -58,7 +57,7 @@ is_service_autostart()
...
@@ -58,7 +57,7 @@ is_service_autostart()
serv_status
()
serv_status
()
{
{
is_service_autostart
$1
&&
echo
"Service
$1
is sheduled to run on startup"
||
echo
"Service
$1
will NOT run on startup"
is_service_autostart
$1
&&
echo
"Service
$1
is s
c
heduled to run on startup"
||
echo
"Service
$1
will NOT run on startup"
local
SERVICE
=
"
$1
"
local
SERVICE
=
"
$1
"
shift
shift
...
@@ -71,7 +70,7 @@ serv_status()
...
@@ -71,7 +70,7 @@ serv_status()
sudocmd /etc/init.d/
$SERVICE
status
"
$@
"
sudocmd /etc/init.d/
$SERVICE
status
"
$@
"
;;
;;
systemd
)
systemd
)
sudocmd systemctl status
$SERVICE
.service
"
$@
"
sudocmd systemctl status
$SERVICE
"
$@
"
;;
;;
*
)
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
fatal
"Have no suitable command for
$SERVICETYPE
"
...
...
eepm.spec
View file @
2d72a762
# This spec is backported to ALTLinux p6 automatically by rpmbph script. Do not edit it.
# This spec is backported to ALTLinux p6 automatically by rpmbph script. Do not edit it.
#
#
Name: eepm
Name: eepm
Version: 1.
2.6
Version: 1.
3.1
Release: alt0.M60P.1
Release: alt0.M60P.1
Summary: Etersoft EPM package manager
Summary: Etersoft EPM package manager
License: A
F
GPLv3
License: AGPLv3
Group: System/Configuration/Packaging
Group: System/Configuration/Packaging
Url: http://wiki.etersoft.ru/EPM
Url: http://wiki.etersoft.ru/EPM
...
@@ -46,6 +46,10 @@ install -m 0755 packed/serv.sh %buildroot/%_datadir/%name/serv-packed.sh
...
@@ -46,6 +46,10 @@ install -m 0755 packed/serv.sh %buildroot/%_datadir/%name/serv-packed.sh
mkdir -p %buildroot%_sysconfdir/bash_completion.d/
mkdir -p %buildroot%_sysconfdir/bash_completion.d/
install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/serv
install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/serv
ln -s serv %buildroot%_sysconfdir/bash_completion.d/cerv
# shebang.req.files
chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%files
%files
%doc README TODO LICENSE
%doc README TODO LICENSE
...
@@ -57,11 +61,39 @@ install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/se
...
@@ -57,11 +61,39 @@ install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/se
%_bindir/distr_info
%_bindir/distr_info
%_datadir/%name/
%_datadir/%name/
%_sysconfdir/bash_completion.d/serv
%_sysconfdir/bash_completion.d/serv
%_sysconfdir/bash_completion.d/cerv
%changelog
%changelog
* T
ue Apr 30 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.6
-alt0.M60P.1
* T
hu Jul 25 2013 Vitaly Lipatov <lav@altlinux.ru> 1.3.1
-alt0.M60P.1
- backport to ALTLinux p6 (by rpmbph script)
- backport to ALTLinux p6 (by rpmbph script)
* Wed Jul 24 2013 Vitaly Lipatov <lav@altlinux.ru> 1.3.1-alt1
- epm-packages: add size sort support for rpm and dpkg
- fix epm query for non rpm/deb systems
- epm-install: rewrite pkg_(non)installed for get correct return status
* Thu Jul 11 2013 Vitaly Lipatov <lav@altlinux.ru> 1.3.0-alt1
- slackware: fix repo update, fix install pkg from file
- query, packages: print out in name-version format
- remove: add support for remove by package file
- remove: improve remove versioned packages via apt and yum
* Sat Jun 29 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.9-alt1
- fix simulate for ArchLinux and old yum
- small fixes
* Wed Jun 26 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.8-alt1
- add epmql short command for epm -ql
- autoremove: add --auto support for yum
- epm-simulate: rewrite check yum result with store_output
* Wed Jun 19 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.7-alt1
- add epmu == epm update command
- serv: fix without param checking
- serv: fixes for systemd after real use
- epm-install: fix Slackware install with sudocmd_foreach
- epm-install: do not fall to hi level if rpm is already installed
* Tue Apr 30 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.6-alt1
* Tue Apr 30 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.6-alt1
- epm Install: do package base update only if really need install something
- epm Install: do package base update only if really need install something
...
...
packed/epm.sh
View file @
2d72a762
This diff is collapsed.
Click to expand it.
packed/serv.sh
View file @
2d72a762
...
@@ -124,6 +124,18 @@ sudocmd()
...
@@ -124,6 +124,18 @@ sudocmd()
$SUDO
"
$@
"
$SUDO
"
$@
"
}
}
sudocmd_foreach
()
{
local
cmd
cmd
=
"
$1
"
#showcmd "$@"
shift
for
pkg
in
"
$@
"
;
do
sudocmd
$cmd
$pkg
done
}
filter_strip_spaces
()
filter_strip_spaces
()
{
{
# possible use just
# possible use just
...
@@ -137,6 +149,27 @@ strip_spaces()
...
@@ -137,6 +149,27 @@ strip_spaces()
echo
"
$*
"
| filter_strip_spaces
echo
"
$*
"
| filter_strip_spaces
}
}
subst_option
()
{
eval
"[ -n
\"\$
$1
\"
]"
&&
echo
"
$2
"
||
echo
"
$3
"
}
store_output
()
{
# use make_temp_file from etersoft-build-utils
RC_STDOUT
=
$(
mktemp
)
#RC_STDERR=$(mktemp)
"
$@
"
2>&1 |
tee
$RC_STDOUT
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return
$PIPESTATUS
}
clean_store_output
()
{
rm
-f
$RC_STDOUT
}
epm
()
epm
()
{
{
$PROGDIR
/epm
$@
$PROGDIR
/epm
$@
...
@@ -150,6 +183,13 @@ fatal()
...
@@ -150,6 +183,13 @@ fatal()
exit
1
exit
1
}
}
warning
()
{
if
[
-z
"
$TEXTDOMAIN
"
]
;
then
echo
"Warning:
$@
"
>
&2
fi
}
set_sudo
()
set_sudo
()
{
{
SUDO
=
""
SUDO
=
""
...
@@ -170,7 +210,7 @@ set_sudo()
...
@@ -170,7 +210,7 @@ set_sudo()
get_help
()
get_help
()
{
{
grep
-
-
"#
$1
"
$0
|
while
read
n
;
do
grep
-
v
--
"^#"
$0
|
grep
--
"#
$1
"
|
while
read
n
;
do
opt
=
$(
echo
$n
|
sed
-e
"s|) #
$1
:.*||g"
)
opt
=
$(
echo
$n
|
sed
-e
"s|) #
$1
:.*||g"
)
desc
=
$(
echo
$n
|
sed
-e
"s|.*) #
$1
:||g"
)
desc
=
$(
echo
$n
|
sed
-e
"s|.*) #
$1
:||g"
)
printf
" %-20s %s
\n
"
$opt
"
$desc
"
printf
" %-20s %s
\n
"
$opt
"
$desc
"
...
@@ -235,7 +275,7 @@ case $DISTRNAME in
...
@@ -235,7 +275,7 @@ case $DISTRNAME in
CMD
=
"ipkg"
CMD
=
"ipkg"
;;
;;
*
)
*
)
fatal
"
Do not known
DISTRNAME
$DISTRNAME
"
fatal
"
Have no suitable
DISTRNAME
$DISTRNAME
"
;;
;;
esac
esac
PMTYPE
=
$CMD
PMTYPE
=
$CMD
...
@@ -259,7 +299,7 @@ serv_common()
...
@@ -259,7 +299,7 @@ serv_common()
sudocmd systemctl
"
$@
"
$SERVICE
sudocmd systemctl
"
$@
"
$SERVICE
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
...
@@ -284,7 +324,7 @@ serv_disable()
...
@@ -284,7 +324,7 @@ serv_disable()
sudocmd systemctl disable
$1
sudocmd systemctl disable
$1
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
...
@@ -308,7 +348,7 @@ serv_enable()
...
@@ -308,7 +348,7 @@ serv_enable()
sudocmd systemctl
enable
$1
sudocmd systemctl
enable
$1
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
...
@@ -326,13 +366,13 @@ serv_list()
...
@@ -326,13 +366,13 @@ serv_list()
sudocmd service
--status-all
sudocmd service
--status-all
;;
;;
systemd
)
systemd
)
sudocmd systemctl list-units
sudocmd systemctl list-units
$@
;;
;;
*
)
*
)
load_helper serv-list_all
load_helper serv-list_all
load_helper serv-status
load_helper serv-status
for
i
in
$(
serv_list_all
)
;
do
for
i
in
$(
serv_list_all
)
;
do
is_service_running
$i
&&
echo
$i
is_service_running
$i
>
/dev/null
&&
echo
$i
done
done
;;
;;
esac
esac
...
@@ -351,10 +391,10 @@ serv_list_all()
...
@@ -351,10 +391,10 @@ serv_list_all()
sudocmd
ls
-1
/etc/init.d/
*
|
sed
-e
"s|/etc/init.d/||g"
|
grep
-v
README
sudocmd
ls
-1
/etc/init.d/
*
|
sed
-e
"s|/etc/init.d/||g"
|
grep
-v
README
;;
;;
systemd
)
systemd
)
sudocmd systemctl list-unit-files
sudocmd systemctl list-unit-files
$@
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
...
@@ -365,8 +405,13 @@ serv_list_startup()
...
@@ -365,8 +405,13 @@ serv_list_startup()
{
{
case
$SERVICETYPE
in
case
$SERVICETYPE
in
*
)
*
)
fatal
"Do not known command for
$SERVICETYPE
"
load_helper serv-list_all
load_helper serv-status
for
i
in
$(
serv_list_all |
cut
-f
1
-d
" "
|
grep
"
\.
service$"
)
;
do
is_service_autostart
>
/dev/null
$i
&&
echo
$i
done
;;
;;
esac
esac
}
}
...
@@ -388,7 +433,7 @@ serv_start()
...
@@ -388,7 +433,7 @@ serv_start()
sudocmd systemctl start
"
$SERVICE
"
"
$@
"
sudocmd systemctl start
"
$SERVICE
"
"
$@
"
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
...
@@ -405,11 +450,10 @@ is_service_running()
...
@@ -405,11 +450,10 @@ is_service_running()
$SUDO
/etc/init.d/
$1
status
>
/dev/null
$SUDO
/etc/init.d/
$1
status
>
/dev/null
;;
;;
systemd
)
systemd
)
#sudocmd systemctl is-enabled $1
$SUDO
systemctl status
$1
>
/dev/null
fatal
"FIXME: don't know how detect current startup state"
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
...
@@ -424,17 +468,17 @@ is_service_autostart()
...
@@ -424,17 +468,17 @@ is_service_autostart()
fatal
"FIXME: don't know how detect current startup state"
fatal
"FIXME: don't know how detect current startup state"
;;
;;
systemd
)
systemd
)
sudocmd systemctl is-enabled
$1
.service
$SUDO
systemctl is-enabled
$1
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
serv_status
()
serv_status
()
{
{
is_service_autostart
$1
&&
echo
"Service
$1
is sheduled to run on startup"
||
echo
"Service
$1
will NOT run on startup"
is_service_autostart
$1
&&
echo
"Service
$1
is s
c
heduled to run on startup"
||
echo
"Service
$1
will NOT run on startup"
local
SERVICE
=
"
$1
"
local
SERVICE
=
"
$1
"
shift
shift
...
@@ -447,10 +491,10 @@ serv_status()
...
@@ -447,10 +491,10 @@ serv_status()
sudocmd /etc/init.d/
$SERVICE
status
"
$@
"
sudocmd /etc/init.d/
$SERVICE
status
"
$@
"
;;
;;
systemd
)
systemd
)
sudocmd systemctl status
$SERVICE
.service
"
$@
"
sudocmd systemctl status
$SERVICE
"
$@
"
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
...
@@ -473,7 +517,7 @@ serv_stop()
...
@@ -473,7 +517,7 @@ serv_stop()
sudocmd systemctl stop
$SERVICE
"
$@
"
sudocmd systemctl stop
$SERVICE
"
$@
"
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
...
@@ -499,7 +543,7 @@ serv_try_restart()
...
@@ -499,7 +543,7 @@ serv_try_restart()
sudocmd systemctl try-restart
$SERVICE
"
$@
"
sudocmd systemctl try-restart
$SERVICE
"
$@
"
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
}
}
...
@@ -529,7 +573,7 @@ serv_usage()
...
@@ -529,7 +573,7 @@ serv_usage()
sudocmd systemctl
$SERVICE
2>&1
sudocmd systemctl
$SERVICE
2>&1
;;
;;
*
)
*
)
fatal
"
Do not known
command for
$SERVICETYPE
"
fatal
"
Have no suitable
command for
$SERVICETYPE
"
;;
;;
esac
esac
...
@@ -644,7 +688,9 @@ if distro altlinux-release ; then
...
@@ -644,7 +688,9 @@ if distro altlinux-release ; then
elif
distro gentoo-release
;
then
elif
distro gentoo-release
;
then
DISTRIB_ID
=
"Gentoo"
DISTRIB_ID
=
"Gentoo"
DISTRIB_RELEASE
=
`
basename
$(
readlink
$ROOTDIR
/etc/make.profile
)
`
MAKEPROFILE
=
$(
readlink
$ROOTDIR
/etc/portage/make.profile 2>/dev/null
)
||
MAKEPROFILE
=
$(
readlink
$ROOTDIR
/etc/make.profile
)
DISTRIB_RELEASE
=
`
basename
$MAKEPROFILE
`
echo
$DISTRIB_RELEASE
|
grep
-q
"[0-9]"
||
DISTRIB_RELEASE
=
`
basename
$(
dirname
$MAKEPROFILE
)
`
# Slackware based
# Slackware based
elif
distro mopslinux-version
;
then
elif
distro mopslinux-version
;
then
...
@@ -890,7 +936,7 @@ case $DISTRNAME in
...
@@ -890,7 +936,7 @@ case $DISTRNAME in
# CMD="chocolatey"
# CMD="chocolatey"
# ;;
# ;;
*
)
*
)
fatal
"
Do not known
DISTRNAME
$DISTRNAME
yet"
fatal
"
Have no suitable
DISTRNAME
$DISTRNAME
yet"
;;
;;
esac
esac
...
@@ -920,7 +966,7 @@ $(get_help HELPOPT)
...
@@ -920,7 +966,7 @@ $(get_help HELPOPT)
print_version
()
print_version
()
{
{
echo
"Service manager version 1.
2.2
"
echo
"Service manager version 1.
3.0
"
echo
"Running on
$(
$DISTRVENDOR
)
"
echo
"Running on
$(
$DISTRVENDOR
)
"
echo
"Copyright (c) Etersoft 2012, 2013"
echo
"Copyright (c) Etersoft 2012, 2013"
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
echo
"This program may be freely redistributed under the terms of the GNU AGPLv3."
...
@@ -940,7 +986,7 @@ show_command_only=
...
@@ -940,7 +986,7 @@ show_command_only=
serv_cmd
=
serv_cmd
=
service_name
=
service_name
=
params
=
params
=
withoutservicename
=
check_command
()
check_command
()
{
{
...
@@ -953,6 +999,7 @@ check_command()
...
@@ -953,6 +999,7 @@ check_command()
;;
;;
usage
)
# HELPCMD: print out usage of the service
usage
)
# HELPCMD: print out usage of the service
serv_cmd
=
usage
serv_cmd
=
usage
withoutservicename
=
1
;;
;;
#restart) # HELPCMD: restart service
#restart) # HELPCMD: restart service
#reload) # HELPCMD: reload service
#reload) # HELPCMD: reload service
...
@@ -967,12 +1014,15 @@ check_command()
...
@@ -967,12 +1014,15 @@ check_command()
;;
;;
list
)
# HELPCMD: list running services
list
)
# HELPCMD: list running services
serv_cmd
=
list
serv_cmd
=
list
withoutservicename
=
1
;;
;;
list-all
)
# HELPCMD: list all available services
list-all
)
# HELPCMD: list all available services
serv_cmd
=
list_all
serv_cmd
=
list_all
withoutservicename
=
1
;;
;;
list-startup
)
# HELPCMD: list all services to run on startup
list-startup
)
# HELPCMD: list all services to run on startup
serv_cmd
=
list_startup
serv_cmd
=
list_startup
withoutservicename
=
1
;;
;;
on|enable
)
# HELPCMD: add service to run on startup and start it now
on|enable
)
# HELPCMD: add service to run on startup and start it now
serv_cmd
=
enable
serv_cmd
=
enable
...
@@ -1028,7 +1078,7 @@ echover "service: $service_name"
...
@@ -1028,7 +1078,7 @@ echover "service: $service_name"
echover
"command:
$serv_cmd
"
echover
"command:
$serv_cmd
"
# Just printout help if run without args
# Just printout help if run without args
if
[
"
$serv_cmd
"
!=
"list"
]
&&
[
"
$serv_cmd
"
!=
"list_all
"
]
&&
[
-z
"
$service_name
"
]
;
then
if
[
-z
"
$withoutservicename
"
]
&&
[
-z
"
$service_name
"
]
;
then
print_version
print_version
echo
echo
fatal
"Run
$ $progname
--help for get help"
fatal
"Run
$ $progname
--help for get help"
...
...
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