Skip to content

Commit

Permalink
Enable support for multiple mirrors
Browse files Browse the repository at this point in the history
This is for cases when a mirror doesn't have the hash file available
(temporarily).
  • Loading branch information
johnny-mnemonic committed Nov 12, 2024
1 parent 18f7093 commit 7ac65a1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion config/binutils-snapshot.url
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://snapshots.sourceware.org/binutils/trunk/latest/src/sha512.sum
https://snapshots.sourceware.org/binutils/trunk/latest/src/sha512.sum
4 changes: 3 additions & 1 deletion config/gcc-snapshot.url
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
https://ftp.gwdg.de/pub/misc/gcc/snapshots/LATEST-15/sha512.sum
https://ftp.gwdg.de/pub/misc/gcc/snapshots/LATEST-15/sha512.sum
https://ftp.fu-berlin.de/unix/languages/gcc/snapshots/LATEST-15/sha512.sum
https://ftp.mpi-inf.mpg.de/mirrors/gnu/mirror/gcc.gnu.org/pub/gcc/snapshots/LATEST-15/sha512.sum
2 changes: 1 addition & 1 deletion config/glibc-snapshot.url
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://snapshots.sourceware.org/glibc/trunk/latest/src/sha512.sum
https://snapshots.sourceware.org/glibc/trunk/latest/src/sha512.sum
46 changes: 25 additions & 21 deletions tools/find-snapshot.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,38 @@ _url_file_name=$( basename "$_url_file" )

_package=${_url_file_name%%-*}

read _url < "$_url_file"
while read _url; do

_base_url=$( dirname ${_url} )
_base_url=$( dirname ${_url} )

_exit_code=0
_exit_code=0

read _snapshot_sha512 _snapshot_filename <<-EOM
$( wget "$_url" -O - 2>/dev/null | grep ${_package} )
EOM
read _snapshot_sha512 _snapshot_filename <<-EOM
$( wget "$_url" -O - 2>/dev/null | grep ${_package} )
EOM

if [[ "$_snapshot_sha512" == "" || \
"$_snapshot_filename" == "" ]]; then
if [[ "$_snapshot_sha512" == "" || \
"$_snapshot_filename" == "" ]]; then

# something went wrong, so exit early
echo "E: either hash or filename empty. Cannot continue." 1>&2
exit 2
fi
# something went wrong, so try next URL - if available
echo "E: either hash or filename empty. Trying another URL - if available." 1>&2
_exit_code=2
continue
fi

if [[ -e "${_past_builds_worktree}/${_package}/${_snapshot_sha512}" ]]; then
if [[ -e "${_past_builds_worktree}/${_package}/${_snapshot_sha512}" ]]; then

# already built, ignore
_exit_code=1
else
# new snapshot found
mkdir -p "${_snapshots_dir}"
echo "${_snapshot_sha512} ${_snapshot_filename}" > "${_snapshots_dir}/${_snapshot_filename}.SHA512"
# already built, ignore
_exit_code=1
continue
else
# new snapshot found
mkdir -p "${_snapshots_dir}"
echo "${_snapshot_sha512} ${_snapshot_filename}" > "${_snapshots_dir}/${_snapshot_filename}.SHA512"

echo "${_base_url}/${_snapshot_filename}"
fi
echo "${_base_url}/${_snapshot_filename}"
break
fi
done < "$_url_file"

exit ${_exit_code}

0 comments on commit 7ac65a1

Please sign in to comment.