Gentoo Archives: gentoo-commits

From: Alex Legler <a3li@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] sites/www:master commit in: bin/
Date: Fri, 27 May 2016 12:07:26
Message-Id: 1464350137.4af8d661243e0da0b17210a8ddd788a92b19d19b.a3li@gentoo
1 commit: 4af8d661243e0da0b17210a8ddd788a92b19d19b
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 26 18:11:34 2016 +0000
4 Commit: Alex Legler <a3li <AT> gentoo <DOT> org>
5 CommitDate: Fri May 27 11:55:37 2016 +0000
6 URL: https://gitweb.gentoo.org/sites/www.git/commit/?id=4af8d661
7
8 update-downloads: rewrite to make it easier to manage
9
10 This also adds hppa netboot images to the list.
11
12 bin/update-downloads.sh | 98 ++++++++++++++++++++++++++++++++++++++-----------
13 1 file changed, 77 insertions(+), 21 deletions(-)
14
15 diff --git a/bin/update-downloads.sh b/bin/update-downloads.sh
16 index 8dea718..3b0b894 100755
17 --- a/bin/update-downloads.sh
18 +++ b/bin/update-downloads.sh
19 @@ -1,24 +1,80 @@
20 #!/bin/bash
21 -ARCHES=(amd64 x86 alpha arm hppa ia64 mips ppc s390 sh sparc)
22 +# TODO: fix this handling for temp files and if one of the downloads fails but not others.
23
24 -echo -n 'Updating downloads...'
25 +URI_BASE="http://distfiles.gentoo.org/releases"
26
27 -# TODO: fix this handling for temp files and if one of the downloads fails but not others.
28 -for arch in "${ARCHES[@]}"; do
29 - mkdir -p _data/downloads/${arch}/
30 - wget -T 60 "http://distfiles.gentoo.org/releases/${arch}/autobuilds/latest-iso.txt" -O _data/downloads/${arch}/iso.txt 2>/dev/null
31 - wget -T 60 "http://distfiles.gentoo.org/releases/${arch}/autobuilds/latest-stage3.txt" -O _data/downloads/${arch}/stage3.txt 2>/dev/null
32 -
33 - if [ ${arch} = "amd64" ]; then
34 - wget -T 60 "http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-admincd-amd64.txt" -O - >> _data/downloads/${arch}/iso.txt 2>/dev/null
35 - elif [ ${arch} = "s390" ]; then
36 - wget -T 60 "http://distfiles.gentoo.org/releases/s390/autobuilds/latest-netboot-s390-initramfs.txt" -O - >> _data/downloads/${arch}/iso.txt 2>/dev/null
37 - wget -T 60 "http://distfiles.gentoo.org/releases/s390/autobuilds/latest-netboot-s390-kernel.txt" -O - >> _data/downloads/${arch}/iso.txt 2>/dev/null
38 - wget -T 60 "http://distfiles.gentoo.org/releases/s390/autobuilds/latest-netboot-s390x-initramfs.txt" -O - >> _data/downloads/${arch}/iso.txt 2>/dev/null
39 - wget -T 60 "http://distfiles.gentoo.org/releases/s390/autobuilds/latest-netboot-s390x-kernel.txt" -O - >> _data/downloads/${arch}/iso.txt 2>/dev/null
40 - elif [ ${arch} = "x86" ]; then
41 - wget -T 60 "http://distfiles.gentoo.org/releases/x86/autobuilds/latest-admincd-x86.txt" -O - >> _data/downloads/${arch}/iso.txt 2>/dev/null
42 - fi
43 -done
44 -
45 -echo 'done.'
46 +ARCHES=(alpha amd64 arm hppa ia64 mips ppc s390 sh sparc x86)
47 +
48 +usage() {
49 + cat <<EOF
50 +Usage: update-downloads.sh
51 +
52 +Helper script that runs on the servers to refresh the files that back the
53 +downloads page: https://gentoo.org/downloads/
54 +EOF
55 + exit 0
56 +}
57 +
58 +fetch() {
59 + wget -T 60 -q "$@"
60 +}
61 +
62 +# Append extra images to the specified list.
63 +# append_list <local file> <list of remote urls to append>
64 +append_list() {
65 + local list=$1 file
66 + shift
67 + for file in "$@" ; do
68 + fetch -O - >>"${list}" "${uri_base}/${file}"
69 + done
70 +}
71 +
72 +update_amd64() {
73 + append_list "${boot_list}" "latest-admincd-amd64.txt"
74 +}
75 +
76 +update_hppa() {
77 + append_list "${boot_list}" latest-netboot-hppa{32,64}.txt
78 +}
79 +
80 +update_s390() {
81 + append_list "${boot_list}" latest-netboot-s390{,x}-{initramfs,kernel}.txt
82 +}
83 +
84 +update_x86() {
85 + append_list "${boot_list}" "latest-admincd-x86.txt"
86 +}
87 +
88 +# Update the bootable & stage lists.
89 +update_arch() {
90 + local arch=$1
91 + local uri_base="${URI_BASE}/${arch}/autobuilds"
92 + local list_base="_data/downloads/${arch}"
93 + local boot_list="${list_base}/iso.txt"
94 + local stage_list="${list_base}/stage3.txt"
95 +
96 + mkdir -p "${list_base}"
97 + fetch "${uri_base}/latest-iso.txt" -O "${boot_list}"
98 + fetch "${uri_base}/latest-stage3.txt" -O "${stage_list}"
99 + if [[ $(type -t "update_${arch}") == "function" ]] ; then
100 + update_${arch}
101 + fi
102 +}
103 +
104 +main() {
105 + if [[ $# -ne 0 ]] ; then
106 + usage
107 + fi
108 +
109 + # Make sure we're in the top level dir.
110 + cd "$(dirname "$0")"/..
111 +
112 + local arch
113 + printf 'Updating ... '
114 + for arch in "${ARCHES[@]}" ; do
115 + printf '%s ' "${arch}"
116 + update_arch "${arch}"
117 + done
118 + echo '... done'
119 +}
120 +main "$@"