Commit a7bd6270 authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to M60P as 1.2.3-alt0.M60P.1 (with rpmbph script)

parents 19ee114a aa4ddf98
......@@ -9,8 +9,8 @@ install:
#install -m 755 `ls -1 bin/* | grep -v "-"` $(DESTDIR)$(bindir)/
cp -a `ls -1 bin/* | grep -v "-"` $(DESTDIR)$(bindir)/
chmod 0755 $(DESTDIR)$(bindir)/*
sed -e "s|SHAREDIR=.*|SHAREDIR=$(instpkgdatadir)|g" <bin/epm >$(DESTDIR)$(bindir)/epm
sed -e "s|SHAREDIR=.*|SHAREDIR=$(instpkgdatadir)|g" <bin/serv >$(DESTDIR)$(bindir)/serv
sed -e "s|SHAREDIR=.*|SHAREDIR=$(instpkgdatadir)|g" -e "s|@VERSION@|$(version)|g" <bin/epm >$(DESTDIR)$(bindir)/epm
sed -e "s|SHAREDIR=.*|SHAREDIR=$(instpkgdatadir)|g" -e "s|@VERSION@|$(version)|g" <bin/serv >$(DESTDIR)$(bindir)/serv
mkdir -p $(DESTDIR)$(pkgdatadir)/
install -m 644 `ls -1 bin/* | grep "-"` $(DESTDIR)$(pkgdatadir)/
# cerv(8) completion
# This completes on a list of all available services for the
# 'cerv' command, followed by that script's available commands
#
_service_list()
{
COMPREPLY=( $( cerv list-all 2>/dev/null ; echo "list list-all list-startup" ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
}
_service_usage_list()
{
local USLIST=$(cerv ${prev##*/} usage 2>/dev/null | sed -e "y/|/ /" -ne "s/^.*\(u\|U\|msg_u\)sage.*{\(.*\)}.*$/\2/p")
COMPREPLY=( $( compgen -W '$USLIST' -- "$cur" ) )
}
_cerv()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
# don't complete for things like killall, ssh and mysql if it's
# the standalone command, rather than the init script
[[ ${COMP_WORDS[0]} != "cerv" ]] && return 0
# don't complete past 2nd token
[ $COMP_CWORD -gt 2 ] && return 0
if [[ $COMP_CWORD -eq 1 && $prev == "cerv" ]]; then
_service_list
else
_service_usage_list
fi
return 0
} &&
complete -F _cerv cerv
serv
\ No newline at end of file
......@@ -47,7 +47,7 @@ pkgtype()
freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;;
archlinux) echo "tar.xz" ;;
archlinux) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
debian|ubuntu|mint|runtu) echo "deb" ;;
......
......@@ -18,8 +18,10 @@
#
PROGDIR=$(dirname $0)
[ "$PROGDIR" = "." ] && PROGDIR=$(pwd)
# will replaced to /usr/share/eepm during install
SHAREDIR=$(dirname $0)
SHAREDIR=$PROGDIR
load_helper()
{
......@@ -56,10 +58,11 @@ print_version()
{
echo "EPM package manager version @VERSION@"
echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
echo "Copyright (c) Etersoft 2012"
echo "This program may be freely redistributed under the terms of the GNU GPL."
echo "Copyright (c) Etersoft 2012-2013"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
}
Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager"
......@@ -69,6 +72,7 @@ verbose=
quiet=
nodeps=
force=
short=
non_interactive=
skip_installed=
show_command_only=
......@@ -77,6 +81,7 @@ pkg_files=
pkg_names=
progname="${0##*/}"
case $progname in
epmi)
epm_cmd=install
......@@ -84,12 +89,18 @@ case $progname in
epme)
epm_cmd=remove
;;
epmcl)
epm_cmd=changelog
;;
epms)
epm_cmd=search
;;
epmq)
epm_cmd=query
;;
epmqi)
epm_cmd=info
;;
epmqf)
epm_cmd=query_file
;;
......@@ -112,6 +123,7 @@ check_command()
# do not override command
[ -z "$epm_cmd" ] || return
# Base commands
case $1 in
-i|install|add) # HELPCMD: install package(s) from remote repositories or from local file
epm_cmd=install
......@@ -129,6 +141,7 @@ check_command()
epm_cmd=query_file
;;
# Useful commands
reinstall) # HELPCMD: reinstall package(s) from remote repositories or from local file
epm_cmd=reinstall
;;
......@@ -156,7 +169,11 @@ check_command()
-qa|list|packages|-l) # HELPCMD: list of installed package(s)
epm_cmd=packages
;;
programs) # HELPCMD: list of installed program(s)
epm_cmd=programs
;;
# Repository control
update) # HELPCMD: update remote package repository databases
epm_cmd=update
;;
......@@ -169,7 +186,14 @@ check_command()
removerepo|rr) # HELPCMD: remove package repo
epm_cmd=removerepo
;;
release-upgrade) # HELPCMD: update whole system to the next release
epm_cmd=release_upgrade
;;
kernel-update|kernel-upgrade|update-kernel) # HELPCMD: update system kernel to the last repo version
epm_cmd=kernel_update
;;
# Other commands
clean) # HELPCMD: clean local package cache
epm_cmd=clean
;;
......@@ -179,6 +203,9 @@ check_command()
upgrade|dist-upgrade) # HELPCMD: performs upgrades of package software distributions
epm_cmd=upgrade
;;
Upgrade) # HELPCMD: performs update && upgrade command
epm_cmd=Upgrade
;;
simulate) # HELPCMD: simulate install (it does check requires, minimally)
epm_cmd=simulate
;;
......@@ -222,6 +249,9 @@ check_option()
--force) # HELPOPT: force install/remove package (f.i., override)
force="--force"
;;
--short) # HELPOPT: short output (package instead package-version-release)
short="--short"
;;
--auto) # HELPOPT: non interactive mode
non_interactive=1
;;
......@@ -236,7 +266,7 @@ for opt in "$@" ; do
check_command $opt && continue
check_option $opt && continue
if [ -f "$opt" ] ; then
if [ -f "$opt" ] && echo $opt | grep -q "\." ; then
pkg_files="$pkg_files $opt"
else
pkg_names="$pkg_names $opt"
......@@ -248,15 +278,16 @@ pkg_names=$(strip_spaces "$pkg_names")
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
echover "command: $epm_cmd"
echover "pkg_files=$pkg_files"
echover "pkg_names=$pkg_names"
# Just debug
#echover "command: $epm_cmd"
#echover "pkg_files=$pkg_files"
#echover "pkg_names=$pkg_names"
# Just printout help if run without args
if [ -z "$epm_cmd" ] ; then
print_version
echo
fatal "Run $ epm --help for get help"
fatal "Run $ $progname --help for get help"
fi
# Run helper for command
......
#!/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-update
load_helper epm-upgrade
epm_Upgrade()
{
case $PMTYPE in
yum-rpm)
;;
*)
epm_update || return
;;
esac
epm_upgrade $pkg_filenames
}
......@@ -40,6 +40,8 @@ case $PMTYPE in
;;
pacman)
echo "You need manually add repo to /etc/pacman.conf"
# Only for alone packages:
#sudocmd repo-add $pkg_filenames
;;
npackd)
docmd npackdcl add-repo --url=$pkg_filenames
......
......@@ -24,7 +24,10 @@ case $PMTYPE in
# sudocmd apt-get autoclean
# ;;
apt-dpkg)
sudocmd apt-get autoclean
sudocmd apt-get autoremove
;;
aura)
sudocmd aura -Oj
;;
#yum-rpm)
# sudocmd yum clean all
......
......@@ -21,7 +21,7 @@ load_helper epm-query
__epm_changelog_files()
{
[ -z "$@" ] && return
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm)
......@@ -39,7 +39,7 @@ __epm_changelog_files()
__epm_changelog_local_names()
{
[ -z "$@" ] && return
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
......@@ -51,9 +51,10 @@ __epm_changelog_local_names()
;;
emerge)
docmd view /usr/portage/category/$1/ChangeLog | less
# docmd equery changes -f $1 | less
;;
pacman)
docmd pacman -Qc package | less
docmd pacman -Qc $1 | less
;;
*)
fatal "Do not known command for $PMTYPE"
......@@ -63,7 +64,7 @@ __epm_changelog_local_names()
__epm_changelog_unlocal_names()
{
[ -z "$@" ] && return
[ -z "$*" ] && return
case $PMTYPE in
#apt-rpm)
......
#!/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
......@@ -22,17 +22,35 @@ epm_check()
case $PMTYPE in
apt-rpm|apt-dpkg)
#sudocmd apt-get check || exit
sudocmd apt-get update || exit
#sudocmd apt-get update || exit
sudocmd apt-get -f install || exit
;;
apt-dpkg)
sudocmd apt-get update || exit
#sudocmd apt-get update || exit
#sudocmd apt-get check || exit
sudocmd apt-get -f install || exit
sudocmd apt-get autoremove
;;
yum-rpm)
docmd package-cleanup --leaves
a= package-cleanup --leaves | xargs yum remove
docmd yum check
docmd package-cleanup --problems
#docmd package-cleanup --dupes
sudocmd package-cleanup --cleandupes
# cleanup orphanes?
while true ; do
docmd package-cleanup --leaves
# FIXME: package-cleanup have to use stderr for errors
local PKGLIST=$(package-cleanup --leaves | grep -v "Loaded plugins" | grep -v "Unable to")
[ -n "$PKGLIST" ] || break
sudocmd yum remove $PKGLIST
done
docmd rpm -Va --nofiles --nodigest
;;
pacman)
sudocmd revdep-rebuild
;;
urpm-rpm)
sudocmd urpme --auto-orphans
......
......@@ -85,12 +85,49 @@ check_pkg_integrity()
local EXT=`echo "$1" | sed -e "s|.*\.\([a-z0-9]*\)\$|\1|g"`
local PKG="$1"
local RET
# TODO: Попробовать здесь оставить возможность перегрузки функций
case $EXT in
rpm)
docmd rpm --checksig $@
;;
deb)
# FIXME: debsums -ca package ?
docmd dpkg --contents $@
;;
bz2)
docmd bunzip -t $1
;;
#*)
# fatal "Unknown package extension '$EXT' in $PKG package"
# ;;
esac
check_${EXT}_integrity "$PKG" || fatal "Unknown package extension '$EXT' in $PKG package"
}
__epm_check_installed_pkg()
{
case $PMTYPE in
*-rpm)
docmd rpm -V $@
;;
*-dpkg)
docmd debsums $@
;;
*)
fatal "Do not known command for $PMTYPE"
;;
esac
}
epm_checkpkg()
{
if [ -n "$pkg_names" ] ; then
__epm_check_installed_pkg $pkg_names
return
fi
[ -n "$pkg_files" ] || fatal "Run without names"
local pkg
for pkg in $pkg_files ; do
......
......@@ -27,9 +27,15 @@ case $PMTYPE in
sudocmd yum clean all
sudocmd yum makecache
;;
dnf-rpm)
sudocmd dnf clean all
;;
urpm-rpm)
sudocmd urpmi --clean
;;
pacman)
sudocmd pacman -Sc
;;
zypper-rpm)
sudocmd zypper clean
;;
......
......@@ -23,7 +23,7 @@ __epm_filelist_file()
{
local CMD
[ -z "$@" ] && return
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
......@@ -44,7 +44,7 @@ __epm_filelist_name()
{
local CMD
[ -z "$@" ] && return
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm)
......@@ -63,7 +63,8 @@ __epm_filelist_name()
CMD="rpm -ql"
;;
pacman)
CMD="pacman -Ql"
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g"
return
;;
slackpkg)
is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized"
......
......@@ -47,13 +47,22 @@ case $PMTYPE in
__epm_info_rpm_low && return
docmd yum info $pkg_names
;;
dnf-rpm)
__epm_info_rpm_low && return
docmd dnf info $pkg_names
;;
zypper-rpm)
__epm_info_rpm_low && return
docmd zypper info $pkg_names
;;
pacman)
is_installed $pkg_names && docmd pacman -Qi $pkg_names && return
docmd pacman -Si $pkg_names
;;
aura)
is_installed $pkg_names && docmd pacman -Qi $pkg_names && return
docmd aura -Ai $pkg_names
;;
npackd)
# FIXME: --version=
docmd npackdcl info --package=$pkg_names
......@@ -61,6 +70,9 @@ case $PMTYPE in
slackpkg)
docmd /usr/sbin/slackpkg info $pkg_names
;;
ipkg)
docmd ipkg info $pkg_names
;;
*)
fatal "Do not known command for $PMTYPE"
;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-13 Etersoft
# Copyright (C) 2012-13 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,28 +17,26 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-query
# TODO: use when run install with epm --skip-installed install
filter_out_installed_packages()
{
[ -z "$skip_installed" ] && cat && return
# TODO: rewrite with use is_installed
# TODO: use this more effectively way
#for i in $(cat) ; do
# rpm -q $i >/dev/null && continue
# echo $i
#done |
case $PKGFORMAT in
"rpm")
LANG=C LC_ALL=C xargs -n1 rpm -q 2>&1 | grep 'is not installed' |
sed -e 's|^.*package \(.*\) is not installed.*|\1|g'
;;
"deb")
LANG=C LC_ALL=C xargs -n1 dpkg -L 2>&1 | grep 'is not installed.' |
sed -e 's|^Package .\(.*\). is not installed.*|\1|g'
LANG=C LC_ALL=C xargs -n1 dpkg -l 2>&1 | grep -i 'no packages found matching' |
sed -e 's|\.\+$||g' -e 's|^.*[Nn]o packages found matching \(.*\)|\1|g'
;;
*)
cat
for i in $(cat) ; do
is_installed $i || echo $i
done
;;
esac | sed -e "s|rpm-build-altlinux-compat[^ ]*||g" | filter_strip_spaces
}
......@@ -55,35 +53,52 @@ epm_install_names()
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|apt-dpkg)
sudocmd apt-get install $@
sudocmd apt-get $APTOPTIONS install $@
return ;;
deepsolver-rpm)
sudocmd ds-install $@
return ;;
urpm-rpm)
sudocmd urpmi $@
sudocmd urpmi $URPMOPTIONS $@
return ;;
pkg_add)
pkgsrc)
sudocmd pkg_add -r $@
return ;;
emerge)
sudocmd emerge -uD $@
return ;;
pacman)
sudocmd pacman -S $@
sudocmd pacman -S $force $nodeps $@
return ;;
aura)
sudocmd aura -A $force $nodeps $@
return ;;
yum-rpm)
sudocmd yum install $@
sudocmd yum $YUMOPTIONS install $@
return ;;
dnf-rpm)
sudocmd dnf install $@
return ;;
zypper-rpm)
sudocmd zypper install $@
sudocmd zypper install $ZYPPEROPTIONS $@
return ;;
mpkg)
sudocmd mpkg install $@
return ;;
slackpkg)
separate_installed $@
# TODO: use upgrade if package is already installed
sudocmd /usr/sbin/slackpkg install $@
[ -n "$pkg_noninstalled" ] && sudocmd /usr/sbin/slackpkg install $pkg_noninstalled
[ -n "$pkg_installed" ] && sudocmd /usr/sbin/slackpkg upgrade $pkg_installed
return ;;
homebrew)
separate_installed $@
[ -n "$pkg_noninstalled" ] && sudocmd brew install $pkg_noninstalled
[ -n "$pkg_installed" ] && sudocmd brew upgrade $pkg_installed
return ;;
ipkg)
[ -n "$force" ] && force=-force-depends
sudocmd ipkg $force install $@
return ;;
*)
fatal "Do not known install command for $PMTYPE"
......@@ -97,22 +112,26 @@ epm_ni_install_names()
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|apt-dpkg)
sudocmd apt-get -y --force-yes install $@
sudocmd apt-get -y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@
return ;;
yum-rpm)
sudocmd yum -y install $@
sudocmd yum -y $YUMOPTIONS install $@
return ;;
urpm-rpm)
sudocmd urpmi --auto --no-verify-rpm $@
sudocmd urpmi --auto $URPMOPTIONS $@
return ;;
zypper-rpm)
yes | sudocmd zypper --non-interactive install $@
# FIXME: returns true ever no package found, need check for "no found", "Nothing to do."
yes | sudocmd zypper --non-interactive $ZYPPEROPTIONS install $@
return ;;
pkg_add)
pkgsrc)
sudocmd pkg_add -r $@
return ;;
pacman)
sudocmd pacman -S --noconfirm $@
sudocmd pacman -S --noconfirm $force $nodeps $@
return ;;
aura)
sudocmd aura -A $force $nodeps $@
return ;;
npackd)
# npackdcl update --package=<package> (remove old and install new)
......@@ -121,6 +140,9 @@ epm_ni_install_names()
chocolatey)
docmd chocolatey install $@
return ;;
ipkg)
sudocmd ipkg -force-defaults install $@
return ;;
slackpkg)
# TODO: use upgrade if package is already installed
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes install $@
......@@ -136,23 +158,59 @@ epm_install_files()
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|urpm-rpm)
apt-rpm)
sudocmd rpm -Uvh $force $nodeps $@ && return
# TODO: check for "is already installed"
# if run with --nodeps, do not fallback on hi level
[ -n "$nodeps" ] && return
# use install_names
;;
apt-dpkg)
sudocmd dpkg -i $@
sudocmd apt-get -f install
return ;;
yum-rpm)
sudocmd rpm -Uvh $force $@ && return
sudocmd yum --nogpgcheck install $@
return ;;
pkg_add)
# the new version of the conf. file is installed with a .dpkg-dist suffix
if [ -n "$non_interactive" ] ; then
DPKGOPTIONS="--force-confdef --force-confold"
fi
sudocmd dpkg $DPKGOPTIONS -i $@
# if run with --nodeps, do not fallback on hi level
[ -n "$nodeps" ] && return
# fall to apt-get -f install for fix deps
# can't use APTOPTIONS with empty install args
epm_install_names -f
return
;;
yum-rpm|dnf-rpm)
sudocmd rpm -Uvh $force $nodeps $@ && return
# if run with --nodeps, do not fallback on hi level
[ -n "$nodeps" ] && return
YUMOPTIONS=--nogpgcheck
# use install_names
;;
zypper-rpm)
sudocmd rpm -Uvh $force $nodeps $@ && return
# if run with --nodeps, do not fallback on hi level
[ -n "$nodeps" ] && return
ZYPPEROPTIONS=--no-gpg-checks
# use install_names
;;
urpm-rpm)
sudocmd rpm -Uvh $force $nodeps $@ && return
# if run with --nodeps, do not fallback on hi level
[ -n "$nodeps" ] && return
URPMOPTIONS=--no-verify-rpm
# use install_names
;;
pkgsrc)
sudocmd pkg_add $@
return ;;
pacman)
sudocmd pacman -U --noconfirm $@
sudocmd pacman -U --noconfirm $force $nodeps $@ && return
[ -n "$nodeps" ] && return
sudocmd pacman -U $force $@
return ;;
slackpkg)
sudocmd /sbin/installpkg $@
......@@ -166,17 +224,17 @@ epm_install_files()
epm_print_install_command()
{
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $@"
;;
apt-dpkg)
echo "dpkg -i $@"
;;
pkg_add)
pkgsrc)
echo "pkg_add $@"
;;
pacman)
echo "pacman -U --noconfirm $@"
echo "pacman -U --noconfirm --force $nodeps $@"
;;
slackpkg)
echo "/sbin/installpkg $@"
......@@ -184,6 +242,9 @@ epm_print_install_command()
npackd)
echo "npackdcl add --package=$@"
;;
ipkg)
echo "ipkg install $@"
;;
*)
fatal "Do not known appropriate install command for $PMTYPE"
;;
......@@ -203,7 +264,7 @@ epm_install()
local names="$(echo $pkg_names | filter_out_installed_packages)"
local files="$(echo $pkg_files | filter_out_installed_packages)"
[ -z "$files$names" ] && echo "Skip empty install list" && return 2
[ -z "$files$names" ] && echo "Skip empty install list" && return 22
epm_install_names $names || return
epm_install_files $files
......
#!/bin/sh
#
# Copyright (C) 2013 Etersoft
# Copyright (C) 2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
epm_kernel_update()
{
echo "Start update system kernel to the latest version"
case $DISTRNAME in
ALTLinux)
sudocmd update-kernel
return ;;
esac
case $PMTYPE in
*)
fatal "Do not known command for $PMTYPE"
;;
esac
}
......@@ -24,21 +24,29 @@ epm_packages()
case $PMTYPE in
apt-rpm)
CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
;;
apt-dpkg)
CMD="dpkg -l $pkg_filenames"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n $pkg_filenames"
;;
yum-rpm|urpm-rpm|zypper-rpm)
yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
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"
;;
pkg_add)
pkgsrc)
CMD="pkg_info"
;;
pacman)
CMD="pacman -Qs"
CMD="pacman -Qs $pkg_filenames"
if [ -n "$short" ] ; then
docmd $CMD | sed -e "s| .*||g" -e "s|.*/||g" | grep -v "^$"
return
fi
;;
npackd)
CMD="npackdcl list"
......@@ -49,6 +57,12 @@ case $PMTYPE in
slackpkg)
CMD="ls -1 /var/log/packages/"
;;
homebrew)
CMD="brew $pkg_filenames"
;;
ipkg)
CMD="ipkg list"
;;
*)
fatal "Do not known query command for $PMTYPE"
;;
......
#!/bin/sh
#
# Copyright (C) 2013 Etersoft
# Copyright (C) 2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-query_file
# Inspired by http://www.altlinux.org/Tips
epm_programs()
{
local DESKTOPDIR=/usr/share/applications
[ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system."
#find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u
showcmd "find /usr/share/applications -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u"
find /usr/share/applications -type f -name "*.desktop" | \
xargs $0 -qf --quiet --short | sort -u
}
......@@ -26,9 +26,10 @@ _query_via_packages_list()
local res=0
local firstpkg=$1
shift
epm_packages | grep "$firstpkg-" || res=1
# separate first line for print out command
short=1 pkg_filenames=$firstpkg epm_packages | grep -- "^$firstpkg$" || res=1
for pkg in "$@" ; do
epm_packages 2>/dev/null | grep "$pkg-" || res=1
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -- "^$pkg$" || res=1
done
return $res
}
......@@ -37,10 +38,10 @@ __epm_query_file()
{
local CMD
[ -z "$@" ] && return
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
*-rpm)
CMD="rpm -qp"
;;
apt-dpkg)
......@@ -62,10 +63,10 @@ __epm_query_name()
{
local CMD
[ -z "$@" ] && return
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
*-rpm)
CMD="rpm -q"
;;
apt-dpkg)
......@@ -78,6 +79,10 @@ __epm_query_name()
npackd)
CMD="npackdcl path --package=$@"
;;
brew)
warning "fix query"
return 1
;;
*)
_query_via_packages_list $@
return
......@@ -90,7 +95,18 @@ __epm_query_name()
# check if pkg is installed
is_installed()
{
pkg_filenames="$@" epm_query >/dev/null
#pkg_filenames="$@" epm_query >/dev/null
epm installed $@ >/dev/null
}
# fill pkg_installed and pkg_noninstalled
separate_installed()
{
pkg_installed=
pkg_noninstalled=
for i in $* ; do
is_installed $i && pkg_installed="$pkg_installed $i" || pkg_noninstalled="$pkg_noninstalled $i"
done
}
epm_query()
......
......@@ -63,13 +63,14 @@ dpkg_print_name_version()
__do_query()
{
local CMD
case $PMTYPE in
apt-rpm)
CMD="rpm -qf"
;;
apt-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||")
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")
return ;;
yum-rpm|urpm-rpm)
CMD="rpm -qf"
......@@ -85,6 +86,40 @@ __do_query()
;;
slackpkg)
# note: need remove leading slash for grep
docmd grep -R -- "$(echo $@ | sed -e 's|^/\+||g')" /var/log/packages | sed -e "s|/var/log/packages/||g"
return
;;
ipkg)
CMD="ipkg files"
;;
*)
fatal "Do not known query command for $PMTYPE"
;;
esac
docmd $CMD $@
}
__do_short_query()
{
local CMD
case $PMTYPE in
*-rpm)
CMD="rpm -qf --queryformat %{NAME}\n"
;;
NOapt-dpkg)
showcmd dpkg -S $1
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")
return ;;
NOemerge)
CMD="equery belongs"
;;
NOpacman)
CMD="pacman -Qo"
;;
NOslackpkg)
# note: need remove leading slash for grep
docmd grep -R "$(echo $@ | sed -e 's|^/\+||g')" /var/log/packages | sed -e "s|/var/log/packages/||g"
return
;;
......@@ -96,8 +131,17 @@ __do_query()
docmd $CMD $@
}
epm_query_file()
{
# in short mode print handle only real names and do short output
# TODO: move to separate command?
if [ -n "$short" ] ; then
[ -n "$pkg_files" ] || fatal "Run query without file names (needed path to files)"
__do_short_query $pkg_files
return
fi
# file can exists or not
[ -n "$pkg_filenames" ] || fatal "Run query without file names"
......
......@@ -22,5 +22,5 @@ load_helper epm-packages
epm_query_package()
{
#showcmd grep --color "$pkg_filenames"
pkg_filenames= epm_packages | grep --color "$pkg_filenames"
pkg_filenames= epm_packages | grep --color -- "$pkg_filenames"
}
......@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-install
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_reinstall_names()
{
......@@ -25,28 +27,16 @@ epm_reinstall_names()
apt-rpm|apt-dpkg)
sudocmd apt-get --reinstall install $@
return ;;
yum-rpm)
sudocmd yum install $@
return ;;
urpm-rpm)
sudocmd urpmi $@
return ;;
zypper-rpm)
sudocmd zypper install $@
return ;;
pkg_add)
sudocmd pkg_add -r $@
return ;;
pacman)
sudocmd pacman -U $@
dnf-rpm)
sudocmd dnf reinstall $@
return ;;
slackpkg)
sudocmd /usr/sbin/slackpkg reinstall $@
return ;;
*)
fatal "Do not known install command for $PMTYPE"
;;
esac
# fallback to generic install
epm_install_names
}
epm_reinstall_files()
......
#!/bin/sh
#
# Copyright (C) 2013 Etersoft
# Copyright (C) 2013 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
epm_release_upgrade()
{
echo "Start upgrade whole system to the next release"
echo "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
case $PMTYPE in
apt-rpm)
docmd epm update
docmd epm install apt rpm
showcmd "TODO: change repo"
docmd epm Upgrade
;;
apt-dpkg)
sudocmd do-release-upgrade -d
;;
yum-rpm)
docmd epm install rpm yum
sudocmd yum clean all
# TODO
showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
docmd epm Upgrade
;;
urpm-rpm)
sudocmd urpmi.removemedia -av
# TODO
showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
sudocmd urpmi --auto-update --replacefiles
;;
zypper-rpm)
docmd epm repolist
# TODO
# sudocmd zypper rr <номер_репозитория>
showcmd rr N
showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
showcmd zypper ref
docmd epm update
docmd epm install rpm zypper
docmd epm upgrade
;;
pacman)
epm Upgrade
;;
*)
fatal "Do not known command for $PMTYPE"
;;
esac
sudocmd $CMD $pkg_filenames
}
......@@ -22,18 +22,22 @@ epm_remove_low()
{
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm)
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
sudocmd rpm -ev $nodeps $@
return ;;
apt-dpkg)
sudocmd dpkg -P $@
[ -n "$nodeps" ] && nodeps="--force-all"
sudocmd dpkg -P $nodeps $@
return ;;
pkg_add)
pkgsrc)
sudocmd pkg_delete -r $@
return ;;
emerge)
sudocmd emerge --unmerge $@
return ;;
pacman)
sudocmd pacman -R $@
return ;;
slackpkg)
sudocmd /sbin/removepkg $@
return ;;
......@@ -55,7 +59,7 @@ epm_remove_names()
urpm-rpm)
sudocmd urpme $@
return ;;
pkg_add) # without dependencies
pkgsrc) # without dependencies
sudocmd pkg_delete $@
return ;;
emerge)
......@@ -63,11 +67,14 @@ epm_remove_names()
sudocmd emerge -aC $@
return ;;
pacman)
sudocmd pacman -R $@
sudocmd pacman -Rc $@
return ;;
yum-rpm)
sudocmd yum remove $@
return ;;
dnf-rpm)
sudocmd dnf remove $@
return ;;
zypper-rpm)
sudocmd zypper remove $@
return ;;
......@@ -83,6 +90,13 @@ epm_remove_names()
slackpkg)
sudocmd /usr/sbin/slackpkg remove $@
return ;;
homebrew)
sudocmd brew remove $@
return ;;
ipkg)
[ -n "$force" ] && force=-force-depends
sudocmd ipkg $force remove $@
return ;;
*)
fatal "Do not known command for $PMTYPE"
;;
......@@ -100,7 +114,7 @@ epm_remove_nonint()
sudocmd urpme --auto $@
return ;;
pacman)
sudocmd pacman -R --noconfirm $@
sudocmd pacman -Rc --noconfirm $@
return ;;
yum-rpm)
sudocmd yum -y remove $@
......@@ -111,6 +125,9 @@ epm_remove_nonint()
slackpkg)
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes remove $@
return ;;
ipkg)
sudocmd ipkg -force-defaults remove $@
return ;;
esac
return 5
}
......@@ -118,21 +135,27 @@ epm_remove_nonint()
epm_print_remove_command()
{
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm)
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@"
;;
apt-dpkg)
echo "dpkg -P $@"
;;
pkg_add)
pkgsrc)
echo "pkg_delete -r $@"
;;
pacman)
echo "pacman -R $@"
;;
emerge)
echo "emerge --unmerge $@"
;;
slackpkg)
echo "/sbin/removepkg $@"
;;
ipkg)
echo "ipkg remove $@"
;;
*)
fatal "Do not known appropriate remove command for $PMTYPE"
;;
......
......@@ -24,8 +24,8 @@ print_apt_sources_list()
test -r "$i" || continue
#echo
#echo "$i:"
grep -v "^#" $i
done | grep -v "^ *\$"
grep -v -- "^#" $i
done | grep -v -- "^ *\$"
}
epm_repolist()
......@@ -44,6 +44,9 @@ case $PMTYPE in
yum-rpm)
docmd yum repolist
;;
dnf-rpm)
docmd dnf repolist -v
;;
urpm-rpm)
docmd urpmq --list-url
;;
......@@ -54,10 +57,10 @@ case $PMTYPE in
docmd layman -L
;;
pacman)
docmd grep -v "^#\|^$" /etc/pacman.conf
docmd grep -v -- "^#\|^$" /etc/pacman.conf
;;
slackpkg)
docmd grep -v "^#\|^$" /etc/slackpkg/mirrors
docmd grep -v -- "^#\|^$" /etc/slackpkg/mirrors
;;
*)
fatal "Do not known command for $PMTYPE"
......
......@@ -22,7 +22,7 @@ epm_requires()
local CMD
[ -n "$pkg_filenames" ] || fatal "Run query without names"
# by file package
# by package file
case $PMTYPE in
apt-rpm|urpm-rpm|zypper-rpm|yum-rpm)
CMD="rpm -q --requires -p"
......@@ -39,7 +39,7 @@ esac
[ -n "$pkg_files" ] && docmd $CMD $pkg_files
# by file name
# by package name
case $PMTYPE in
apt-rpm|urpm-rpm|zypper-rpm)
# FIXME: use hi level commands
......@@ -48,6 +48,9 @@ case $PMTYPE in
yum-rpm)
CMD="yum deplist"
;;
pacman)
CMD="pactree"
;;
apt-dpkg)
CMD="apt-cache depends"
;;
......
......@@ -31,7 +31,7 @@ case $PMTYPE in
urpm-rpm)
CMD="urpmq -y"
;;
pkg_add)
pkgsrc)
CMD="pkg_info -x"
;;
emerge)
......@@ -40,9 +40,15 @@ case $PMTYPE in
pacman)
CMD="pacman -Ss"
;;
aura)
CMD="aura -As"
;;
yum-rpm)
CMD="yum search"
;;
dnf-rpm)
CMD="dnf search"
;;
zypper-rpm)
CMD="zypper search"
;;
......@@ -61,6 +67,9 @@ case $PMTYPE in
docmd_foreach "/usr/sbin/slackpkg search" $pkg_filenames
return
;;
homebrew)
CMD="brew search"
;;
*)
fatal "Do not known search command for $PMTYPE"
;;
......
......@@ -36,7 +36,7 @@ local_content_search()
{
[ -n "$USETTY" ] && echo "Search in $CI and $CINOA for $1..."
grep -h ".*$1.*\t" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
grep -h -- ".*$1.*\t" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
} | $OUTCMD
}
......@@ -56,6 +56,9 @@ case $PMTYPE in
yum-rpm)
CMD="yum provides"
;;
dnf-rpm)
CMD="dnf provides"
;;
urpm-rpm)
CMD="urpmf"
;;
......@@ -68,6 +71,9 @@ case $PMTYPE in
slackpkg)
CMD="/usr/sbin/slackpkg file-search"
;;
ipkg)
CMD="ipkg search"
;;
*)
fatal "Do not known search file command for $PMTYPE"
;;
......
......@@ -128,6 +128,10 @@ strip_spaces()
echo "$*" | filter_strip_spaces
}
epm()
{
$PROGDIR/epm $@
}
# Print error message and stop the program
fatal()
......@@ -161,7 +165,7 @@ set_sudo()
# print options description from HELPCMD/HELPOPT lines in the code
get_help()
{
grep "# $1" $0 | while read n ; do
grep -- "# $1" $0 | while read n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g")
printf " %-20s %s\n" $opt "$desc"
......@@ -176,7 +180,7 @@ set_pm_type()
# Fill for use: PMTYPE, DISTRNAME, DISTRVERSION, PKGFORMAT, PKGVENDOR, RPMVENDOR
DISTRVENDOR=$PROGDIR/distr_info
[ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d)
[ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d) || fatal "Can't get distro name."
[ -n "$DISTRVERSION" ] || DISTRVERSION=$($DISTRVENDOR -v)
set_target_pkg_env
......@@ -200,8 +204,8 @@ case $DISTRNAME in
Mandriva|ROSA)
CMD="urpm-rpm"
;;
FreeBSD)
CMD="pkg_add"
FreeBSD|NetBSD|OpenBSD|Solaris)
CMD="pkgsrc"
;;
Gentoo)
CMD="emerge"
......@@ -221,6 +225,12 @@ case $DISTRNAME in
Windows)
CMD="chocolatey"
;;
MacOS)
CMD="homebrew"
;;
OpenWRT)
CMD="ipkg"
;;
*)
fatal "Do not known DISTRNAME $DISTRNAME"
;;
......
#!/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
......@@ -20,25 +20,51 @@
load_helper epm-install
load_helper epm-search
# for zypper before SUSE/11.0
__use_zypper_dry_run()
{
a= zypper install --help 2>&1 | grep -q -- "--dry-run" && echo "--dry-run"
}
__use_yum_assumeno()
{
a= yum --help 2>&1 | grep -q -- "--assumeno"
}
_epm_do_simulate()
{
local CMD
local filenames=$@
local CMD
local filenames="$*"
case $PMTYPE in
apt-rpm|apt-dpkg)
CMD="apt-get --simulate install"
;;
yum-rpm)
LC_ALL=C sudocmd yum --assumeno install $filenames
# FIXME: check only error output
LC_ALL=C sudocmd yum --assumeno install $filenames 2>&1 | grep "^No package" && return 1
if __use_yum_assumeno ; then
LC_ALL=C sudocmd yum --assumeno install $filenames
# FIXME: check only error output
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
LC_ALL=C echo n | sudocmd yum install $filenames
# FIXME: check only error output
LC_ALL=C echo n | sudocmd yum install $filenames 2>&1 | grep "^No package" && return 1
LC_ALL=C echo n | sudocmd yum install $filenames 2>&1 | grep "^Complete!" && return 0
LC_ALL=C echo n | sudocmd yum install $filenames >/dev/null 2>&1 || return
fi
return 0 ;;
urpm-rpm)
CMD="urpmi --test --auto"
;;
zypper-rpm)
CMD="zypper --non-interactive install --dry-run"
if ! __use_zypper_dry_run >/dev/null ; then
echo "zypper is too old: does not support --dry-run"
return
fi
CMD="zypper --non-interactive install"
;;
emerge)
echo "FIXME: Skip with emerge"
......@@ -70,7 +96,7 @@ _epm_do_simulate()
epm_simulate()
{
[ -z "$pkg_filenames" ] && echo "Skip empty list" && return 2
[ -z "$pkg_filenames" ] && echo "Skip empty list" && return 22
local filenames="$(echo $pkg_filenames | filter_out_installed_packages)"
......
......@@ -21,6 +21,8 @@
epm_update()
{
echo "Run command for update remote package repository database"
case $PMTYPE in
apt-rpm)
sudocmd apt-get update || exit
......@@ -40,6 +42,9 @@ case $PMTYPE in
pacman)
sudocmd pacman -S -y
;;
aura)
sudocmd aura -A -y
;;
zypper-rpm)
sudocmd zypper refresh
;;
......@@ -52,6 +57,12 @@ case $PMTYPE in
deepsolver-rpm)
sudocmd ds-update
;;
homebrew)
sudocmd brew update
;;
ipkg)
sudocmd ipkg update
;;
*)
fatal "Do not known update command for $PMTYPE"
;;
......
......@@ -30,6 +30,9 @@ epm_upgrade()
yum-rpm)
CMD="yum update"
;;
dnf-rpm)
CMD="dnf update"
;;
urpm-rpm)
# or --auto-select --replace-files
CMD="urpmi --auto-update"
......@@ -40,15 +43,24 @@ epm_upgrade()
pacman)
CMD="pacman -S -u"
;;
aura)
CMD="aura -A -u"
;;
emerge)
CMD="emerge -NuDa world"
;;
pkg_add)
pkgsrc)
CMD="freebsd-update fetch install"
;;
chocolatey)
CMD="chocolatey update all"
;;
homebrew)
CMD="brew upgrade"
;;
ipkg)
CMD="ipkg upgrade"
;;
slackpkg)
CMD="/usr/sbin/slackpkg upgrade-all"
;;
......
epm
\ No newline at end of file
epm
\ No newline at end of file
#!/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
......@@ -18,6 +18,8 @@
#
PROGDIR=$(dirname $0)
[ "$PROGDIR" = "." ] && PROGDIR=$(pwd)
# will replaced to /usr/share/eepm during install
SHAREDIR=$(dirname $0)
......@@ -46,10 +48,17 @@ set_service_type()
# Fill for use: PMTYPE, DISTRNAME, DISTRVERSION, PKGFORMAT, PKGVENDOR, RPMVENDOR
DISTRVENDOR=$PROGDIR/distr_info
[ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d)
[ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d) || fatal "Can't get distro name."
[ -n "$DISTRVERSION" ] || DISTRVERSION=$($DISTRVENDOR -v)
set_target_pkg_env
is_active_systemd()
{
SYSTEMCTL=/bin/systemctl
SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd
[ -x "$SYSTEMCTL" ] && [ -d "$SYSTEMD_CGROUP_DIR" ] && mountpoint -q "$SYSTEMD_CGROUP_DIR"
}
case $DISTRNAME in
ALTLinux)
CMD="service-chkconfig"
......@@ -85,7 +94,15 @@ case $DISTRNAME in
fatal "Do not known DISTRNAME $DISTRNAME yet"
;;
esac
# Note: force systemd using if active
is_active_systemd && CMD="systemd"
# override system control detection result
[ -n "$FORCESERVICE" ] && CMD=$FORCESERVICE
SERVICETYPE=$CMD
}
......@@ -107,10 +124,12 @@ print_version()
echo "Service manager version @VERSION@"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013"
echo "This program may be freely redistributed under the terms of the GNU GPL."
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
}
Usage="Usage: serv [options] [<service>] [<command>] [params]..."
progname="${0##*/}"
Usage="Usage: $progname [options] [<service>] [<command>] [params]..."
Descr="serv - Service manager"
set_service_type
......@@ -123,6 +142,7 @@ serv_cmd=
service_name=
params=
check_command()
{
# do not override command
......@@ -212,7 +232,7 @@ echover "command: $serv_cmd"
if [ "$serv_cmd" != "list" ] && [ "$serv_cmd" != "list_all" ] && [ -z "$service_name" ] ; then
print_version
echo
fatal "Run $ serv --help for get help"
fatal "Run $ $progname --help for get help"
fi
if [ -z "$serv_cmd" ] ; then
......
......@@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# FIXME: sudo ask password, but we do not print command before
is_service_running()
{
case $SERVICETYPE in
......@@ -36,6 +37,7 @@ is_service_running()
esac
}
# FIXME: sudo ask password, but we do not print command before
is_service_autostart()
{
case $SERVICETYPE in
......@@ -46,7 +48,7 @@ is_service_autostart()
fatal "FIXME: don't know how detect current startup state"
;;
systemd)
sudocmd systemctl is-enabled $1
sudocmd systemctl is-enabled $1.service
;;
*)
fatal "Do not known command for $SERVICETYPE"
......@@ -69,7 +71,7 @@ serv_status()
sudocmd /etc/init.d/$SERVICE status "$@"
;;
systemd)
sudocmd systemctl status $service "$@"
sudocmd systemctl status $SERVICE.service "$@"
;;
*)
fatal "Do not known command for $SERVICETYPE"
......
# This spec is backported to ALTLinux p6 automatically by rpmbph script. Do not edit it.
#
Name: eepm
Version: 1.1.4
Version: 1.2.3
Release: alt0.M60P.1
Summary: Etersoft EPM package manager
......@@ -12,7 +12,7 @@ Url: http://wiki.etersoft.ru/EPM
Packager: Vitaly Lipatov <lav@altlinux.ru>
# git-clone http://git.altlinux.org/people/lav/packages/epm.git
# git-clone http://git.etersoft.ru/projects/korinf/eepm.git
Source: ftp://updates.etersoft.ru/pub/Etersoft/Sisyphus/sources/tarball/%name-%version.tar
BuildArchitectures: noarch
......@@ -38,14 +38,12 @@ See detailed description here: http://wiki.etersoft.ru/EPM
%prep
%setup
%build
%__subst "s|@VERSION@|%version-%release|g" bin/epm bin/serv
%install
# install to datadir and so on
%makeinstall
./pack_in_onefile.sh
install -m 0755 *packed.sh %buildroot/%_datadir/%name/
%makeinstall version=%version-%release
install -m 0755 packed/epm.sh %buildroot/%_datadir/%name/epm-packed.sh
install -m 0755 packed/serv.sh %buildroot/%_datadir/%name/serv-packed.sh
mkdir -p %buildroot%_sysconfdir/bash_completion.d/
install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/serv
......@@ -55,14 +53,73 @@ install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/se
%_bindir/eepm
%_bindir/upm
%_bindir/serv
%_bindir/cerv
%_bindir/distr_info
%_datadir/%name/
%_sysconfdir/bash_completion.d/serv
%changelog
* Tue Jan 01 2013 Vitaly Lipatov <lav@altlinux.ru> 1.1.4-alt0.M60P.1
* Mon Mar 04 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.3-alt0.M60P.1
- backport to ALTLinux p6 (by rpmbph script)
* Fri Feb 22 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.3-alt1
- add initial aura support
- epm-install: fix skip-installed for old Debian
* Wed Feb 20 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.2-alt1
- epm-checkpkg: add experimental case instead function call
- epm-simulate: accept Exiting on user Command (Fedora 17)
- epm-checkpkg: add support for check installed package integrity
- epm: do not add to pkg_files if filename has not dot (it is not package file)
* Tue Feb 19 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.1-alt1
- initial support for kernel-update
- add support ipkg on OpenWRT
- add support homebrew on MacOS
- add check for separate_installed
- small fixes
* Thu Feb 14 2013 Vitaly Lipatov <lav@altlinux.ru> 1.2.0-alt1
- epm-reinstall: fallback to install if the command is the same
- epm-install: realize already installed with is_installed for any distro
- epm-install: allow nodeps and force to pacman commands
- epm-query: optimize, use --short
- epm-simulate: fix for yum without --assumeno
- epm-packages: add short support for pacman
- epm-remove: add --nodeps support for dpkg
* Tue Feb 12 2013 Vitaly Lipatov <lav@altlinux.ru> 1.1.9-alt1
- fix install with dpkg
- add initial release-upgrade command
- add more pacman commands
- epm-packages: add --short support for dpkg and rpm
- add cerv alias for serv support
* Mon Feb 11 2013 Vitaly Lipatov <lav@altlinux.ru> 1.1.8-alt1
- add epm programs command (lists installed programs, detected by desktop files)
- add initial support for short output (just package name, without version-release)
- add short commands epmqi epmcl
- small fixes
* Tue Feb 05 2013 Vitaly Lipatov <lav@altlinux.ru> 1.1.7-alt1
- epm-install: user --force-confold for dpkg/apt on Debian/Ubunti in auto mode
- epm-autoremove: use apt-get autoremove
- serv-status: fix systemd support
- epm-simulate: skip simulate if zypper does not have --dry-run
- epm-install: try install with rpm before zypper use
- epm-install: fall to standalone apt install for fix deps
* Sat Feb 02 2013 Vitaly Lipatov <lav@altlinux.ru> 1.1.6-alt1
- epm-install: fix fallback from low level to hi level install
- serv: add support for FORCESERVICE
- add initial support for DNF package manager
- add epm Upgrade command (epm update && upgrade)
* Tue Jan 29 2013 Vitaly Lipatov <lav@altlinux.ru> 1.1.5-alt1
- serv: add systemd detect
- fix check for empty args
- epm-install: with --nodeps do not fallback on apt-get during install from file
* Tue Jan 01 2013 Vitaly Lipatov <lav@altlinux.ru> 1.1.4-alt1
- fix broken autoremove: rename epm-autoclean to epm-autoremove
......
......@@ -34,14 +34,22 @@ cat <<EOF >>$OUTPUT
EOF
}
get_version()
{
grep "^Version:" eepm.spec | head -n1 | sed "s|Version: *||g"
}
filter_out()
{
grep -v "^load_helper " | sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g'
grep -v "^load_helper " | sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g' | \
sed -e "s|@VERSION@|$(get_version)|g"
}
incorporate_all()
{
OUTPUT=$PACKCOMMAND-packed.sh
mkdir -p packed
OUTPUT=packed/$PACKCOMMAND.sh
echo -n >$OUTPUT
awk 'BEGIN{desk=0}{if(/^load_helper epm-sh-functions/){desk++};if(desk==0) {print}}' <bin/$PACKCOMMAND | filter_out >>$OUTPUT
......@@ -54,6 +62,7 @@ done | filter_out >>$OUTPUT
incorporate_distr_info
awk 'BEGIN{desk=0}{if(desk>0) {print} ; if(/^load_helper epm-sh-functions/){desk++}}' <bin/$PACKCOMMAND | filter_out >>$OUTPUT
chmod 0755 $OUTPUT
}
###############
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
#!/bin/sh
LOG=~/epm_test_log
cepm()
{
echo
../bin/epm --verbose $@ >/dev/null
epm --verbose $@ >> $LOG
}
log()
{
echo "$@" >> $LOG
}
cepm changelog mc
......@@ -21,7 +28,13 @@ cepm requires mc
# query packages
#cepm -qp mc
#cepm install mc
cepm remove nmap && log "nmap removed"
! cepm remove nmap && log "nmap doesnt installed"
cepm install --auto nmap && log "nmap installed"
cepm remove --auto nmap && log "nmap removed"
#cepm packages mc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment