Commit aeac7c5d authored by Vitaly Lipatov's avatar Vitaly Lipatov

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

parents 0bdbb892 5fd32a7e
[18:21:12] <danil> Вот так можно:
RED='\033[0;31m' ; NC='\033[0m' b="b" ; echo -e "aba" | sed -e "s|${b}|\\${RED}${b}\\${NC}|g" | xargs -0 printf
[18:23:40] <danil> > Ты знаешь способы?
colorise_word(){ //aba b
RED='\033[0;31m'
NC='\033[0m' b="b"
echo -e "$1" | sed -e "s|${2}|\\${RED}${2}\\${NC}|g" | xargs -0 printf
}
[18:24:18] <lav> Ну в общем-то да... Ещё можно попробовать готовый
yum list extras – имена тех пакетов, которые наличествуют в системе, но которыми в репозиториях и не пахло, то есть установленные “в лоб”, например, через
--dump-options for write simple bash completition
add epm site / epmurl in replace to rpmurl
......
......@@ -87,8 +87,12 @@ fi
if distro altlinux-release ; then
DISTRIB_ID="ALTLinux"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7.0" ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux 6.0" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p8" ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux p7" ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux p6" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p5" ; then DISTRIB_RELEASE="p5"
......
......@@ -28,7 +28,8 @@ case $PMTYPE in
info "You need manually add repo to /etc/apt/sources.list"
;;
yum-rpm)
info "You need manually add repo to /etc/yum.repos.d/"
assure_exists yum-utils
sudocmd yum-config-manager --add-repo "$pkg_filenames"
;;
urpm-rpm)
sudocmd urpmi.addmedia "$pkg_filenames"
......
......@@ -19,6 +19,9 @@
epm_audit()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
pkgng)
sudocmd pkg audit -F
......
......@@ -19,6 +19,10 @@
epm_autoorphans()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
#apt-rpm)
# ALT Linux only
......@@ -31,7 +35,7 @@ case $PMTYPE in
apt-dpkg|aptitude-dpkg)
assure_exists deborphan
showcmd deborphan
deborphan | sudocmd epm remove
a= deborphan | sudocmd epm remove
;;
#aura)
# sudocmd aura -Oj
......
......@@ -37,6 +37,10 @@ __epm_autoremove_altrpm()
epm_autoremove()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm)
# ALT Linux only
......@@ -62,6 +66,9 @@ case $PMTYPE in
sudocmd yum remove $PKGLIST
done
;;
dnf-rpm)
sudocmd dnf autoremove
;;
# see autoorhans
#urpm-rpm)
# sudocmd urpme --auto-orphans
......
......@@ -58,10 +58,11 @@ update_repo_if_needed()
sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; }
fi
cd /
if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then
load_helper epm-update
epm_update
return
pkg_filenames= epm_update
fi
cd - >/dev/null
}
......@@ -22,10 +22,11 @@
epm_checksystem_ALTLinux()
{
local TDIR=$(mktemp -d)
assure_exists time
touch $TDIR/added
for ft in $(ls /usr/lib/rpm/*.filetrigger | sort) ; do
echo "Try run $ft ..."
echo $TDIR/added $TDIR/removed | time $ft
echo $TDIR/added $TDIR/removed | a= time $ft
done
rm -f $TDIR/added fatal
rmdir $TDIR || fatal
......@@ -50,6 +51,10 @@ esac
}
SUDO=sudo
DISTRNAME=ALTLinux
epm_checksystem
# direct debug run
if [ "$1" = "--debug" ] ; then
shift
SUDO=sudo
DISTRNAME=ALTLinux
epm_checksystem
fi
......@@ -36,6 +36,10 @@ __remove_deb_apt_cache_file()
epm_clean()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm)
sudocmd apt-get clean
......
#!/bin/sh
#
# Copyright (C) 2012,2014 Etersoft
# Copyright (C) 2012,2014 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,2014,2016 Etersoft
# Copyright (C) 2012,2014,2016 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
......@@ -19,13 +19,39 @@
load_helper epm-check_updated_repo
__epm_add_apt_downgrade_preferences()
__epm_add_alt_apt_downgrade_preferences()
{
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
cat <<EOF | $SUDO tee /etc/apt/preferences
# main repo
Package: *
Pin: release c=$1
Pin: release c=classic
Pin-Priority: 1001
# overload with addon repo
Package: *
Pin: release c=addon
Pin-Priority: 1101
EOF
}
# See https://wiki.debian.org/ru/AptPreferences
__epm_add_deb_apt_downgrade_preferences()
{
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
info "Running with /etc/apt/preferences:"
cat <<EOF | $SUDO tee /etc/apt/preferences
Package: *
Pin: release a=stable
Pin-Priority: 1001
Package: *
Pin: release a=testing
Pin-Priority: 900
Package: *
Pin: release a=unstable
Pin-Priority: 800
EOF
}
......@@ -45,21 +71,29 @@ epm_downgrade()
case $PMTYPE in
apt-rpm)
__epm_add_apt_downgrade_preferences classic || return
__epm_add_alt_apt_downgrade_preferences || return
if [ -n "$pkg_filenames" ] ; then
sudocmd apt-get install $pkg_filenames
else
sudocmd apt-get dist-upgrade
fi
__epm_remove_apt_downgrade_preferences
;;
apt-dpkg)
__epm_add_apt_downgrade_preferences testing || return
__epm_add_deb_apt_downgrade_preferences || return
if [ -n "$pkg_filenames" ] ; then
sudocmd apt-get install $pkg_filenames
else
sudocmd apt-get dist-upgrade
fi
__epm_remove_apt_downgrade_preferences
;;
yum-rpm)
# can do update repobase automagically
sudocmd yum downgrade $pkg_filename
sudocmd yum downgrade $pkg_filenames
;;
dnf-rpm)
sudocmd dnf downgrade $pkg_filename
sudocmd dnf downgrade $pkg_filenames
;;
urpm-rpm)
assure_exists urpm-reposync urpm-tools
......
......@@ -43,7 +43,7 @@ __alt_local_content_filelist()
__deb_local_content_filelist()
{
showcmd "apt-file list $1 | grep '^$1: ' | sed -e 's|$1: ||g'"
apt-file list "$1" | grep "^$1: " | sed -e "s|$1: ||g"
a= apt-file list "$1" | grep "^$1: " | sed -e "s|$1: ||g"
}
......
......@@ -24,7 +24,7 @@ epm_kernel_update()
case $DISTRNAME in
ALTLinux)
assure_exists update-kernel
sudocmd update-kernel
sudocmd update-kernel $pkg_filenames
return ;;
esac
......
......@@ -32,6 +32,8 @@ __repack_rpm_base()
epm_optimize()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
*-rpm)
#__repack_rpm_base
......
......@@ -134,6 +134,7 @@ case $PMTYPE in
CMD="apt-cyg list $pkg_filenames"
if [ -z "$short" ] ; then
showcmd $CMD
# TODO: fix this slow way
for i in $($CMD) ; do
__aptcyg_print_full $i
done
......
#!/bin/sh
#
# Copyright (C) 2015 Etersoft
# Copyright (C) 2008, 2015 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2015, 2016 Etersoft
# Copyright (C) 2008, 2015, 2016 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
......@@ -77,6 +77,12 @@ print_srcname()
print_name $(print_srcpkgname "$@")
}
print_specname()
{
# CHECKME: it is possible to have two or more specs in one package?
rpm -qlp "$@" | grep "\.spec\$"
}
print_srcpkgname()
{
query_package_field sourcerpm "$@"
......@@ -113,9 +119,10 @@ cat <<EOF
epm print version [from filename|for package] NN print only version of package name or package file
epm print release [from filename|for package] NN print only release of package name or package file
epm print field FF for package NN print field of the package
epm print pkgname from filename NN print package name for package file
epm print srcname from filename NN print source name for package file
epm print pkgname from filename NN print package name for the package file
epm print srcname from filename NN print source name for the package file
epm print srcpkgname from [filename|package] NN print source package name for the binary package file
epm print specname from filename NN print spec filename for the source package file
epm print binpkgfilelist in DIR for NN list binary package(s) filename(s) from DIR for the source package file
EOF
;;
......@@ -172,6 +179,11 @@ EOF
[ -n "$1" ] || fatal "Arg is missed"
print_srcpkgname "$@"
;;
"specname")
[ -n "$FNFLAG" ] || [ -n "$PKFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
print_specname "$@"
;;
"binpkgfilelist")
# TODO: rpm only
# TODO: replace get_binpkg_list
......
......@@ -63,7 +63,7 @@ case $PMTYPE in
return
fi
;;
urpm-rpm|zypper-rpm|yum-rpm)
urpm-rpm|zypper-rpm|yum-rpm|dnf-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --provides"
else
......
......@@ -66,12 +66,12 @@ _query_via_packages_list()
# Note: we use short=1 here due grep by ^name$
# separate first line for print out command
short=1 pkg_filenames=$firstpkg epm_packages | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$firstpkg epm_packages $firstpkg || res=1
short=1 pkg_filenames=$firstpkg epm_packages | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$firstpkg epm_packages || res=1
local pkg
for pkg in "$@" ; do
grepexp=$(_get_grep_exp $pkg)
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$pkg epm_packages $pkg || res=1
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$pkg epm_packages || res=1
done
return $res
......
......@@ -146,6 +146,7 @@ __do_short_query()
epm_query_file()
{
# И где это используется?
# in short mode print handle only real names and do short output
# TODO: move to separate command?
# FIXME: it is possible use query
......
......@@ -27,5 +27,6 @@ epm_query_package()
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS
# Note: get all packages list and do grep
eval "pkg_filenames= epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS"
}
......@@ -35,7 +35,7 @@ epm_reinstall_names()
sudocmd dnf reinstall $@
return ;;
pkgng)
sudocmf pkg install -f $@
sudocmd pkg install -f $@
return ;;
slackpkg)
sudocmd_foreach "/usr/sbin/slackpkg reinstall" $@
......
......@@ -28,7 +28,8 @@ case $PMTYPE in
info "You need remove repo from /etc/apt/sources.list"
;;
yum-rpm)
info "You need remove repo from /etc/yum.repos.d/"
assure_exists yum-utils
sudocmd yum-config-manager --disable "$pkg_filenames"
;;
urpm-rpm)
sudocmd urpmi.removemedia "$pkg_filenames"
......
......@@ -31,6 +31,9 @@ __fix_apt_sources_list()
epm_repofix()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
......
......@@ -68,7 +68,18 @@ case $PMTYPE in
CMD="rpm -q --requires"
;;
yum-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --requires"
else
CMD="yum deplist"
fi
;;
dnf-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --requires"
else
CMD="dnf repoquery --requires"
fi
;;
pacman)
CMD="pactree"
......
......@@ -96,7 +96,7 @@ case $PMTYPE in
;;
esac
docmd $CMD $string
LANG=C docmd $CMD $string
}
# TODO: use ^ as first word, use ~ for negate, for epmqp too
......@@ -123,22 +123,28 @@ __epm_search_make_grep()
#list=$(strip_spaces $list | sed -e "s/ /|/g")
listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g")
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
[ -n "$listN" ] && echon " | egrep -i -v -- \"$listN\""
# FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
# Need only if we have more than one word (with one word we will grep for colorify)
if [ "$(echo "$list" | wc -w)" -gt 1 ] ; then
for i in $list ; do
# FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
# FIXME: move from it
#isatty || return
# TODO: sorts word by length from large to short
local COLO=""
# rule for colorife
for i in $list $listN; do
......@@ -146,6 +152,7 @@ __epm_search_make_grep()
COLO="$COLO$i"
done
# TODO: use some colorifer instead grep (check grep adove too)
if [ -n "$list" ] ; then
echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi
......
......@@ -49,9 +49,13 @@ case $PMTYPE in
docmd apt-file search $pkg_filenames
return ;;
yum-rpm)
# TODO
info "Search by full packages list does not realized"
CMD="yum provides"
;;
dnf-rpm)
# TODO
info "Search by full packages list does not realized"
CMD="dnf provides"
;;
urpm-rpm)
......
#!/bin/sh
#
# Copyright (C) 2015 Etersoft
# Copyright (C) 2015 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2015,2016 Etersoft
# Copyright (C) 2015,2016 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,6 +20,8 @@
load_helper epm-query
load_helper epm-print
PAOURL="https://packages.altlinux.org"
run_command_if_exists()
{
local CMD="$1"
......@@ -41,12 +43,13 @@ open_browser()
__query_package_hl_url()
{
local PAOAPI="$PAOURL/api"
case $DISTRNAME in
ALTLinux)
# http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs
epm assure curl || return 1
showcmd curl "http://packages.altlinux.org/api/srpms/$1"
curl -s --header "Accept: application/json" "http://packages.altlinux.org/api/srpms/$1" | grep '"url"' | sed -e 's|.*"url":"||g' | sed -e 's|".*||g'
showcmd curl "$PAOAPI/srpms/$1"
curl -s --header "Accept: application/json" "$PAOAPI/srpms/$1" | grep '"url"' | sed -e 's|.*"url":"||g' | sed -e 's|".*||g'
return 0
;;
esac
......@@ -87,7 +90,7 @@ get_pao_url()
*)
loc=en
esac
echo "http://packages.altlinux.org/$loc/Sisyphus/srpms"
echo "$PAOURL/$loc/Sisyphus/srpms"
}
query_altlinux_url()
......@@ -109,7 +112,7 @@ epm_site()
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
PAO=
local PAO=""
for f in $pkg_names $pkg_files ; do
[ "$f" = "-p" ] && PAO="$f" && continue
if [ -n "$PAO" ] ; then
......
......@@ -21,6 +21,7 @@
epm_update()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
info "Running command for update remote package repository database"
case $PMTYPE in
......
......@@ -23,6 +23,8 @@ epm_upgrade()
{
local CMD
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
# it is useful for first time running
update_repo_if_needed
......
......@@ -40,6 +40,9 @@ case $PMTYPE in
yum-rpm)
CMD="repoquery --whatrequires"
;;
dnf-rpm)
CMD="repoquery --whatrequires"
;;
emerge)
assure_exists equery
CMD="equery depends -a"
......
......@@ -38,6 +38,9 @@ case $PMTYPE in
yum-rpm)
CMD="yum whatprovides"
;;
dnf-rpm)
CMD="yum provides"
;;
zypper-rpm)
CMD="zypper what-provides"
;;
......
#!/bin/sh
#
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2013, 2016 Etersoft
# Copyright (C) 2012-2013, 2016 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
......@@ -61,7 +61,9 @@ is_active_systemd()
SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd
[ -x "$SYSTEMCTL" ] || return
[ -d "$SYSTEMD_CGROUP_DIR" ] || return
a= mountpoint -q "$SYSTEMD_CGROUP_DIR"
a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
# some hack
pidof systemd >/dev/null
}
case $DISTRNAME in
......@@ -128,7 +130,7 @@ print_version()
{
echo "Service manager version @VERSION@"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013"
echo "Copyright (c) Etersoft 2012, 2013, 2016"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
}
......@@ -192,6 +194,10 @@ check_command()
off|disable) # HELPCMD: remove service to run on startup and stop it now
serv_cmd=disable
;;
print) # HELPCMD: print some info
serv_cmd=print
withoutservicename=1
;;
*)
return 1
;;
......
#!/bin/sh
#
# Copyright (C) 2016 Etersoft
# Copyright (C) 2016 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/>.
#
serv_print()
{
echo "Detected init system: $SERVICETYPE"
}
......@@ -20,37 +20,61 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
WGET="wget"
WGET="wget -q"
if [ "$1" = "-q" ] ; then
WGET="wget -q"
shift
fi
# TODO:
# -P support
# If ftp protocol or have no asterisk, jus download
# TODO: use has()
if echo "$1" | grep -q "\(^ftp://\|[^*]$\)" ; then
$WGET $1 && exit 0
$WGET "$1"
exit
fi
URL=$(echo $1 | grep /$ || dirname $1)
MASK=$(basename $1)
MYTMPDIR="$(mktemp -d)"
DIRALLFILES="$MYTMPDIR/files/"
get_index(){
echo "Fall to http workaround"
URL=$(echo "$1" | grep "/$" || dirname "$1")
# mask allowed only in last part of path
MASK=$(basename "$1")
get_index()
{
MYTMPDIR="$(mktemp -d)"
INDEX=$MYTMPDIR/index
$WGET $URL -O $INDEX
}
save_temp_files(){
mkdir -p $DIRALLFILES
ALLFILES="$MYTMPDIR/allfiles"
cat $INDEX | grep -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2 > $ALLFILES
while read line ; do
touch $DIRALLFILES/$line
done <$ALLFILES
print_files()
{
cat $INDEX | grep -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2
}
create_fake_files()
{
DIRALLFILES="$MYTMPDIR/files/"
mkdir -p "$DIRALLFILES"
print_files | while read line ; do
touch $DIRALLFILES/$(basename "$line")
done
}
sort_files(){
download_files()
{
ERROR=0
for line in $DIRALLFILES/$MASK ; do
$WGET $URL/`basename "$line"` -P $CURRENTDIR/
$WGET $URL/$(basename "$line") || ERROR=1
done
return $ERROR
}
get_index
save_temp_files
sort_files
get_index || exit
create_fake_files
download_files || echo "There was some download errors" >&2
rm -rf "$MYTMPDIR"
#!/bin/sh
/usr/lib/rpm/shell.req bin/epm-* | sort -u
# This spec is backported to ALTLinux p7 automatically by rpmbph script. Do not edit it.
# This spec is backported to ALTLinux p7 automatically by rpmbph script from etersoft-build-utils.
#
Name: eepm
Version: 1.5.24
Version: 1.6.3
Release: alt0.M70P.1
Summary: Etersoft EPM package manager
......@@ -67,8 +67,39 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
%_sysconfdir/bash_completion.d/cerv
%changelog
* Mon Dec 07 2015 Andrey Cherepanov <cas@altlinux.org> 1.5.24-alt0.M70P.1
- Backport new version to p7 branch
* Thu Apr 07 2016 Vitaly Lipatov <lav@altlinux.ru> 1.6.3-alt0.M70P.1
- backport to ALTLinux p7 (by rpmbph script)
* Tue Apr 05 2016 Vitaly Lipatov <lav@altlinux.ru> 1.6.3-alt1
- epm-checksystem: add assure_exists time
- check_updated_repo fix epm update
* Thu Mar 17 2016 Vitaly Lipatov <lav@altlinux.ru> 1.6.2-alt2
- add check_reqs script and cleanup all reqs
* Thu Mar 17 2016 Vitaly Lipatov <lav@altlinux.ru> 1.6.2-alt1
- epm: print error for extra unallowed args
- drop time requires
* Fri Feb 26 2016 Vitaly Lipatov <lav@altlinux.ru> 1.6.1-alt1
- distr_info: add Simply Linux detection
- epm: use yum-config-manager for managing repo in yum based distros
- fix downgrade for LINUX@Etersoft, Debian, Ubuntu, add support for downgrade one or a few packages
- epm search: optimize grep when search for one word, apply short option before all, disable localized description
- epm-site: use https for packages.altlinux.org
- add serv print command
- serv: fix systemd detection
* Wed Jan 27 2016 Vitaly Lipatov <lav@altlinux.ru> 1.6.0-alt1
- release long term support version 1.6
- epm-print: add print specname
- rewrite eget
* Wed Dec 16 2015 Vitaly Lipatov <lav@altlinux.ru> 1.5.25-alt1
- epm-checksystem: fix working in packed
- fix packed version
- improve dnf support
- small fixes
* Tue Dec 01 2015 Vitaly Lipatov <lav@altlinux.ru> 1.5.24-alt1
- add support apt-cyg on Cygwin
......@@ -76,9 +107,6 @@ chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
- epm-check_updated_rep: do not check on deb systems
- epm-query: fix print package version for other systems
* Sun Nov 22 2015 Vitaly Lipatov <lav@altlinux.ru> 1.5.23-alt0.M70P.1
- backport to ALTLinux p7 (by rpmbph script)
* Sun Nov 22 2015 Vitaly Lipatov <lav@altlinux.ru> 1.5.23-alt1
- epm install: disable update if try install local package files
- epm clean: remove partial files
......
......@@ -249,6 +249,10 @@ set_sudo()
SUDO=""
# skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return
if [ "$DISTRNAME" = "Cygwin" ] || [ "$DISTRNAME" = "Windows" ] ; then
# skip sudo using on Windows
return
fi
EFFUID=`id -u`
......@@ -280,7 +284,7 @@ set_eatmydata()
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata"
info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
[ -n "$verbose" ] && info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
return 0
}
......@@ -426,6 +430,9 @@ case $DISTRNAME in
Android)
CMD="android"
;;
Cygwin)
CMD="aptcyg"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......@@ -447,7 +454,8 @@ case $PMTYPE in
info "You need manually add repo to /etc/apt/sources.list"
;;
yum-rpm)
info "You need manually add repo to /etc/yum.repos.d/"
assure_exists yum-utils
sudocmd yum-config-manager --add-repo "$pkg_filenames"
;;
urpm-rpm)
sudocmd urpmi.addmedia "$pkg_filenames"
......@@ -549,6 +557,9 @@ epm_assure()
epm_audit()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
pkgng)
sudocmd pkg audit -F
......@@ -564,6 +575,10 @@ esac
epm_autoorphans()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
#apt-rpm)
# ALT Linux only
......@@ -576,7 +591,7 @@ case $PMTYPE in
apt-dpkg|aptitude-dpkg)
assure_exists deborphan
showcmd deborphan
deborphan | sudocmd epm remove
a= deborphan | sudocmd epm remove
;;
#aura)
# sudocmd aura -Oj
......@@ -640,6 +655,10 @@ __epm_autoremove_altrpm()
epm_autoremove()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm)
# ALT Linux only
......@@ -665,6 +684,9 @@ case $PMTYPE in
sudocmd yum remove $PKGLIST
done
;;
dnf-rpm)
sudocmd dnf autoremove
;;
# see autoorhans
#urpm-rpm)
# sudocmd urpme --auto-orphans
......@@ -717,7 +739,7 @@ __epm_changelog_files()
case $(get_package_type $1) in
rpm)
assure_exists rpm
docmd_foreach "rpm -p --changelog" $@ | less
docmd_foreach "rpm -q -p --changelog" $@ | less
;;
*)
fatal "Have no suitable command for $1"
......@@ -731,7 +753,7 @@ __epm_changelog_local_names()
case $PMTYPE in
apt-rpm|yum-rpm|dnf-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm --changelog" $@ | less
docmd_foreach "rpm -q --changelog" $@ | less
;;
apt-dpkg|aptitude-dpkg)
docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
......@@ -775,7 +797,7 @@ __epm_changelog_unlocal_names()
docmd equery changes -f $1 | less
;;
*)
fatal "Have no suitable command for $PMTYPE"
fatal "Have no suitable command for $PMTYPE. Try install the package firstly."
;;
esac
......@@ -924,15 +946,75 @@ epm_checkpkg()
done
}
# File bin/epm-checksystem:
epm_checksystem_ALTLinux()
{
local TDIR=$(mktemp -d)
assure_exists time
touch $TDIR/added
for ft in $(ls /usr/lib/rpm/*.filetrigger | sort) ; do
echo "Try run $ft ..."
echo $TDIR/added $TDIR/removed | a= time $ft
done
rm -f $TDIR/added fatal
rmdir $TDIR || fatal
echo "Count lines:"
wc -l /var/lib/rpm/files-awaiting-filetriggers
}
epm_checksystem()
{
[ -n "$SUDO" ] || fatal "Do not use checksystem under root"
case $DISTRNAME in
ALTLinux)
epm_checksystem_$DISTRNAME
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
if [ "$1" = "--debug" ] ; then
shift
SUDO=sudo
DISTRNAME=ALTLinux
epm_checksystem
fi
# File bin/epm-check_updated_repo:
__is_repo_info_download()
__is_repo_info_downloaded()
{
case $PMTYPE in
apt-*)
if [ -r /var/cache/apt ] ; then
# FIXME: only if root permissions
test -r /var/cache/apt/pkgcache.bin || return
$SUDO test -r /var/cache/apt/pkgcache.bin || return
fi
;;
*)
;;
esac
return 0
}
__is_repo_info_uptodate()
{
case $PMTYPE in
apt-rpm)
# apt-deb do not update lock file date
if $SUDO [ -r /var/lib/apt/lists ] ; then
local LOCKFILE=/var/lib/apt/lists/lock
$SUDO test -r $LOCKFILE || return
# if repo older than 1 day, return false
# find print string if file is obsoleted
test -z "$($SUDO find $LOCKFILE -mtime +1)" || return
fi
;;
*)
......@@ -943,26 +1025,58 @@ __is_repo_info_download()
update_repo_if_needed()
{
if ! __is_repo_info_download ; then
load_helper epm-update
epm_update
return
# check if we need skip update checking
if [ "$1" = "soft" ] && [ -n "$SUDO" ] ; then
# if sudo requires a password, skip autoupdate
sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; }
fi
# TODO: if repo info is very obsoleted (a few days?), we need run update
cd /
if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then
load_helper epm-update
pkg_filenames= epm_update
fi
cd - >/dev/null
}
# File bin/epm-clean:
__remove_alt_apt_cache_file()
{
sudocmd rm -vf /var/cache/apt/*.bin
sudocmd rm -vf /var/cache/apt/partial/*
sudocmd rm -vf /var/lib/apt/lists/*pkglist*
sudocmd rm -vf /var/lib/apt/lists/*release*
}
__remove_deb_apt_cache_file()
{
sudocmd rm -vf /var/cache/apt/*.bin
sudocmd rm -vf /var/cache/apt/archives/partial/*
sudocmd rm -vf /var/lib/apt/lists/*Packages*
sudocmd rm -vf /var/lib/apt/lists/*Release*
sudocmd rm -vf /var/lib/apt/lists/*Translation*
}
epm_clean()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm|apt-dpkg)
apt-rpm)
sudocmd apt-get clean
__remove_alt_apt_cache_file
;;
apt-dpkg)
sudocmd apt-get clean
__remove_deb_apt_cache_file
;;
aptitude-dpkg)
sudocmd aptitude clean
__remove_deb_apt_cache_file
;;
yum-rpm)
sudocmd yum clean all
......@@ -1086,13 +1200,36 @@ epm_conflicts()
# File bin/epm-downgrade:
__epm_add_apt_downgrade_preferences()
__epm_add_alt_apt_downgrade_preferences()
{
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
cat <<EOF | $SUDO tee /etc/apt/preferences
Package: *
Pin: release c=classic
Pin-Priority: 1001
Package: *
Pin: release c=addon
Pin-Priority: 1101
EOF
}
__epm_add_deb_apt_downgrade_preferences()
{
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
info "Running with /etc/apt/preferences:"
cat <<EOF | $SUDO tee /etc/apt/preferences
Package: *
Pin: release c=$1
Pin: release a=stable
Pin-Priority: 1001
Package: *
Pin: release a=testing
Pin-Priority: 900
Package: *
Pin: release a=unstable
Pin-Priority: 800
EOF
}
......@@ -1112,21 +1249,29 @@ epm_downgrade()
case $PMTYPE in
apt-rpm)
__epm_add_apt_downgrade_preferences classic || return
__epm_add_alt_apt_downgrade_preferences || return
if [ -n "$pkg_filenames" ] ; then
sudocmd apt-get install $pkg_filenames
else
sudocmd apt-get dist-upgrade
fi
__epm_remove_apt_downgrade_preferences
;;
apt-dpkg)
__epm_add_apt_downgrade_preferences testing || return
__epm_add_deb_apt_downgrade_preferences || return
if [ -n "$pkg_filenames" ] ; then
sudocmd apt-get install $pkg_filenames
else
sudocmd apt-get dist-upgrade
fi
__epm_remove_apt_downgrade_preferences
;;
yum-rpm)
# can do update repobase automagically
sudocmd yum downgrade $pkg_filename
sudocmd yum downgrade $pkg_filenames
;;
dnf-rpm)
sudocmd dnf downgrade $pkg_filename
sudocmd dnf downgrade $pkg_filenames
;;
urpm-rpm)
assure_exists urpm-reposync urpm-tools
......@@ -1146,7 +1291,10 @@ epm_download()
case $PMTYPE in
dnf-rpm)
sudocmd dnf download $pkg_filename
sudocmd dnf download $pkg_filenames
;;
aptcyg)
sudocmd apt-cyg download $pkg_filenames
;;
*)
fatal "Have no suitable command for $PMTYPE"
......@@ -1174,6 +1322,12 @@ __alt_local_content_filelist()
} | $OUTCMD
}
__deb_local_content_filelist()
{
showcmd "apt-file list $1 | grep '^$1: ' | sed -e 's|$1: ||g'"
a= apt-file list "$1" | grep "^$1: " | sed -e "s|$1: ||g"
}
__epm_filelist_remote()
{
......@@ -1185,9 +1339,10 @@ __epm_filelist_remote()
docmd_foreach __alt_local_content_filelist $@
;;
apt-dpkg)
assure_exists apt-file
sudocmd apt-file update
docmd apt-file list $@
assure_exists apt-file || return
# if sudo requires a password, skip autoupdate
sudo -n true 2>/dev/null && sudocmd apt-file update || info "sudo requires a password, skip apt-file update"
docmd_foreach __deb_local_content_filelist $@
;;
*)
fatal "Query filelist for non installed packages does not realized"
......@@ -1226,21 +1381,12 @@ __epm_filelist_name()
[ -z "$*" ] && return
case $PMTYPE in
apt-rpm)
*-rpm)
CMD="rpm -ql"
;;
*-dpkg)
CMD="dpkg -L"
;;
yum-rpm)
CMD="rpm -ql"
;;
urpm-rpm)
CMD="rpm -ql"
;;
zypper-rpm)
CMD="rpm -ql"
;;
android)
CMD="pm list packages -f"
;;
......@@ -1248,7 +1394,7 @@ __epm_filelist_name()
CMD="conary query --ls"
;;
pacman)
docmd pacman -Ql $pkg_names | sed -e "s|.* ||g" | less
docmd pacman -Ql $@ | sed -e "s|.* ||g" | less
return
;;
emerge)
......@@ -1258,8 +1404,12 @@ __epm_filelist_name()
pkgng)
CMD="pkg info -l"
;;
aptcyg)
docmd apt-cyg listfiles $@ | sed -e "s|^|/|g"
return
;;
slackpkg)
is_installed $pkg_names || fatal "Query filelist for non installed packages does not realized"
is_installed $@ || 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
return
;;
......@@ -1269,9 +1419,9 @@ __epm_filelist_name()
esac
# TODO: add less
docmd $CMD $pkg_names && return
docmd $CMD $@ && return
# TODO: may be we need check is installed before prev. line?
is_installed $pkg_names || __epm_filelist_remote $pkg_names
is_installed $@ || __epm_filelist_remote $@
}
......@@ -1281,7 +1431,7 @@ epm_filelist()
__epm_filelist_file $pkg_files || return
__epm_filelist_name $pkg_names || return
__epm_filelist_name $(print_name $pkg_names) || return
}
......@@ -1369,6 +1519,9 @@ case $PMTYPE in
homebrew)
docmd brew info $pkg_names
;;
aptcyg)
docmd apt-cyg show $pkg_names
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......@@ -1523,6 +1676,9 @@ epm_install_names()
android)
fatal "We still have no idea how to use package repository, ever if it is F-Droid."
return ;;
aptcyg)
sudocmd apt-cyg install $@
return ;;
*)
fatal "Have no suitable install command for $PMTYPE"
;;
......@@ -1747,6 +1903,9 @@ epm_print_install_command()
android)
echo "pm install $@"
;;
aptcyg)
echo "apt-cyg install $@"
;;
*)
fatal "Have no suitable appropriate install command for $PMTYPE"
;;
......@@ -1777,8 +1936,10 @@ epm_install()
[ -z "$files$names" ] && info "Skip empty install list" && return 22
if [ -z "$files" ] ; then
# it is useful for first time running
update_repo_if_needed
fi
epm_install_names $names || return
epm_install_files $files
......@@ -1893,7 +2054,7 @@ epm_kernel_update()
case $DISTRNAME in
ALTLinux)
assure_exists update-kernel
sudocmd update-kernel
sudocmd update-kernel $pkg_filenames
return ;;
esac
......@@ -1904,6 +2065,37 @@ epm_kernel_update()
esac
}
# File bin/epm-optimize:
__repack_rpm_base()
{
assure_exists db_dump || fatal
assure_exists db_load || fatal
cd /var/lib/rpm || fatal
mv Packages Packages.BACKUP || fatal
# mask dependencies with a=
a= db_dump Packages.BACKUP | a= db_load Packages || fatal
rm Packages.BACKUP
}
epm_optimize()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
*-rpm)
#__repack_rpm_base
#rm -f /var/lib/rpm/__db*
rpm --rebuilddb
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
# File bin/epm-packages:
__epm_packages_sort()
......@@ -1922,6 +2114,13 @@ case $PMTYPE in
esac
}
__aptcyg_print_full()
{
#showcmd apt-cyg show
local VERSION=$(apt-cyg show "$1" | grep -m1 "^version: " | sed -e "s|^version: ||g")
echo "$1-$VERSION"
}
epm_packages()
{
local CMD
......@@ -1934,8 +2133,10 @@ case $PMTYPE in
;;
*-dpkg)
#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"
CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}-\${Version}\n $pkg_filenames"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}\n $pkg_filenames"
docmd $CMD | grep "^i" | sed -e "s|.* ||g"
return
;;
snappy)
CMD="snappy info"
......@@ -2008,6 +2209,17 @@ case $PMTYPE in
docmd $CMD | sed -e "s|^package:||g"
return
;;
aptcyg)
CMD="apt-cyg list $pkg_filenames"
if [ -z "$short" ] ; then
showcmd $CMD
# TODO: fix this slow way
for i in $($CMD) ; do
__aptcyg_print_full $i
done
return
fi
;;
*)
fatal "Have no suitable query command for $PMTYPE"
;;
......@@ -2017,6 +2229,213 @@ docmd $CMD
}
# File bin/epm-policy:
epm_policy()
{
[ -n "$pkg_names" ] || fatal "Info: missing package(s) name"
case $PMTYPE in
apt-rpm)
docmd apt-cache policy $pkg_names
;;
apt-dpkg)
docmd apt-cache policy $pkg_names
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
# File bin/epm-print:
query_package_field()
{
local FORMAT="%{$1}\n"
shift
local INSTALLED="-p"
# if not file, drop -p for get from rpm base
[ -e "$1" ] || INSTALLED=""
rpmquery $INSTALLED --queryformat "$FORMAT" "$@"
}
print_binpkgfilelist()
{
local PKGDIR=$1
local PKGNAME=$(basename $2)
find "$PKGDIR" ! -name '*\.src\.rpm' -name '*\.rpm' -execdir \
rpmquery -p --qf='%{sourcerpm}\t%{name}-%{version}-%{release}.%{arch}.rpm\n' "{}" \; \
| grep "^$PKGNAME[[:space:]].*" | cut -f2 | xargs -n1 -I "{}" echo -n "$PKGDIR/{} "
}
PKGNAMEMASK="\(.*\)-\([0-9].*\)-\(.*[0-9].*\)"
print_name()
{
echo "$@" | xargs -n1 echo | sed -e "s|$PKGNAMEMASK|\1|g"
}
print_version()
{
echo "$1" | xargs -n1 echo | sed -e "s|$PKGNAMEMASK|\2|g"
}
print_release()
{
echo "$1" | xargs -n1 echo | sed -e "s|$PKGNAMEMASK|\3|g"
}
print_pkgname()
{
local i
for i in $@ ; do
# TODO: deb and other, arch string
echo "$(basename "$i") " | sed -e "s|\.[a-z_0-9]*\.rpm||g" -e "s|\(.*\)_\(.*\)_[a-z_0-9]*\.deb|\1-\2|g"
done
}
print_srcname()
{
print_name $(print_srcpkgname "$@")
}
print_specname()
{
# CHECKME: it is possible to have two or more specs in one package?
rpm -qlp "$@" | grep "\.spec\$"
}
print_srcpkgname()
{
query_package_field sourcerpm "$@"
}
__epm_print()
{
local WHAT="$1"
shift
local FNFLAG=
local PKFLAG=
[ "$1" = "from" ] && shift
[ "$1" = "for" ] && shift
[ "$1" = "in" ] && shift
if [ "$1" = "filename" ] ; then
FNFLAG="$1"
shift
fi
if [ "$1" = "package" ] ; then
PKFLAG="$1"
shift
fi
case "$WHAT" in
"")
fatal "Use epm print help for get help."
;;
"-h"|"--help"|"help")
cat <<EOF
Examples:
epm print name [from filename|for package] NN print only name of package name or package file
epm print version [from filename|for package] NN print only version of package name or package file
epm print release [from filename|for package] NN print only release of package name or package file
epm print field FF for package NN print field of the package
epm print pkgname from filename NN print package name for the package file
epm print srcname from filename NN print source name for the package file
epm print srcpkgname from [filename|package] NN print source package name for the binary package file
epm print specname from filename NN print spec filename for the source package file
epm print binpkgfilelist in DIR for NN list binary package(s) filename(s) from DIR for the source package file
EOF
;;
"name")
[ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then
print_name $(print_pkgname "$@")
elif [ -n "$PKFLAG" ] ; then
query_package_field "name" "$@"
else
print_name "$@"
fi
;;
"version")
[ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then
print_version $(print_pkgname "$@")
elif [ -n "$PKFLAG" ] ; then
query_package_field "version" "$@"
else
print_version "$@"
fi
;;
"release")
[ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then
print_release $(print_pkgname "$@")
elif [ -n "$PKFLAG" ] ; then
query_package_field "release" "$@"
else
print_release "$@"
fi
;;
"field")
[ -n "$1" ] || fatal "Arg is missed"
local FIELD="$1"
shift
[ "$1" = "for" ] && shift
query_package_field "$FIELD" "$@"
;;
"pkgname")
[ -n "$FNFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
# TODO: drop_pkg_extensions
print_pkgname "$@"
;;
"srcname")
[ -n "$FNFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
print_srcname "$@"
;;
"srcpkgname")
[ -n "$FNFLAG" ] || [ -n "$PKFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
print_srcpkgname "$@"
;;
"specname")
[ -n "$FNFLAG" ] || [ -n "$PKFLAG" ] || fatal "print $WHAT works only for filename(s)"
[ -n "$1" ] || fatal "Arg is missed"
print_specname "$@"
;;
"binpkgfilelist")
# TODO: rpm only
# TODO: replace get_binpkg_list
local DIR="$1"
shift
[ "$1" = "for" ] && shift
[ -n "$DIR" ] || fatal "DIR arg is missed"
[ -n "$1" ] || fatal "source package filename is missed"
print_binpkgfilelist "$DIR" "$1"
;;
*)
fatal "Unknown command $ epm print $WHAT. Use epm print help for get help."
;;
esac
}
epm_print()
{
[ -n "$pkg_filenames" ] || fatal "Missed args. Use epm print help for get help."
__epm_print $(eval echo $quoted_args)
}
# File bin/epm-programs:
......@@ -2083,7 +2502,7 @@ case $PMTYPE in
return
fi
;;
urpm-rpm|zypper-rpm|yum-rpm)
urpm-rpm|zypper-rpm|yum-rpm|dnf-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --provides"
else
......@@ -2123,7 +2542,7 @@ epm_provides()
[ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name"
epm_provides_files $pkg_files
epm_provides_names $pkg_names
epm_provides_names $(print_name $pkg_names)
}
# File bin/epm-query:
......@@ -2139,7 +2558,7 @@ _get_grep_exp()
echo "/$1$"
}
_query_via_packages_list()
_shortquery_via_packages_list()
{
local res=0
local grepexp
......@@ -2148,9 +2567,11 @@ _query_via_packages_list()
grepexp=$(_get_grep_exp $firstpkg)
# Note: we use short=1 here due grep by ^name$
# separate first line for print out command
short=1 pkg_filenames=$firstpkg epm_packages | grep -- "$grepexp" || res=1
local pkg
for pkg in "$@" ; do
grepexp=$(_get_grep_exp $pkg)
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -- "$grepexp" || res=1
......@@ -2159,6 +2580,28 @@ _query_via_packages_list()
return $res
}
_query_via_packages_list()
{
local res=0
local grepexp
local firstpkg=$1
shift
grepexp=$(_get_grep_exp $firstpkg)
# Note: we use short=1 here due grep by ^name$
# separate first line for print out command
short=1 pkg_filenames=$firstpkg epm_packages | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$firstpkg epm_packages || res=1
local pkg
for pkg in "$@" ; do
grepexp=$(_get_grep_exp $pkg)
short=1 pkg_filenames=$pkg epm_packages 2>/dev/null | grep -q -- "$grepexp" && quiet=1 pkg_filenames=$pkg epm_packages || res=1
done
return $res
}
__epm_get_hilevel_nameform()
{
[ -n "$*" ] || return
......@@ -2194,7 +2637,7 @@ __epm_get_hilevel_name()
for i in $@ ; do
local pkg
# get short form in pkg
quiet=1 short=1 pkg=$(__epm_query_name $i) || continue # drop not installed packages
quiet=1 pkg=$(__epm_query_shortname $i) || continue # drop not installed packages
# if already short form, skipped
[ "$pkg" = "$i" ] && echo "$i" && continue
# try get long form or use short form
......@@ -2234,12 +2677,10 @@ __epm_query_name()
case $PMTYPE in
*-rpm)
CMD="rpm -q"
[ -n "$short" ] && CMD="rpm -q --queryformat %{name}\n"
;;
*-dpkg)
#docmd dpkg -l $@ | grep "^ii"
CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n"
;;
npackd)
docmd "npackdcl path --package=$@"
......@@ -2267,9 +2708,48 @@ __epm_query_name()
docmd $CMD $@
}
__epm_query_shortname()
{
local CMD
[ -z "$*" ] && return
case $PMTYPE in
*-rpm)
CMD="rpm -q --queryformat %{name}\n"
;;
*-dpkg)
CMD="dpkg-query -W --showformat=\${Package}\n"
;;
npackd)
docmd "npackdcl path --package=$@"
return
;;
conary)
CMD="conary query"
;;
homebrew)
warning "fix query"
return 1
;;
# TODO: need to print name if exists
#pkgng)
# CMD="pkg info -e"
# ;;
# Note: slackpkg info pkgname
*)
# default slow workaround
_shortquery_via_packages_list $@
return
;;
esac
docmd $CMD $@
}
is_installed()
{
pkg_filenames="$@" pkg_names="$@" epm_query >/dev/null 2>/dev/null
short=1 pkg_filenames="$@" pkg_names="$@" epm_query >/dev/null 2>/dev/null
# broken way to recursive call here (overhead!)
#epm installed $@ >/dev/null 2>/dev/null
}
......@@ -2289,7 +2769,11 @@ epm_query()
__epm_query_file $pkg_files || return
__epm_query_name $pkg_names || return
if [ -n "$short" ] ; then
__epm_query_shortname $(print_name $pkg_names) || return
else
__epm_query_name $(print_name $pkg_names) || return
fi
}
# File bin/epm-query_file:
......@@ -2313,7 +2797,7 @@ __do_query_real_file()
if [ -L "$TOFILE" ] ; then
local LINKTO
__do_query "$TOFILE"
LINKTO=$(readlink "$TOFILE")
LINKTO=$(readlink -f "$TOFILE")
info "Note: $TOFILE is link to $LINKTO"
__do_query_real_file "$LINKTO"
return
......@@ -2374,6 +2858,11 @@ __do_query()
ipkg)
CMD="ipkg files"
;;
aptcyg)
#CMD="apt-cyg packageof"
# do not realized locally
return 1
;;
*)
fatal "Have no suitable query command for $PMTYPE"
;;
......@@ -2417,6 +2906,7 @@ __do_short_query()
epm_query_file()
{
# И где это используется?
# in short mode print handle only real names and do short output
# TODO: move to separate command?
# FIXME: it is possible use query
......@@ -2449,6 +2939,7 @@ epm_query_package()
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS
# Note: get all packages list and do grep
eval "pkg_filenames= epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS"
}
......@@ -2470,7 +2961,7 @@ epm_reinstall_names()
sudocmd dnf reinstall $@
return ;;
pkgng)
sudocmf pkg install -f $@
sudocmd pkg install -f $@
return ;;
slackpkg)
sudocmd_foreach "/usr/sbin/slackpkg reinstall" $@
......@@ -2585,7 +3076,7 @@ epm_remove_low()
sudocmd rpm -ev $nodeps $@
return ;;
apt-dpkg|aptitude-dpkg)
sudocmd dpkg -P $(subst_option nodeps --force-all) $@
sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@")
return ;;
pkgsrc)
sudocmd pkg_delete -r $@
......@@ -2678,6 +3169,9 @@ epm_remove_names()
homebrew)
sudocmd brew remove $@
return ;;
aptcyg)
sudocmd apt-cyg remove $@
return ;;
ipkg)
sudocmd ipkg $(subst_option force -force-depends) remove $@
return ;;
......@@ -2751,6 +3245,9 @@ epm_print_remove_command()
ipkg)
echo "ipkg remove $@"
;;
aptcyg)
echo "apt-cyg remove $@"
;;
*)
fatal "Have no suitable appropriate remove command for $PMTYPE"
;;
......@@ -2798,7 +3295,8 @@ case $PMTYPE in
info "You need remove repo from /etc/apt/sources.list"
;;
yum-rpm)
info "You need remove repo from /etc/yum.repos.d/"
assure_exists yum-utils
sudocmd yum-config-manager --disable "$pkg_filenames"
;;
urpm-rpm)
sudocmd urpmi.removemedia "$pkg_filenames"
......@@ -2825,6 +3323,47 @@ esac
}
# File bin/epm-repofix:
SUBST_ALT_RULE='s!^([^#].*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p7[/ ]branch|p6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
__fix_apt_sources_list()
{
[ -n "$SUDO" ] && fatal "run only under root"
for i in "$@" ; do
[ -s "$i" ] || continue
perl -i.bak -pe "$SUBST_ALT_RULE" $i
done
}
epm_repofix()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in
apt-rpm)
assure_exists apt-repo
docmd apt-repo list
__fix_apt_sources_list /etc/apt/sources.list
__fix_apt_sources_list /etc/apt/sources.list.d/*.list
docmd apt-repo list
# rebuild rpm database
#sudocmd rm -fv /var/lib/rpm/__db*
#sudocmd rpm --rebuilddb
;;
yum-rpm|dnf-rpm)
sudocmd rm -fv /var/lib/rpm/__db*
sudocmd rpm --rebuilddb
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
}
# File bin/epm-repolist:
print_apt_sources_list()
......@@ -2931,7 +3470,18 @@ case $PMTYPE in
CMD="rpm -q --requires"
;;
yum-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --requires"
else
CMD="yum deplist"
fi
;;
dnf-rpm)
if is_installed $pkg_names ; then
CMD="rpm -q --requires"
else
CMD="dnf repoquery --requires"
fi
;;
pacman)
CMD="pactree"
......@@ -2954,6 +3504,12 @@ case $PMTYPE in
#CMD="pkg rquery '%dn-%dv'"
CMD="pkg info -d"
;;
aptcyg)
#CMD="apt-cyg depends"
# print show version
docmd apt-cyg show $pkg_names | grep "^requires: " | sed "s|^requires: ||g"
return
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......@@ -2968,7 +3524,7 @@ epm_requires()
{
[ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name"
epm_requires_files $pkg_files
epm_requires_names $pkg_names
epm_requires_names $(print_name $pkg_names)
}
# File bin/epm-search:
......@@ -3043,12 +3599,15 @@ case $PMTYPE in
android)
CMD="pm list packages"
;;
aptcyg)
CMD="apt-cyg searchall"
;;
*)
fatal "Have no suitable search command for $PMTYPE"
;;
esac
docmd $CMD $string
LANG=C docmd $CMD $string
}
__epm_search_make_grep()
......@@ -3073,22 +3632,28 @@ __epm_search_make_grep()
#list=$(strip_spaces $list | sed -e "s/ /|/g")
listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g")
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
[ -n "$listN" ] && echon " | egrep -i -v -- \"$listN\""
# FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
# Need only if we have more than one word (with one word we will grep for colorify)
if [ "$(echo "$list" | wc -w)" -gt 1 ] ; then
for i in $list ; do
# FIXME -n on MacOS?
echon " | egrep -i -- \"$i\""
done
if [ "$short" ] ; then
echon " | sed -e \"s| .*||g\""
fi
# FIXME: move from it
#isatty || return
# TODO: sorts word by length from large to short
local COLO=""
# rule for colorife
for i in $list $listN; do
......@@ -3096,6 +3661,7 @@ __epm_search_make_grep()
COLO="$COLO$i"
done
# TODO: use some colorifer instead grep (check grep adove too)
if [ -n "$list" ] ; then
echon " | egrep -i $EGREPCOLOR -- \"($COLO)\""
fi
......@@ -3107,7 +3673,7 @@ epm_search()
[ -n "$pkg_filenames" ] || fatal "Search: missing search argument(s)"
# it is useful for first time running
update_repo_if_needed
update_repo_if_needed soft
# FIXME: do it better
local MGS
......@@ -3150,9 +3716,13 @@ case $PMTYPE in
docmd apt-file search $pkg_filenames
return ;;
yum-rpm)
# TODO
info "Search by full packages list does not realized"
CMD="yum provides"
;;
dnf-rpm)
# TODO
info "Search by full packages list does not realized"
CMD="dnf provides"
;;
urpm-rpm)
......@@ -3170,6 +3740,10 @@ case $PMTYPE in
ipkg)
CMD="ipkg search"
;;
aptcyg)
docmd apt-cyg searchall $(echo " $pkg_filenames" | sed -e "s| /| |g")
return
;;
*)
fatal "Have no suitable search file command for $PMTYPE"
;;
......@@ -3329,11 +3903,123 @@ epm_simulate()
}
# File bin/epm-site:
PAOURL="https://packages.altlinux.org"
run_command_if_exists()
{
local CMD="$1"
shift
if which "$CMD" 2>/dev/null >/dev/null ; then
docmd "$CMD" "$@"
return 0
fi
return 1
}
open_browser()
{
local i
for i in xdg-open firefox chromium links ; do
run_command_if_exists $i "$@" && return
done
}
__query_package_hl_url()
{
local PAOAPI="$PAOURL/api"
case $DISTRNAME in
ALTLinux)
# http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs
epm assure curl || return 1
showcmd curl "$PAOAPI/srpms/$1"
curl -s --header "Accept: application/json" "$PAOAPI/srpms/$1" | grep '"url"' | sed -e 's|.*"url":"||g' | sed -e 's|".*||g'
return 0
;;
esac
return 1
}
query_package_url()
{
local URL
case $PMTYPE in
*-rpm)
# TODO: for binary packages?
query_package_field URL "$1" || __query_package_hl_url "$1"
#LANG=C epm info "$1"
return
;;
esac
fatal "rpm based distro supported only. TODO: Realize via web service?"
}
get_locale()
{
local loc
loc=$(a= natspec --locale 2>/dev/null)
[ -n "$loc" ] || loc=$LANG
echo $loc
}
get_pao_url()
{
local loc
loc=$(get_locale | cut -c1-2)
case $loc in
en|ru|uk|br)
loc=$loc
;;
*)
loc=en
esac
echo "$PAOURL/$loc/Sisyphus/srpms"
}
query_altlinux_url()
{
local URL
case $PMTYPE in
*-rpm)
local srpm=$(print_srcname "$1")
[ -n "$srpm" ] || fatal "Can't get source name for $1"
echo "$(get_pao_url)/$srpm"
return
;;
esac
fatal "rpm based distro supported only. TODO: Realize via web service?"
}
epm_site()
{
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
local PAO=""
for f in $pkg_names $pkg_files ; do
[ "$f" = "-p" ] && PAO="$f" && continue
if [ -n "$PAO" ] ; then
pkg_url=$(query_altlinux_url $f)
else
pkg_url=$(query_package_url $f)
fi
[ -n "$pkg_url" ] && open_browser "$pkg_url" && continue
warning "Can't get URL for $f package"
done
}
# File bin/epm-update:
epm_update()
{
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
info "Running command for update remote package repository database"
case $PMTYPE in
......@@ -3354,10 +4040,12 @@ case $PMTYPE in
;;
yum-rpm)
info "update command is stubbed for yum"
# yum makecache
#sudocmd yum check-update
;;
dnf-rpm)
info "update command is stubbed for dnf"
# dnf makecache
#sudocmd dnf check-update
;;
urpm-rpm)
......@@ -3394,6 +4082,9 @@ case $PMTYPE in
# portsnap extract for the first time?
sudocmd portsnap fetch update
;;
aptcyg)
sudocmd apt-cyg update
;;
*)
fatal "Have no suitable update command for $PMTYPE"
;;
......@@ -3408,6 +4099,8 @@ epm_upgrade()
{
local CMD
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
# it is useful for first time running
update_repo_if_needed
......@@ -3474,6 +4167,10 @@ epm_upgrade()
guix)
CMD="guix package -u"
;;
aptcyg)
docmd_foreach "epm install" $(short=1 epm packages)
return
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
......@@ -3500,10 +4197,13 @@ epm_Upgrade()
# File bin/epm-whatdepends:
epm_whatdepends()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Whatdepends: missing package(s) name"
[ -n "$pkg_files" ] && fatal "whatdepends do not handle files"
[ -n "$pkg_names" ] || fatal "whatdepends: missing package(s) name"
local pkg=$(print_name $pkg_names)
case $PMTYPE in
apt-rpm)
......@@ -3518,6 +4218,9 @@ case $PMTYPE in
yum-rpm)
CMD="repoquery --whatrequires"
;;
dnf-rpm)
CMD="repoquery --whatrequires"
;;
emerge)
assure_exists equery
CMD="equery depends -a"
......@@ -3525,33 +4228,42 @@ case $PMTYPE in
pkgng)
CMD="pkg info -r"
;;
aptcyg)
CMD="apt-cyg rdepends"
;;
*)
fatal "Have no suitable command for $PMTYPE"
;;
esac
docmd $CMD $pkg_filenames
docmd $CMD $pkg
}
# File bin/epm-whatprovides:
epm_whatprovides()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Whatprovides: missing package(s) name"
[ -n "$pkg_files" ] && fatal "whatprovides does not handle files"
[ -n "$pkg_names" ] || fatal "whatprovides: missing package(s) name"
local pkg=$(print_name $pkg_names)
case $PMTYPE in
conary)
CMD="conary repquery --what-provides"
;;
apt-rpm|apt-dpkg|aptitude-dpkg)
LANG=C docmd apt-get install --print-uris $pkg_filenames | grep "^Selecting" | cut -f2 -d" "
LANG=C docmd apt-get install --print-uris $pkg | grep "^Selecting" | cut -f2 -d" "
return
;;
yum-rpm)
CMD="yum whatprovides"
;;
dnf-rpm)
CMD="yum provides"
;;
zypper-rpm)
CMD="zypper what-provides"
;;
......@@ -3560,7 +4272,7 @@ case $PMTYPE in
;;
esac
docmd $CMD $pkg_filenames
docmd $CMD $pkg
}
internal_distr_info()
......@@ -3618,7 +4330,8 @@ pkgtype()
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;;
cygwin) echo "tar.xz" ;;
debian|ubuntu|mint|runtu|mcst) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;;
fedora|redhat|scientific|centos|rhel)
......@@ -3652,24 +4365,31 @@ fi
# ALT Linux based
if distro altlinux-release ; then
DISTRIB_ID="ALTLinux"
if has Strawberry ; then DISTRIB_RELEASE="2.3"
elif has Citron ; then DISTRIB_RELEASE="2.4"
elif has 20050723 ; then DISTRIB_RELEASE="3.0"
elif has Ajuga ; then DISTRIB_RELEASE="4.0"
elif has 20070810 ; then DISTRIB_RELEASE="4.0"
elif has "ALT Linux 4.0" ; then DISTRIB_RELEASE="4.0"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux 6.0" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p8" ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux p7" ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux p6" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p5" ; then DISTRIB_RELEASE="p5"
elif has "ALT Linux 5.1" ; then DISTRIB_RELEASE="5.1"
elif has "ALT Linux 5.0" ; then DISTRIB_RELEASE="5.0"
elif has "ALT Linux 4.1" ; then DISTRIB_RELEASE="4.1"
elif has "ALT Linux 4.0" ; then DISTRIB_RELEASE="4.0"
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 "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"
elif has 6.0 ; then DISTRIB_RELEASE="p6"
elif has Centaurea ; then DISTRIB_RELEASE="p6"
elif has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has 20070810 ; then DISTRIB_RELEASE="4.0"
elif has Ajuga ; then DISTRIB_RELEASE="4.0"
elif has 20050723 ; then DISTRIB_RELEASE="3.0"
elif has Citron ; then DISTRIB_RELEASE="2.4"
fi
elif [ `uname -o` = "Cygwin" ] ; then
DISTRIB_ID="Cygwin"
DISTRIB_RELEASE="all"
elif distro gentoo-release ; then
DISTRIB_ID="Gentoo"
MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile)
......@@ -3696,6 +4416,10 @@ elif distro arch-release ; then
DISTRIB_RELEASE="2011"
fi
elif distro mcst_version ; then
DISTRIB_ID="MCST"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "release" | sed -e "s|.*release \([0-9]*\).*|\1|g")
# for Ubuntu use standard LSB info
elif [ "$DISTRIB_ID" = "Ubuntu" ] && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB version
......@@ -3878,6 +4602,8 @@ esac
#PATH=$PATH:/sbin:/usr/sbin
set_pm_type
set_sudo
check_tty
......@@ -3898,7 +4624,7 @@ $(get_help HELPOPT)
print_version()
{
echo "EPM package manager version 1.5.15"
echo "EPM package manager version 1.6.3"
echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
echo "Copyright (c) Etersoft 2012-2015"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......@@ -3908,7 +4634,6 @@ print_version()
Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager"
set_pm_type
verbose=
quiet=
......@@ -4048,6 +4773,9 @@ check_command()
assure) # HELPCMD: <command> [package]: install package if command does not exists
epm_cmd=assure
;;
policy) # HELPCMD: print detailed information about the priority selection of package
epm_cmd=policy
;;
# Repository control
update) # HELPCMD: update remote package repository databases
......@@ -4059,6 +4787,9 @@ check_command()
repolist|sl|rl|listrepo) # HELPCMD: print repo list
epm_cmd=repolist
;;
repofix) # HELPCMD: fix paths in sources lists (ALT Linux only)
epm_cmd=repofix
;;
removerepo|rr) # HELPCMD: remove package repo
epm_cmd=removerepo
;;
......@@ -4097,10 +4828,23 @@ check_command()
audit) # HELPCMD: audits installed packages against known vulnerabilities
epm_cmd=audit
;;
#checksystem) # HELPCMD: check system for known errors (package management related)
# epm_cmd=checksystem
# ;;
site|url) # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
epm_cmd=site
;;
print) # HELPCMD: print various info, run epm print help for details
epm_cmd=print
;;
-V|checkpkg|integrity) # HELPCMD: check package file integrity (checksum)
epm_cmd=checkpkg
;;
-h|--help|help) # HELPOPT: print this help
help=1
phelp
exit 0
;;
*)
return 1
;;
......@@ -4111,10 +4855,6 @@ check_command()
check_option()
{
case $1 in
-h|--help|help) # HELPOPT: this help
phelp
exit 0
;;
-v|--version) # HELPOPT: print version
print_version
exit 0
......
#!/bin/sh
#
# Copyright (C) 2012-2013 Etersoft
# Copyright (C) 2012-2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012-2013, 2016 Etersoft
# Copyright (C) 2012-2013, 2016 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
......@@ -247,6 +247,10 @@ set_sudo()
SUDO=""
# skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return
if [ "$DISTRNAME" = "Cygwin" ] || [ "$DISTRNAME" = "Windows" ] ; then
# skip sudo using on Windows
return
fi
EFFUID=`id -u`
......@@ -278,7 +282,7 @@ set_eatmydata()
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata"
info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
[ -n "$verbose" ] && info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
return 0
}
......@@ -424,6 +428,9 @@ case $DISTRNAME in
Android)
CMD="android"
;;
Cygwin)
CMD="aptcyg"
;;
*)
fatal "Have no suitable DISTRNAME $DISTRNAME"
;;
......@@ -574,6 +581,13 @@ serv_list_startup()
esac
}
# File bin/serv-print:
serv_print()
{
echo "Detected init system: $SERVICETYPE"
}
# File bin/serv-restart:
......@@ -819,7 +833,8 @@ pkgtype()
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
debian|ubuntu|mint|runtu) echo "deb" ;;
cygwin) echo "tar.xz" ;;
debian|ubuntu|mint|runtu|mcst) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;;
fedora|redhat|scientific|centos|rhel)
......@@ -853,24 +868,31 @@ fi
# ALT Linux based
if distro altlinux-release ; then
DISTRIB_ID="ALTLinux"
if has Strawberry ; then DISTRIB_RELEASE="2.3"
elif has Citron ; then DISTRIB_RELEASE="2.4"
elif has 20050723 ; then DISTRIB_RELEASE="3.0"
elif has Ajuga ; then DISTRIB_RELEASE="4.0"
elif has 20070810 ; then DISTRIB_RELEASE="4.0"
elif has "ALT Linux 4.0" ; then DISTRIB_RELEASE="4.0"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux 6.0" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p8" ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux p7" ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux p6" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p5" ; then DISTRIB_RELEASE="p5"
elif has "ALT Linux 5.1" ; then DISTRIB_RELEASE="5.1"
elif has "ALT Linux 5.0" ; then DISTRIB_RELEASE="5.0"
elif has "ALT Linux 4.1" ; then DISTRIB_RELEASE="4.1"
elif has "ALT Linux 4.0" ; then DISTRIB_RELEASE="4.0"
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 "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"
elif has 6.0 ; then DISTRIB_RELEASE="p6"
elif has Centaurea ; then DISTRIB_RELEASE="p6"
elif has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has 20070810 ; then DISTRIB_RELEASE="4.0"
elif has Ajuga ; then DISTRIB_RELEASE="4.0"
elif has 20050723 ; then DISTRIB_RELEASE="3.0"
elif has Citron ; then DISTRIB_RELEASE="2.4"
fi
elif [ `uname -o` = "Cygwin" ] ; then
DISTRIB_ID="Cygwin"
DISTRIB_RELEASE="all"
elif distro gentoo-release ; then
DISTRIB_ID="Gentoo"
MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile)
......@@ -897,6 +919,10 @@ elif distro arch-release ; then
DISTRIB_RELEASE="2011"
fi
elif distro mcst_version ; then
DISTRIB_ID="MCST"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "release" | sed -e "s|.*release \([0-9]*\).*|\1|g")
# for Ubuntu use standard LSB info
elif [ "$DISTRIB_ID" = "Ubuntu" ] && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB version
......@@ -1106,7 +1132,9 @@ is_active_systemd()
SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd
[ -x "$SYSTEMCTL" ] || return
[ -d "$SYSTEMD_CGROUP_DIR" ] || return
a= mountpoint -q "$SYSTEMD_CGROUP_DIR"
a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
# some hack
pidof systemd >/dev/null
}
case $DISTRNAME in
......@@ -1171,9 +1199,9 @@ $(get_help HELPOPT)
print_version()
{
echo "Service manager version 1.5.15"
echo "Service manager version 1.6.3"
echo "Running on $($DISTRVENDOR)"
echo "Copyright (c) Etersoft 2012, 2013"
echo "Copyright (c) Etersoft 2012, 2013, 2016"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
}
......@@ -1237,6 +1265,10 @@ check_command()
off|disable) # HELPCMD: remove service to run on startup and stop it now
serv_cmd=disable
;;
print) # HELPCMD: print some info
serv_cmd=print
withoutservicename=1
;;
*)
return 1
;;
......
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