|
2 | 2 | # |
3 | 3 | # Download the current Gentoo stage3 |
4 | 4 | # |
5 | | -# Copyright (C) 2014-2015 W. Trevor King <[email protected]> |
| 5 | +# Copyright (C) 2014-2018 W. Trevor King <[email protected]> |
6 | 6 | # |
7 | 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
8 | 8 | # you may not use this file except in compliance with the License. |
|
16 | 16 | # See the License for the specific language governing permissions and |
17 | 17 | # limitations under the License. |
18 | 18 |
|
| 19 | +die() |
| 20 | +{ |
| 21 | + echo "$1" |
| 22 | + exit 1 |
| 23 | +} |
| 24 | + |
19 | 25 | MIRROR="${MIRROR:-http://distfiles.gentoo.org/}" |
20 | | -STAGE3_ARCH="${STAGE3_ARCH:-amd64}" |
| 26 | +if test -n "${STAGE3}" |
| 27 | +then |
| 28 | + if test -n "${STAGE3_ARCH}" |
| 29 | + then |
| 30 | + die 'if you set STAGE3, you do not need to set STAGE3_ARCH' |
| 31 | + fi |
| 32 | + if test -n "${DATE}" |
| 33 | + then |
| 34 | + die 'if you set STAGE3, you do not need to set DATE' |
| 35 | + fi |
| 36 | + STAGE3_ARCH=$(echo "${STAGE3}" | sed -n 's/stage3-\([^-]*\)-.*/\1/p') |
| 37 | + if test -z "${STAGE3_ARCH}" |
| 38 | + then |
| 39 | + die "could not calculate STAGE3_ARCH from ${STAGE3}" |
| 40 | + fi |
| 41 | + DATE=$(echo "${STAGE3}" | sed -n "s/stage3-${STAGE3_ARCH}-\([0-9]*\)[.]tar[.].*/\1/p") |
| 42 | + if test -z "${DATE}" |
| 43 | + then |
| 44 | + die "could not calculate DATE from ${STAGE3}" |
| 45 | + fi |
| 46 | +else |
| 47 | + STAGE3_ARCH="${STAGE3_ARCH:-amd64}" |
| 48 | +fi |
21 | 49 |
|
22 | 50 | if test -z "${BASE_ARCH}" |
23 | 51 | then |
|
38 | 66 | fi |
39 | 67 |
|
40 | 68 | BASE_ARCH_URL="${BASE_ARCH_URL:-${MIRROR}releases/${BASE_ARCH}/autobuilds/}" |
41 | | -LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt") |
42 | | -DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9]*[.]tar[.]bz2.*||p") |
| 69 | + |
| 70 | +if test -z "${STAGE3}" |
| 71 | +then |
| 72 | + LATEST=$(wget -O - "${BASE_ARCH_URL}latest-stage3.txt") |
| 73 | + if test -z "${DATE}" |
| 74 | + then |
| 75 | + DATE=$(echo "${LATEST}" | sed -n "s|/stage3-${STAGE3_ARCH}-[0-9]*[.]tar.*||p") |
| 76 | + if test -z "${DATE}" |
| 77 | + then |
| 78 | + die "could not calculate DATE from ${BASE_ARCH_URL}latest-stage3.txt" |
| 79 | + fi |
| 80 | + fi |
| 81 | + STAGE3="${STAGE3:-stage3-${STAGE3_ARCH}-${DATE}.tar.bz2}" |
| 82 | +fi |
| 83 | + |
43 | 84 | ARCH_URL="${ARCH_URL:-${BASE_ARCH_URL}${DATE}/}" |
44 | | -STAGE3="${STAGE3:-stage3-${STAGE3_ARCH}-${DATE}.tar.bz2}" |
45 | 85 | STAGE3_CONTENTS="${STAGE3_CONTENTS:-${STAGE3}.CONTENTS}" |
46 | 86 | STAGE3_DIGESTS="${STAGE3_DIGESTS:-${STAGE3}.DIGESTS.asc}" |
47 | 87 |
|
48 | | -die() |
49 | | -{ |
50 | | - echo "$1" |
51 | | - exit 1 |
52 | | -} |
53 | | - |
54 | 88 | for FILE in "${STAGE3}" "${STAGE3_CONTENTS}" "${STAGE3_DIGESTS}"; do |
55 | 89 | if [ ! -f "downloads/${FILE}" ]; then |
56 | 90 | wget -O "downloads/${FILE}" "${ARCH_URL}${FILE}" |
|
0 commit comments