Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bashbrew to gather the canonical list of supported suites #164

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apply-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fi
if [ "$#" -eq 0 ]; then
versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)"
eval "set -- $versions"

# TODO make this cleaner
rm -rf debian ubuntu
fi

generated_warning() {
Expand Down
37 changes: 36 additions & 1 deletion versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,42 @@ set -Eeuo pipefail

distsSuites=( "$@" )
if [ "${#distsSuites[@]}" -eq 0 ]; then
distsSuites=( */*/ )
# when run without arguments, let's use "bashbrew" to get the canonical list of currently supported suites/codenames
bashbrew --version > /dev/null
if [ -z "${BASHBREW_LIBRARY:-}" ] || [ ! -s "$BASHBREW_LIBRARY/debian" ] || [ ! -s "$BASHBREW_LIBRARY/ubuntu" ]; then
tempDir="$(mktemp -d)"
trap 'rm -rf "$tempDir"' EXIT
wget -qO "$tempDir/debian" 'https://github.com/docker-library/official-images/raw/HEAD/library/debian'
wget -qO "$tempDir/ubuntu" 'https://github.com/docker-library/official-images/raw/HEAD/library/ubuntu'
export BASHBREW_LIBRARY="$tempDir"
bashbrew cat debian ubuntu > /dev/null
fi
dists="$(
bashbrew cat debian ubuntu --format '
{{- range .Entries -}}
{{- $.Tags "" false . | json -}}
{{- "\n" -}}
{{- end -}}
' | jq -r '
map(select(test("
# a few tags we explicitly want to ignore in our search for codenames
:(
experimental | rc-buggy # not a release
|
latest | .*stable | devel | rolling | testing # stable/development/rolling aliases
|
.* - .* # anything with a hyphen

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the "x" option causes the regular expression engine to ignore whitespace, but is there a reason to not just have .*-.* or even just - here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought .*-.* looked a little compressed and this helped it be more obvious, personally, but I don't feel strongly about it (especially with the comment out to the side which makes it pretty obvious 😂) -- we can't do just - because of the :+$ anchoring outside the parenthesis here (we're matching the full "tag" portion of the image references explicitly with this).

|
[0-9].* # likewise with numerics
)$
"; "x") | not))
| .[0] // empty # then we filter to the first leftover in each tag group and it should be the codename
| sub(":"; "/")
| @sh
'
)"
# TODO expand this and do our supported architectures detection here too, while we've already done the lookups? Ubuntu version number lookups via this method too? (unfortunately we can't map Debian codenames to aliases like "stable" this way)
eval "distsSuites=( $dists )"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this safer than mapfile/readarray?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more reliable in my experience (and certainly no less safe).

json='{}'
else
json="$(< versions.json)"
Expand Down
Loading