Commit a6cbbc81 authored by Vitaly Lipatov's avatar Vitaly Lipatov

backported to p8 as 1.9.9-alt0.M80P.1 (with rpmbph script)

parents 537524b7 816228f8
/etc/eepm.conf конфиг /etc/eepm.conf конфиг
<<<<<<< HEAD
FIXME: epm-install need realpath, missed on some systems FIXME: epm-install need realpath, missed on some systems
Lock a Specific Package Lock a Specific Package
...@@ -8,6 +9,8 @@ Remove Lock from a Package ...@@ -8,6 +9,8 @@ Remove Lock from a Package
# zypper rl ypbind # zypper rl ypbind
=======
>>>>>>> heads/master
[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
[18:23:40] <danil> > Ты знаешь способы? [18:23:40] <danil> > Ты знаешь способы?
......
...@@ -298,7 +298,11 @@ elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then ...@@ -298,7 +298,11 @@ 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 case "$DISTRIB_ID" in
"openSUSE Tumbleweed")
DISTRIB_ID="Tumbleweed"
;;
esac
fi fi
case $1 in case $1 in
......
...@@ -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=
...@@ -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"
......
...@@ -19,12 +19,41 @@ ...@@ -19,12 +19,41 @@
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
;;
esac
assure_exists apt-repo assure_exists apt-repo
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,11 +17,36 @@ ...@@ -17,11 +17,36 @@
# 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"
...@@ -34,28 +59,34 @@ __epm_autoremove_altrpm() ...@@ -34,28 +59,34 @@ __epm_autoremove_altrpm()
# 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 -- "$libexclude" \
| grep -E -v -- "-(devel|debuginfo)$" \ | 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" \ | sed -e "s/\.32bit$//g" \
| grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|eepm)" ) | grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|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()
{ {
......
...@@ -19,11 +19,17 @@ ...@@ -19,11 +19,17 @@
__use_url_install() __use_url_install()
{ {
case $PMTYPE in case $DISTRNAME in
apt-rpm) "ALTLinux")
# ALT Linux really?
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,7 +60,7 @@ __download_pkg_urls() ...@@ -54,7 +60,7 @@ __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
...@@ -70,8 +76,8 @@ __handle_pkg_urls_to_install() ...@@ -70,8 +76,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 +104,37 @@ __handle_pkg_urls_to_checking() ...@@ -98,11 +104,37 @@ __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)
# 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
......
...@@ -323,6 +323,23 @@ __epm_check_if_try_install_rpm() ...@@ -323,6 +323,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 +531,10 @@ epm_install() ...@@ -514,6 +531,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 +548,7 @@ epm_install() ...@@ -527,7 +548,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
......
...@@ -22,6 +22,7 @@ __alt_local_content_search() ...@@ -22,6 +22,7 @@ __alt_local_content_search()
load_helper epm-sh-altlinux load_helper epm-sh-altlinux
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" #local OUTCMD="less"
#[ -n "$USETTY" ] || OUTCMD="cat" #[ -n "$USETTY" ] || OUTCMD="cat"
......
...@@ -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"
...@@ -466,7 +474,7 @@ case $DISTRNAME in ...@@ -466,7 +474,7 @@ case $DISTRNAME in
Slackware) Slackware)
CMD="slackpkg" CMD="slackpkg"
;; ;;
SUSE|SLED|SLES) SUSE|SLED|SLES|Tumbleweed)
CMD="zypper-rpm" CMD="zypper-rpm"
;; ;;
ForesightLinux|rPathLinux) ForesightLinux|rPathLinux)
......
...@@ -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
......
...@@ -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 p8 automatically by rpmbph script from etersoft-build-utils. # This spec is backported to ALTLinux p8 automatically by rpmbph script from etersoft-build-utils.
# #
Name: eepm Name: eepm
Version: 1.9.8 Version: 1.9.9
Release: alt0.M80P.1 Release: alt0.M80P.1
Summary: Etersoft EPM package manager Summary: Etersoft EPM package manager
...@@ -68,9 +68,18 @@ chmod a+x %buildroot%_datadir/%name/tools_* ...@@ -68,9 +68,18 @@ 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.M80P.1 * Thu Dec 08 2016 Vitaly Lipatov <lav@altlinux.ru> 1.9.9-alt0.M80P.1
- backport to ALTLinux p8 (by rpmbph script) - backport to ALTLinux p8 (by rpmbph script)
* Wed Dec 07 2016 Vitaly Lipatov <lav@altlinux.ru> 1.9.9-alt1
- add realpath realization 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"
...@@ -451,7 +458,7 @@ case $DISTRNAME in ...@@ -451,7 +458,7 @@ case $DISTRNAME in
Slackware) Slackware)
CMD="slackpkg" CMD="slackpkg"
;; ;;
SUSE|SLED|SLES) SUSE|SLED|SLES|Tumbleweed)
CMD="zypper-rpm" CMD="zypper-rpm"
;; ;;
ForesightLinux|rPathLinux) ForesightLinux|rPathLinux)
...@@ -501,7 +508,7 @@ is_active_systemd() ...@@ -501,7 +508,7 @@ is_active_systemd()
[ -d "$SYSTEMD_CGROUP_DIR" ] || return [ -d "$SYSTEMD_CGROUP_DIR" ] || return
a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
# some hack # some hack
ps ax | grep -q '[s]ystemd' >/dev/null ps ax | grep -q '[s]ystemd' | grep -v 'systemd-udev' >/dev/null
} }
# File bin/serv-common: # File bin/serv-common:
...@@ -1293,7 +1300,11 @@ elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then ...@@ -1293,7 +1300,11 @@ 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 case "$DISTRIB_ID" in
"openSUSE Tumbleweed")
DISTRIB_ID="Tumbleweed"
;;
esac
fi fi
case $1 in case $1 in
...@@ -1391,7 +1402,7 @@ fi ...@@ -1391,7 +1402,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 +1450,220 @@ download_files || echo "There was some download errors" >&2 ...@@ -1439,6 +1450,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
...@@ -1489,7 +1714,7 @@ case $DISTRNAME in ...@@ -1489,7 +1714,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 +1761,7 @@ $(get_help HELPOPT) ...@@ -1536,7 +1761,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 1.9.6" echo "Service manager version 1.9.9"
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."
......
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