Skip to content

Commit f67402e

Browse files
committed
Improve update.sh to no longer create a temporary file (but still have nice debuggability via "bash -x")
1 parent 48d2a53 commit f67402e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

update.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ versions=( "${versions[@]%/}" )
1616

1717
#packagesUrl='https://ftpmirror.gnu.org/gcc/'
1818
packagesUrl='https://mirrors.kernel.org/gnu/gcc/' # the actual HTML of the page changes based on which mirror we end up hitting, so let's hit a specific one for now... :'(
19-
packages="$(echo "$packagesUrl" | sed -r 's/[^a-zA-Z.-]+/-/g')"
20-
curl -fsSL "$packagesUrl" > "$packages"
19+
packages="$(wget -qO- "$packagesUrl")"
2120

2221
# our own "supported" window is 18 months from the most recent release because upstream doesn't have a good guideline, but appears to only release maintenance updates for 2-3 years after the initial release
2322
# in addition, maintenance releases are _usually_ less than a year apart; from 4.7+ there's a handful of outliers, like 4.7.3->4.7.4 at ~14 months, 6.4->6.5 at ~15 months, etc
@@ -31,8 +30,8 @@ eols=()
3130
dateFormat='%Y-%m-%d'
3231

3332
for version in "${versions[@]}"; do
34-
fullVersion="$(grep -E '<a href="(gcc-)?'"$version." "$packages" | sed -r 's!.*<a href="(gcc-)?([^"/]+)/?".*!\2!' | sort -V | tail -1)"
35-
lastModified="$(grep -Em1 '<a href="(gcc-)?'"$fullVersion"'/"' "$packages" | awk -F ' +' '{ print $2 }')"
33+
fullVersion="$(grep -E '<a href="(gcc-)?'"$version." <<<"$packages" | sed -r 's!.*<a href="(gcc-)?([^"/]+)/?".*!\2!' | sort -V | tail -1)"
34+
lastModified="$(grep -Em1 '<a href="(gcc-)?'"$fullVersion"'/"' <<<"$packages" | awk -F ' +' '{ print $2 }')"
3635
lastModified="$(date -d "$lastModified" +"$dateFormat")"
3736

3837
releaseAge="$(( $today - $(date +'%s' -d "$lastModified") ))"
@@ -85,5 +84,3 @@ if [ ${#eols[@]} -gt 0 ]; then
8584
echo
8685
} >&2
8786
fi
88-
89-
rm "$packages"

0 commit comments

Comments
 (0)