Update variant.sh with a bit more flexibility (so we can have "variant override" files per-image)

This commit is contained in:
Tianon Gravi 2015-07-16 11:47:12 -07:00
parent 112dd86402
commit 7b731dc9b2
1 changed files with 12 additions and 7 deletions

View File

@ -9,6 +9,7 @@ if [ -z "$repo" ]; then
fi
dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
repoDir="$dir/../$repo"
url='https://raw.githubusercontent.com/docker-library/official-images/master/library/'"$repo"
IFS=$'\n'
@ -17,12 +18,15 @@ unset IFS
text=
for tag in "${tags[@]}"; do
if [ -f "$dir/variant-${tag}.md" ]; then
for f in "$repoDir/variant-$tag.md" "$dir/variant-$tag.md"; do
if [ -f "$f" ]; then
text+=$'\n' # give a little space
# because parameter expansion eats the trailing newline
text+="$(<"$dir/variant-${tag}.md")"$'\n'
text+="$(<"$f")"$'\n'
break
fi
done
done
if [ "$text" ]; then
latest=($(curl -fsSL "$url" | grep "latest.*github.com" | sed -e 's!git://github.com/!!' -e 's/@/ /' -))
if [ -z "latest" ]; then
@ -34,9 +38,10 @@ if [ "$text" ]; then
echo
echo
if [ "$baseImage" = "buildpack-deps" ]; then
cat "$dir/variant-buildpacks.md"
f='variant-buildpacks.md'
else
cat "$dir/variant.md"
f='variant.md'
fi
[ -f "$repoDir/$f" ] && cat "$repoDir/$f" || cat "$dir/$f"
echo "$text"
fi