Commit 8e03ea17 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm: use rsync to get contents_index for ALT (with rsyncable gzip mirror)

parent 5ecba37f
...@@ -28,7 +28,7 @@ __alt_local_content_filelist() ...@@ -28,7 +28,7 @@ __alt_local_content_filelist()
{ {
load_helper epm-sh-altlinux load_helper epm-sh-altlinux
local CI="$(get_local_alt_contents_index)" local CI="$(get_local_alt_contents_index_rsync)"
[ -n "$CI" ] || fatal "Have no local contents index. Check epm repo --help." [ -n "$CI" ] || fatal "Have no local contents index. Check epm repo --help."
# TODO: safe way to use less # TODO: safe way to use less
......
...@@ -32,7 +32,7 @@ __alt_local_content_search() ...@@ -32,7 +32,7 @@ __alt_local_content_search()
load_helper epm-search load_helper epm-search
info "Locate contents index file(s) ..." info "Locate contents index file(s) ..."
local CI="$(get_local_alt_contents_index)" local CI="$(get_local_alt_contents_index_rsync)"
# TODO use something like # TODO use something like
[ -n "$CI" ] || fatal "Have no local contents index. Check epm repo --help." [ -n "$CI" ] || fatal "Have no local contents index. Check epm repo --help."
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
# apt-file like. See also # 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 # convert "http://download.etersoft.ru/pub/ALTLinux/p8/branch x86_64" to ALTLinux/p8/branch/x86_64
get_local_alt_mirror_path() get_alt_repo_path()
{ {
local DN1=$(dirname "$1") local DN1=$(dirname "$1")
local DN2=$(dirname $DN1) local DN2=$(dirname $DN1)
...@@ -32,7 +32,13 @@ get_local_alt_mirror_path() ...@@ -32,7 +32,13 @@ get_local_alt_mirror_path()
local BN2=$(basename $DN2) # p8/ALTLinux local BN2=$(basename $DN2) # p8/ALTLinux
local BN3=$(basename $DN3) # ALTLinux/ local BN3=$(basename $DN3) # ALTLinux/
[ "$BN1" = "branch" ] && echo "/tmp/eepm/$BN3/$BN2/$BN1/$BN0" || echo "/tmp/eepm/$BN2/$BN1/$BN0" [ "$BN1" = "branch" ] && echo "$BN3/$BN2/$BN1/$BN0" || echo "$BN2/$BN1/$BN0"
}
# convert "http://download.etersoft.ru/pub/ALTLinux/p8/branch x86_64" to /tmp/epm/ALTLinux/p8/branch/x86_64
get_local_alt_mirror_path()
{
echo "/tmp/eepm/$(get_alt_repo_path "$1")"
} }
__local_ercat() __local_ercat()
...@@ -56,6 +62,7 @@ __local_ercat() ...@@ -56,6 +62,7 @@ __local_ercat()
done done
} }
# TODO: obsoleted
# something like gzip # something like gzip
compress_file_inplace() compress_file_inplace()
{ {
...@@ -66,12 +73,13 @@ compress_file_inplace() ...@@ -66,12 +73,13 @@ compress_file_inplace()
docmd lz4 -f "$OFILE" "$OFILE.lz4" || return docmd lz4 -f "$OFILE" "$OFILE.lz4" || return
rm -fv "$OFILE" rm -fv "$OFILE"
else else
epm assure xz </dev/null || return epm assure xz </dev/null || fatal "Can't install nor lz4, nor xz compressor"
docmd xz -f "$OFILE" || return docmd xz -f "$OFILE" || return
fi fi
return 0 return 0
} }
# TODO: obsoleted
# args: url/path target_file # args: url/path target_file
# result: will set FILE # result: will set FILE
download_alt_contents_index() download_alt_contents_index()
...@@ -92,7 +100,7 @@ download_alt_contents_index() ...@@ -92,7 +100,7 @@ download_alt_contents_index()
URL=$(echo "$URL" | sed -e "s|^file:||") URL=$(echo "$URL" | sed -e "s|^file:||")
[ -s "$URL" ] || { touch $OFILE.failed ; return 1; } [ -s "$URL" ] || { touch $OFILE.failed ; return 1; }
ln -sf "$URL" "$OFILE" || { touch $OFILE.failed ; return 1; } ln -sf "$URL" "$OFILE" || { touch $OFILE.failed ; return 1; }
# TODO rsync # TODO rsync -z
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449#c22 # https://bugzilla.altlinux.org/show_bug.cgi?id=14449#c22
else else
docmd eget -O "$OFILE" "$URL" || { rm -fv $OFILE ; touch $OFILE.failed ; return 1; } docmd eget -O "$OFILE" "$URL" || { rm -fv $OFILE ; touch $OFILE.failed ; return 1; }
...@@ -102,6 +110,47 @@ download_alt_contents_index() ...@@ -102,6 +110,47 @@ download_alt_contents_index()
compress_file_inplace "$OFILE" compress_file_inplace "$OFILE"
} }
# URL TARGETDIR
rsync_alt_contents_index()
{
local URL="$1"
local TD="$2"
assure_exists rsync
a= rsync --partial --inplace -z -av --progress "$URL" "$TD"
test -s "$TD"
}
# URL
get_url_to_etersoft_mirror()
{
local REPOPATH
local ETERSOFT_MIRROR="rsync://download.etersoft.ru/pub"
echo "$ETERSOFT_MIRROR/$(get_alt_repo_path "$1" | sed -e "s|^ALTLinux/|ALTLinux/contents_index/|")"
}
get_local_alt_contents_index_rsync()
{
load_helper epm-repolist
# TODO: fix for Etersoft/LINUX@Etersoft
epm_repolist | grep -v " task$" | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read -r URL ARCH other ; do
if echo "$URL" | grep -q "^file:/" ; then
# first check for local mirror
local LOCALPATH="$(echo "$URL" | sed -e "s|^file:||")/$ARCH/base"
local LOCALPATHGZIP="$(echo "$LOCALPATH" | sed -e "s|/ALTLinux/|/ALTLinux/contents_index/|")"
[ -s "$LOCALPATHGZIP/contents_index.gz" ] && echo "$LOCALPATHGZIP/contents_index.gz" && continue
[ -s "$LOCALPATH/contents_index" ] && echo "$LOCALPATH/contents_index"
else
local LOCALPATH="$(get_local_alt_mirror_path "$URL/$ARCH")"
local REMOTEURL="$(get_url_to_etersoft_mirror "$URL/$ARCH")/base"
rsync_alt_contents_index $REMOTEURL/contents_index.gz $LOCALPATH/contents_index.gz >/dev/null 2>/dev/null </dev/null && echo "$LOCALPATH/contents_index.gz" && continue
[ -n "$verbose" ] && info "Note: Can't retrieve $REMOTEURL/contents_index.gz, fallback to $URL/$ARCH/base/contents_index"
rsync_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH/contents_index >/dev/null 2>/dev/null </dev/null && echo "$LOCALPATH/contents_index" && continue
fi
done
}
# TODO: obsoleted
get_local_alt_contents_index() get_local_alt_contents_index()
{ {
load_helper epm-repolist load_helper epm-repolist
...@@ -113,9 +162,9 @@ get_local_alt_contents_index() ...@@ -113,9 +162,9 @@ get_local_alt_contents_index()
download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH >&2 </dev/null || continue download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH >&2 </dev/null || continue
echo "$LOCALPATH/contents_index*" echo "$LOCALPATH/contents_index*"
done done
} }
tasknumber() tasknumber()
{ {
local num="$(echo "$1" | sed -e "s| *#*||g")" local num="$(echo "$1" | sed -e "s| *#*||g")"
......
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