|
@ -28,19 +28,17 @@ |
|
|
# definitions (optionally using a mirroring 'cache' server). |
|
|
# definitions (optionally using a mirroring 'cache' server). |
|
|
# |
|
|
# |
|
|
# This script also allows for checksum display/validation. |
|
|
# This script also allows for checksum display/validation. |
|
|
# |
|
|
|
|
|
# Key to understanding this script is that all file lists get broken |
|
|
|
|
|
# down to a single file download using ./scripts/Download filename. |
|
|
|
|
|
|
|
|
|
|
|
umask 022 |
|
|
umask 022 |
|
|
|
|
|
|
|
|
|
|
|
. scripts/functions |
|
|
|
|
|
|
|
|
if [ "$1" = '--help' ] ; then |
|
|
if [ "$1" = '--help' ] ; then |
|
|
{ echo |
|
|
{ echo |
|
|
echo "Usage:" |
|
|
echo "Usage:" |
|
|
echo |
|
|
echo |
|
|
echo " ./scripts/Download [options] [ Filename(s) ]" |
|
|
|
|
|
echo " ./scripts/Download [options] -pattern Pattern(s)" |
|
|
|
|
|
echo " ./scripts/Download [options] -package Package(s)" |
|
|
|
|
|
|
|
|
echo " ./scripts/Download [options] [ Package(s) ]" |
|
|
|
|
|
echo " ./scripts/Download [options] [ Desc file(s) ]" |
|
|
echo " ./scripts/Download [options] -repository Repositories" |
|
|
echo " ./scripts/Download [options] -repository Repositories" |
|
|
echo " ./scripts/Download [options] { -all | -required }" |
|
|
echo " ./scripts/Download [options] { -all | -required }" |
|
|
echo |
|
|
echo |
|
@ -49,6 +47,7 @@ if [ "$1" = '--help' ] ; then |
|
|
echo " [ -mirror <URL> | -check ] [ -try-questionable ] [ -notimeout ]" |
|
|
echo " [ -mirror <URL> | -check ] [ -try-questionable ] [ -notimeout ]" |
|
|
echo " [ -longtimeout ] [ -curl-opt <curl-option>[:<curl-option>[:..]] ]" |
|
|
echo " [ -longtimeout ] [ -curl-opt <curl-option>[:<curl-option>[:..]] ]" |
|
|
echo " [ -proxy <server>[:<port>] ] [ -proxy-auth <username>[:<password>] ]" |
|
|
echo " [ -proxy <server>[:<port>] ] [ -proxy-auth <username>[:<password>] ]" |
|
|
|
|
|
echo " [ -copy ] [ -move ]" |
|
|
echo |
|
|
echo |
|
|
echo " On default, this script auto-detects the best ROCK Linux mirror." |
|
|
echo " On default, this script auto-detects the best ROCK Linux mirror." |
|
|
echo |
|
|
echo |
|
@ -93,6 +92,8 @@ this_is_the_2nd_run=0 |
|
|
mirror='' ; checkonly=0 ; altdir='' ; loop=1 |
|
|
mirror='' ; checkonly=0 ; altdir='' ; loop=1 |
|
|
tryques=0 ; nocheck=0 ; options='-this_is_the_2nd_run ' |
|
|
tryques=0 ; nocheck=0 ; options='-this_is_the_2nd_run ' |
|
|
notimeout=0 ; curl_options='--disable-epsv --location' |
|
|
notimeout=0 ; curl_options='--disable-epsv --location' |
|
|
|
|
|
altcopy=link |
|
|
|
|
|
|
|
|
# |
|
|
# |
|
|
while [ $loop -eq 1 ] ; do |
|
|
while [ $loop -eq 1 ] ; do |
|
|
case "$1" in |
|
|
case "$1" in |
|
@ -176,6 +177,9 @@ while [ $loop -eq 1 ] ; do |
|
|
# also try to download questionable URLs |
|
|
# also try to download questionable URLs |
|
|
options="$options -try-questionable" |
|
|
options="$options -try-questionable" |
|
|
tryques=1 ; shift ;; |
|
|
tryques=1 ; shift ;; |
|
|
|
|
|
|
|
|
|
|
|
-move) altcopy=move ; shift ;; |
|
|
|
|
|
-copy) altcopy=copy ; shift ;; |
|
|
|
|
|
|
|
|
*) |
|
|
*) |
|
|
loop=0 ;; |
|
|
loop=0 ;; |
|
@ -260,7 +264,7 @@ detect_mirror() { |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# download_file local-filename download-location cksum |
|
|
|
|
|
|
|
|
# download_file local-filename download-location cksum repo pkg |
|
|
# |
|
|
# |
|
|
# This function decides if download directly or from a mirror, |
|
|
# This function decides if download directly or from a mirror, |
|
|
# validates checksum, etc. |
|
|
# validates checksum, etc. |
|
@ -270,7 +274,7 @@ download_file() { |
|
|
|
|
|
|
|
|
# Init |
|
|
# Init |
|
|
# |
|
|
# |
|
|
gzfile="$1" ; location="$2" ; cksum="$3" |
|
|
|
|
|
|
|
|
local gzfile="$1" location="$2" cksum="$3" repo="$4" pkg="$5" |
|
|
# Make src directory for creating tar balls |
|
|
# Make src directory for creating tar balls |
|
|
mkdir -p src/ |
|
|
mkdir -p src/ |
|
|
# Tarball file name: (if you change this one - also adapt Create-ISO) |
|
|
# Tarball file name: (if you change this one - also adapt Create-ISO) |
|
@ -370,10 +374,25 @@ download_file() { |
|
|
altfile="" |
|
|
altfile="" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
#FIXME: compatibility, can be removed sooner or later... |
|
|
|
|
|
# Check old download dir layout |
|
|
|
|
|
if [ -z "$altfile" ]; then |
|
|
|
|
|
if [ -f "download/$repo${pkg:+/}$pkg/`basename $bzfile`" ]; then |
|
|
|
|
|
altfile="download/$repo${pkg:+/}$pkg/`basename $bzfile`" |
|
|
|
|
|
fi |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
if [ "$altfile" ] ; then |
|
|
if [ "$altfile" ] ; then |
|
|
|
|
|
|
|
|
echo "Found `basename $bzfile` as $altfile." |
|
|
echo "Found `basename $bzfile` as $altfile." |
|
|
cp -lv $altfile $bzfile ; gzfile="$bzfile" |
|
|
|
|
|
|
|
|
if [ "$altcopy" = 'link' ]; then |
|
|
|
|
|
cp -lv $altfile $bzfile |
|
|
|
|
|
elif [ "$altcopy" = 'copy' ]; then |
|
|
|
|
|
cp -v $altfile $bzfile |
|
|
|
|
|
elif [ "$altcopy" = 'move' ]; then |
|
|
|
|
|
mv -v $altfile $bzfile |
|
|
|
|
|
fi |
|
|
|
|
|
gzfile="$bzfile" |
|
|
|
|
|
|
|
|
else |
|
|
else |
|
|
|
|
|
|
|
@ -383,10 +402,15 @@ download_file() { |
|
|
|
|
|
|
|
|
if [ "$mirror" -a "$mirror" != "none" ] ; then |
|
|
if [ "$mirror" -a "$mirror" != "none" ] ; then |
|
|
# try to use mirror |
|
|
# try to use mirror |
|
|
|
|
|
|
|
|
if ! download_file_now "!$mirror/${bzfile#download/}" $bzfile $bzfile; then |
|
|
if ! download_file_now "!$mirror/${bzfile#download/}" $bzfile $bzfile; then |
|
|
# oops... so try direct (original URL) |
|
|
|
|
|
echo "INFO: download from mirror failed, trying original URL." |
|
|
|
|
|
download_file_now $location $gzfile $bzfile |
|
|
|
|
|
|
|
|
#FIXME: compatibility, can be removed sooner or later... |
|
|
|
|
|
# Try old download format for remote file |
|
|
|
|
|
if ! download_file_now "!$mirror/$repo${pkg:+/}$pkg/`basename $bzfile`" $bzfile $bzfile; then |
|
|
|
|
|
# oops... so try direct (original URL) |
|
|
|
|
|
echo "INFO: download from mirror failed, trying original URL." |
|
|
|
|
|
download_file_now $location $gzfile $bzfile |
|
|
|
|
|
fi |
|
|
else |
|
|
else |
|
|
gzfile="$bzfile" |
|
|
gzfile="$bzfile" |
|
|
fi |
|
|
fi |
|
@ -456,7 +480,8 @@ download_file_now() { |
|
|
if test -s src/Download-Errors && |
|
|
if test -s src/Download-Errors && |
|
|
grep -q " $url\$" src/Download-Errors ; then |
|
|
grep -q " $url\$" src/Download-Errors ; then |
|
|
echo "ERROR: According to src/Download-Errors" \ |
|
|
echo "ERROR: According to src/Download-Errors" \ |
|
|
"we had already an error for that URL." |
|
|
|
|
|
|
|
|
"we had already an error for the URL" |
|
|
|
|
|
echo "ERROR: $url" |
|
|
echo "ERROR: So I'm not trying to download" \ |
|
|
echo "ERROR: So I'm not trying to download" \ |
|
|
"it again (remove src/Download-Errors" |
|
|
"it again (remove src/Download-Errors" |
|
|
echo "ERROR: if you want to force a retry)." |
|
|
echo "ERROR: if you want to force a retry)." |
|
@ -601,69 +626,25 @@ download_file_now() { |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
list_dtags() { |
|
|
|
|
|
{ |
|
|
|
|
|
grep -H '^\[D\] ' package/*/*/*.desc |
|
|
|
|
|
grep -H '^[X0-9]' target/*/download.txt | sed 's,:,:[D] ,' |
|
|
|
|
|
|
|
|
# handle_file filename |
|
|
|
|
|
# |
|
|
|
|
|
# This function fetches the checksum and download information |
|
|
|
|
|
# from the desc files and calls the download_file function. |
|
|
|
|
|
# |
|
|
|
|
|
handle_file() { |
|
|
|
|
|
|
|
|
|
|
|
# Handle pkg file (package/.../*.desc) |
|
|
|
|
|
# |
|
|
|
|
|
tree="`echo "$1" | cut -f2 -d/`" |
|
|
|
|
|
pkg="` echo "$1" | cut -f3 -d/`" |
|
|
|
|
|
file="`echo "$1" | cut -f4 -d/`" |
|
|
|
|
|
if grep -q "^\[D\].* $file " package/$tree/$pkg/$pkg.desc 2> /dev/null |
|
|
|
|
|
then |
|
|
|
|
|
grep "^\[D\].* $file " package/$tree/$pkg/$pkg.desc | |
|
|
|
|
|
while read tag cksum file url ; do |
|
|
|
|
|
download_file "$1" "$url" "$cksum" |
|
|
|
|
|
done |
|
|
|
|
|
return 0 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Handle target file (target/.../download.txt) |
|
|
|
|
|
# |
|
|
|
|
|
target="`echo "$1" | cut -f2 -d/`" |
|
|
|
|
|
file="`echo "$1" | cut -f3- -d/`" |
|
|
|
|
|
if grep -q " $file " target/$target/download.txt 2> /dev/null |
|
|
|
|
|
then |
|
|
|
|
|
grep " $file " target/$target/download.txt | |
|
|
|
|
|
while read cksum file url ; do |
|
|
|
|
|
download_file "$1" "$url" "$cksum" |
|
|
|
|
|
done |
|
|
|
|
|
return 0 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Handle misc file (scripts/miscdown.txt) |
|
|
|
|
|
# |
|
|
|
|
|
if [ "${1#download/misc/}" != "$1" ] ; then |
|
|
|
|
|
file="`echo "$1" | cut -f3- -d/`" |
|
|
|
|
|
if grep -q " $file " scripts/miscdown.txt |
|
|
|
|
|
then |
|
|
|
|
|
grep " $file " scripts/miscdown.txt | |
|
|
|
|
|
while read cksum file url ; do |
|
|
|
|
|
download_file "$1" "$url" "$cksum" |
|
|
|
|
|
done |
|
|
|
|
|
return 0 |
|
|
|
|
|
fi |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Can't handle file / file not found |
|
|
|
|
|
# |
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
|
#FIXME the following have relative paths in the archive-file column |
|
|
|
|
|
# is it needed anyway? |
|
|
|
|
|
grep -H '^[X0-9]' scripts/miscdown.txt | sed 's,:,:[D] ,' |
|
|
|
|
|
} | column_clean |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
list_cksums() { |
|
|
list_cksums() { |
|
|
trap '' INT |
|
|
trap '' INT |
|
|
{ grep -H '^\[D\] ' package/*/*/*.desc | tr '\t' ' ' | tr -s ' ' | |
|
|
|
|
|
sed -e 's,^package/,download/,;' |
|
|
|
|
|
grep -H '^[X0-9]' target/*/download.txt | tr '\t' ' ' | tr -s ' ' | |
|
|
|
|
|
sed -e 's,^target/,download/,; s,:,:[D] ,;' |
|
|
|
|
|
grep -H '^[X0-9]' scripts/miscdown.txt | tr '\t' ' ' | tr -s ' ' | |
|
|
|
|
|
sed 's,^scripts/,download/misc/,; s,:,:[D] ,;' |
|
|
|
|
|
} | sed 's,^\(.*/\)[^/:]*:[^ ]* \([X0-9]*\) ,\2 \1,;' | cut -f1,2 -d' ' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list_dtags | sed \ |
|
|
|
|
|
-e "s,^$Dre[ ].*\($NODISTre\).*$,\3 download/nodist/\5/\4,;" \ |
|
|
|
|
|
-e "s,^$Dre$,\3 download/mirror/\5/\4,;" \ |
|
|
|
|
|
| sed 's,^\(.*/\)[^/:]*:[^ ]* \([X0-9]*\) ,\2 \1,;' | cut -f1,2 -d' ' |
|
|
|
|
|
|
|
|
trap INT |
|
|
trap INT |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -696,27 +677,9 @@ list_missing() { |
|
|
trap INT |
|
|
trap INT |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pattern() { |
|
|
|
|
|
for pattern ; do |
|
|
|
|
|
echo "Processing pattern $pattern ..." |
|
|
|
|
|
list | while read fn ; do |
|
|
|
|
|
if [ "${fn##$pattern}" = '' ] ; then |
|
|
|
|
|
echo "Matched: $fn" |
|
|
|
|
|
$0 $options "$fn" |
|
|
|
|
|
fi |
|
|
|
|
|
done |
|
|
|
|
|
done |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
package() { |
|
|
|
|
|
for package ; do |
|
|
|
|
|
pattern "download/*/$package/*" |
|
|
|
|
|
done |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
repository() { |
|
|
repository() { |
|
|
for repository ; do |
|
|
for repository ; do |
|
|
pattern "download/$repository/*" |
|
|
|
|
|
|
|
|
packages `echo package/$repository/*/*.desc` |
|
|
done |
|
|
done |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -729,41 +692,96 @@ required() { |
|
|
exit 1 |
|
|
exit 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
while read on a b tree pkg c ; do |
|
|
|
|
|
|
|
|
while read on a b repo pkg c ; do |
|
|
if [ "$on" = "X" ] ; then |
|
|
if [ "$on" = "X" ] ; then |
|
|
grep -H '^\[D\] ' package/$tree/$pkg/$pkg.desc > src/down.$$.lst |
|
|
|
|
|
while read tag cksum file url ; do |
|
|
|
|
|
download_file "download/$tree/$pkg/$file" "$url" "$cksum" |
|
|
|
|
|
|
|
|
grep -H '^\[D\] ' package/$repo/$pkg/$pkg.desc > src/down.$$.lst |
|
|
|
|
|
while read tag cksum file url flags ; do |
|
|
|
|
|
download_file "`source_file cksum $file url $flags`" "$url" "$cksum" "$repo" "$pkg" |
|
|
done < src/down.$$.lst ; rm -f src/down.$$.lst |
|
|
done < src/down.$$.lst ; rm -f src/down.$$.lst |
|
|
fi |
|
|
fi |
|
|
done < config/$config/packages |
|
|
done < config/$config/packages |
|
|
target=`grep '^export ROCKCFG_TARGET=' config/$config/config | \ |
|
|
target=`grep '^export ROCKCFG_TARGET=' config/$config/config | \ |
|
|
cut -f2 -d= | tr -d "'"` |
|
|
cut -f2 -d= | tr -d "'"` |
|
|
if [ -f target/$target/download.txt ] ; then |
|
|
if [ -f target/$target/download.txt ] ; then |
|
|
while read cksum file url ; do |
|
|
|
|
|
download_file "download/$target/$file" "$url" "$cksum" |
|
|
|
|
|
|
|
|
while read cksum file url flags ; do |
|
|
|
|
|
download_file "`source_file cksum $file url $flags`" "$url" "$cksum" "$target" |
|
|
done < target/$target/download.txt |
|
|
done < target/$target/download.txt |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
#FIXME what's about scripts/miscdown.txt? |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
single_files() { |
|
|
|
|
|
for file_name ; do |
|
|
|
|
|
file_name_gz="`echo "$file_name" | sed 's,\.\(t\?\)bz2$,.\1gz,'`" |
|
|
|
|
|
file_name_Z="`echo "$file_name" | sed 's,\.\(t\?\)bz2$,.\1Z,'`" |
|
|
|
|
|
if ! handle_file "$file_name" && \ |
|
|
|
|
|
! handle_file "$file_name_gz" && \ |
|
|
|
|
|
! handle_file "$file_name_Z" |
|
|
|
|
|
then |
|
|
|
|
|
echo "ERROR: Unknown file: $file_name." |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
all() { |
|
|
|
|
|
local each repo pkg |
|
|
|
|
|
|
|
|
|
|
|
for each in package/*/*/*.desc; do |
|
|
|
|
|
pkg="`echo $descfile | cut -f3 -d/`" |
|
|
|
|
|
repo="`echo $descfile | cut -f2 -d/`" |
|
|
|
|
|
|
|
|
|
|
|
while read tag cksum file url flags ; do |
|
|
|
|
|
download_file "`source_file cksum $file url $flags`" "$url" "$cksum" "$repo" "$pkg" |
|
|
|
|
|
done < <(grep -H '^\[D\] ' package/$repo/$pkg/$pkg.desc) |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
for each in target/*/download.txt; do |
|
|
|
|
|
target="`echo $descfile | cut -f2 -d/`" |
|
|
|
|
|
|
|
|
|
|
|
while read cksum file url flags ; do |
|
|
|
|
|
download_file "`source_file cksum $file url $flags`" "$url" "$cksum" "$target" |
|
|
|
|
|
done < <(cat $each) |
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
#FIXME miscdown.txt contains relative paths in 2nd column |
|
|
|
|
|
for each in scripts/miscdown.txt; do |
|
|
|
|
|
while read cksum file url flags ; do |
|
|
|
|
|
file="`basename $file`" |
|
|
|
|
|
download_file "`source_file cksum $file url $flags`" "$url" "$cksum" "$target" |
|
|
|
|
|
done < <(cat $each) |
|
|
done |
|
|
done |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
all() { |
|
|
|
|
|
if [ $checkonly = 1 ] ; then list |
|
|
|
|
|
else list_missing ; fi > src/down.$$.lst |
|
|
|
|
|
while read fn ; do single_files $fn ; done < src/down.$$.lst |
|
|
|
|
|
rm -f src/down.$$.lst |
|
|
|
|
|
|
|
|
packages() { |
|
|
|
|
|
local descfile |
|
|
|
|
|
for arg; do |
|
|
|
|
|
case "$arg" in |
|
|
|
|
|
target/*) |
|
|
|
|
|
if [ ! -f $arg ]; then |
|
|
|
|
|
echo "Skipping \"$arg\" (not found)!" |
|
|
|
|
|
continue |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
target="`echo $arg | cut -f2 -d/`" |
|
|
|
|
|
|
|
|
|
|
|
while read cksum file url flags ; do |
|
|
|
|
|
download_file "`source_file cksum $file url $flags`" \ |
|
|
|
|
|
"$url" "$cksum" "$target" |
|
|
|
|
|
done < <(cat $arg) |
|
|
|
|
|
;; |
|
|
|
|
|
scripts/*) |
|
|
|
|
|
: #FIXME miscdown.txt not handled yet |
|
|
|
|
|
;; |
|
|
|
|
|
*) |
|
|
|
|
|
if [ ! "${arg%.desc}" = "$arg" ]; then |
|
|
|
|
|
descfile=$arg |
|
|
|
|
|
else |
|
|
|
|
|
descfile="`echo package/*/$arg/$arg.desc`" |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f $descfile ]; then |
|
|
|
|
|
echo "Skipping \"$arg\" (not found)!" |
|
|
|
|
|
continue |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
pkg="`echo $descfile | cut -f3 -d/`" |
|
|
|
|
|
repo="`echo $descfile | cut -f2 -d/`" |
|
|
|
|
|
|
|
|
|
|
|
while read tag cksum file url flags ; do |
|
|
|
|
|
download_file "`source_file cksum $file url $flags`" \ |
|
|
|
|
|
"$url" "$cksum" "$repo" "$pkg" |
|
|
|
|
|
done < <(grep -H '^\[D\] ' package/$repo/$pkg/$pkg.desc) |
|
|
|
|
|
;; |
|
|
|
|
|
esac |
|
|
|
|
|
done |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# Things to do only for downloading |
|
|
# Things to do only for downloading |
|
@ -812,14 +830,14 @@ case "$1" in |
|
|
-list-missing) list_missing ;; |
|
|
-list-missing) list_missing ;; |
|
|
-list-cksums) list_cksums ;; |
|
|
-list-cksums) list_cksums ;; |
|
|
|
|
|
|
|
|
-pattern) shift ; pattern "$@" ;; |
|
|
|
|
|
-package) shift ; package "$@" ;; |
|
|
|
|
|
-repository) shift ; repository "$@" ;; |
|
|
|
|
|
-required) required ;; |
|
|
-required) required ;; |
|
|
-all) all ;; |
|
|
-all) all ;; |
|
|
|
|
|
|
|
|
|
|
|
-repository) shift ; repository "$@" ;; |
|
|
|
|
|
|
|
|
-*|"") exec $0 --help ;; |
|
|
-*|"") exec $0 --help ;; |
|
|
*) single_files "$@" ;; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*) packages "$@" ;; |
|
|
esac |
|
|
esac |
|
|
|
|
|
|
|
|
exit 0 |
|
|
exit 0 |