Commit 7cc72170 authored by Vitaly Lipatov's avatar Vitaly Lipatov

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

parents f79977d3 c2b8ffc0
https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks_(Русский)
systemctl edit юнит
аналог epm purge: запоминаем список файлов, удаляем пакеты и по возможности всё, от чего зависит (рекурсивно).
......@@ -9,12 +11,13 @@ systemctl edit юнит
хочется видеть прямые зависимости, обратные, и рекурсивно.
выводить в цивилизованном виде (в прямом только с --direct)
Синхронизация списков файлов по пакетам:
rsync -av --inplace --progress --compress
Но лучше получать с сервиса
epm sf - скачивание через rsync -z для компактности?
epmqp uuid на x86_64/Ubuntu не различает архитектуру
eon sf - скачивание через rsync -z для компактности?
get system checking
https://github.com/gwicke/mediawiki-containers
......
......@@ -204,7 +204,7 @@ check_command()
provides|prov) # HELPCMD: print package provides
epm_cmd=provides
;;
whatdepends) # HELPCMD: print packages dependences on that
whatdepends|wd|rdepends) # HELPCMD: print packages dependences on that
epm_cmd=whatdepends
;;
whatprovides) # HELPCMD: print packages provides that target
......@@ -274,6 +274,7 @@ check_command()
download) # HELPCMD: download package(s) file to the current dir
epm_cmd=download
;;
# TODO: replace with install --simulate
simulate) # HELPCMD: simulate install with check requires
epm_cmd=simulate
;;
......@@ -286,7 +287,7 @@ check_command()
site|url) # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
epm_cmd=site
;;
ei|epminstall|epm-install|selfinstall) # HELPCMD: install or update eepm package from all in one script
ei|ik|epminstall|epm-install|selfinstall) # HELPCMD: install package(s) from Korinf (eepm by default)
epm_cmd=epm_install
;;
print) # HELPCMD: print various info, run epm print help for details
......@@ -323,7 +324,7 @@ check_option()
--show-command-only) # HELPOPT: show command only, do not any action (supports install and remove ONLY)
show_command_only=1
;;
--quiet) # HELPOPT: quiet mode (do not print commands before exec)
--quiet|--silent) # HELPOPT: quiet mode (do not print commands before exec)
quiet=1
;;
--nodeps) # HELPOPT: skip dependency check (during install/simulate and so on)
......@@ -335,7 +336,7 @@ check_option()
--noremove|--no-remove) # HELPOPT: exit if any packages are to be removed during upgrade
noremove="--no-remove"
;;
--dry-run|--simulate|--just-print|-recon--no-act) # HELPOPT: print only (autoremove/autoorphans only)
--dry-run|--simulate|--just-print|-recon--no-act) # HELPOPT: print only (autoremove/autoorphans/remove only)
dryrun="--dry-run"
;;
--short) # HELPOPT: short output (just 'package' instead 'package-version-release')
......
......@@ -88,10 +88,10 @@ case $PMTYPE in
sudocmd pacman -Qdtq | sudocmd pacman -Rs -
fi
;;
#slackpkg)
slackpkg)
# clean-system removes non official packages
#sudocmd slackpkg clean-system
# ;;
sudocmd slackpkg clean-system
;;
#guix)
# sudocmd guix gc
# ;;
......
......@@ -69,12 +69,12 @@ __epm_autoremove_altrpm_lib()
local force=force
local flag=
local libexclude='^(lib|i586-lib)'
[ -n "$force" ] || libexclude=$libexclude'[^-]*$'
local libgrep='^(lib|i586-lib|bzlib|zlib)'
[ -n "$force" ] || libexclude=$libgrep'[^-]*$'
# https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps
showcmd "apt-cache list-nodeps | grep -- \"$libexclude\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" \
showcmd "apt-cache list-nodeps | grep -E -- \"$libgrep\""
pkgs=$(apt-cache list-nodeps | grep -E -- "$libgrep" \
| sed -e "s/[-\.]32bit$//g" \
| grep -E -v -- "$develrule" \
| grep -E -v -- "-(debuginfo)$" \
......@@ -87,6 +87,13 @@ __epm_autoremove_altrpm_lib()
return 0
fi
# commented, with hi probability user install i586- manually
# workaround against missed i586- handling in apt-cache list-nodeps
if epmqp i586-lib >/dev/null ; then
info "You can try removing i586- with follow command"
showcmd rpm -v -e $(epmqp i586-lib)
fi
[ -n "$pkgs" ] && sudocmd rpm -v -e $pkgs && flag=1
if [ -n "$flag" ] ; then
......
......@@ -58,6 +58,7 @@ case $PMTYPE in
docmd rpm -V $@
;;
*-dpkg)
assure_exists debsums
docmd debsums $@
;;
emerge)
......@@ -98,6 +99,7 @@ epm_checkpkg()
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
#fatal "Broken package $pkg"
return $RETVAL
......
......@@ -64,7 +64,7 @@ case $PMTYPE in
sudocmd urpmi --clean
;;
pacman)
sudocmd pacman -Sc
sudocmd pacman -Sc --noconfirm
;;
zypper-rpm)
sudocmd zypper clean
......
#!/bin/sh
#
# Copyright (C) 2016 Etersoft
# Copyright (C) 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2016-2017 Etersoft
# Copyright (C) 2016-2017 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
......@@ -17,12 +17,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
alt_base_dist_url="http://ftp.basealt.ru/pub/distributions"
__use_url_install()
{
case $DISTRNAME in
"ALTLinux")
# not for https
# do not support https yet
echo "$pkg_urls" | grep -q "https://" && return 1
# force download if wildcard is used
echo "$pkg_urls" | grep -q "[?*]" && return 1
pkg_names="$pkg_names $pkg_urls"
return 0
;;
......@@ -60,16 +64,21 @@ __download_pkg_urls()
local url
[ -z "$pkg_urls" ] && return
for url in $pkg_urls ; do
# TODO: use some individual tmp dir
local new_file=/tmp/$(basename "$url")
if docmd eget -O $new_file $url && [ -s "$new_file" ] ; then
pkg_files="$pkg_files $new_file"
to_remove_pkg_files="$to_remove_pkg_files $new_file"
local tmppkg=$(mktemp -d) || fatal "failed mktemp -d"
cd $tmppkg || fatal
if docmd eget "$url" ; then
local i
for i in $(basename $url) ; do
[ -s "$tmppkg/$i" ] || continue
pkg_files="$pkg_files $tmppkg/$i"
to_remove_pkg_files="$to_remove_pkg_files $tmppkg/$i"
done
else
warning "Failed to download $url, ignoring"
fi
cd - >/dev/null
done
# restore
# reconstruct
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
}
......@@ -121,7 +130,54 @@ __epm_get_altpkg_url()
# 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"
echo "$alt_base_dist_url/$dv/$arch/RPMS.classic/$filename"
}
__epm_print_url_alt()
{
local url="$1"
echo "$url"
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://mirror.yandex.ru/altlinux|g"
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://download.etersoft.ru/pub/ALTLinux|g"
}
__epm_print_url_alt_check()
{
local pkg=$1
shift
local tm=$(mktemp)
epm assure curl
load_helper epm-site
quiet=1
local buildtime=$(paoapi packages/$pkg | get_pao_var buildtime)
echo
echo "Latest release: $(paoapi packages/$pkg | get_pao_var sourcepackage) $buildtime"
__epm_print_url_alt "$1" | while read url ; do
curl -s --head $url >$tm || { echo "$url: missed" ; continue ; }
local http=$(cat $tm | grep "^HTTP" | sed -e "s|\r||g")
local lastdate=$(cat $tm | grep "^Last-Modified:" | sed -e "s|\r||g")
local size=$(cat $tm | grep "^Content-Length:" | sed -e "s|^Content-Length: ||g" | sed -e "s|\r||g")
echo "$url ($http $lastdate) Size: $size"
done
rm -f $tm
}
__epm_download_alt()
{
local pkg
if [ "$1" = "--check" ] ; then
local checkflag="$1"
shift
fi
for pkg in "$@" ; do
local url=$(__epm_get_altpkg_url $pkg)
[ -n "$url" ] || warning "Can't get URL for $pkg"
if [ -n "$checkflag" ] ; then
__epm_print_url_alt_check "$pkg" "$url"
else
docmd eget $url || return
fi
done
}
epm_download()
......@@ -130,12 +186,7 @@ epm_download()
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
__epm_download_alt $pkg_filenames
return
;;
esac
......
......@@ -20,11 +20,46 @@
load_helper epm-install
epm_epm_install(){
assure_exists wget
local etersoft_updates_site="http://updates.etersoft.ru/pub/Korinf/$($DISTRVENDOR -e)"
# FIXME: some way to get latest package
local download_link=$etersoft_updates_site/$(wget -qO- $etersoft_updates_site/ | grep -m1 -Eo "eepm[^\"]+\.$($DISTRVENDOR -p)" | tail -n1) #"
__epm_korinf_site() {
local archprefix=""
[ "$($DISTRVENDOR -b)" = "64" ] && archprefix="x86_64/"
local aftername="-"
[ "$($DISTRVENDOR -p)" = "deb" ] && aftername="_"
echo "http://updates.etersoft.ru/pub/Korinf/$archprefix$($DISTRVENDOR -e)"
}
__epm_korinf_list() {
[ "$1" = "--list" ] && shift
local MASK="$1"
showcmd eget --list "$(__epm_korinf_site)/$MASK*.$($DISTRVENDOR -p)"
eget --list "$(__epm_korinf_site)/$MASK*.$($DISTRVENDOR -p)" | sort
}
__epm_korinf_install(){
local PACKAGE="$1"
# FIXME: some way to get latest package
local fn="$(__epm_korinf_list $PACKAGE$aftername | tail -n1)"
[ -n "$fn" ] || fatal "Can't find package file for $PACKAGE"
local download_link=$(__epm_korinf_site)/$fn
#info "Install $download_link ..."
pkg_names='' pkg_files='' pkg_urls="$download_link" epm_install
}
epm_epm_install(){
local i
local pkglist="$pkg_filenames"
# install epm by default
[ -n "$pkglist" ] || pkglist="eepm"
case "$pkglist" in
--list*)
__epm_korinf_list $pkglist
return
;;
esac
for i in $pkglist ; do
__epm_korinf_install $i
done
}
......@@ -150,6 +150,7 @@ local RETVAL=$?
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
return $RETVAL
}
......@@ -478,7 +478,9 @@ epm_install_files()
epm_print_install_command()
{
[ -z "$1" ] && return
# print out low level command by default (wait --low-level for control it)
#[ -z "$1" ] && return
[ -z "$1" ] && [ -n "$pkg_names" ] && return
case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $*"
......@@ -533,6 +535,8 @@ epm_print_install_command()
epm_print_install_names_command()
{
# check for pkg_files to support print out command without pkg names in args
#[ -z "$1" ] && [ -n "$pkg_files" ] && return
[ -z "$1" ] && return
case $PMTYPE in
apt-rpm|apt-dpkg)
......@@ -619,6 +623,7 @@ epm_install()
# TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
return $RETVAL
}
......@@ -178,11 +178,11 @@ epm_query_file()
[ -n "$pkg_filenames" ] || fatal "Run query without file names"
load_helper epm-search_file
#load_helper epm-search_file
for pkg in $pkg_filenames ; do
__do_query_real_file "$pkg"
__do_query "$FULLFILEPATH" || pkg_filenames="$FULLFILEPATH" epm_search_file
__do_query "$FULLFILEPATH" || info "Try epm sf for search file in all packages in repository" #|| pkg_filenames="$FULLFILEPATH" epm_search_file
done
}
......@@ -77,14 +77,57 @@ __alt_repofix()
load_helper epm-repofix
showcmd epm repofix
quiet=1 pkg_filenames='' epm_repofix >/dev/null
__replace_text_in_alt_repo "/^ *#/! s!\[[tp][6-9]\]![updates]!g"
__replace_text_in_alt_repo "/^ *#/! s!\[[tpc][6-9]\]![updates]!g"
}
__get_conflict_release_pkg()
{
epmqf --quiet --short /etc/fedora-release | head -n1
}
get_fix_release_pkg()
{
# TODO: check for version incompatibilities
if epmqf /etc/altlinux-release | grep -q sisyphus ; then
echo altlinux-release-$1
local TOINSTALL=''
local FORCE=''
if [ "$1" == "--force" ] ; then
FORCE="$1"
shift
fi
local TO="$1"
echo "rpm apt"
if [ "$TO" = "Sisyphus" ] ; then
TO="sisyphus"
echo "apt-conf-$TO"
else
echo "apt-conf-branch"
fi
if [ "$FORCE" == "--force" ] ; then
# assure we have set needed release
TOINSTALL="altlinux-release-$TO"
else
# just assure we have /etc/altlinux-release and switched from sisyphus
if [ ! -s /etc/altlinux-release ] || epmqf /etc/altlinux-release | grep -q sisyphus ; then
TOINSTALL="altlinux-release-$TO"
fi
fi
# workaround against obsoleted altlinux-release-sisyphus package from 2008 year
[ "$TOINSTALL" = "altlinux-release-sisyphus" ] && TOINSTALL="branding-alt-sisyphus-release"
if [ -n "$TOINSTALL" ] ; then
echo "$TOINSTALL"
# workaround against
# file /etc/fedora-release from install of altlinux-release-p8-20160414-alt1 conflicts with file from package branding-simply-linux-release-8.2.0-alt1
# problem
if __get_conflict_release_pkg | grep -q -v "^altlinux-release" && [ "$TOINSTALL" != "$(__get_conflict_release_pkg)" ] ; then
echo $(__get_conflict_release_pkg)-
fi
fi
}
......@@ -95,7 +138,7 @@ __update_to_the_distro()
case "$TO" in
p7)
docmd epm update || fatal
docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
docmd epm install "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal
......@@ -103,14 +146,11 @@ __update_to_the_distro()
;;
p8)
docmd epm update || fatal
if ! docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" ; then
# Hack for error: execution of %post scriptlet from glibc-core-2.23-alt1.eter1
docmd rpm -ev glibc-core-2.17 || fatal "Check an error and run epm release-upgrade again"
docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
fi
docmd epm install "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal
# sure we have systemd if systemd is running
if is_installed systemd && is_active_systemd systemd ; then
docmd epm install systemd || fatal
fi
......@@ -118,33 +158,35 @@ __update_to_the_distro()
;;
Sisyphus)
docmd epm update || fatal
docmd epm install apt rpm librpm7 librpm apt-conf-sisyphus altlinux-release-sisyphus || fatal "Check an error and run again"
docmd epm install librpm7 librpm "$(get_fix_release_pkg --force "$TO")" || fatal "Check an error and run again"
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;;
*)
esac
}
__update_alt_to_next_distro()
{
local TO=""
local TO="$2"
local FROM="$1"
[ -n "$TO" ] || TO="$FROM"
info
case "$*" in
"p6"|"p6 p7"|"t6 p7")
"p6"|"p6 p7"|"t6 p7"|"c6 c7")
TO="p7"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "$FROM/branch/" "$TO/branch/"
__update_to_the_distro "$TO"
docmd epm update-kernel
info "Done."
info "Run epm release-upgrade again for update to p8"
;;
"p7"|"p7 p8"|"t7 p8")
"p7"|"p7 p8"|"t7 p8"|"c7 c8"|"p8 p8")
TO="p8"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch "$(get_fix_release_pkg "$FROM")" || fatal
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo $FROM/branch/ $TO/branch/
__update_to_the_distro $TO
docmd epm update-kernel || fatal
......@@ -153,17 +195,17 @@ __update_alt_to_next_distro()
"Sisyphus p8")
TO="p8"
info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
__replace_alt_version_in_repo "$FROM/" "$FROM/branch/"
__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__update_to_the_distro $TO
docmd epm downgrade || fatal
info "Done."
;;
"p8 Sisyphus")
"p8 Sisyphus"|"Sisyphus Sisyphus")
TO="Sisyphus"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal
docmd epm install "$(get_fix_release_pkg "$FROM")" || fatal
docmd epm upgrade || fatal
__replace_alt_version_in_repo "$FROM/branch/" "$TO/"
__alt_repofix
......@@ -173,7 +215,11 @@ __update_alt_to_next_distro()
info "Done."
;;
*)
warning "Have no idea how to update from $DISTRNAME $FROM to $DISTRNAME $TO."
if [ "$FROM" = "$TO" ] ; then
info "It seems your system is already updated to newest $DISTRNAME $TO"
else
warning "Have no idea how to update from $DISTRNAME $FROM to $DISTRNAME $TO."
fi
info "Try run f.i. # epm release-upgrade p8 or # epm release-upgrade Sisyphus"
info "Also possible you need install altlinux-release-p? package for correct distro version detecting"
return 1
......@@ -186,10 +232,12 @@ epm_release_upgrade()
info "Starting upgrade whole system to the next release"
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
# TODO: it is possible eatmydata does not do his work
export EPMNOEATMYDATA=1
case $DISTRNAME in
ALTLinux)
docmd epm update
docmd epm install apt rpm
# try to detect current release by repo
if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then
......@@ -208,6 +256,7 @@ epm_release_upgrade()
[ "$(__wcount $pkg_filenames)" = "1" ] || fatal "Too many args: $pkg_filenames"
fi
# TODO: ask before upgrade
__update_alt_to_next_distro $DISTRVERSION $pkg_filenames
return
;;
......
......@@ -64,13 +64,13 @@ epm_remove_names()
case $PMTYPE in
apt-dpkg)
sudocmd apt-get remove --purge $@
sudocmd apt-get remove --purge $APTOPTIONS $@
return ;;
aptitude-dpkg)
sudocmd aptitude purge $@
return ;;
apt-rpm)
sudocmd apt-get remove $@
sudocmd apt-get remove $APTOPTIONS $@
return ;;
deepsolver-rpm)
sudocmd ds-remove $@
......@@ -255,11 +255,20 @@ epm_remove()
if [ -n "$dryrun" ] ; then
info "Packages for removing:"
echo "$pkg_names"
return
case $PMTYPE in
apt-rpm)
nodeps="--test"
APTOPTIONS="--simulate"
;;
*)
return
;;
esac
fi
epm_remove_low $pkg_names && return
local STATUS=$?
# TODO: check if we need continue with hi level
if [ -n "$direct" ] ; then
return $STATUS
......
......@@ -49,7 +49,7 @@ __try_fix_apt_source_list()
__fix_apt_sources_list()
{
# for beauty spaces
local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p8[/ ]branch|p7[/ ]branch|t7[/ ]branch|c7[/ ]branch|p6[/ ]branch|t6[/ ]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|t7[/ ]branch|c7[/ ]branch|p6[/ ]branch|t6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local i
assure_root
for i in "$@" ; do
......
......@@ -118,6 +118,7 @@ get_local_alt_contents_index()
tasknumber()
{
local num="${*/\#/}"
local num="$(echo "$*" | sed -e "s| *#*||g")"
isnumber "$num" && echo "$num"
}
......@@ -137,7 +137,7 @@ docmd_foreach()
# Print command line and run command line with SUDO
sudocmd()
{
showcmd "$SUDO $*"
[ -n "$SUDO" ] && showcmd "$SUDO $*" || showcmd "$*"
$SUDO $@
}
......@@ -311,7 +311,7 @@ set_eatmydata()
[ -n "$EPMNOEATMYDATA" ] && return
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata"
[ -n "$SUDO" ] && SUDO="$SUDO eatmydata" || SUDO="eatmydata"
[ -n "$verbose" ] && info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
return 0
}
......@@ -367,10 +367,26 @@ assure_exists()
__epm_assure "$1" $package $3 || fatal "Can't assure in '$1' command from $package$textpackage package"
}
# will replaced within disabled_eget in packaged version
eget()
{
# use internal eget only if exists
if [ -s $SHAREDIR/tools_eget ] ; then
$SHAREDIR/tools_eget "$@"
return
fi
assure_exists eget
# run external command, not the function
EGET=$(which eget) || fatal "Missed command eget from installed package eget"
$EGET "$@"
}
# will replaced within eget() in packed version
onefile_eget()
{
assure_exists wget
$SHAREDIR/tools_eget "$@"
internal_tools_eget "$@"
}
# TODO: improve and drop!
......
......@@ -31,7 +31,9 @@ epm_whatdepends()
# by package name
case $PMTYPE in
apt-rpm)
CMD="apt-cache whatdepends"
#CMD="apt-cache whatdepends"
# more quiet
CMD="apt-cache rdepends"
;;
apt-dpkg|aptitude-dpkg)
CMD="apt-cache rdepends"
......
#!/bin/sh
# eget - simply shell on wget for loading directories over http
# eget - simply shell on wget for loading directories over http (wget does not support wildcard for http)
# Example use:
# eget ftp://ftp.altlinux.ru/pub/security/ssl/*
# eget http://ftp.altlinux.ru/pub/security/ssl/*
#
# Copyright (C) 2014-2014, 2016 Etersoft
# Copyright (C) 2014 Daniil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2016-2017 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
......@@ -23,12 +23,31 @@
WGET="wget"
# TODO: passthrou all wget options
if [ "$1" = "-q" ] ; then
WGET="wget -q"
shift
fi
# TODO:
if [ "$1" = "--list" ] ; then
LISTONLY="$1"
shift
fi
fatal()
{
echo "$*" >&2
exit 1
}
# check man glob
filter_glob()
{
# translate glob to regexp
grep "^$(echo "$1" | sed -e "s|\*|.*|g" -e "s|\?|.|g")$"
}
# download to this file
WGET_OPTION_TARGET=
if [ "$1" = "-O" ] ; then
......@@ -40,51 +59,56 @@ fi
# TODO:
# -P support
# If ftp protocol or have no asterisk, just download
# TODO: use has()
if echo "$1" | grep -q "\(^ftp://\|[^*]\)" ; then
if [ -z "$1" ] ; then
echo "eget - wget wrapper" >&2
fatal "Run with URL, like http://somesite.ru/dir/*.log"
fi
# do not support /
if echo "$1" | grep -q "/$" ; then
fatal "Use http://example.com/e/* to download all files in dir"
fi
# If ftp protocol, just download
if echo "$1" | grep -q "^ftp://" ; then
[ -n "$LISTONLY" ] && fatal "Error: list files for ftp:// do not supported yet"
$WGET $WGET_OPTION_TARGET "$1"
exit
fi
echo "Fall to http workaround"
# drop mask part
URL="$(dirname "$1")/"
if echo "$URL" | grep -q "[*?]" ; then
fatal "Error: there are globbing symbols (*?) in $URL"
fi
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
}
# If have no wildcard symbol like asterisk, just download
if echo "$MASK" | grep -qv "[*?]" ; then
$WGET $WGET_OPTION_TARGET "$1"
exit
fi
print_files()
get_urls()
{
cat $INDEX | grep -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2
$WGET -O- $URL | \
grep -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2
}
create_fake_files()
{
DIRALLFILES="$MYTMPDIR/files/"
mkdir -p "$DIRALLFILES"
print_files | while read -r line ; do
touch $DIRALLFILES/$(basename "$line")
if [ -n "$LISTONLY" ] ; then
WGET="$WGET -q"
for fn in $(get_urls | filter_glob "$MASK") ; do
echo "$(basename "$fn")"
done
}
exit
fi
download_files()
{
ERROR=0
for line in $DIRALLFILES/$MASK ; do
$WGET $URL/$(basename "$line") || ERROR=1
done
return $ERROR
}
ERROR=0
for fn in $(get_urls | filter_glob "$MASK") ; do
$WGET "$URL/$(basename "$fn")" || ERROR=1
done
exit $ERROR
get_index || exit
create_fake_files
download_files || echo "There was some download errors" >&2
rm -rf "$MYTMPDIR"
......@@ -12,6 +12,7 @@ EXCL="$EXCL,SC2154,SC2002"
if [ -n "$1" ] ; then
shellcheck $EXCL "$1"
checkbashisms -f "$1"
exit
fi
......
# This spec is backported to ALTLinux p8 automatically by rpmbph script from etersoft-build-utils.
#
Name: eepm
Version: 2.1.8
Version: 2.3.1
Release: alt0.M80P.1
Summary: Etersoft EPM package manager
......@@ -43,8 +43,8 @@ See detailed description here: http://wiki.etersoft.ru/EPM
# install to datadir and so on
# do not use uncommon makeinstall_std here
%make_install install DESTDIR=%buildroot datadir=%_datadir bindir=%_bindir mandir=%_mandir version=%version-%release
install -m 0755 packed/epm.sh %buildroot/%_datadir/%name/epm-packed.sh
install -m 0755 packed/serv.sh %buildroot/%_datadir/%name/serv-packed.sh
#install -m 0755 packed/epm.sh %buildroot/%_datadir/%name/epm-packed.sh
#install -m 0755 packed/serv.sh %buildroot/%_datadir/%name/serv-packed.sh
mkdir -p %buildroot%_sysconfdir/bash_completion.d/
install -m 0644 bash_completion/serv %buildroot%_sysconfdir/bash_completion.d/serv
......@@ -54,6 +54,11 @@ ln -s serv %buildroot%_sysconfdir/bash_completion.d/cerv
chmod a+x %buildroot%_datadir/%name/{serv-,epm-}*
chmod a+x %buildroot%_datadir/%name/tools_*
%if %_vendor == "alt"
# use external eget
rm -f %buildroot%_datadir/%name/tools_eget
%endif
%files
%doc README TODO LICENSE
%_bindir/epm*
......@@ -68,9 +73,35 @@ chmod a+x %buildroot%_datadir/%name/tools_*
%_sysconfdir/bash_completion.d/cerv
%changelog
* Thu Nov 02 2017 Vitaly Lipatov <lav@altlinux.ru> 2.1.8-alt0.M80P.1
* Sun Nov 19 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.1-alt0.M80P.1
- backport to ALTLinux p8 (by rpmbph script)
* Sun Nov 19 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.1-alt1
- epm whatdepends: use rdepends
- repofix: fix signing when we have /
- query_file: only inform about epm sf using
- allow ei/ik install any package(s) from Korinf
- ei/ik: add support for --list [mask], install via eget
* Sun Nov 12 2017 Vitaly Lipatov <lav@altlinux.ru> 2.3.0-alt2
- epm: rewrite release_upgrade for ALT
- autoremove: small improvement
- remove: add support dry mode for rpm/apt
* Sat Nov 11 2017 Vitaly Lipatov <lav@altlinux.ru> 2.2.0-alt1
- use external eget on ALT
- disable one file version packing
- update internal eget to 2.0
* Fri Nov 10 2017 Vitaly Lipatov <lav@altlinux.ru> 2.1.10-alt1
- install: print low level install command if args is empty
- epm: add wd alias for whatdepends
- epm-clean: add --noconfirm for pacman
- fix and text install via url with wildcard
* Wed Nov 08 2017 Vitaly Lipatov <lav@altlinux.ru> 2.1.9-alt1
- tasknumber: fix bashism
* Thu Nov 02 2017 Vitaly Lipatov <lav@altlinux.ru> 2.1.8-alt1
- epm addrepo: use http for ALT archive, add date format checking
- ep-seach: use ~ for negate and ^ for a begin of line in __epm_search_make_grep
......
......@@ -2,8 +2,8 @@
#
# Run for create one-file-scripts
#
# Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016, 2017 Etersoft
# Copyright (C) 2012, 2016, 2017 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
......@@ -24,14 +24,17 @@ incorporate_subfile()
{
cat <<EOF >>$OUTPUT
internal_$1()
################# incorporate $1 #################
internal_$(basename $1)()
{
EOF
cat bin/$1 | grep -v "^#!/bin/sh" | sed -e "s| exit$| return|g" >>$OUTPUT
cat $1 | grep -v "^#!/bin/sh" | sed -e "s| exit$| return|g" >>$OUTPUT
cat <<EOF >>$OUTPUT
}
################# end of incorporated $1 #################
EOF
}
......@@ -43,7 +46,8 @@ get_version()
filter_out()
{
grep -v "^[ ]*load_helper " | \
sed -e 's|$SHAREDIR/tools_eget|internal_tools_eget|g' | \
sed -e 's|^eget()|disabled_eget()|g' | \
sed -e 's|^onefile_eget()|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|@VERSION@|$(get_version)|g"
......@@ -63,9 +67,10 @@ for i in bin/epm-sh-functions $(ls -1 bin/$PACKCOMMAND-* | grep -v epm-sh-functi
cat $i | grep -v "^#"
done | filter_out >>$OUTPUT
incorporate_subfile distr_info
incorporate_subfile tools_eget
incorporate_subfile tools_json
incorporate_subfile bin/distr_info
#incorporate_subfile /usr/bin/eget
incorporate_subfile bin/tools_eget
incorporate_subfile bin/tools_json
awk 'BEGIN{desk=0}{if(desk>0) {print} ; if(/^load_helper epm-sh-functions/){desk++}}' <bin/$PACKCOMMAND | filter_out >>$OUTPUT
chmod 0755 $OUTPUT
......
......@@ -144,7 +144,7 @@ docmd_foreach()
sudocmd()
{
showcmd "$SUDO $*"
[ -n "$SUDO" ] && showcmd "$SUDO $*" || showcmd "$*"
$SUDO $@
}
......@@ -178,6 +178,11 @@ get_lastarg()
echon "$lastarg"
}
isnumber()
{
echo "$*" | filter_strip_spaces | grep -q "^[0-9]\+$"
}
filter_strip_spaces()
{
# possible use just
......@@ -285,12 +290,12 @@ withtimeout()
{
local TO=$(which timeout 2>/dev/null || which gtimeout 2>/dev/null)
if [ -x "$TO" ] ; then
$TO $@
$TO "$@"
return
fi
# fallback: drop time arg and run without timeout
shift
$@
"$@"
}
set_eatmydata()
......@@ -299,7 +304,7 @@ set_eatmydata()
[ -n "$EPMNOEATMYDATA" ] && return
# use if possible
which eatmydata >/dev/null 2>/dev/null || return
SUDO="$SUDO eatmydata"
[ -n "$SUDO" ] && SUDO="$SUDO eatmydata" || SUDO="eatmydata"
[ -n "$verbose" ] && info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
return 0
}
......@@ -351,6 +356,20 @@ assure_exists()
__epm_assure "$1" $package $3 || fatal "Can't assure in '$1' command from $package$textpackage package"
}
disabled_eget()
{
# use internal eget only if exists
if [ -s $SHAREDIR/tools_eget ] ; then
$SHAREDIR/tools_eget "$@"
return
fi
assure_exists eget
# run external command, not the function
EGET=$(which eget) || fatal "Missed command eget from installed package eget"
$EGET "$@"
}
eget()
{
assure_exists wget
......@@ -1000,6 +1019,7 @@ _print_additional_usage
}
################# incorporate bin/distr_info #################
internal_distr_info()
{
# Author: Vitaly Lipatov <lav@etersoft.ru>
......@@ -1028,6 +1048,11 @@ has()
grep "$*" "$DISTROFILE" >/dev/null 2>&1
}
firstupper()
{
echo "$*" | sed 's/.*/\u&/'
}
# Translate DISTRIB_ID to vendor name (like %_vendor does)
rpmvendor()
{
......@@ -1049,11 +1074,12 @@ pkgvendor()
# Print pkgtype (need DISTRIB_ID var)
pkgtype()
{
# TODO: try use generic names
case $(pkgvendor) in
freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;;
archlinux) echo "pkg.tar.xz" ;;
archlinux|manjaro) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
......@@ -1143,7 +1169,7 @@ elif distro slackware-version ; then
elif distro os-release && which apk 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="$ID"
DISTRIB_ID="$(firstupper "$ID")"
DISTRIB_RELEASE="$VERSION_ID"
elif distro os-release && which tce-ab 2>/dev/null >/dev/null ; then
......@@ -1165,6 +1191,7 @@ elif distro arch-release ; then
DISTRIB_RELEASE="2011"
fi
# Elbrus
elif distro mcst_version ; then
DISTRIB_ID="MCST"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "release" | sed -e "s|.*release \([0-9]*\).*|\1|g")
......@@ -1275,6 +1302,14 @@ elif distro SuSe-release || distro SuSE-release ; then
DISTRIB_ID="SLES"
fi
# https://www.freedesktop.org/software/systemd/man/os-release.html
elif distro os-release ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="$(firstupper "$ID")"
DISTRIB_RELEASE="$VERSION_ID"
[ -n "$DISTRIB_RELEASE" ] || DISTRIB_RELEASE="CUR"
# fixme: can we detect by some file?
elif [ "$(uname)" = "FreeBSD" ] ; then
DISTRIB_ID="FreeBSD"
......@@ -1317,6 +1352,112 @@ elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
esac
fi
get_base_os_name()
{
local DIST_OS
# Resolve the os
DIST_OS=`uname -s | tr [:upper:] [:lower:] | tr -d " \t\r\n"`
case "$DIST_OS" in
'sunos')
DIST_OS="solaris"
;;
'hp-ux' | 'hp-ux64')
DIST_OS="hpux"
;;
'darwin' | 'oarwin')
DIST_OS="macosx"
;;
'unix_sv')
DIST_OS="unixware"
;;
'freebsd' | 'openbsd' | 'netbsd')
DIST_OS="freebsd"
;;
esac
echo "$DIST_OS"
}
get_arch()
{
local DIST_ARCH
# Resolve the architecture
DIST_ARCH=`uname -m | tr [:upper:] [:lower:] | tr -d " \t\r\n"`
case "$DIST_ARCH" in
'amd64' | 'ia32' | 'i386' | 'i486' | 'i586' | 'i686' | 'x86_64')
DIST_ARCH="x86"
;;
'ia64' | 'ia-64')
DIST_ARCH="ia64"
;;
'ip27' | 'mips')
DIST_ARCH="mips"
;;
'powermacintosh' | 'power' | 'powerpc' | 'power_pc' | 'ppc64')
DIST_ARCH="ppc"
;;
'pa_risc' | 'pa-risc')
DIST_ARCH="parisc"
;;
'sun4u' | 'sparcv9')
DIST_ARCH="sparc"
;;
'9000/800')
DIST_ARCH="parisc"
;;
armv*)
if [ -z "`readelf -A /proc/self/exe | grep Tag_ABI_VFP_args`" ] ; then
DIST_ARCH="armel"
else
DIST_ARCH="armhf"
fi
;;
esac
echo "$DIST_ARCH"
}
get_bit_size()
{
local DIST_BIT
# Check if we are running on 64bit platform, seems like a workaround for now...
DIST_BIT=`uname -m | tr [:upper:] [:lower:] | tr -d " \t\r\n"`
case "$DIST_BIT" in
'amd64' | 'ia64' | 'x86_64' | 'ppc64')
DIST_BIT="64"
;;
# 'pa_risc' | 'pa-risc') # Are some of these 64bit? Least not all...
# BIT="64"
# ;;
'sun4u' | 'sparcv9') # Are all sparcs 64?
DIST_BIT="64"
;;
# '9000/800')
# DIST_BIT="64"
# ;;
*) # In any other case default to 32
DIST_BIT="32"
;;
esac
echo "$DIST_BIT"
}
get_memory_size() {
local detected=0
local DIST_OS=$(get_base_os_name)
if [ $DIST_OS = "macosx" ]
then
detected=$((`sysctl hw.memsize | sed s/"hw.memsize: "//`/1024/1024))
elif [ $DIST_OS = "freebsd" ]
then
detected=$((`sysctl hw.physmem | sed s/"hw.physmem: "//`/1024/1024))
elif [ $DIST_OS = "linux" ]
then
detected=$((`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`/1024))
fi
# Exit codes only support values between 0 and 255. So use stdout.
echo $detected
}
case $1 in
-p)
# override DISTRIB_ID
......@@ -1329,6 +1470,10 @@ case $1 in
echo "Usage: distr_vendor [options] [args]"
echo "-p [SystemName] - print type of packaging system"
echo "-d - print distro name"
echo "-a - print hardware architecture"
echo "-b - print size of arch bit (32/64)"
echo "-m - print system memory size (in MB)"
echo "-o - print base os name"
echo "-v - print version of distro"
echo "-e - print full name of distro with version (by default)"
echo "-s [SystemName] - print name of distro for build system (like in the package release name)"
......@@ -1340,6 +1485,18 @@ case $1 in
-d)
echo $DISTRIB_ID
;;
-a)
get_arch
;;
-b)
get_bit_size
;;
-m)
get_memory_size
;;
-o)
get_base_os_name
;;
-v)
echo $DISTRIB_RELEASE
;;
......@@ -1366,16 +1523,19 @@ case $1 in
esac
}
################# end of incorporated bin/distr_info #################
################# incorporate bin/tools_eget #################
internal_tools_eget()
{
# eget - simply shell on wget for loading directories over http
# eget - simply shell on wget for loading directories over http (wget does not support wildcard for http)
# Example use:
# eget ftp://ftp.altlinux.ru/pub/security/ssl/*
# eget http://ftp.altlinux.ru/pub/security/ssl/*
#
# Copyright (C) 2014-2014, 2016 Etersoft
# Copyright (C) 2014 Daniil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2016-2017 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
......@@ -1410,29 +1570,39 @@ fi
# TODO:
# -P support
# If ftp protocol or have no asterisk, just download
# TODO: use has()
if echo "$1" | grep -q "\(^ftp://\|[^*]\)" ; then
if [ -z "$1" ] ; then
echo "eget - wget wrapper" >&2
echo "Run with URL, like http://somesite.ru/dir/*.log" >&2
exit 1
fi
# If ftp protocol, just download
if echo "$1" | grep -q "^ftp://" ; then
$WGET $WGET_OPTION_TARGET "$1"
return
fi
# drop mask part (if has /$, not changed)
URL=$(echo "$1" | grep "/$" || dirname "$1")
# If have no wildcard symbol like asterisk and no / at the end, just download
if [ "$URL" != "$1" ] && echo "$1" | grep -qv "[*?]" ; then
$WGET $WGET_OPTION_TARGET "$1"
return
fi
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
}
# TODO: skip create_fake_files for full dir
# add * if full dir
#[ "$URL" != "$1" ] && MASK="*"
print_files()
{
cat $INDEX | grep -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2
$WGET -O- $URL | \
grep -o -E 'href="([^\*/"#]+)"' | cut -d'"' -f2
}
create_fake_files()
......@@ -1448,18 +1618,23 @@ create_fake_files()
download_files()
{
ERROR=0
# TODO: test fix / at the end
for line in $DIRALLFILES/$MASK ; do
[ -r "$line" ] || { ERROR=1 ; break ; }
$WGET $URL/$(basename "$line") || ERROR=1
done
return $ERROR
}
get_index || return
MYTMPDIR="$(mktemp -d)"
create_fake_files
download_files || echo "There was some download errors" >&2
rm -rf "$MYTMPDIR"
}
################# end of incorporated bin/tools_eget #################
################# incorporate bin/tools_json #################
internal_tools_json()
{
......@@ -1673,6 +1848,8 @@ fi
# vi: expandtab sw=2 ts=2
}
################# end of incorporated bin/tools_json #################
INITDIR=/etc/init.d
......@@ -1771,7 +1948,7 @@ $(get_help HELPOPT)
print_version()
{
echo "Service manager version 2.1.1"
echo "Service manager version 2.3.0"
echo "Running on $($DISTRVENDOR) with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012, 2013, 2016"
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