Commit 3f9ad4eb authored by Downloader's avatar Downloader

rsync_contents_index.sh

parent 8d89ac1b
#!/bin/bash
# Written by Lav (c) 2001, 2002, 2003, 2004, 2008, 2016, 2019
# Vitaly Lipatov <lav@etersoft.ru>
LISTARCH="x86_64 noarch i586 aarch64"
# armh ppc64le"
BRANCHLIST="c7 c8 p8 p9 c9f2 c10f1 c10f2 p10 p11"
RPMS=/var/ftp/pub/ALTLinux/contents_index
TIMEOUT=5000
RSYNCOPTS="--partial --inplace -z"
FORCE=''
if [ "$1" = "--force" ] ; then
FORCE="$1"
shift
fi
CP=$(cat $TMPDIR/rsync_con_pid 2>/dev/null)
if [ -n "$CP" ] && [ -d "/proc/$CP" ] ; then
echo "Run conflicts with $CP"
date
[ -n "$FORCE" ] || exit
fi
echo "$$" >$TMPDIR/rsync_con_pid
date
get_rsync_path()
{
local RSYNCPATH
if [ "$1" = "c6/branch" ] || [ "$1" = "c7/branch" ] || [ "$1" = "c8/branch" ] ; then
RSYNCPATH=rsync.altlinux.ru::ALTLinux
#elif echo "$1" | grep -q "p8/" ; then
elif true ; then
#RSYNCPATH=rsync://ftp.basealt.ru/pub/distributions/ALTLinux
RSYNCPATH=rsync://ftp.basealt.ru/ALTLinux
else
RSYNCPATH=rsync://mirror.yandex.ru/altlinux
fi
echo "$RSYNCPATH"
}
update_compress()
{
[ -s $1 ] || return
[ "$1" -nt "$1.gz" ] || return
gzip -qkvf $1
}
DDD=$0.tmp.t1
was_error()
{
[ -s "$DDD" ] || return 1
grep "^$1" $DDD
}
save_error()
{
echo "IGNORE SAVE ERROR"
return
echo "add $1 to $DDD"
echo "$1" >>$DDD
}
sync_file()
{
local RET
was_error $RPMS/$1 && return 1
RSYNCPATH=$(get_rsync_path $1)
echo
echo "Start sync from $RSYNCPATH/$1 to $RPMS/$1"
mkdir -p $(dirname $RPMS/$1)
rsync $DELETE --fuzzy --partial --timeout=$TIMEOUT --progress $CHECKSUM --stats -vrlt --copy-links \
--exclude "*SRPMS*" \
$RSYNCPATH/$1 $RPMS/$1
RET=$?
[ "$RET" = "0" ] || save_error $RPMS/$1
return $RET
}
# p8/branch i586 classic
sync_cont_branch()
{
local BRANCH="$1"
local ARCH="$2"
local COMPONENT="$3"
[ -n "$COMPONENT" ] || fatal "sync_branch: missed COMPONENT"
RSYNCPATH=$(get_rsync_path $BRANCH)
sync_file $BRANCH/$ARCH/base/contents_index || return
update_compress $RPMS/$BRANCH/$ARCH/base/contents_index
}
# branch component
sync_cont_branches()
{
RSYNCPATH=$(get_rsync_path $1)
local i
for i in $LISTARCH; do
sync_cont_branch "$1" "$i" "$2"
done
}
CHECKSUM=''
if [ "$1" = "--checksum" ] ; then
CHECKSUM="--checksum"
shift
fi
if [ "$1" = "Sisyphus" ] ; then
sync_cont_branches $1 classic
sync_cont_branches $1 debuginfo
exit
elif echo "$1" | grep -q branch ; then
sync_cont_branches $1 classic
sync_cont_branches $1 debuginfo
exit
fi
for i in $BRANCHLIST; do
sync_cont_branches $i/branch classic
sync_cont_branches $i/branch debuginfo
done
for i in Sisyphus ; do
sync_cont_branches $i classic
sync_cont_branches $i debuginfo
done
date
rm -f $TMPDIR/rsync_con_pid
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