Commit 1d7fac49 authored by Vitaly Lipatov's avatar Vitaly Lipatov

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

parents cd35c5e9 6dba764e
TODO: yaourt (pacman frontend), need we?
https://archlinux.fr/man/yaourt.8.html
/etc/eepm.conf конфиг /etc/eepm.conf конфиг
FIXME: epm-install need realpath, missed on some systems implement distr_info as inside tool and do access via epm command
[18:21:12] <danil> Вот так можно: [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 RED='\033[0;31m' ; NC='\033[0m' b="b" ; echo -e "aba" | sed -e "s|${b}|\\${RED}${b}\\${NC}|g" | xargs -0 printf
......
...@@ -61,7 +61,7 @@ pkgtype() ...@@ -61,7 +61,7 @@ pkgtype()
debian|ubuntu|mint|runtu|mcst|astra) echo "deb" ;; debian|ubuntu|mint|runtu|mcst|astra) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles) alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;; echo "rpm" ;;
fedora|redhat|scientific|centos|rhel) fedora|redhat|scientific|centos|rhel|goslinux)
echo "rpm" ;; echo "rpm" ;;
*) echo "rpm" ;; *) echo "rpm" ;;
esac esac
...@@ -69,8 +69,8 @@ pkgtype() ...@@ -69,8 +69,8 @@ pkgtype()
get_var() get_var()
{ {
grep -i "^$1 *=" | head -n 1 | sed -e "s/^[^=]*[ \t]*=[ \t]*//" # get first variable and print it out, drop quotes if exists
grep -i "^$1 *=" | head -n 1 | sed -e "s/^[^=]*[ \t]*=[ \t]*//" | sed -e "s/^[\'\"]\(.*\)[\'\"]/\1/"
} }
# 2010.1 -> 2010 # 2010.1 -> 2010
...@@ -97,6 +97,7 @@ if distro altlinux-release ; then ...@@ -97,6 +97,7 @@ if distro altlinux-release ; then
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus" if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7" elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8" elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6" elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7" elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8" elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
...@@ -241,6 +242,8 @@ elif distro redhat-release ; then ...@@ -241,6 +242,8 @@ elif distro redhat-release ; then
DISTRIB_ID="CentOS" DISTRIB_ID="CentOS"
elif has Scientific ; then elif has Scientific ; then
DISTRIB_ID="Scientific" DISTRIB_ID="Scientific"
elif has GosLinux ; then
DISTRIB_ID="GosLinux"
fi fi
if has Beryllium ; then if has Beryllium ; then
DISTRIB_ID="Scientific" DISTRIB_ID="Scientific"
...@@ -298,7 +301,13 @@ elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then ...@@ -298,7 +301,13 @@ elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then
# try use standart LSB info by default # try use standart LSB info by default
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB # use LSB
true
# fix distro name
case "$DISTRIB_ID" in
"openSUSE Tumbleweed")
DISTRIB_ID="Tumbleweed"
;;
esac
fi fi
case $1 in case $1 in
...@@ -340,7 +349,7 @@ case $1 in ...@@ -340,7 +349,7 @@ case $1 in
exit 0 exit 0
;; ;;
-V) -V)
echo "20160822" echo "20161212"
exit 0 exit 0
;; ;;
*) *)
......
...@@ -65,7 +65,7 @@ print_version() ...@@ -65,7 +65,7 @@ print_version()
{ {
echo "EPM package manager version @VERSION@" echo "EPM package manager version @VERSION@"
echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)" echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
echo "Copyright (c) Etersoft 2012-2016" echo "Copyright (c) Etersoft 2012-2017"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
} }
...@@ -80,6 +80,7 @@ nodeps= ...@@ -80,6 +80,7 @@ nodeps=
noremove= noremove=
force= force=
short= short=
direct=
sort= sort=
non_interactive= non_interactive=
skip_installed= skip_installed=
...@@ -157,7 +158,7 @@ check_command() ...@@ -157,7 +158,7 @@ check_command()
-i|install|add|i) # HELPCMD: install package(s) from remote repositories or from local file -i|install|add|i) # HELPCMD: install package(s) from remote repositories or from local file
epm_cmd=install epm_cmd=install
;; ;;
-e|-P|remove|delete|uninstall|erase|e) # HELPCMD: remove (delete) package(s) from the database and the system -e|-P|rm|del|remove|delete|uninstall|erase|e) # HELPCMD: remove (delete) package(s) from the database and the system
epm_cmd=remove epm_cmd=remove
;; ;;
-s|search|s) # HELPCMD: search in remote package repositories -s|search|s) # HELPCMD: search in remote package repositories
...@@ -189,7 +190,7 @@ check_command() ...@@ -189,7 +190,7 @@ check_command()
check|fix|verify) # HELPCMD: check local package base integrity and fix it check|fix|verify) # HELPCMD: check local package base integrity and fix it
epm_cmd=check epm_cmd=check
;; ;;
changelog|cl|-cl) # HELPCMD: show changelog for package -cl|cl|changelog) # HELPCMD: show changelog for package
epm_cmd=changelog epm_cmd=changelog
;; ;;
-qi|qi|info|show) # HELPCMD: print package detail info -qi|qi|info|show) # HELPCMD: print package detail info
...@@ -210,13 +211,13 @@ check_command() ...@@ -210,13 +211,13 @@ check_command()
conflicts) # HELPCMD: print package conflicts conflicts) # HELPCMD: print package conflicts
epm_cmd=conflicts epm_cmd=conflicts
;; ;;
-qa|list|packages|-l|qa) # HELPCMD: print list of installed package(s) -qa|qa|-l|list|packages) # HELPCMD: print list of installed package(s)
epm_cmd=packages epm_cmd=packages
;; ;;
programs) # HELPCMD: print list of installed GUI program(s) programs) # HELPCMD: print list of installed GUI program(s) (they have .desktop files)
epm_cmd=programs epm_cmd=programs
;; ;;
assure) # HELPCMD: <command> [package]: install package if command does not exists assure) # HELPCMD: <command> [package]: install package if command does not exist
epm_cmd=assure epm_cmd=assure
;; ;;
policy) # HELPCMD: print detailed information about the priority selection of package policy) # HELPCMD: print detailed information about the priority selection of package
...@@ -283,7 +284,7 @@ check_command() ...@@ -283,7 +284,7 @@ check_command()
site|url) # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site) site|url) # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
epm_cmd=site epm_cmd=site
;; ;;
ei|epminstall|epm-install|selfinstall) # HELPCMD: install or update eepm from all in one script ei|epminstall|epm-install|selfinstall) # HELPCMD: install or update eepm package from all in one script
epm_cmd=epm_install epm_cmd=epm_install
;; ;;
print) # HELPCMD: print various info, run epm print help for details print) # HELPCMD: print various info, run epm print help for details
...@@ -335,6 +336,9 @@ check_option() ...@@ -335,6 +336,9 @@ check_option()
--short) # HELPOPT: short output (just 'package' instead 'package-version-release') --short) # HELPOPT: short output (just 'package' instead 'package-version-release')
short="--short" short="--short"
;; ;;
--direct) # HELPOPT: direct install package file from ftp (not via hilevel repository manager)
direct="--direct"
;;
--sort) # HELPOPT: sort output, f.i. --sort=size (supported only for packages command) --sort) # HELPOPT: sort output, f.i. --sort=size (supported only for packages command)
# TODO: how to read arg? # TODO: how to read arg?
sort="$1" sort="$1"
...@@ -402,7 +406,9 @@ pkg_filenames=$(strip_spaces "$pkg_files $pkg_names") ...@@ -402,7 +406,9 @@ pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
if [ -z "$epm_cmd" ] ; then if [ -z "$epm_cmd" ] ; then
print_version print_version
echo echo
fatal "Unknown command $@. Run $ $PROGNAME --help for get help" fatstr="Unknown command in $@ arg(s)"
[ -n "$*" ] || fatstr="That program needs be running with some command"
fatal "$fatstr. Run $ $PROGNAME --help to get help."
fi fi
# Use eatmydata for write specific operations # Use eatmydata for write specific operations
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012, 2016 Etersoft # Copyright (C) 2012, 2017 Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012, 2017 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -19,12 +19,49 @@ ...@@ -19,12 +19,49 @@
epm_addrepo() epm_addrepo()
{ {
local repo="$(eval echo $quoted_args)" local repo="$(eval echo "$quoted_args")"
case $PMTYPE in
apt-rpm) case $DISTRNAME in
ALTLinux)
case "$repo" in
etersoft)
info "add etersoft repo"
load_helper epm-query
epm install --skip-installed apt-conf-etersoft-common apt-conf-etersoft-hold || fatal
local branch="$DISTRVERSION/branch"
[ "$DISTRVERSION" = "Sisyphus" ] && branch="$DISTRVERSION"
# FIXME
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
local arch=$(uname -m)
[ "$arch" = "i686" ] && arch="i586"
echo "" | sudocmd tee -a /etc/apt/sources.list
echo "# added with eepm addrepo etersoft" | sudocmd tee -a /etc/apt/sources.list
echo "rpm [etersoft] http://download.etersoft.ru/pub/Etersoft LINUX@Etersoft/$branch/$arch addon" | sudocmd tee -a /etc/apt/sources.list
if [ "$arch" = "x86_64" ] ; then
echo "rpm [etersoft] http://download.etersoft.ru/pub/Etersoft LINUX@Etersoft/$branch/$arch-i586 addon" | sudocmd tee -a /etc/apt/sources.list
fi
echo "rpm [etersoft] http://download.etersoft.ru/pub/Etersoft LINUX@Etersoft/$branch/noarch addon" | sudocmd tee -a /etc/apt/sources.list
repo="$DISTRVERSION"
return 0
;;
autoimports)
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "[A-Z]" "[a-z]")"
esac
assure_exists apt-repo assure_exists apt-repo
if [ -z "$repo" ] ; then
docmd apt-repo add branch
echo "etersoft"
return
fi
sudocmd apt-repo add "$repo" sudocmd apt-repo add "$repo"
return
;; ;;
esac
case $PMTYPE in
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
info "You need manually add repo to /etc/apt/sources.list" info "You need manually add repo to /etc/apt/sources.list"
;; ;;
......
...@@ -17,45 +17,76 @@ ...@@ -17,45 +17,76 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
__epm_autoremove_altrpm() __epm_autoremove_altrpm_pp()
{ {
local pkg local pkgs
load_helper epm-packages
assure_exists /etc/buildreqs/files/ignore.d/apt-scripts apt-scripts info "Removing unused python/perl modules..."
#[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force
local flag=
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
libexclude='^(python-module-|python3-module-|python-modules-|python3-modules|perl-)'
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then
info ""
info "call again for next cycle until all modules will be removed"
__epm_autoremove_altrpm_pp
fi
return 0
}
__epm_autoremove_altrpm_lib()
{
local pkgs
info info
info "Removing all non -devel/-debuginfo libs packages not need by anything..." info "Removing all non -devel/-debuginfo libs packages not need by anything..."
#[ -n "$force" ] || info "You can run with --force for more deep removing" #[ -n "$force" ] || info "You can run with --force for more deep removing"
local force=force local force=force
local flag= local flag=
local libexclude='^lib' local libexclude='^(lib|i586-lib)'
[ -n "$force" ] || libexclude=$libexclude'[^-]*$' [ -n "$force" ] || libexclude=$libexclude'[^-]*$'
# https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps # https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps
showcmd "apt-cache list-nodeps | grep -- \"$libexclude\"" showcmd "apt-cache list-nodeps | grep -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -- "$libexclude" \ pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" \
| grep -E -v -- "-(devel|debuginfo)$" \ | sed -e "s/[-\.]32bit$//g" \
| grep -E -v -- "-(devel|devel-static|debuginfo)$" \
| grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \ | grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \
| sed -e "s/\.32bit$//g" \ | grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|eepm)" )
| grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|eepm)" )
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
info "Removing unused python/perl modules..."
libexclude='^(python-module-|python3-module-|python-modules-|python3-modules|perl-)'
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1 [ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then if [ -n "$flag" ] ; then
info "" info ""
info "call again for next cycle until all libs will be removed" info "call again for next cycle until all libs will be removed"
__epm_autoremove_altrpm __epm_autoremove_altrpm_lib
fi fi
return 0 return 0
} }
__epm_autoremove_altrpm()
{
local pkg
load_helper epm-packages
assure_exists /etc/buildreqs/files/ignore.d/apt-scripts apt-scripts
__epm_autoremove_altrpm_pp
__epm_autoremove_altrpm_lib
return 0
}
# TODO: keep our eepm package # TODO: keep our eepm package
epm_autoremove() epm_autoremove()
{ {
......
...@@ -34,15 +34,15 @@ __is_repo_info_downloaded() ...@@ -34,15 +34,15 @@ __is_repo_info_downloaded()
__is_repo_info_uptodate() __is_repo_info_uptodate()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-*)
# apt-deb do not update lock file date # apt-deb do not update lock file date
if $SUDO test -r /var/lib/apt/lists ; then #if $SUDO test -r /var/lib/apt/lists ; then
local LOCKFILE=/var/lib/apt/lists/lock local LOCKFILE=/var/lib/apt/lists
$SUDO test -r $LOCKFILE || return $SUDO test -r $LOCKFILE || return
# if repo older than 1 day, return false # if repo older than 1 day, return false
# find print string if file is obsoleted # find print string if file is obsoleted
test -z "$($SUDO find $LOCKFILE -mtime +1)" || return test -z "$(find $LOCKFILE -maxdepth 0 -mtime +1)" || return
fi #fi
;; ;;
*) *)
;; ;;
......
...@@ -19,11 +19,19 @@ ...@@ -19,11 +19,19 @@
__use_url_install() __use_url_install()
{ {
case $PMTYPE in case $DISTRNAME in
apt-rpm) "ALTLinux")
# ALT Linux really? # not for https
echo "$pkg_urls" | grep -q "https://" && return 1
pkg_names="$pkg_names $pkg_urls" pkg_names="$pkg_names $pkg_urls"
return 0
;; ;;
esac
case $PMTYPE in
#apt-rpm)
# pkg_names="$pkg_names $pkg_urls"
# ;;
#deepsolver-rpm) #deepsolver-rpm)
# pkg_names="$pkg_names $pkg_urls" # pkg_names="$pkg_names $pkg_urls"
# ;; # ;;
...@@ -54,13 +62,15 @@ __download_pkg_urls() ...@@ -54,13 +62,15 @@ __download_pkg_urls()
for url in $pkg_urls ; do for url in $pkg_urls ; do
# TODO: use some individual tmp dir # TODO: use some individual tmp dir
local new_file=/tmp/$(basename "$url") local new_file=/tmp/$(basename "$url")
if eget -O $new_file $url && [ -s "$new_file" ] ; then if docmd eget -O $new_file $url && [ -s "$new_file" ] ; then
pkg_files="$pkg_files $new_file" pkg_files="$pkg_files $new_file"
to_remove_pkg_files="$to_remove_pkg_files $new_file" to_remove_pkg_files="$to_remove_pkg_files $new_file"
else else
warning "Failed to download $url, ignoring" warning "Failed to download $url, ignoring"
fi fi
done done
# restore
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
} }
# NOTE: call __clean_downloaded_pkg_files after # NOTE: call __clean_downloaded_pkg_files after
...@@ -70,8 +80,8 @@ __handle_pkg_urls_to_install() ...@@ -70,8 +80,8 @@ __handle_pkg_urls_to_install()
# TODO: do it correctly # TODO: do it correctly
to_remove_pkg_files= to_remove_pkg_files=
# FIXME: check type of pkg_urls separately?
if [ "$(get_package_type "$pkg")" != $PKGFORMAT ] || ! __use_url_install ; then if [ "$(get_package_type "$pkg_urls")" != $PKGFORMAT ] || ! __use_url_install ; then
# use workaround with eget: download and put in pkg_files # use workaround with eget: download and put in pkg_files
__download_pkg_urls __download_pkg_urls
fi fi
...@@ -98,11 +108,38 @@ __handle_pkg_urls_to_checking() ...@@ -98,11 +108,38 @@ __handle_pkg_urls_to_checking()
# rm -fv $to_remove_pkg_files # rm -fv $to_remove_pkg_files
#} #}
__epm_get_altpkg_url()
{
info "TODO: https://packages.altlinux.org/api/branches"
load_helper epm-site
local arch=$(paoapi packages/$1 | get_pao_var arch)
# FIXME: arch can be list
[ "$arch" = "noarch" ] || arch=$(arch)
# HACK: filename can be list
local filename=$(paoapi packages/$1 | get_pao_var filename | grep $arch)
[ -n "$filename" ] || fatal "Can't get filename"
# fixme: get from /branches
local dv=$DISTRNAME/$DISTRVERSION/branch
[ "$DISTRVERSION" = "Sisyphus" ] && dv=$DISTRNAME/$DISTRVERSION
echo "http://ftp.basealt.ru/pub/distributions/$dv/$arch/RPMS.classic/$filename"
}
epm_download() epm_download()
{ {
local CMD local CMD
case $DISTRNAME in
ALTLinux)
local pkg
for pkg in $pkg_filenames ; do
local url=$(__epm_get_altpkg_url $pkg)
[ -n "$url" ] || warning "Can't get url for $pkg"
docmd eget $url
done
return
;;
esac
case $PMTYPE in case $PMTYPE in
dnf-rpm) dnf-rpm)
sudocmd dnf download $pkg_filenames sudocmd dnf download $pkg_filenames
...@@ -118,6 +155,9 @@ epm_download() ...@@ -118,6 +155,9 @@ epm_download()
dnf-rpm) dnf-rpm)
sudocmd dnf download $pkg_filenames sudocmd dnf download $pkg_filenames
;; ;;
urpm-rpm)
sudocmd urpmi --no-install $URPMOPTIONS $@
;;
tce) tce)
sudocmd tce-load -w $pkg_filenames sudocmd tce-load -w $pkg_filenames
;; ;;
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012-2016 Etersoft # Copyright (C) 2012-2017 Etersoft
# Copyright (C) 2012-2016 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012-2017 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -37,7 +37,7 @@ __alt_local_content_filelist() ...@@ -37,7 +37,7 @@ __alt_local_content_filelist()
{ {
[ -n "$USETTY" ] && info "Search in $CI for $1..." [ -n "$USETTY" ] && info "Search in $CI for $1..."
grep -h -- ".*$1$" $CI | sed -e "s|\(.*\)\t\(.*\)|\1|g" __local_ercat $CI | grep -h -- ".*$1$" | sed -e "s|\(.*\)\t\(.*\)|\1|g"
} | $OUTCMD } | $OUTCMD
} }
...@@ -64,7 +64,7 @@ __epm_filelist_remote() ...@@ -64,7 +64,7 @@ __epm_filelist_remote()
docmd_foreach __deb_local_content_filelist $@ docmd_foreach __deb_local_content_filelist $@
;; ;;
*) *)
fatal "Query filelist for non installed packages does not realized" fatal "Query filelist for non installed packages is not implemented yet."
;; ;;
esac esac
} }
...@@ -134,7 +134,7 @@ __epm_filelist_name() ...@@ -134,7 +134,7 @@ __epm_filelist_name()
return return
;; ;;
slackpkg) slackpkg)
is_installed $@ || fatal "Query filelist for non installed packages does not realized" is_installed $@ || fatal "Query filelist for non installed packages is not implemented yet"
docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* | less docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* | less
return return
;; ;;
......
...@@ -29,10 +29,16 @@ __epm_info_rpm_low() ...@@ -29,10 +29,16 @@ __epm_info_rpm_low()
} }
# TODO: separate to _files and _names parts # TODO: separate to _files and _names parts
# realize _files part per package, not by PMTYPE (see filelist) # implement _files part per package, not by PMTYPE (see filelist)
epm_info() epm_info()
{ {
# if possible, it will put pkg_urls into pkg_files or pkg_names
if [ -n "$pkg_urls" ] ; then
load_helper epm-download
__handle_pkg_urls_to_checking
fi
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name" [ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
case $PMTYPE in case $PMTYPE in
...@@ -117,4 +123,10 @@ case $PMTYPE in ...@@ -117,4 +123,10 @@ case $PMTYPE in
;; ;;
esac esac
local RETVAL=$?
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
return $RETVAL
} }
...@@ -312,7 +312,6 @@ __epm_check_if_try_install_rpm() ...@@ -312,7 +312,6 @@ __epm_check_if_try_install_rpm()
cd $TDIR cd $TDIR
for pkg in $rpmpkgs ; do for pkg in $rpmpkgs ; do
showcmd_store_output fakeroot alien -d -k --scripts "$pkg" showcmd_store_output fakeroot alien -d -k --scripts "$pkg"
clean_store_output
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g") local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
clean_store_output clean_store_output
epm install $DEBCONVERTED epm install $DEBCONVERTED
...@@ -323,6 +322,23 @@ __epm_check_if_try_install_rpm() ...@@ -323,6 +322,23 @@ __epm_check_if_try_install_rpm()
return 0 return 0
} }
__handle_direct_install()
{
case "$DISTRNAME" in
"ALTLinux")
load_helper epm-download
local pkg url
for pkg in $pkg_names ; do
url=$(__epm_get_altpkg_url $pkg)
[ -n "$url" ] || continue
# TODO: use estrlist
pkg_urls="$pkg_urls $url"
done
# FIXME: need remove
pkg_names=""
;;
esac
}
epm_install_files() epm_install_files()
{ {
...@@ -514,6 +530,10 @@ epm_install() ...@@ -514,6 +530,10 @@ epm_install()
return return
fi fi
if [ -n "$direct" ] ; then
__handle_direct_install
fi
# if possible, it will put pkg_urls into pkg_files or pkg_names # if possible, it will put pkg_urls into pkg_files or pkg_names
if [ -n "$pkg_urls" ] ; then if [ -n "$pkg_urls" ] ; then
load_helper epm-download load_helper epm-download
...@@ -527,7 +547,7 @@ epm_install() ...@@ -527,7 +547,7 @@ epm_install()
[ -z "$files$names" ] && info "Skip empty install list" && return 22 [ -z "$files$names" ] && info "Skip empty install list" && return 22
if [ -z "$files" ] ; then if [ -z "$files" ] && [ -z "$direct" ] ; then
# it is useful for first time running # it is useful for first time running
update_repo_if_needed update_repo_if_needed
fi fi
......
...@@ -23,13 +23,13 @@ __epm_packages_sort() ...@@ -23,13 +23,13 @@ __epm_packages_sort()
case $PMTYPE in case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm) apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
# FIXME: space with quotes problems, use point instead # FIXME: space with quotes problems, use point instead
docmd rpm -qa --queryformat "%{size}.%{name}-%{version}-%{release}\n" $pkg_filenames | sort -n docmd rpm -qa --queryformat "%{size}@%{name}-%{version}-%{release}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1
;; ;;
apt-dpkg) apt-dpkg)
docmd dpkg-query -W --showformat="\${Size}.\${Package}-\${Version}\n" $pkg_filenames | sort -n docmd dpkg-query -W --showformat="\${Installed-Size}@\${Package}-\${Version}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1
;; ;;
*) *)
fatal "Sorted package list are not realized for $PMTYPE" fatal "Sorted package list function is not implemented for $PMTYPE"
;; ;;
esac esac
} }
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2015 Etersoft # Copyright (C) 2015, 2017 Etersoft
# Copyright (C) 2015 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2015, 2017 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -17,11 +17,16 @@ ...@@ -17,11 +17,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
load_helper epm-query
epm_policy() epm_policy()
{ {
[ -n "$pkg_names" ] || fatal "Info: missing package(s) name" [ -n "$pkg_names" ] || fatal "Info: missing package(s) name"
# get package name for hi level package management command (with version if supported and if possible)
pkg_names=$(__epm_get_hilevel_name $pkg_names)
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
docmd apt-cache policy $pkg_names docmd apt-cache policy $pkg_names
......
...@@ -98,11 +98,11 @@ __epm_get_hilevel_nameform() ...@@ -98,11 +98,11 @@ __epm_get_hilevel_nameform()
echo $pkg echo $pkg
return return
;; ;;
yum-rpm) yum-rpm|dnf-rpm)
# just use strict version with Epoch and Serial # just use strict version with Epoch and Serial
local pkg local pkg
pkg=$(rpm -q --queryformat "%{EPOCH}:%{NAME}%{VERSION}-%{RELEASE}.${ARCH}\n" $1) pkg=$(rpm -q --queryformat "%{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" $1)
echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.${ARCH}\n" $1) echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" $1)
echo $pkg echo $pkg
return return
;; ;;
......
...@@ -19,13 +19,27 @@ ...@@ -19,13 +19,27 @@
# copied from etersoft-build-utils/bin/rpmqf # copied from etersoft-build-utils/bin/rpmqf
# TODO: check for lib64/name situations
__abs_filename()
{
if echo "$1" | grep -q "/" ; then
echo "$1"
return
fi
if [ -e "$1" ] ; then
echo "$(pwd)/$1"
return
fi
echo "$1"
}
__do_query_real_file() __do_query_real_file()
{ {
local TOFILE local TOFILE
# get canonical path # get canonical path
if [ -e "$1" ] ; then if [ -e "$1" ] ; then
TOFILE=$(realpath "$1") TOFILE="$(__abs_filename "$1")"
else else
TOFILE=$(which "$1" 2>/dev/null || echo "$1") TOFILE=$(which "$1" 2>/dev/null || echo "$1")
if [ "$TOFILE" != "$1" ] ; then if [ "$TOFILE" != "$1" ] ; then
...@@ -104,7 +118,7 @@ __do_query() ...@@ -104,7 +118,7 @@ __do_query()
;; ;;
aptcyg) aptcyg)
#CMD="apt-cyg packageof" #CMD="apt-cyg packageof"
# do not realized locally # is not implemented locally
return 1 return 1
;; ;;
*) *)
......
...@@ -117,7 +117,7 @@ __update_to_the_distro() ...@@ -117,7 +117,7 @@ __update_to_the_distro()
;; ;;
Sisyphus) Sisyphus)
docmd epm update || fatal docmd epm update || fatal
docmd epm install apt rpm apt-conf-sisyphus altlinux-release-sisyphus || fatal "Check an error and run again" docmd epm install apt rpm librpm7 librpm apt-conf-sisyphus altlinux-release-sisyphus || fatal "Check an error and run again"
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again" docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;; ;;
*) *)
...@@ -232,9 +232,11 @@ epm_release_upgrade() ...@@ -232,9 +232,11 @@ epm_release_upgrade()
assure_exists dnf-plugin-system-upgrade assure_exists dnf-plugin-system-upgrade
sudocmd dnf system-upgrade sudocmd dnf system-upgrade
local RELEASEVER="$pkg_filenames" local RELEASEVER="$pkg_filenames"
[ -n "$RELEASEVER" ] || fatal "Run me with new version" [ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
#[ -n "$RELEASEVER" ] || fatal "Run me with new version"
info "Upgrate to $DISTRNAME/$RELEASEVER"
sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER
sudocmd dnf system-upgrade sudocmd dnf distro-sync --releasever=$RELEASEVER
info "Run epm autoorphans to remove orphaned packages" info "Run epm autoorphans to remove orphaned packages"
;; ;;
urpm-rpm) urpm-rpm)
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012, 2016 Etersoft # Copyright (C) 2012, 2017 Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012, 2017 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -20,11 +20,24 @@ ...@@ -20,11 +20,24 @@
epm_removerepo() epm_removerepo()
{ {
local repo="$(eval echo $quoted_args)" local repo="$(eval echo $quoted_args)"
case $PMTYPE in
apt-rpm) case $DISTRNAME in
ALTLinux)
case "$repo" in
autoimports)
info "remove autoimports repo"
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "[A-Z]" "[a-z]")"
;;
esac
assure_exists apt-repo assure_exists apt-repo
sudocmd apt-repo rm "$repo" sudocmd apt-repo rm "$repo"
return
;; ;;
esac;
case $PMTYPE in
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
info "You need remove repo from /etc/apt/sources.list" info "You need remove repo from /etc/apt/sources.list"
;; ;;
......
...@@ -29,8 +29,26 @@ __repofix_check_vendor() ...@@ -29,8 +29,26 @@ __repofix_check_vendor()
return 1 return 1
} }
# source-list vendor path
# example: /etc/apt/source.list p7 ALTLinux\/Sisyphus
__try_fix_apt_source_list()
{
local list="$1"
local br="$2"
local path="$3"
if grep -q -e "^[^#].*$path" $list ; then
if __repofix_check_vendor $br ; then
regexp_subst "/$path/s/^rpm[[:space:]]*([fhr])/rpm [$br] \1/" $list
else
warning "Skip set $br vendor key (it misssed) for $list"
regexp_subst "/$path/s/^rpm[[:space:]]*\[$br\][[:space:]]*([fhr])/rpm \1/" $list
fi
fi
}
__fix_apt_sources_list() __fix_apt_sources_list()
{ {
# for beauty spaces
local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p8[/ ]branch|p7[/ ]branch|p6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi' local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p8[/ ]branch|p7[/ ]branch|p6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local i local i
assure_root assure_root
...@@ -42,33 +60,14 @@ __fix_apt_sources_list() ...@@ -42,33 +60,14 @@ __fix_apt_sources_list()
regexp_subst "/^ *#/! $SUBST_ALT_RULE" $i regexp_subst "/^ *#/! $SUBST_ALT_RULE" $i
# Sisyphus uses 'alt' vendor key # Sisyphus uses 'alt' vendor key
if __repofix_check_vendor alt ; then __try_fix_apt_source_list $i alt "ALTLinux\/Sisyphus"
regexp_subst "/ALTLinux\/Sisyphus\//s/^rpm *([fhr])/rpm [alt] \1/" $i
else
warning "Skip set alt vendor key (it misssed)"
fi
# skip branch replacement for ALT Linux Sisyphus # skip branch replacement for ALT Linux Sisyphus
[ "$DISTRVERSION" = "Sisyphus" ] && continue [ "$DISTRVERSION" = "Sisyphus" ] && continue
# add signs for branches # add signs for branches
local br __try_fix_apt_source_list $i $DISTRVERSION "ALTLinux\/$DISTRVERSION\/branch"
for br in $DISTRVERSION ; do __try_fix_apt_source_list $i etersoft "Etersoft\/$DISTRVERSION\/branch"
if ! __repofix_check_vendor $br ; then
warning "Skip set $br vendor key (it misssed)"
continue
fi
regexp_subst "/ALTLinux\/$br\/branch/s/^rpm *([fhr])/rpm [$br] \1/" $i
done
for br in $DISTRVERSION ; do
#if is_installed apt-conf-etersoft-common ; then
if ! __repofix_check_vendor etersoft ; then
warning "Skip set etersoft vendor key (it misssed)"
continue
fi
regexp_subst "/Etersoft\/$br\/branch/s/^rpm *([fhr])/rpm [etersoft] \1/" $i
done
done done
} }
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012, 2016 Etersoft # Copyright (C) 2012, 2016, 2017 Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012, 2016, 2017 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -17,21 +17,34 @@ ...@@ -17,21 +17,34 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# TODO: see epm-search (colorify for all distro)
# args: index_lists word grep_string
__alt_search_file_output()
{
# grep only on left part (filename), then revert order and grep with color
__local_ercat $1 | grep -h -- ".*$2.*[[:space:]]" | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g" $3
}
__alt_local_content_search() __alt_local_content_search()
{ {
load_helper epm-sh-altlinux load_helper epm-sh-altlinux
load_helper epm-search
info "Locate contents index file(s) ..."
local CI="$(get_local_alt_contents_index)" local CI="$(get_local_alt_contents_index)"
# TODO use something like
[ -n "$CI" ] || fatal "Have no local contents index" [ -n "$CI" ] || fatal "Have no local contents index"
#local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat"
OUTCMD="cat"
{ info "Searching in"
[ -n "$USETTY" ] && info "Search in $CI for $1..." echo "$CI"
# note! tabulation below! echo "for $1... "
grep -h -- ".*$1.* " $CI | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
} | $OUTCMD # FIXME: do it better
local MGS
MGS=$(eval __epm_search_make_grep $quoted_args)
showcmd "$ cat contents_index $MGS"
eval "__alt_search_file_output \"$CI\" \"$(eval get_firstarg $quoted_args)\" $MGS"
} }
epm_search_file() epm_search_file()
...@@ -50,12 +63,12 @@ case $PMTYPE in ...@@ -50,12 +63,12 @@ case $PMTYPE in
return ;; return ;;
yum-rpm) yum-rpm)
# TODO # TODO
info "Search by full packages list does not realized" info "Search by full packages list is not implemented yet"
CMD="yum provides" CMD="yum provides"
;; ;;
dnf-rpm) dnf-rpm)
# TODO # TODO
info "Search by full packages list does not realized" info "Search by full packages list is not implemented yet"
CMD="dnf provides" CMD="dnf provides"
;; ;;
urpm-rpm) urpm-rpm)
......
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2014 Etersoft # Copyright (C) 2014, 2017 Etersoft
# Copyright (C) 2014 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2014, 2017 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -17,19 +17,98 @@ ...@@ -17,19 +17,98 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# TODO: port or rewrite apt-file # apt-file like. See also
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449 # https://bugzilla.altlinux.org/show_bug.cgi?id=14449
# convert "http://download.etersoft.ru/pub/ALTLinux/p8/branch x86_64" to /tmp/epm/ALTLinux/p8/branch/x86_64
get_local_alt_mirror_path()
{
local DN1=$(dirname "$1")
local DN2=$(dirname $DN1)
local DN3=$(dirname $DN2)
local BN0=$(basename "$1") # arch
local BN1=$(basename $DN1) # branch/Sisyphus
local BN2=$(basename $DN2) # p8/ALTLinux
local BN3=$(basename $DN3) # ALTLinux/
[ "$BN1" = "branch" ] && echo "/tmp/eepm/$BN3/$BN2/$BN1/$BN0" || echo "/tmp/eepm/$BN2/$BN1/$BN0"
}
__local_ercat()
{
local i
for i in $* ; do
case "$i" in
*.xz)
a= xzcat $i
;;
*.lz4)
a= lz4cat $i
;;
*.failed)
# just ignore
;;
*)
cat $i
;;
esac
done
}
# something like gzip
compress_file_inplace()
{
local OFILE="$1"
if epm assure lz4 </dev/null ; then
#docmd lz4 --rm "$OFILE" "$OFILE.lz4" || return
# due old lz4
docmd lz4 "$OFILE" "$OFILE.lz4" || return
rm -fv "$OFILE"
else
epm assure xz </dev/null || return
docmd xz "$OFILE" || return
fi
return 0
}
# args: url/path target_file
# result: will set FILE
download_alt_contents_index()
{
local URL="$1"
local TD="$2"
local OFILE="$TD/$(basename "$URL")"
local DONE=$(echo $OFILE*)
# TODO: check if too old
if [ -r "$DONE" ] ; then
return
fi
mkdir -p "$TD"
if echo "$URL" | grep -q "^file:/" ; then
URL=$(echo "$URL" | sed -e "s|^file:||")
[ -s "$URL" ] || { touch $OFILE.failed ; return 1; }
ln -s "$URL" "$OFILE" || { touch $OFILE.failed ; return 1; }
else
docmd eget -O "$OFILE" "$URL" || { rm -fv $OFILE ; touch $OFILE.failed ; return 1; }
fi
compress_file_inplace "$OFILE"
}
get_local_alt_contents_index() get_local_alt_contents_index()
{ {
load_helper epm-repolist load_helper epm-repolist
epm_repolist | grep "rpm.*file:/" | sed -e "s|^rpm.*file:||g" | while read URL ARCH other ; do local LOCALPATH
test -d "$URL/$ARCH" || continue # fatal "Local mirror is not accessible via $URL/$ARCH"
FILE="$URL/$ARCH/base/contents_index" epm_repolist | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read URL ARCH other ; do
if [ -r "$FILE" ] ; then LOCALPATH=$(get_local_alt_mirror_path "$URL/$ARCH")
echo "$FILE" download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH >&2 || continue
else echo "$LOCALPATH/contents_index*"
info "TODO for girar server: There is no $(basename $FILE) file in $(dirname $FILE)"
fi
done done
} }
...@@ -154,6 +154,14 @@ sudocmd_foreach() ...@@ -154,6 +154,14 @@ sudocmd_foreach()
done done
} }
# add realpath if missed
if ! which realpath 2>/dev/null >/dev/null ; then
realpath()
{
readlink -f "$@"
}
fi
get_firstarg() get_firstarg()
{ {
echon "$1" echon "$1"
...@@ -459,14 +467,14 @@ case $DISTRNAME in ...@@ -459,14 +467,14 @@ case $DISTRNAME in
ArchLinux) ArchLinux)
CMD="pacman" CMD="pacman"
;; ;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux)
CMD="yum-rpm" CMD="yum-rpm"
which dnf 2>/dev/null >/dev/null && test -d /var/lib/dnf/yumdb && CMD=dnf-rpm which dnf 2>/dev/null >/dev/null && test -d /var/lib/dnf/yumdb && CMD=dnf-rpm
;; ;;
Slackware) Slackware)
CMD="slackpkg" CMD="slackpkg"
;; ;;
SUSE|SLED|SLES) SUSE|SLED|SLES|Tumbleweed)
CMD="zypper-rpm" CMD="zypper-rpm"
;; ;;
ForesightLinux|rPathLinux) ForesightLinux|rPathLinux)
...@@ -515,6 +523,7 @@ is_active_systemd() ...@@ -515,6 +523,7 @@ is_active_systemd()
[ -x "$SYSTEMCTL" ] || return [ -x "$SYSTEMCTL" ] || return
[ -d "$SYSTEMD_CGROUP_DIR" ] || return [ -d "$SYSTEMD_CGROUP_DIR" ] || return
a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
readlink /sbin/init | grep -q 'systemd' || return
# some hack # some hack
ps ax | grep -q '[s]ystemd' | grep -v 'systemd-udev' >/dev/null ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev'
} }
...@@ -22,6 +22,24 @@ load_helper epm-print ...@@ -22,6 +22,24 @@ load_helper epm-print
PAOURL="https://packages.altlinux.org" PAOURL="https://packages.altlinux.org"
paoapi()
{
# http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs
epm assure curl || return 1
showcmd curl "$PAOURL/api/$1"
a= curl -s --header "Accept: application/json" "$PAOURL/api/$1"
}
# TODO: use /home/lav/Projects/git/JSON.sh
get_pao_var()
{
local FIELD="$1"
#grep '"$FIELD"' | sed -e 's|.*"$FIELD":"||g' | sed -e 's|".*||g'
$SHAREDIR/tools_json -b | egrep "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g'
return 0
}
run_command_if_exists() run_command_if_exists()
{ {
local CMD="$1" local CMD="$1"
...@@ -43,14 +61,9 @@ open_browser() ...@@ -43,14 +61,9 @@ open_browser()
__query_package_hl_url() __query_package_hl_url()
{ {
local PAOAPI="$PAOURL/api"
case $DISTRNAME in case $DISTRNAME in
ALTLinux) ALTLinux)
# http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs paoapi srpms/$1 | get_pao_var url
epm assure curl || return 1
showcmd curl "$PAOAPI/srpms/$1"
a= curl -s --header "Accept: application/json" "$PAOAPI/srpms/$1" | grep '"url"' | sed -e 's|.*"url":"||g' | sed -e 's|".*||g'
return 0
;; ;;
esac esac
return 1 return 1
......
...@@ -23,7 +23,7 @@ epm_upgrade() ...@@ -23,7 +23,7 @@ epm_upgrade()
{ {
local CMD local CMD
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here" #[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
# it is useful for first time running # it is useful for first time running
update_repo_if_needed update_repo_if_needed
...@@ -42,18 +42,18 @@ epm_upgrade() ...@@ -42,18 +42,18 @@ epm_upgrade()
yum-rpm) yum-rpm)
local OPTIONS="$(subst_option non_interactive -y)" local OPTIONS="$(subst_option non_interactive -y)"
# can do update repobase automagically # can do update repobase automagically
CMD="yum $OPTIONS update" CMD="yum $OPTIONS update $pkg_filenames"
;; ;;
dnf-rpm) dnf-rpm)
local OPTIONS="$(subst_option non_interactive -y)" local OPTIONS="$(subst_option non_interactive -y)"
CMD="dnf $OPTIONS distro-sync" CMD="dnf $OPTIONS distro-sync $pkg_filenames"
;; ;;
snappy) snappy)
CMD="snappy update" CMD="snappy update"
;; ;;
urpm-rpm) urpm-rpm)
# or --auto-select --replace-files # or --auto-select --replace-files
CMD="urpmi --update --auto-select" CMD="urpmi --update --auto-select $pkg_filenames"
;; ;;
zypper-rpm) zypper-rpm)
CMD="zypper dist-upgrade" CMD="zypper dist-upgrade"
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# TODO: will it has local only mode?
load_helper epm-print load_helper epm-print
epm_whatdepends() epm_whatdepends()
...@@ -44,6 +46,7 @@ case $PMTYPE in ...@@ -44,6 +46,7 @@ case $PMTYPE in
CMD="urpmq --whatrequires" CMD="urpmq --whatrequires"
;; ;;
dnf-rpm) dnf-rpm)
# check command: dnf repoquery --whatrequires
CMD="repoquery --whatrequires" CMD="repoquery --whatrequires"
;; ;;
emerge) emerge)
......
...@@ -58,7 +58,7 @@ case $DISTRNAME in ...@@ -58,7 +58,7 @@ case $DISTRNAME in
ALTLinux) ALTLinux)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
Ubuntu|Debian|Mint) Ubuntu|Debian|Mint|AstraLinux)
CMD="service-update" CMD="service-update"
;; ;;
Mandriva|ROSA) Mandriva|ROSA)
...@@ -73,7 +73,7 @@ case $DISTRNAME in ...@@ -73,7 +73,7 @@ case $DISTRNAME in
# ArchLinux) # ArchLinux)
# CMD="pacman" # CMD="pacman"
# ;; # ;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
VoidLinux) VoidLinux)
...@@ -82,7 +82,7 @@ case $DISTRNAME in ...@@ -82,7 +82,7 @@ case $DISTRNAME in
Slackware) Slackware)
CMD="service-initd" CMD="service-initd"
;; ;;
SUSE|SLED|SLES) SUSE|SLED|SLES|Tumbleweed)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
# Windows) # Windows)
......
#!/bin/sh
# License: MIT or Apache
# Homepage: http://github.com/dominictarr/JSON.sh
throw() {
echo "$*" >&2
exit 1
}
BRIEF=0
LEAFONLY=0
PRUNE=0
NO_HEAD=0
NORMALIZE_SOLIDUS=0
usage() {
echo
echo "Usage: JSON.sh [-b] [-l] [-p] [-s] [-h]"
echo
echo "-p - Prune empty. Exclude fields with empty values."
echo "-l - Leaf only. Only show leaf nodes, which stops data duplication."
echo "-b - Brief. Combines 'Leaf only' and 'Prune empty' options."
echo "-n - No-head. Do not show nodes that have no path (lines that start with [])."
echo "-s - Remove escaping of the solidus symbol (straight slash)."
echo "-h - This help text."
echo
}
parse_options() {
set -- "$@"
local ARGN=$#
while [ "$ARGN" -ne 0 ]
do
case $1 in
-h) usage
exit 0
;;
-b) BRIEF=1
LEAFONLY=1
PRUNE=1
;;
-l) LEAFONLY=1
;;
-p) PRUNE=1
;;
-n) NO_HEAD=1
;;
-s) NORMALIZE_SOLIDUS=1
;;
?*) echo "ERROR: Unknown option."
usage
exit 0
;;
esac
shift 1
ARGN=$((ARGN-1))
done
}
awk_egrep () {
local pattern_string=$1
gawk '{
while ($0) {
start=match($0, pattern);
token=substr($0, start, RLENGTH);
print token;
$0=substr($0, start+RLENGTH);
}
}' pattern="$pattern_string"
}
tokenize () {
local GREP
local ESCAPE
local CHAR
if echo "test string" | egrep -ao --color=never "test" >/dev/null 2>&1
then
GREP='egrep -ao --color=never'
else
GREP='egrep -ao'
fi
if echo "test string" | egrep -o "test" >/dev/null 2>&1
then
ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
CHAR='[^[:cntrl:]"\\]'
else
GREP=awk_egrep
ESCAPE='(\\\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
CHAR='[^[:cntrl:]"\\\\]'
fi
local STRING="\"$CHAR*($ESCAPE$CHAR*)*\""
local NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?'
local KEYWORD='null|false|true'
local SPACE='[[:space:]]+'
# Force zsh to expand $A into multiple words
local is_wordsplit_disabled=$(unsetopt 2>/dev/null | grep -c '^shwordsplit$')
if [ $is_wordsplit_disabled != 0 ]; then setopt shwordsplit; fi
$GREP "$STRING|$NUMBER|$KEYWORD|$SPACE|." | egrep -v "^$SPACE$"
if [ $is_wordsplit_disabled != 0 ]; then unsetopt shwordsplit; fi
}
parse_array () {
local index=0
local ary=''
read -r token
case "$token" in
']') ;;
*)
while :
do
parse_value "$1" "$index"
index=$((index+1))
ary="$ary""$value"
read -r token
case "$token" in
']') break ;;
',') ary="$ary," ;;
*) throw "EXPECTED , or ] GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
[ "$BRIEF" -eq 0 ] && value=$(printf '[%s]' "$ary") || value=
:
}
parse_object () {
local key
local obj=''
read -r token
case "$token" in
'}') ;;
*)
while :
do
case "$token" in
'"'*'"') key=$token ;;
*) throw "EXPECTED string GOT ${token:-EOF}" ;;
esac
read -r token
case "$token" in
':') ;;
*) throw "EXPECTED : GOT ${token:-EOF}" ;;
esac
read -r token
parse_value "$1" "$key"
obj="$obj$key:$value"
read -r token
case "$token" in
'}') break ;;
',') obj="$obj," ;;
*) throw "EXPECTED , or } GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
[ "$BRIEF" -eq 0 ] && value=$(printf '{%s}' "$obj") || value=
:
}
parse_value () {
local jpath="${1:+$1,}$2" isleaf=0 isempty=0 print=0
case "$token" in
'{') parse_object "$jpath" ;;
'[') parse_array "$jpath" ;;
# At this point, the only valid single-character tokens are digits.
''|[!0-9]) throw "EXPECTED value GOT ${token:-EOF}" ;;
*) value=$token
# if asked, replace solidus ("\/") in json strings with normalized value: "/"
[ "$NORMALIZE_SOLIDUS" -eq 1 ] && value=$(echo "$value" | sed 's#\\/#/#g')
isleaf=1
[ "$value" = '""' ] && isempty=1
;;
esac
[ "$value" = '' ] && return
[ "$NO_HEAD" -eq 1 ] && [ -z "$jpath" ] && return
[ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 0 ] && print=1
[ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && [ $PRUNE -eq 0 ] && print=1
[ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 1 ] && [ "$isempty" -eq 0 ] && print=1
[ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && \
[ $PRUNE -eq 1 ] && [ $isempty -eq 0 ] && print=1
[ "$print" -eq 1 ] && printf "[%s]\t%s\n" "$jpath" "$value"
:
}
parse () {
read -r token
parse_value
read -r token
case "$token" in
'') ;;
*) throw "EXPECTED EOF GOT $token" ;;
esac
}
if ([ "$0" = "$BASH_SOURCE" ] || ! [ -n "$BASH_SOURCE" ]);
then
parse_options "$@"
tokenize | parse
fi
# vi: expandtab sw=2 ts=2
# This spec is backported to ALTLinux p7 automatically by rpmbph script from etersoft-build-utils. # This spec is backported to ALTLinux p7 automatically by rpmbph script from etersoft-build-utils.
# #
Name: eepm Name: eepm
Version: 1.9.8 Version: 2.0.6
Release: alt0.M70P.1 Release: alt0.M70P.1
Summary: Etersoft EPM package manager Summary: Etersoft EPM package manager
...@@ -68,9 +68,58 @@ chmod a+x %buildroot%_datadir/%name/tools_* ...@@ -68,9 +68,58 @@ chmod a+x %buildroot%_datadir/%name/tools_*
%_sysconfdir/bash_completion.d/cerv %_sysconfdir/bash_completion.d/cerv
%changelog %changelog
* Fri Dec 02 2016 Vitaly Lipatov <lav@altlinux.ru> 1.9.8-alt0.M70P.1 * Thu Mar 23 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.6-alt0.M70P.1
- backport to ALTLinux p7 (by rpmbph script) - backport to ALTLinux p7 (by rpmbph script)
* Mon Mar 13 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.6-alt1
- epm-packages: improve sort output
- hack to support old lz4
* Fri Mar 10 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.5-alt1
- epm sf: make compressed cache for local file too
- rewrite epm sf, colorify it
- more correct message when empty run
* Thu Mar 09 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.4-alt1
- epm-policy: move to hilevel package name
- implement local cache for contents index for ALT repos
* Tue Mar 07 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.3-alt1
- fix query hilevel name for yum/dnf
- epm install: fix install rpm on deb
- add missed in some cases AstraLinux and GosLinux
* Thu Mar 02 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.2-alt1
- distr_info: fix version detection for all ALT p8 distros
- add workaround for ALT rpm missed https support
- install librpm7 during upgrade to Sisyphus
- improve systemd checking
* Tue Feb 07 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.1-alt1
- autoremove: skip -32bit suffix
* Mon Jan 16 2017 Vitaly Lipatov <lav@altlinux.ru> 2.0.0-alt1
- distr_info: fix get lsb-release file with quoted fields
- epm-download: add filename empty checking
- epm info: add URL support
- epm upgrade: allow extra args
- release_upgrade: improve for Fedora
- epm-download: add support for urpm
- check_update_repo: check for /var/lib/apt/lists date
- query_file: improve check for relative path
- epm-automove: fix i586-lib issue
- fix systemd detection
- epm: add/remove autoimports
* Wed Dec 07 2016 Vitaly Lipatov <lav@altlinux.ru> 1.9.9-alt1
- add own realpath implementation if missed
- add openSUSE Tumbleweed support
- autoremove: do separate removing cycles for python/perl and libs
- epm-site: fix json parsing
- epm-download: realize download via info from packages.altlinux.org
- epm-install: add direct install (not via apt) support for ALT Linux
- addrepo: implement support for epm addrepo etersoft
* Thu Dec 01 2016 Vitaly Lipatov <lav@altlinux.ru> 1.9.8-alt1 * Thu Dec 01 2016 Vitaly Lipatov <lav@altlinux.ru> 1.9.8-alt1
- epm-install: move download code to epm-download - epm-install: move download code to epm-download
- epm-checkpkg: add support for checking package by url - epm-checkpkg: add support for checking package by url
......
...@@ -44,6 +44,7 @@ filter_out() ...@@ -44,6 +44,7 @@ filter_out()
{ {
grep -v "^[ ]*load_helper " | \ grep -v "^[ ]*load_helper " | \
sed -e 's|$SHAREDIR/tools_eget|internal_tools_eget|g' | \ sed -e 's|$SHAREDIR/tools_eget|internal_tools_eget|g' | \
sed -e 's|$SHAREDIR/tools_json|internal_tools_json|g' | \
sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g' | \ sed -e 's|DISTRVENDOR=$PROGDIR/distr_info|DISTRVENDOR=internal_distr_info|g' | \
sed -e "s|@VERSION@|$(get_version)|g" sed -e "s|@VERSION@|$(get_version)|g"
...@@ -64,6 +65,7 @@ done | filter_out >>$OUTPUT ...@@ -64,6 +65,7 @@ done | filter_out >>$OUTPUT
incorporate_subfile distr_info incorporate_subfile distr_info
incorporate_subfile tools_eget incorporate_subfile tools_eget
incorporate_subfile tools_json
awk 'BEGIN{desk=0}{if(desk>0) {print} ; if(/^load_helper epm-sh-functions/){desk++}}' <bin/$PACKCOMMAND | filter_out >>$OUTPUT awk 'BEGIN{desk=0}{if(desk>0) {print} ; if(/^load_helper epm-sh-functions/){desk++}}' <bin/$PACKCOMMAND | filter_out >>$OUTPUT
chmod 0755 $OUTPUT chmod 0755 $OUTPUT
......
...@@ -159,6 +159,13 @@ sudocmd_foreach() ...@@ -159,6 +159,13 @@ sudocmd_foreach()
done done
} }
if ! which realpath 2>/dev/null >/dev/null ; then
realpath()
{
readlink -f "$@"
}
fi
get_firstarg() get_firstarg()
{ {
echon "$1" echon "$1"
...@@ -444,14 +451,14 @@ case $DISTRNAME in ...@@ -444,14 +451,14 @@ case $DISTRNAME in
ArchLinux) ArchLinux)
CMD="pacman" CMD="pacman"
;; ;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux)
CMD="yum-rpm" CMD="yum-rpm"
which dnf 2>/dev/null >/dev/null && test -d /var/lib/dnf/yumdb && CMD=dnf-rpm which dnf 2>/dev/null >/dev/null && test -d /var/lib/dnf/yumdb && CMD=dnf-rpm
;; ;;
Slackware) Slackware)
CMD="slackpkg" CMD="slackpkg"
;; ;;
SUSE|SLED|SLES) SUSE|SLED|SLES|Tumbleweed)
CMD="zypper-rpm" CMD="zypper-rpm"
;; ;;
ForesightLinux|rPathLinux) ForesightLinux|rPathLinux)
...@@ -500,8 +507,9 @@ is_active_systemd() ...@@ -500,8 +507,9 @@ is_active_systemd()
[ -x "$SYSTEMCTL" ] || return [ -x "$SYSTEMCTL" ] || return
[ -d "$SYSTEMD_CGROUP_DIR" ] || return [ -d "$SYSTEMD_CGROUP_DIR" ] || return
a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
readlink /sbin/init | grep -q 'systemd' || return
# some hack # some hack
ps ax | grep -q '[s]ystemd' >/dev/null ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev'
} }
# File bin/serv-common: # File bin/serv-common:
...@@ -1056,7 +1064,7 @@ pkgtype() ...@@ -1056,7 +1064,7 @@ pkgtype()
debian|ubuntu|mint|runtu|mcst|astra) echo "deb" ;; debian|ubuntu|mint|runtu|mcst|astra) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles) alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;; echo "rpm" ;;
fedora|redhat|scientific|centos|rhel) fedora|redhat|scientific|centos|rhel|goslinux)
echo "rpm" ;; echo "rpm" ;;
*) echo "rpm" ;; *) echo "rpm" ;;
esac esac
...@@ -1064,8 +1072,8 @@ pkgtype() ...@@ -1064,8 +1072,8 @@ pkgtype()
get_var() get_var()
{ {
grep -i "^$1 *=" | head -n 1 | sed -e "s/^[^=]*[ \t]*=[ \t]*//" # get first variable and print it out, drop quotes if exists
grep -i "^$1 *=" | head -n 1 | sed -e "s/^[^=]*[ \t]*=[ \t]*//" | sed -e "s/^[\'\"]\(.*\)[\'\"]/\1/"
} }
# 2010.1 -> 2010 # 2010.1 -> 2010
...@@ -1092,6 +1100,7 @@ if distro altlinux-release ; then ...@@ -1092,6 +1100,7 @@ if distro altlinux-release ; then
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus" if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7" elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8" elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6" elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7" elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8" elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
...@@ -1236,6 +1245,8 @@ elif distro redhat-release ; then ...@@ -1236,6 +1245,8 @@ elif distro redhat-release ; then
DISTRIB_ID="CentOS" DISTRIB_ID="CentOS"
elif has Scientific ; then elif has Scientific ; then
DISTRIB_ID="Scientific" DISTRIB_ID="Scientific"
elif has GosLinux ; then
DISTRIB_ID="GosLinux"
fi fi
if has Beryllium ; then if has Beryllium ; then
DISTRIB_ID="Scientific" DISTRIB_ID="Scientific"
...@@ -1293,7 +1304,13 @@ elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then ...@@ -1293,7 +1304,13 @@ elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then
# try use standart LSB info by default # try use standart LSB info by default
elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# use LSB # use LSB
true
# fix distro name
case "$DISTRIB_ID" in
"openSUSE Tumbleweed")
DISTRIB_ID="Tumbleweed"
;;
esac
fi fi
case $1 in case $1 in
...@@ -1335,7 +1352,7 @@ case $1 in ...@@ -1335,7 +1352,7 @@ case $1 in
exit 0 exit 0
;; ;;
-V) -V)
echo "20160822" echo "20161212"
exit 0 exit 0
;; ;;
*) *)
...@@ -1391,7 +1408,7 @@ fi ...@@ -1391,7 +1408,7 @@ fi
# If ftp protocol or have no asterisk, just download # If ftp protocol or have no asterisk, just download
# TODO: use has() # TODO: use has()
if echo "$1" | grep -q "\(^ftp://\|[^*]$\)" ; then if echo "$1" | grep -q "\(^ftp://\|[^*]\)" ; then
$WGET $WGET_OPTION_TARGET "$1" $WGET $WGET_OPTION_TARGET "$1"
return return
fi fi
...@@ -1439,6 +1456,220 @@ download_files || echo "There was some download errors" >&2 ...@@ -1439,6 +1456,220 @@ download_files || echo "There was some download errors" >&2
rm -rf "$MYTMPDIR" rm -rf "$MYTMPDIR"
} }
internal_tools_json()
{
# License: MIT or Apache
# Homepage: http://github.com/dominictarr/JSON.sh
throw() {
echo "$*" >&2
exit 1
}
BRIEF=0
LEAFONLY=0
PRUNE=0
NO_HEAD=0
NORMALIZE_SOLIDUS=0
usage() {
echo
echo "Usage: JSON.sh [-b] [-l] [-p] [-s] [-h]"
echo
echo "-p - Prune empty. Exclude fields with empty values."
echo "-l - Leaf only. Only show leaf nodes, which stops data duplication."
echo "-b - Brief. Combines 'Leaf only' and 'Prune empty' options."
echo "-n - No-head. Do not show nodes that have no path (lines that start with [])."
echo "-s - Remove escaping of the solidus symbol (straight slash)."
echo "-h - This help text."
echo
}
parse_options() {
set -- "$@"
local ARGN=$#
while [ "$ARGN" -ne 0 ]
do
case $1 in
-h) usage
exit 0
;;
-b) BRIEF=1
LEAFONLY=1
PRUNE=1
;;
-l) LEAFONLY=1
;;
-p) PRUNE=1
;;
-n) NO_HEAD=1
;;
-s) NORMALIZE_SOLIDUS=1
;;
?*) echo "ERROR: Unknown option."
usage
exit 0
;;
esac
shift 1
ARGN=$((ARGN-1))
done
}
awk_egrep () {
local pattern_string=$1
gawk '{
while ($0) {
start=match($0, pattern);
token=substr($0, start, RLENGTH);
print token;
$0=substr($0, start+RLENGTH);
}
}' pattern="$pattern_string"
}
tokenize () {
local GREP
local ESCAPE
local CHAR
if echo "test string" | egrep -ao --color=never "test" >/dev/null 2>&1
then
GREP='egrep -ao --color=never'
else
GREP='egrep -ao'
fi
if echo "test string" | egrep -o "test" >/dev/null 2>&1
then
ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
CHAR='[^[:cntrl:]"\\]'
else
GREP=awk_egrep
ESCAPE='(\\\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
CHAR='[^[:cntrl:]"\\\\]'
fi
local STRING="\"$CHAR*($ESCAPE$CHAR*)*\""
local NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?'
local KEYWORD='null|false|true'
local SPACE='[[:space:]]+'
# Force zsh to expand $A into multiple words
local is_wordsplit_disabled=$(unsetopt 2>/dev/null | grep -c '^shwordsplit$')
if [ $is_wordsplit_disabled != 0 ]; then setopt shwordsplit; fi
$GREP "$STRING|$NUMBER|$KEYWORD|$SPACE|." | egrep -v "^$SPACE$"
if [ $is_wordsplit_disabled != 0 ]; then unsetopt shwordsplit; fi
}
parse_array () {
local index=0
local ary=''
read -r token
case "$token" in
']') ;;
*)
while :
do
parse_value "$1" "$index"
index=$((index+1))
ary="$ary""$value"
read -r token
case "$token" in
']') break ;;
',') ary="$ary," ;;
*) throw "EXPECTED , or ] GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
[ "$BRIEF" -eq 0 ] && value=$(printf '[%s]' "$ary") || value=
:
}
parse_object () {
local key
local obj=''
read -r token
case "$token" in
'}') ;;
*)
while :
do
case "$token" in
'"'*'"') key=$token ;;
*) throw "EXPECTED string GOT ${token:-EOF}" ;;
esac
read -r token
case "$token" in
':') ;;
*) throw "EXPECTED : GOT ${token:-EOF}" ;;
esac
read -r token
parse_value "$1" "$key"
obj="$obj$key:$value"
read -r token
case "$token" in
'}') break ;;
',') obj="$obj," ;;
*) throw "EXPECTED , or } GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
[ "$BRIEF" -eq 0 ] && value=$(printf '{%s}' "$obj") || value=
:
}
parse_value () {
local jpath="${1:+$1,}$2" isleaf=0 isempty=0 print=0
case "$token" in
'{') parse_object "$jpath" ;;
'[') parse_array "$jpath" ;;
# At this point, the only valid single-character tokens are digits.
''|[!0-9]) throw "EXPECTED value GOT ${token:-EOF}" ;;
*) value=$token
# if asked, replace solidus ("\/") in json strings with normalized value: "/"
[ "$NORMALIZE_SOLIDUS" -eq 1 ] && value=$(echo "$value" | sed 's#\\/#/#g')
isleaf=1
[ "$value" = '""' ] && isempty=1
;;
esac
[ "$value" = '' ] && return
[ "$NO_HEAD" -eq 1 ] && [ -z "$jpath" ] && return
[ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 0 ] && print=1
[ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && [ $PRUNE -eq 0 ] && print=1
[ "$LEAFONLY" -eq 0 ] && [ "$PRUNE" -eq 1 ] && [ "$isempty" -eq 0 ] && print=1
[ "$LEAFONLY" -eq 1 ] && [ "$isleaf" -eq 1 ] && \
[ $PRUNE -eq 1 ] && [ $isempty -eq 0 ] && print=1
[ "$print" -eq 1 ] && printf "[%s]\t%s\n" "$jpath" "$value"
:
}
parse () {
read -r token
parse_value
read -r token
case "$token" in
'') ;;
*) throw "EXPECTED EOF GOT $token" ;;
esac
}
if ([ "$0" = "$BASH_SOURCE" ] || ! [ -n "$BASH_SOURCE" ]);
then
parse_options "$@"
tokenize | parse
fi
# vi: expandtab sw=2 ts=2
}
INITDIR=/etc/init.d INITDIR=/etc/init.d
PATH=$PATH:/sbin:/usr/sbin PATH=$PATH:/sbin:/usr/sbin
...@@ -1465,7 +1696,7 @@ case $DISTRNAME in ...@@ -1465,7 +1696,7 @@ case $DISTRNAME in
ALTLinux) ALTLinux)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
Ubuntu|Debian|Mint) Ubuntu|Debian|Mint|AstraLinux)
CMD="service-update" CMD="service-update"
;; ;;
Mandriva|ROSA) Mandriva|ROSA)
...@@ -1480,7 +1711,7 @@ case $DISTRNAME in ...@@ -1480,7 +1711,7 @@ case $DISTRNAME in
# ArchLinux) # ArchLinux)
# CMD="pacman" # CMD="pacman"
# ;; # ;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
VoidLinux) VoidLinux)
...@@ -1489,7 +1720,7 @@ case $DISTRNAME in ...@@ -1489,7 +1720,7 @@ case $DISTRNAME in
Slackware) Slackware)
CMD="service-initd" CMD="service-initd"
;; ;;
SUSE|SLED|SLES) SUSE|SLED|SLES|Tumbleweed)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
# Windows) # Windows)
...@@ -1536,7 +1767,7 @@ $(get_help HELPOPT) ...@@ -1536,7 +1767,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.9.6" echo "Service manager version 2.0.5"
echo "Running on $($DISTRVENDOR) with $SERVICETYPE" echo "Running on $($DISTRVENDOR) with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012, 2013, 2016" echo "Copyright (c) Etersoft 2012, 2013, 2016"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
LSB_VERSION="core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64"
DISTRIB_ID="openSUSE Tumbleweed"
DISTRIB_RELEASE="20161014"
DISTRIB_CODENAME=""
DISTRIB_DESCRIPTION="openSUSE Tumbleweed"
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