update.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #!/bin/bash
  2. set -eo pipefail
  3. cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. helperDir='.template-helpers'
  5. repos=( "$@" )
  6. if [ ${#repos[@]} -eq 0 ]; then
  7. repos=( */ )
  8. fi
  9. repos=( "${repos[@]%/}" )
  10. replace_field() {
  11. repo="$1"
  12. field="$2"
  13. content="$3"
  14. extraSed="${4:-}"
  15. sed_escaped_value="$(echo "$content" | sed 's/[\/&]/\\&/g')"
  16. sed_escaped_value="${sed_escaped_value//$'\n'/\\n}"
  17. sed -ri "s/${extraSed}%%${field}%%${extraSed}/$sed_escaped_value/g" "$repo/README.md"
  18. }
  19. declare -A otherRepos=(
  20. [aerospike]='https://github.com/aerospike/aerospike-server.docker'
  21. [alpine]='https://github.com/gliderlabs/docker-alpine'
  22. [arangodb]='https://github.com/arangodb/arangodb-docker'
  23. [bonita]='https://github.com/Bonitasoft-Community/docker_bonita'
  24. [busybox]='https://github.com/jpetazzo/docker-busybox'
  25. [centos]='https://github.com/CentOS/sig-cloud-instance-images'
  26. [cirros]='https://github.com/ewindisch/docker-cirros'
  27. [clojure]='https://github.com/Quantisan/docker-clojure'
  28. [crate]='https://github.com/crate/docker-crate'
  29. [crux]='https://github.com/therealprologic/docker-crux'
  30. [debian]='https://github.com/tianon/docker-brew-debian'
  31. [docker-dev]='https://github.com/docker/docker'
  32. [erlang]='https://github.com/c0b/docker-erlang-otp'
  33. [fedora]='https://github.com/lsm5/docker-brew-fedora'
  34. [gazebo]='https://github.com/osrf/docker_images'
  35. [glassfish]='https://github.com/aws/aws-eb-glassfish'
  36. [haskell]='https://github.com/freebroccolo/docker-haskell'
  37. [hipache]='https://github.com/dotcloud/hipache'
  38. [hylang]='https://github.com/hylang/hy'
  39. [iojs]='https://github.com/nodejs/docker-iojs'
  40. [irssi]='https://github.com/jfrazelle/irssi'
  41. [jenkins]='https://github.com/cloudbees/jenkins-ci.org-docker'
  42. [jetty]='https://github.com/appropriate/docker-jetty'
  43. [joomla]='https://github.com/joomla/docker-joomla'
  44. [jruby]='https://github.com/cpuguy83/docker-jruby'
  45. [kaazing-gateway]='https://github.com/kaazing/gateway.docker'
  46. [mageia]='https://github.com/juanluisbaptiste/docker-brew-mageia'
  47. [maven]='https://github.com/carlossg/docker-maven'
  48. [mono]='https://github.com/mono/docker'
  49. [neo4j]='https://github.com/neo4j/docker-neo4j'
  50. [neurodebian]='https://github.com/neurodebian/dockerfiles'
  51. [nginx]='https://github.com/nginxinc/docker-nginx'
  52. [node]='https://github.com/nodejs/docker-node'
  53. [nuxeo]='https://github.com/nuxeo/docker-nuxeor'
  54. [odoo]='https://github.com/odoo/docker'
  55. [opensuse]='https://github.com/openSUSE/docker-containers-build'
  56. [oraclelinux]='https://github.com/oracle/docker'
  57. [perl]='https://github.com/Perl/docker-perl'
  58. [photon]='https://github.com/frapposelli/photon-docker-image'
  59. [r-base]='https://github.com/rocker-org/rocker'
  60. [rakudo]='https://github.com/perl6/docker'
  61. [registry]='https://github.com/docker/docker-registry'
  62. [rethinkdb]='https://github.com/stuartpb/rethinkdb-dockerfiles'
  63. [rocket.chat]='https://github.com/RocketChat/Docker.Official.Image'
  64. [ros]='https://github.com/osrf/docker_images'
  65. [sentry]='https://github.com/getsentry/docker-sentry'
  66. [solr]='https://github.com/docker-solr/solr'
  67. [sonarqube]='https://github.com/SonarSource/docker-sonarqube'
  68. [sourcemage]='https://github.com/vaygr/docker-sourcemage'
  69. [swarm]='https://github.com/docker/swarm-library-image'
  70. [thrift]='https://github.com/ahawkins/docker-thrift'
  71. [ubuntu-debootstrap]='https://github.com/tianon/docker-brew-ubuntu-debootstrap'
  72. [ubuntu-upstart]='https://github.com/tianon/dockerfiles'
  73. [ubuntu]='https://github.com/tianon/docker-brew-ubuntu-core'
  74. [websphere-liberty]='https://github.com/WASdev/ci.docker'
  75. )
  76. dockerLatest="$(curl -fsSL 'https://get.docker.com/latest')"
  77. for repo in "${repos[@]}"; do
  78. if [ -x "$repo/update.sh" ]; then
  79. ( set -x; "$repo/update.sh" )
  80. fi
  81. if [ -e "$repo/content.md" ]; then
  82. gitRepo="${otherRepos[$repo]}"
  83. if [ -z "$gitRepo" ]; then
  84. gitRepo="https://github.com/docker-library/$repo"
  85. fi
  86. mailingList="$(cat "$repo/mailing-list.md" 2>/dev/null || true)"
  87. if [ "$mailingList" ]; then
  88. mailingList=" $mailingList "
  89. else
  90. mailingList=' '
  91. fi
  92. dockerVersions="$(cat "$repo/docker-versions.md" 2>/dev/null || cat "$helperDir/docker-versions.md")"
  93. userFeedback="$(cat "$repo/user-feedback.md" 2>/dev/null || cat "$helperDir/user-feedback.md")"
  94. license="$(cat "$repo/license.md" 2>/dev/null || true)"
  95. if [ "$license" ]; then
  96. license=$'\n\n''# License'$'\n\n'"$license"
  97. fi
  98. logo=
  99. logoFile=
  100. for f in png svg; do
  101. if [ -e "$repo/logo.$f" ]; then
  102. logoFile="$repo/logo.$f"
  103. break
  104. fi
  105. done
  106. if [ "$logoFile" ]; then
  107. logoCommit="$(git log -1 --format='format:%H' -- "$logoFile" 2>/dev/null || true)"
  108. [ "$logoCommit" ] || logoCommit='master'
  109. if [ "${logoFile##*.}" = 'svg' ]; then
  110. logo="![logo](https://rawgit.com/docker-library/docs/$logoCommit/$logoFile)"
  111. else
  112. logo="![logo](https://raw.githubusercontent.com/docker-library/docs/$logoCommit/$logoFile)"
  113. fi
  114. fi
  115. compose=
  116. composeYml=
  117. if [ -f "$repo/docker-compose.yml" ]; then
  118. compose="$(cat "$repo/compose.md" 2>/dev/null || cat "$helperDir/compose.md")"
  119. composeYml=$'```yaml\n'"$(cat "$repo/docker-compose.yml")"$'\n```'
  120. fi
  121. cp -v "$helperDir/template.md" "$repo/README.md"
  122. echo ' TAGS => generate-dockerfile-links-partial.sh'
  123. partial="$("$helperDir/generate-dockerfile-links-partial.sh" "$repo")"
  124. [ "$partial" ]
  125. replace_field "$repo" 'TAGS' "$partial"
  126. echo ' CONTENT => '"$repo"'/content.md'
  127. replace_field "$repo" 'CONTENT' "$(cat "$repo/content.md")"
  128. echo ' VARIANT => variant.sh'
  129. replace_field "$repo" 'VARIANT' "$("$helperDir/variant.sh" "$repo")"
  130. # has to be after CONTENT because it's contained in content.md
  131. echo " LOGO => $logo"
  132. replace_field "$repo" 'LOGO' "$logo" '\s*'
  133. echo ' COMPOSE => '"$repo"'/compose.md'
  134. replace_field "$repo" 'COMPOSE' "$compose"
  135. echo ' COMPOSE-YML => '"$repo"'/docker-compose.yml'
  136. replace_field "$repo" 'COMPOSE-YML' "$composeYml"
  137. echo ' DOCKER-VERSIONS => '"$repo"'/docker-versions.md'
  138. replace_field "$repo" 'DOCKER-VERSIONS' "$dockerVersions"
  139. echo ' DOCKER-LATEST => "'"$dockerLatest"'"'
  140. replace_field "$repo" 'DOCKER-LATEST' "$dockerLatest"
  141. echo ' LICENSE => '"$repo"'/license.md'
  142. replace_field "$repo" 'LICENSE' "$license"
  143. echo ' USER-FEEDBACK => '"$repo"'/user-feedback.md'
  144. replace_field "$repo" 'USER-FEEDBACK' "$userFeedback"
  145. echo ' MAILING-LIST => '"$repo"'/mailing-list.md'
  146. replace_field "$repo" 'MAILING-LIST' "$mailingList" '\s*'
  147. echo ' REPO => "'"$repo"'"'
  148. replace_field "$repo" 'REPO' "$repo"
  149. echo ' GITHUB-REPO => "'"$gitRepo"'"'
  150. replace_field "$repo" 'GITHUB-REPO' "$gitRepo"
  151. echo
  152. else
  153. echo >&2 "skipping $repo: missing repo/content.md"
  154. fi
  155. done