Skip to content

Commit 06eb255

Browse files
authored
Update to use newer manifest file format (#233)
The new format is base on based on RFC 2822. See: https://github.com/docker-library/official-images#instruction-format Also: * No longer hardcodes the variant names (onbuild slim wheezy) * Sorts version numbers which puts the higher version numbers first * Adds link to generate-stackbrew-library.sh in manifest header * Don't script against `ls` when determining variants * And some other code improvements
1 parent 0e76bf9 commit 06eb255

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

generate-stackbrew-library.sh

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,62 @@ array_6_6='6 latest';
99

1010
cd $(cd ${0%/*} && pwd -P);
1111

12+
self="$(basename "$BASH_SOURCE")"
13+
1214
versions=( */ )
1315
versions=( "${versions[@]%/}" )
14-
url='git://github.com/nodejs/docker-node'
16+
url='https://github.com/nodejs/docker-node'
17+
18+
# sort version numbers with highest first
19+
IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -r) ); unset IFS
20+
21+
# get the most recent commit which modified any of "$@"
22+
fileCommit() {
23+
git log -1 --format='format:%H' HEAD -- "$@"
24+
}
25+
26+
echo "# this file is generated via ${url}/blob/$(fileCommit "$self")/$self"
27+
echo
28+
echo "Maintainers: The Node.js Docker Team <${url}> (@nodejs)"
29+
echo "GitRepo: ${url}.git"
30+
echo
1531

16-
echo '# maintainer: Node.js Docker Team <https://github.com/nodejs/docker-node> (@nodejs)'
32+
# prints "$2$1$3$1...$N"
33+
join() {
34+
local sep="$1"; shift
35+
local out; printf -v out "${sep//%/%%}%s" "$@"
36+
echo "${out#$sep}"
37+
}
1738

1839
for version in "${versions[@]}"; do
19-
if [[ "$version" == "docs" ]]; then
20-
continue
21-
fi
40+
# Skip "docs" and other non-docker directories
41+
[ -f "$version/Dockerfile" ] || continue
42+
2243
eval stub=$(echo "$version" | awk -F. '{ print "$array_" $1 "_" $2 }');
23-
commit="$(git log -1 --format='format:%H' -- "$version")"
44+
commit="$(fileCommit "$version")"
2445
fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)"
2546

2647
versionAliases=( $fullVersion $version ${stub} )
27-
48+
49+
echo "Tags: $(join ', ' "${versionAliases[@]}")"
50+
echo "GitCommit: ${commit}"
51+
echo "Directory: ${version}"
2852
echo
29-
for va in "${versionAliases[@]}"; do
30-
echo "$va: ${url}@${commit} $version"
31-
done
3253

33-
for variant in onbuild slim wheezy; do
34-
commit="$(git log -1 --format='format:%H' -- "$version/$variant")"
54+
variants=$(echo $version/*/ | xargs -n1 basename)
55+
for variant in $variants; do
56+
# Skip non-docker directories
57+
[ -f "$version/$variant/Dockerfile" ] || continue
58+
59+
commit="$(fileCommit "$version/$variant")"
60+
61+
slash='/'
62+
variantAliases=( "${versionAliases[@]/%/-${variant//$slash/-}}" )
63+
variantAliases=( "${variantAliases[@]//latest-/}" )
64+
65+
echo "Tags: $(join ', ' "${variantAliases[@]}")"
66+
echo "GitCommit: ${commit}"
67+
echo "Directory: ${version}/${variant}"
3568
echo
36-
for va in "${versionAliases[@]}"; do
37-
if [ "$va" = 'latest' ]; then
38-
va="$variant"
39-
else
40-
va="$va-$variant"
41-
fi
42-
echo "$va: ${url}@${commit} $version/$variant"
43-
done
4469
done
4570
done

0 commit comments

Comments
 (0)