Commit 0431bde5 authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to M60T as 1.0.7-alt0.M60T.1 (with rpmbph script)

parents 16c07df1 619658c2
......@@ -94,7 +94,6 @@ if distro altlinux-release ; then
elif has Walnut ; then DISTRIB_RELEASE="4.0"
elif has 5.0 ; then DISTRIB_RELEASE="5.0"
elif has 5.1 ; then DISTRIB_RELEASE="5.1"
elif has Ziziphora ; then DISTRIB_RELEASE="5.1"
elif has "ALT Linux p5" ; then DISTRIB_RELEASE="p5"
elif has "ALT Linux p6" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p7" ; then DISTRIB_RELEASE="p7"
......@@ -118,11 +117,7 @@ elif distro mopslinux-version ; then
fi
elif distro slackware-version ; then
DISTRIB_ID="Slackware"
if has 10.2 ; then DISTRIB_RELEASE="10.2"
elif has 11 ; then DISTRIB_RELEASE="11"
elif has 11.1 ; then DISTRIB_RELEASE="11.1"
elif has 12 ; then DISTRIB_RELEASE="12"
fi
DISTRIB_RELEASE="$(grep -Eo [0-9]+\.[0-9]+ $DISTROFILE)"
elif distro arch-release ; then
DISTRIB_ID="ArchLinux"
......
......@@ -28,6 +28,8 @@ load_helper()
load_helper epm-sh-functions
#PATH=$PATH:/sbin:/usr/sbin
set_sudo
check_tty
......@@ -81,6 +83,9 @@ case $progname in
epms)
epm_cmd=search
;;
epmq)
epm_cmd=query
;;
epmqf)
epm_cmd=query_file
;;
......@@ -106,43 +111,26 @@ check_command()
-i|install|add) # HELPCMD: install package(s) from remote repositories or from local file
epm_cmd=install
;;
reinstall) # HELPCMD: reinstall package(s) from remote repositories or from local file
epm_cmd=reinstall
;;
-e|-P|remove|delete) # HELPCMD: remove (delete) package(s) from the database and the system
epm_cmd=remove
;;
-qi|info|show) # HELPCMD: print package detail info
epm_cmd=info
;;
requires|deplist) # HELPCMD: print package requires
epm_cmd=requires
;;
clean) # HELPCMD: clean local package cache
epm_cmd=clean
;;
-qa|list|packages|-l) # HELPCMD: list of installed package(s)
epm_cmd=packages
-s|search) # HELPCMD: search in remote package repositories
epm_cmd=search
;;
-qp|query_package) # HELPCMD: search in the list of installed packages
epm_cmd=query_package
;;
update) # HELPCMD: update remote package repository databases
epm_cmd=update
;;
dist-upgrade|upgrade) # HELPCMD: performs upgrades of package software distributions
epm_cmd=upgrade
-qf|which|belongs) # HELPCMD: query package(s) owning file
epm_cmd=query_file
;;
-s|search) # HELPCMD: search in remote package repositories
epm_cmd=search
reinstall) # HELPCMD: reinstall package(s) from remote repositories or from local file
epm_cmd=reinstall
;;
-q|installed) # HELPCMD: check presence of package(s)
epm_cmd=query
;;
-qf|which|belongs) # HELPCMD: query package(s) owning file
epm_cmd=query_file
;;
-sf|filesearch|search_file) # HELPCMD: search in which package a file is included
-sf|sf|filesearch) # HELPCMD: search in which package a file is included
epm_cmd=search_file
;;
-ql|filelist) # HELPCMD: print package file list
......@@ -151,30 +139,58 @@ check_command()
check|fix|verify) # HELPCMD: check local package base integrity and fix it
epm_cmd=check
;;
checkpkg|integrity) # HELPCMD: check package integrity
epm_cmd=checkpkg
changelog|cl) # HELPCMD: show changelog for package
epm_cmd=changelog
;;
simulate) # HELPCMD: simulate install (check requires)
epm_cmd=simulate
-qi|info|show) # HELPCMD: print package detail info
epm_cmd=info
;;
requires|deplist) # HELPCMD: print package requires
epm_cmd=requires
;;
-qa|list|packages|-l) # HELPCMD: list of installed package(s)
epm_cmd=packages
;;
update) # HELPCMD: update remote package repository databases
epm_cmd=update
;;
addrepo|ar) # HELPCMD: add package repo
epm_cmd=addrepo
;;
repolist|sl|listrepo) # HELPCMD: print repo list
repolist|sl|rl|listrepo) # HELPCMD: print repo list
epm_cmd=repolist
;;
removerepo|rr) # HELPCMD: remove package repo
epm_cmd=removerepo
;;
clean) # HELPCMD: clean local package cache
epm_cmd=clean
;;
autoremove) # HELPCMD: auto remove unneeded package(s)
epm_cmd=autoremove
;;
upgrade|dist-upgrade) # HELPCMD: performs upgrades of package software distributions
epm_cmd=upgrade
;;
simulate) # HELPCMD: simulate install (it does check requires, minimally)
epm_cmd=simulate
;;
checkpkg|integrity) # HELPCMD: check package integrity
epm_cmd=checkpkg
;;
*)
return 1
;;
esac
return 0
}
for opt in "$@" ; do
check_command $opt && continue
case $opt in
check_option()
{
case $1 in
-h|--help|help) # HELPOPT: this help
phelp
exit 0
......@@ -189,7 +205,7 @@ for opt in "$@" ; do
--skip-installed) # HELPOPT: skip already install during install
skip_installed=1
;;
--show-command-only) # HELPOPT: show command only, do not any action
--show-command-only) # HELPOPT: show command only, do not any action (supports install and remove ONLY)
show_command_only=1
;;
--quiet) # HELPOPT: quiet mode (do not print commands before exec)
......@@ -205,13 +221,21 @@ for opt in "$@" ; do
non_interactive=1
;;
*)
return 1
;;
esac
return 0
}
for opt in "$@" ; do
check_command $opt && continue
check_option $opt && continue
if [ -f "$opt" ] ; then
pkg_files="$pkg_files $opt"
else
pkg_names="$pkg_names $opt"
fi
;;
esac
done
pkg_files=$(strip_spaces "$pkg_files")
......@@ -219,6 +243,7 @@ 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"
......
......@@ -42,6 +42,9 @@ case $PMTYPE in
pacman)
echo "You need manually add repo to /etc/pacman.conf"
;;
npackd)
docmd npackdcl add-repo --url=$pkg_filenames
;;
slackpkg)
echo "You need manually add repo to /etc/slackpkg/mirrors"
;;
......
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
epm_autoclean()
{
case $PMTYPE in
#apt-rpm)
# sudocmd apt-get autoclean
# ;;
apt-dpkg)
sudocmd apt-get autoclean
;;
#yum-rpm)
# sudocmd yum clean all
# ;;
#urpm-rpm)
# sudocmd urpmi --clean
# ;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
*)
fatal "Do not known command for $PMTYPE"
;;
esac
}
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
load_helper epm-query
__epm_changelog_files()
{
[ -z "$@" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm)
docmd_foreach "rpm -p --changelog" $@ | less
;;
# apt-dpkg)
#
# ;;
*)
fatal "Do not known command for $PMTYPE"
;;
esac
}
__epm_changelog_local_names()
{
[ -z "$@" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm --changelog" $@ | less
;;
apt-dpkg)
# FIXME: only first pkg
docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
;;
emerge)
docmd view /usr/portage/category/$1/ChangeLog | less
;;
pacman)
docmd pacman -Qc package | less
;;
*)
fatal "Do not known command for $PMTYPE"
;;
esac
}
__epm_changelog_unlocal_names()
{
[ -z "$@" ] && return
case $PMTYPE in
#apt-rpm)
# docmd_foreach "rpm --changelog" $@ | less
# ;;
#apt-dpkg)
# # FIXME: only first pkg
# docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
# ;;
#yum-rpm)
# sudocmd yum clean all
# ;;
#urpm-rpm)
# sudocmd urpmi --clean
# ;;
#zypper-rpm)
# sudocmd zypper clean
# ;;
*)
fatal "Do not known command for $PMTYPE"
;;
esac
}
epm_changelog()
{
[ -n "$pkg_filenames" ] || fatal "Run changelog without params"
__epm_changelog_files $pkg_files
local pkg
for pkg in $pkg_names ; do
if is_installed $pkg ; then
__epm_changelog_local_names $pkg
else
__epm_changelog_unlocal_names $pkg
fi
done
}
......@@ -25,6 +25,7 @@ check_rpm_integrity()
check_deb_integrity()
{
# FIXME: debsums -ca package ?
a= dpkg --contents $@ >/dev/null
}
......@@ -82,8 +83,8 @@ check_pkg_integrity()
epm_checkpkg()
{
[ -n "$pkg_files" ] || fatal "Run without names"
for i in $pkg_files ; do
check_pkg_integrity $i || fatal "Broken package $i"
local pkg
for pkg in $pkg_files ; do
check_pkg_integrity $pkg || fatal "Broken package $pkg"
done
}
......@@ -20,11 +20,34 @@
load_helper epm-query
epm_filelist()
__epm_filelist_file()
{
[ -n "$pkg_filenames" ] || fatal "Run query without names"
local CMD
[ -z "$@" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
CMD="rpm -qlp"
;;
apt-dpkg)
CMD="dpkg --contents"
;;
*)
fatal "Do not known query command for $PMTYPE"
;;
esac
docmd $CMD $@
}
case $PMTYPE in
__epm_filelist_name()
{
local CMD
[ -z "$@" ] && return
case $PMTYPE in
apt-rpm)
CMD="rpm -ql"
;;
......@@ -43,13 +66,27 @@ case $PMTYPE in
pacman)
CMD="pacman -Ql"
;;
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}*
return
;;
*)
fatal "Do not known query command for $PMTYPE"
;;
esac
esac
docmd $CMD $pkg_names && return
is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized"
}
epm_filelist()
{
[ -n "$pkg_filenames" ] || fatal "Run query without names"
docmd $CMD $pkg_filenames && return
epm_query >/dev/null || fatal "Query filelist for non installed packages does not realized"
__epm_filelist_file $pkg_files || return
__epm_filelist_name $pkg_names || return
}
......@@ -20,33 +20,47 @@
load_helper epm-query
epm_info()
__epm_info_rpm_low()
{
case $PMTYPE in
apt-rpm)
if [ -n "$pkg_files" ] ; then
docmd rpm -qip $pkg_files
fi
[ -z "$pkg_names" ] && return
pkg_filenames=$pkg_names epm_query >/dev/null && docmd rpm -qi $pkg_names && return
is_installed $pkg_names && docmd rpm -qi $pkg_names && return
}
epm_info()
{
case $PMTYPE in
apt-rpm)
__epm_info_rpm_low && return
docmd apt-cache show $pkg_names
;;
apt-dpkg)
if [ -n "$pkg_files" ] ; then
docmd dpkg -I $pkg_files
fi
[ -z "$pkg_names" ] && return
pkg_filenames=$pkg_names epm_query >/dev/null && docmd dpkg -I $pkg_names && return
is_installed $pkg_names && docmd dpkg -p $pkg_names && return
docmd apt-cache show $pkg_names
;;
yum-rpm)
__epm_info_rpm_low && return
docmd yum info $pkg_names
;;
zypper-rpm)
__epm_info_rpm_low && return
docmd zypper info $pkg_names
;;
pacman)
docmd pacman -Si $pkg_names
;;
npackd)
# FIXME: --version=
docmd npackdcl info --package=$pkg_names
;;
slackpkg)
docmd slackpkg info $pkg_names
docmd /usr/sbin/slackpkg info $pkg_names
;;
*)
fatal "Do not known command for $PMTYPE"
......
......@@ -23,6 +23,7 @@ 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
......@@ -80,7 +81,7 @@ epm_install_names()
return ;;
slackpkg)
# TODO: use upgrade if package is already installed
sudocmd slackpkg install $@
sudocmd /usr/sbin/slackpkg install $@
return ;;
*)
fatal "Do not known install command for $PMTYPE"
......@@ -111,9 +112,16 @@ epm_ni_install_names()
pacman)
sudocmd pacman -S --noconfirm $@
return ;;
npackd)
# npackdcl update --package=<package> (remove old and install new)
docmd npackdcl add --package=$@
return ;;
chocolatey)
docmd chocolatey install $@
return ;;
slackpkg)
# TODO: use upgrade if package is already installed
sudocmd slackpkg -batch=on -default_answer=yes install $@
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes install $@
return ;;
*)
fatal "Do not known appropriate install command for $PMTYPE"
......@@ -145,7 +153,7 @@ epm_install_files()
sudocmd pacman -U --noconfirm $@
return ;;
slackpkg)
sudocmd installpkg $@
sudocmd /sbin/installpkg $@
return ;;
esac
......@@ -169,7 +177,10 @@ epm_print_install_command()
echo "pacman -U --noconfirm $@"
;;
slackpkg)
echo "installpkg $@"
echo "/sbin/installpkg $@"
;;
npackd)
echo "npackdcl add --package=$@"
;;
*)
fatal "Do not known appropriate install command for $PMTYPE"
......@@ -181,7 +192,7 @@ epm_print_install_command()
epm_install()
{
if [ -n "$show_command_only" ] ; then
epm_print_install_command $names
epm_print_install_command $pkg_filenames
return
fi
......
......@@ -20,6 +20,7 @@
epm_packages()
{
local CMD
case $PMTYPE in
apt-rpm)
......@@ -40,6 +41,12 @@ case $PMTYPE in
pacman)
CMD="pacman -Qs"
;;
npackd)
CMD="npackdcl list"
;;
# chocolatey)
# CMD="chocolatey list"
# ;;
slackpkg)
CMD="ls -1 /var/log/packages/"
;;
......
......@@ -22,11 +22,50 @@ load_helper epm-packages
# TODO: combine with -qa (the difference only in return status now)
epm_query()
_query_via_packages_list()
{
[ -n "$pkg_filenames" ] || fatal "Run query without names"
local res=0
local firstpkg=$1
shift
epm_packages | grep "$firstpkg-" || res=1
for pkg in "$@" ; do
epm_packages 2>/dev/null | grep "$pkg-" || res=1
done
return $res
}
__epm_query_file()
{
local CMD
[ -z "$@" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
CMD="rpm -qp"
;;
apt-dpkg)
CMD="dpkg-deb --show"
# TODO: make rpm-like output
#showcmd dpkg -l $pkg_filenames
#dpkg -l $pkg_filenames | grep "^ii"
#return
;;
*)
fatal "Do not know command for query file package"
;;
esac
docmd $CMD $@
}
__epm_query_name()
{
local CMD
[ -z "$@" ] && return
case $PMTYPE in
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm)
CMD="rpm -q"
;;
......@@ -37,11 +76,29 @@ case $PMTYPE in
#dpkg -l $pkg_filenames | grep "^ii"
#return
;;
npackd)
CMD="npackdcl path --package=$@"
;;
*)
epm_packages | grep "$pkg_filenames"
_query_via_packages_list $@
return
;;
esac
esac
docmd $CMD $@
}
# check if pkg is installed
is_installed()
{
pkg_filenames="$@" epm_query >/dev/null
}
epm_query()
{
[ -n "$pkg_filenames" ] || fatal "Run query without names"
docmd $CMD $pkg_filenames
__epm_query_file $pkg_files || return
__epm_query_name $pkg_names || return
}
......@@ -23,7 +23,7 @@ load_helper epm-search_file
# copied from etersoft-build-utils/bin/rpmqf
# use and modify TOFILE recursively
real_file()
__do_query_real_file()
{
local LINKTO1 LINKTO
local TOFILE
......@@ -40,16 +40,17 @@ real_file()
# get value of symbolic link
if [ -L "$TOFILE" ] ; then
__do_query $TOFILE
LINKTO=`readlink "$TOFILE"`
echo "Note: $TOFILE is link to $LINKTO"
real_file "$LINKTO"
__do_query_real_file "$LINKTO"
fi
FULLFILEPATH=`readlink -f $TOFILE`
FULLFILEPATH=`realpath $TOFILE`
}
dpkg_print_name_version()
{
local ver
local ver i
for i in $* ; do
ver=$(dpkg -s $i 2>/dev/null | grep "Version:" | sed -e "s|Version: ||g")
if [ -z "$ver" ] ; then
......@@ -83,6 +84,11 @@ __do_query()
pacman)
CMD="pacman -Qo"
;;
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
;;
*)
fatal "Do not known query command for $PMTYPE"
;;
......@@ -96,10 +102,9 @@ epm_query_file()
# file can exists or not
[ -n "$pkg_filenames" ] || fatal "Run query without file names"
for i in $pkg_filenames ; do
real_file "$i"
__do_query $FULLFILEPATH || pkg_filenames=$i epm_search_file
done
for pkg in $pkg_filenames ; do
__do_query_real_file "$pkg"
__do_query $FULLFILEPATH || pkg_filenames=$pkg epm_search_file
done
}
......@@ -42,7 +42,7 @@ epm_reinstall_names()
sudocmd pacman -U $@
return ;;
slackpkg)
sudocmd slackpkg reinstall $@
sudocmd /usr/sbin/slackpkg reinstall $@
return ;;
*)
fatal "Do not known install command for $PMTYPE"
......@@ -63,7 +63,7 @@ epm_reinstall_files()
sudocmd dpkg -i $@
return ;;
slackpkg)
sudocmd installpkg $@
sudocmd /sbin/installpkg $@
return ;;
esac
......
......@@ -33,10 +33,10 @@ epm_remove_low()
sudocmd pkg_delete -r $@
return ;;
emerge)
sudocmd emerge -unmerge $@
sudocmd emerge --unmerge $@
return ;;
slackpkg)
sudocmd removepkg $@
sudocmd /sbin/removepkg $@
return ;;
esac
return 1
......@@ -72,8 +72,14 @@ epm_remove_names()
mpkg)
sudocmd mpkg remove $@
return ;;
npackd)
docmd npackdcl remove --package=$@
return ;;
chocolatey)
docmd chocolatey uninstall $@
return ;;
slackpkg)
sudocmd slackpkg remove $@
sudocmd /usr/sbin/slackpkg remove $@
return ;;
*)
fatal "Do not known command for $PMTYPE"
......@@ -101,15 +107,46 @@ epm_remove_nonint()
sudocmd zypper --non-interactive remove $@
return ;;
slackpkg)
sudocmd slackpkg -batch=on -default_answer=yes remove $@
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes remove $@
return ;;
esac
return 5
}
epm_print_remove_command()
{
case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm)
echo "rpm -ev $nodeps $@"
;;
apt-dpkg)
echo "dpkg -P $@"
;;
pkg_add)
echo "pkg_delete -r $@"
;;
emerge)
echo "emerge --unmerge $@"
;;
slackpkg)
echo "/sbin/removepkg $@"
;;
*)
fatal "Do not known appropriate remove command for $PMTYPE"
;;
esac
}
epm_remove()
{
if [ -n "$show_command_only" ] ; then
epm_print_remove_command $pkg_filenames
return
fi
[ -n "$pkg_files" ] && fatal "FIXME: remove by package file is not supported yet"
[ -n "$pkg_filenames" ] || fatal "Run remove without args"
epm_remove_low $pkg_filenames && return
......
......@@ -42,6 +42,9 @@ case $PMTYPE in
pacman)
echo "You need remove repo from /etc/pacman.conf"
;;
npackd)
docmd npackdcl remove-repo --url=$pkg_filenames
;;
slackpkg)
echo "You need remove repo from /etc/slackpkg/mirrors"
;;
......
......@@ -20,6 +20,7 @@
print_apt_sources_list()
{
local i
for i in $@ ; do
test -r "$i" || continue
#echo
......@@ -51,10 +52,10 @@ case $PMTYPE in
docmd layman -L
;;
pacman)
docmd cat /etc/pacman.conf
docmd grep -v "^#\|^$" /etc/pacman.conf
;;
slackpkg)
docmd cat /etc/slackpkg/mirrors
docmd grep -v "^#\|^$" /etc/slackpkg/mirrors
;;
*)
fatal "Do not known command for $PMTYPE"
......
......@@ -18,12 +18,9 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
load_helper epm-packages
# TODO: combine with -qa (the difference only in return status now)
epm_requires()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Run query without names"
# by file package
......
......@@ -22,6 +22,7 @@
epm_search()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Run search without names"
case $PMTYPE in
......@@ -49,8 +50,17 @@ case $PMTYPE in
mpkg)
CMD="mpkg search"
;;
npackd)
fatal "FIXME: Have not idea for search with npackdcl list"
;;
chocolatey)
CMD="chocolatey list"
;;
slackpkg)
CMD="slackpkg search"
# FIXME
echo "FIXME: need case insensitive search"
docmd_foreach "/usr/sbin/slackpkg search" $pkg_filenames
return
;;
*)
fatal "Do not known search command for $PMTYPE"
......
......@@ -29,8 +29,9 @@ local_content_search()
local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
local CI=$REPODIR/$SYSARCH/base/contents_index
local CINOA=$REPODIR/noarch/base/contents_index
local OUTCMD="less"
[ -n "$USETTY" ] || OUTCMD="cat"
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD="cat"
test -r $CI && test -r $CINOA || fatal "Can't locate $CI or $CINOA"
......@@ -42,6 +43,7 @@ local_content_search()
epm_search_file()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Run search without names"
case $PMTYPE in
......@@ -65,7 +67,7 @@ case $PMTYPE in
CMD="pacman -Qo"
;;
slackpkg)
CMD="slackpkg file-search"
CMD="/usr/sbin/slackpkg file-search"
;;
*)
fatal "Do not known search file command for $PMTYPE"
......
......@@ -30,6 +30,10 @@ isatty()
check_tty()
{
isatty || return
which tput >/dev/null 2>/dev/null || return
# FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return
[ -z "$USETTY" ] || return
export USETTY=1
}
......@@ -37,7 +41,7 @@ check_tty()
set_boldcolor()
{
[ -n "$USETTY" ] || return
[ "$USETTY" = "1" ] || return
{
echo bold
echo setaf $1
......@@ -46,7 +50,7 @@ set_boldcolor()
restore_color()
{
[ -n "$USETTY" ] || return
[ "$USETTY" = "1" ] || return
{
echo op; # set Original color Pair.
echo sgr0; # turn off all special graphics mode (bold in our case).
......@@ -56,7 +60,7 @@ restore_color()
echover()
{
[ -n "$verbose" ] || return
echo "$*"
echo "$*" >&2
}
# Used DISTRNAME
......@@ -93,6 +97,18 @@ docmd()
"$@"
}
# Print command line and run command line
docmd_foreach()
{
local cmd
cmd="$1"
#showcmd "$@"
shift
for pkg in "$@" ; do
docmd $cmd $pkg
done
}
# Print command line and run command line with SUDO
sudocmd()
{
......@@ -127,12 +143,20 @@ fatal()
set_sudo()
{
SUDO=""
# skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return
# set SUDO not for root user
SUDO="sudo"
[ -n "$UID" ] || UID=`id -u`
if [ $UID = "0" ]; then
SUDO=""
fi
# do not need sudo
[ $UID = "0" ] && return
# use sudo if possible
which sudo >/dev/null 2>/dev/null && SUDO="sudo" && return
SUDO="fatal 'Can't find sudo. Please install sudo or run epm under root.'"
}
# print options description from HELPCMD/HELPOPT lines in the code
......@@ -185,6 +209,9 @@ case $DISTRNAME in
SUSE|SLED|SLES)
CMD="zypper-rpm"
;;
Windows)
CMD="chocolatey"
;;
*)
fatal "Do not known DISTRNAME $DISTRNAME"
;;
......
......@@ -19,23 +19,22 @@
#
load_helper epm-install
load_helper epm-search
epm_simulate()
_epm_do_simulate()
{
local CMD
[ -z "$pkg_filenames" ] && echo "Skip empty list" && return 2
local filenames="$(echo $pkg_filenames | filter_out_installed_packages)"
[ -z "$filenames" ] && echo "All packages are already installed" && return 2
local filenames=$@
case $PMTYPE in
apt-rpm|apt-dpkg)
CMD="apt-get --simulate install"
;;
yum-rpm)
CMD="yum provides"
;;
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
return 0 ;;
urpm-rpm)
CMD="urpmi --test --auto"
;;
......@@ -50,8 +49,18 @@ epm_simulate()
echo no | $SUDO pacman -v -S $filenames
return ;;
slackpkg)
docmd slackpkg -batch=on -default_answer=yes download
;;
#docmd /usr/sbin/slackpkg -batch=on -default_answer=yes download
# just try search every package
# FIXME: epm_search have to return false status code if the package does not found
local pkg res
res=0
for pkg in $filenames ; do
pkg_filenames="$pkg-[0-9]" epm_search | grep -E "(installed|upgrade)" && continue
pkg_filenames="$pkg" epm_search | grep -E "(installed|upgrade)" && continue
res=1
echo "Does not found in repository."
done
return $res ;;
*)
fatal "Do not known simulate command for $PMTYPE"
;;
......@@ -60,3 +69,19 @@ epm_simulate()
sudocmd $CMD $filenames
}
epm_simulate()
{
[ -z "$pkg_filenames" ] && echo "Skip empty list" && return 2
local filenames="$(echo $pkg_filenames | filter_out_installed_packages)"
[ -z "$filenames" ] && echo "All packages are already installed" && return 0
_epm_do_simulate $filenames
local RES=$?
if [ -z "$quiet" ] ; then
[ "$RES" = 0 ] && echo "Result: $filenames package(s) CAN BE installed" || echo "Result: There are PROBLEMS with install some package(s)"
fi
return $RES
}
......@@ -48,7 +48,7 @@ case $PMTYPE in
sudocmd emerge --sync
;;
slackpkg)
sudocmd slackpkg update
sudocmd /usr/sbin/slackpkg update
;;
*)
fatal "Do not known update command for $PMTYPE"
......
......@@ -20,7 +20,9 @@
epm_upgrade()
{
local CMD
echo "Run command for upgrade packages"
case $PMTYPE in
apt-rpm|apt-dpkg)
# FIXME: apt-get update before
......@@ -45,8 +47,11 @@ epm_upgrade()
pkg_add)
CMD="freebsd-update fetch install"
;;
chocolatey)
CMD="chocolatey update all"
;;
slackpkg)
CMD="slackpkg upgrade-all"
CMD="/usr/sbin/slackpkg upgrade-all"
;;
*)
fatal "Do not known command for $PMTYPE"
......
epm
\ No newline at end of file
# This spec is backported to ALTLinux t6 automatically by rpmbph script. Do not edit it.
#
Name: eepm
Version: 1.0.2
Version: 1.0.7
Release: alt0.M60T.1
Summary: Etersoft EPM package manager
......@@ -51,9 +51,49 @@ with various distros.
%_bindir/distr_info
%changelog
* Fri Oct 05 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.2-alt0.M60T.1
* Sat Dec 08 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.7-alt0.M60T.1
- backport to ALTLinux t6 (by rpmbph script)
* Sat Dec 08 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.7-alt1
- add epmq command as alias to epm -q (epm query)
- epm: rearrange command help
- epm-remove: warning about no support remove by package file
* Sat Nov 24 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.6-alt1
- epm: add changelog (cl) command
- add support for work without tput, with uncompat tput, allow USETTY=0 for disable tput use
- epm: write verbose output to stderr
- epm-filelist: add support for filelist of file package
- epm-query: add support for query file package
- epm-info: rewrite for support low level and hi level package info
- epm-simulate: return 0 if all needed packages are already installed
* Mon Oct 29 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.5-alt1
- epm-simulate: fix for non numeric version on Slackware (libjpeg-v8a)
- epm: intoduce autoremove command
- epm-search_file: do not use less
- epm-query_file: query package for every full path, not only last
* Fri Oct 26 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.4-alt1
- epm-simulate: fix simulate for yum
- epm-simulate: realize simulate for slackware
- epm-search: fix search for multiple packages in slackware
- epm-query: fix query for multiple names
- epm-query_file: more clean output on Slackware
- epm-simulate: print out result of the check
* Mon Oct 22 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.3-alt1
- rewrite set_sudo, skip SUDO if env. var EPMNOSUDO is not empty
- add initial support for window package manager Chocolatey
- add initial support for windows package manager Npackd
- epm-filelist: print package file list for slackware
- epm-query_file: add slackware support (thanks, bormant)
- distr_info: grep version from /etc/slackware-version (thanks, bormant)
- set_sudo: print fatal error if needed absent sudo
- use full path to slackpkg/installpkg/removepkg on Slackware (thanks, bormant)
- epm-remove: add support for --show-command-only (thanks, bormant)
- epm-repolist: fix grep source list (thanks, bormant)
* Tue Sep 18 2012 Vitaly Lipatov <lav@altlinux.ru> 1.0.2-alt1
- replace all docmd $SUDO with sudocmd call
- fix install package rpm-build-altlinux-compat via package fullname
......
#!/bin/sh
cepm()
{
echo
../bin/epm --verbose $@ >/dev/null
}
cepm changelog mc
cepm filelist mc
cepm info mc
cepm -q mc
cepm -qf mc
cepm requires mc
# query packages
#cepm -qp mc
#cepm install mc
#cepm packages mc
#cepm search 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