Commit 5000593e authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to p7 as 1.5.4-alt0.M70P.1 (with rpmbph script)

parents c4ee6403 cd465a9c
pkgdatadir=$(datadir)/eepm
# due using %makeinstallstd in spec
instpkgdatadir=/usr/share/eepm
instpkgdatadir=$(pkgdatadir)
install:
mkdir -p $(DESTDIR)$(bindir)/
......
менеджер пакетов из NetBSD — pkgsrc (команды для поиска нужных пакетов – pkgin update; pkgin avail; pkgin search).
Загрузку конфига
Установку пакета по URL
......
......@@ -235,9 +235,15 @@ check_command()
Upgrade) # HELPCMD: force update package base, then run upgrade
epm_cmd=Upgrade
;;
downgrade) # HELPCMD: downgrade [all] packages to the repo state
epm_cmd=downgrade
;;
simulate) # HELPCMD: simulate install with check requires
epm_cmd=simulate
;;
audit) # HELPCMD: audits installed packages against known vulnerabilities
epm_cmd=audit
;;
-V|checkpkg|integrity) # HELPCMD: check package file integrity (checksum)
epm_cmd=checkpkg
;;
......@@ -318,7 +324,7 @@ done
# if input is not console, get pkg from it too
if ! inputisatty ; then
for opt in $(timeout 1 cat) ; do
for opt in $(timeout 1 cat 2>/dev/null) ; do
check_filenames $opt
done
fi
......
#!/bin/sh
#
# Copyright (C) 2014 Etersoft
# Copyright (C) 2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
epm_audit()
{
case $PMTYPE in
pkgng)
sudocmd pkg audit -F
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
......@@ -79,6 +79,9 @@ case $PMTYPE in
guix)
sudocmd guix gc
;;
pkgng)
sudocmd pkg autoremove
;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
......
......@@ -23,7 +23,7 @@ case $PMTYPE in
apt-rpm|apt-dpkg)
#sudocmd apt-get check || exit
#sudocmd apt-get update || exit
sudocmd apt-get -f install || exit
sudocmd apt-get -f install
;;
apt-dpkg)
#sudocmd apt-get update || exit
......@@ -56,6 +56,9 @@ case $PMTYPE in
conary)
sudocmd conary verify
;;
pkgng)
sudocmd pkg check -d -a
;;
homebrew)
sudocmd brew doctor
;;
......
......@@ -47,6 +47,9 @@ case $PMTYPE in
;;
slackpkg)
;;
pkgng)
sudo pkg clean
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
#!/bin/sh
#
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-check_updated_repo
__epm_add_apt_downgrade_preferences()
{
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
cat <<EOF | $SUDO tee /etc/apt/preferences
Package: *
Pin: release c=$1
Pin-Priority: 1001
EOF
}
__epm_remove_apt_downgrade_preferences()
{
sudocmd rm -f /etc/apt/preferences
}
epm_downgrade()
{
local CMD
# it is useful for first time running
update_repo_if_needed
info "Running command for downgrade packages"
case $PMTYPE in
apt-rpm)
__epm_add_apt_downgrade_preferences classic || return
sudocmd apt-get dist-upgrade
__epm_remove_apt_downgrade_preferences
;;
apt-dpkg)
__epm_add_apt_downgrade_preferences testing || return
sudocmd apt-get dist-upgrade
__epm_remove_apt_downgrade_preferences
;;
yum-rpm)
# can do update repobase automagically
sudocmd yum downgrade $pkg_filename
;;
urpm-rpm)
assure_exists urpm-reposync urpm-tools
sudocmd urpm-reposync -v
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
......@@ -113,6 +113,9 @@ __epm_filelist_name()
assure_exists equery
CMD="equery files"
;;
pkgng)
CMD="pkg info -l"
;;
slackpkg)
is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized"
docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* | less
......
......@@ -96,6 +96,9 @@ case $PMTYPE in
ipkg)
docmd ipkg info $pkg_names
;;
pkgng)
docmd pkg info $pkg_names
;;
homebrew)
docmd brew info $pkg_names
;;
......
......@@ -106,6 +106,9 @@ epm_install_names()
pkgsrc)
sudocmd pkg_add -r $@
return ;;
pkgng)
sudocmd pkg install $@
return ;;
emerge)
sudocmd emerge -uD $@
return ;;
......@@ -185,6 +188,9 @@ epm_ni_install_names()
pkgsrc)
sudocmd pkg_add -r $@
return ;;
pkgng)
sudocmd pkg install -y $@
return ;;
emerge)
sudocmd emerge -uD $@
return ;;
......@@ -299,6 +305,17 @@ epm_install_files()
pkgsrc)
sudocmd pkg_add $@
return ;;
pkgng)
local PKGTYPE="$(get_package_type $@)"
case "$PKGTYPE" in
tbz)
sudocmd pkg_add $@
;;
*)
sudocmd pkg add $@
;;
esac
return ;;
android)
sudocmd pm install $@
return ;;
......@@ -336,6 +353,9 @@ epm_print_install_command()
pkgsrc)
echo "pkg_add $@"
;;
pkgng)
echo "pkg add $@"
;;
emerge)
# need be placed in /usr/portage/packages/somewhere
echo "emerge --usepkg $@"
......
......@@ -55,6 +55,7 @@ __emerge_install_ebuild()
# copy tarballs
local DDIR=/usr/portage/distfiles
# FIXME: use independent dir
[ -d /var/calculate/remote/distfiles ] && DDIR=/var/calculate/remote/distfiles
docmd cp -f $TARBALLS $DDIR/ || return
......
......@@ -59,6 +59,17 @@ case $PMTYPE in
;;
pkgsrc)
CMD="pkg_info"
docmd $CMD | sed -e "s| .*||g"
return
;;
pkgng)
CMD="pkg info -E $pkg_filenames"
if [ -n "$short" ] ; then
docmd $CMD | sed -e "s| .*||g" | sed -e "s|-[0-9].*||g"
else
docmd $CMD | sed -e "s| .*||g"
fi
return
;;
pacman)
CMD="pacman -Qs $pkg_filenames"
......
......@@ -72,6 +72,9 @@ case $PMTYPE in
# yum-rpm)
# CMD="yum deplist"
# ;;
pkgng)
CMD="pkg info -b"
;;
apt-dpkg)
# FIXME: need fix for a few names case
if is_installed $pkg_names ; then
......
......@@ -146,8 +146,13 @@ __epm_query_name()
warning "fix query"
return 1
;;
# TODO: need to print name if exists
#pkgng)
# CMD="pkg info -e"
# ;;
# Note: slackpkg info pkgname
*)
# default slow workaround
_query_via_packages_list $@
return
;;
......
......@@ -86,6 +86,9 @@ __do_query()
pacman)
CMD="pacman -Qo"
;;
pkgng)
CMD="pkg which"
;;
conary)
CMD="conary query --path"
;;
......
......@@ -33,6 +33,9 @@ epm_remove_low()
pkgsrc)
sudocmd pkg_delete -r $@
return ;;
pkgng)
sudocmd pkg delete -R $@
return ;;
emerge)
sudocmd emerge --unmerge $@
return ;;
......@@ -69,6 +72,9 @@ epm_remove_names()
pkgsrc) # without dependencies
sudocmd pkg_delete $@
return ;;
pkgng)
sudocmd pkg delete -R $@
return ;;
emerge)
#sudocmd emerge --unmerge $@
sudocmd emerge -aC $@
......@@ -149,6 +155,9 @@ epm_remove_nonint()
slackpkg)
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes remove $@
return ;;
pkgng)
sudocmd pkg delete -y -R $@
return ;;
ipkg)
sudocmd ipkg -force-defaults remove $@
return ;;
......@@ -168,6 +177,9 @@ epm_print_remove_command()
pkgsrc)
echo "pkg_delete -r $@"
;;
pkgng)
echo "pkg delete -R $@"
;;
pacman)
echo "pacman -R $@"
;;
......
......@@ -82,6 +82,10 @@ case $PMTYPE in
assure_exists equery
CMD="equery depgraph"
;;
pkgng)
#CMD="pkg rquery '%dn-%dv'"
CMD="pkg info -d"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -40,6 +40,9 @@ case $PMTYPE in
pkgsrc)
CMD="pkg_info -x --"
;;
pkgng)
CMD="pkg search -i --"
;;
emerge)
CMD="emerge --search --"
;;
......
......@@ -23,7 +23,7 @@ get_local_alt_contents_index()
{
load_helper epm-repolist
epm_repolist | grep "rpm file:/" | sed -e "s|^rpm file:||g" | while read URL ARCH other ; do
epm_repolist | grep "rpm.*file:/" | sed -e "s|^rpm.*file:||g" | while read URL ARCH other ; do
test -d "$URL/$ARCH" || continue # fatal "Local mirror is not accessible via $URL/$ARCH"
FILE="$URL/$ARCH/base/contents_index"
if [ -r "$FILE" ] ; then
......
......@@ -288,7 +288,9 @@ __get_package_for_command()
assure_exists()
{
load_helper epm-assure
__epm_assure "$1" $(__get_package_for_command "$1")
local package="$2"
[ -n "$package" ] || package="$(__get_package_for_command "$1")"
__epm_assure "$1" $package
}
# improve
......@@ -304,6 +306,14 @@ get_package_type()
echo "rpm"
return
;;
*.txz)
echo "txz"
return
;;
*.tbz)
echo "tbz"
return
;;
*)
#fatal "Don't know type of $1"
# return package name for info
......@@ -359,6 +369,7 @@ case $DISTRNAME in
;;
FreeBSD|NetBSD|OpenBSD|Solaris)
CMD="pkgsrc"
which pkg 2>/dev/null >/dev/null && CMD=pkgng
;;
Gentoo)
CMD="emerge"
......
......@@ -69,6 +69,10 @@ case $PMTYPE in
ipkg)
sudocmd ipkg update
;;
pkgsrc)
# portsnap extract for the first time?
sudocmd portsnap fetch update
;;
*)
fatal "Have no suitable update command for $PMTYPE"
;;
......
......@@ -66,6 +66,9 @@ epm_upgrade()
pkgsrc)
CMD="freebsd-update fetch install"
;;
pkgng)
CMD="pkg upgrade"
;;
chocolatey)
CMD="chocolatey update all"
;;
......
......@@ -40,6 +40,9 @@ case $PMTYPE in
assure_exists equery
CMD="equery depends -a"
;;
pkgng)
CMD="pkg info -r"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......
......@@ -32,6 +32,8 @@ load_helper()
load_helper epm-sh-functions
INITDIR=/etc/init.d
PATH=$PATH:/sbin:/usr/sbin
set_sudo
......@@ -239,6 +241,7 @@ if [ -z "$withoutservicename" ] && [ -z "$service_name" ] ; then
fatal "Run $ $progname --help for get help"
fi
# use common way if the command is unknown
if [ -z "$serv_cmd" ] ; then
serv_cmd=common
fi
......
......@@ -27,14 +27,18 @@ serv_common()
sudocmd service $SERVICE "$@"
;;
service-initd|service-update)
sudocmd /etc/init.d/$SERVICE "$@"
sudocmd $INITDIR/$SERVICE "$@"
;;
systemd)
sudocmd systemctl "$@" $SERVICE
# run init script directly (for nonstandart commands)
if [ -x $INITDIR/$SERVICE ] ; then
sudocmd $INITDIR/$SERVICE "$@"
else
sudocmd systemctl "$@" $SERVICE
fi
;;
*)
fatal "Have no suitable command for $SERVICETYPE"
;;
esac
}
......@@ -26,7 +26,7 @@ serv_list_all()
sudocmd chkconfig --list | cut -f1
;;
service-initd|service-update)
sudocmd ls -1 /etc/init.d/* | sed -e "s|/etc/init.d/||g" | grep -v README
sudocmd ls $INITDIR/ | grep -v README
;;
systemd)
sudocmd systemctl list-unit-files $@
......
......@@ -28,7 +28,7 @@ serv_start()
sudocmd service $SERVICE start "$@"
;;
service-initd|service-update)
sudocmd /etc/init.d/$SERVICE start "$@"
sudocmd $INITDIR/$SERVICE start "$@"
;;
systemd)
sudocmd systemctl start "$SERVICE" "$@"
......
......@@ -25,7 +25,7 @@ is_service_running()
$SUDO service $1 status >/dev/null
;;
service-initd|service-update)
$SUDO /etc/init.d/$1 status >/dev/null
$SUDO $INITDIR/$1 status >/dev/null
;;
systemd)
$SUDO systemctl status $1 >/dev/null
......@@ -67,7 +67,7 @@ serv_status()
sudocmd service $SERVICE status "$@"
;;
service-update)
sudocmd /etc/init.d/$SERVICE status "$@"
sudocmd $INITDIR/$SERVICE status "$@"
;;
systemd)
sudocmd systemctl status $SERVICE "$@"
......
......@@ -28,7 +28,7 @@ serv_stop()
sudocmd service $SERVICE stop "$@"
;;
service-initd|service-update)
sudocmd /etc/init.d/$SERVICE stop "$@"
sudocmd $INITDIR/$SERVICE stop "$@"
;;
systemd)
sudocmd systemctl stop $SERVICE "$@"
......
......@@ -32,7 +32,7 @@ serv_try_restart()
;;
service-initd|service-update)
is_service_running $SERVICE || return 0
sudocmd /etc/init.d/$SERVICE restart "$@"
sudocmd $INITDIR/$SERVICE restart "$@"
;;
systemd)
sudocmd systemctl try-restart $SERVICE "$@"
......
# This spec is backported to ALTLinux p7 automatically by rpmbph script. Do not edit it.
#
Name: eepm
Version: 1.5.2
Version: 1.5.4
Release: alt0.M70P.1
Summary: Etersoft EPM package manager
......@@ -41,7 +41,7 @@ See detailed description here: http://wiki.etersoft.ru/EPM
%install
# install to datadir and so on
%makeinstall version=%version-%release
%makeinstall_std datadir=%_datadir bindir=%_bindir mandir=%_mandir 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
......@@ -66,9 +66,18 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv
%changelog
* Tue Mar 25 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.2-alt0.M70P.1
* Wed Jun 04 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.4-alt0.M70P.1
- backport to ALTLinux p7 (by rpmbph script)
* Wed Jun 04 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.4-alt1
- add initial support for FreeBSD's pkgng
- add audit command for check installed packages against known vulnerabilities
* Wed May 28 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.3-alt1
- prefer to use init script directly
- introduce downgrade command
- use correct datadir
* Tue Mar 25 2014 Vitaly Lipatov <lav@altlinux.ru> 1.5.2-alt1
- use repolist for get local repo path
- support --auto for reinstall
......
......@@ -108,17 +108,12 @@ echon()
set_target_pkg_env()
{
[ -n "$DISTRNAME" ] || fatal "Run set_target_pkg_env without DISTRNAME"
[ -n "$DISTRNAME" ] || fatal "Missing DISTRNAME in set_target_pkg_env."
PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME")
PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME")
RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME")
}
realpath()
{
readlink -f "$@"
}
showcmd()
{
if [ -z "$quiet" ] ; then
......@@ -234,6 +229,19 @@ warning()
fi
}
info()
{
[ -n "$quiet" ] && return
# print message to stderr if stderr forwarded to (a file)
if isatty2 ; then
isatty || return 0
echo "$@"
else
echo "$@" >&2
fi
}
set_sudo()
{
SUDO=""
......@@ -258,33 +266,30 @@ set_eatmydata()
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata"
isatty && echo "Uwaga! eatmydata is installed, we will use it for disable all sync operations." >&2
info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
return 0
}
assure_exists()
__get_package_for_command()
{
PATH=$PATH:/sbin:/usr/sbin which $1 2>/dev/null >/dev/null && return
echo "Install appropriate package for $1 command..."
case $1 in
case "$1" in
equery|revdep-rebuild)
epm install gentoolkit
;;
apt-repo)
epm install apt-repo
;;
apt-file)
epm install apt-file
echo 'gentoolkit'
;;
update-kernel|remove-old-kernels)
epm install update-kernel
;;
*)
fatal "Internal error: Unknown binary $1 to check if exists"
echo 'update-kernel'
;;
esac
}
assure_exists()
{
load_helper epm-assure
local package="$2"
[ -n "$package" ] || package="$(__get_package_for_command "$1")"
__epm_assure "$1" $package
}
get_package_type()
{
local i
......@@ -297,6 +302,14 @@ get_package_type()
echo "rpm"
return
;;
*.txz)
echo "txz"
return
;;
*.tbz)
echo "tbz"
return
;;
*)
#fatal "Don't know type of $1"
# return package name for info
......@@ -349,6 +362,7 @@ case $DISTRNAME in
;;
FreeBSD|NetBSD|OpenBSD|Solaris)
CMD="pkgsrc"
which pkg 2>/dev/null >/dev/null && CMD=pkgng
;;
Gentoo)
CMD="emerge"
......@@ -403,16 +417,20 @@ serv_common()
sudocmd service $SERVICE "$@"
;;
service-initd|service-update)
sudocmd /etc/init.d/$SERVICE "$@"
sudocmd $INITDIR/$SERVICE "$@"
;;
systemd)
sudocmd systemctl "$@" $SERVICE
# run init script directly (for nonstandart commands)
if [ -x $INITDIR/$SERVICE ] ; then
sudocmd $INITDIR/$SERVICE "$@"
else
sudocmd systemctl "$@" $SERVICE
fi
;;
*)
fatal "Have no suitable command for $SERVICETYPE"
;;
esac
}
# File bin/serv-disable:
......@@ -498,7 +516,7 @@ serv_list_all()
sudocmd chkconfig --list | cut -f1
;;
service-initd|service-update)
sudocmd ls -1 /etc/init.d/* | sed -e "s|/etc/init.d/||g" | grep -v README
sudocmd ls $INITDIR/ | grep -v README
;;
systemd)
sudocmd systemctl list-unit-files $@
......@@ -537,7 +555,7 @@ serv_start()
sudocmd service $SERVICE start "$@"
;;
service-initd|service-update)
sudocmd /etc/init.d/$SERVICE start "$@"
sudocmd $INITDIR/$SERVICE start "$@"
;;
systemd)
sudocmd systemctl start "$SERVICE" "$@"
......@@ -557,7 +575,7 @@ is_service_running()
$SUDO service $1 status >/dev/null
;;
service-initd|service-update)
$SUDO /etc/init.d/$1 status >/dev/null
$SUDO $INITDIR/$1 status >/dev/null
;;
systemd)
$SUDO systemctl status $1 >/dev/null
......@@ -598,7 +616,7 @@ serv_status()
sudocmd service $SERVICE status "$@"
;;
service-update)
sudocmd /etc/init.d/$SERVICE status "$@"
sudocmd $INITDIR/$SERVICE status "$@"
;;
systemd)
sudocmd systemctl status $SERVICE "$@"
......@@ -621,7 +639,7 @@ serv_stop()
sudocmd service $SERVICE stop "$@"
;;
service-initd|service-update)
sudocmd /etc/init.d/$SERVICE stop "$@"
sudocmd $INITDIR/$SERVICE stop "$@"
;;
systemd)
sudocmd systemctl stop $SERVICE "$@"
......@@ -647,7 +665,7 @@ serv_try_restart()
;;
service-initd|service-update)
is_service_running $SERVICE || return 0
sudocmd /etc/init.d/$SERVICE restart "$@"
sudocmd $INITDIR/$SERVICE restart "$@"
;;
systemd)
sudocmd systemctl try-restart $SERVICE "$@"
......@@ -1003,6 +1021,8 @@ esac
}
INITDIR=/etc/init.d
PATH=$PATH:/sbin:/usr/sbin
set_sudo
......@@ -1092,7 +1112,7 @@ $(get_help HELPOPT)
print_version()
{
echo "Service manager version 1.5.0"
echo "Service manager version 1.5.4"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......@@ -1210,6 +1230,7 @@ if [ -z "$withoutservicename" ] && [ -z "$service_name" ] ; then
fatal "Run $ $progname --help for get help"
fi
# use common way if the command is unknown
if [ -z "$serv_cmd" ] ; then
serv_cmd=common
fi
......
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