update.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. [elixir]='https://github.com/c0b/docker-elixir'
  33. [erlang]='https://github.com/c0b/docker-erlang-otp'
  34. [fedora]='https://github.com/lsm5/docker-brew-fedora'
  35. [gazebo]='https://github.com/osrf/docker_images'
  36. [glassfish]='https://github.com/aws/aws-eb-glassfish'
  37. [haskell]='https://github.com/freebroccolo/docker-haskell'
  38. [hipache]='https://github.com/dotcloud/hipache'
  39. [hylang]='https://github.com/hylang/hy'
  40. [iojs]='https://github.com/nodejs/docker-iojs'
  41. [irssi]='https://github.com/jfrazelle/irssi'
  42. [jenkins]='https://github.com/cloudbees/jenkins-ci.org-docker'
  43. [jetty]='https://github.com/appropriate/docker-jetty'
  44. [joomla]='https://github.com/joomla/docker-joomla'
  45. [jruby]='https://github.com/cpuguy83/docker-jruby'
  46. [kaazing-gateway]='https://github.com/kaazing/gateway.docker'
  47. [mageia]='https://github.com/juanluisbaptiste/docker-brew-mageia'
  48. [maven]='https://github.com/carlossg/docker-maven'
  49. [mono]='https://github.com/mono/docker'
  50. [neo4j]='https://github.com/neo4j/docker-neo4j'
  51. [neurodebian]='https://github.com/neurodebian/dockerfiles'
  52. [nginx]='https://github.com/nginxinc/docker-nginx'
  53. [node]='https://github.com/nodejs/docker-node'
  54. [nuxeo]='https://github.com/nuxeo/docker-nuxeor'
  55. [odoo]='https://github.com/odoo/docker'
  56. [opensuse]='https://github.com/openSUSE/docker-containers-build'
  57. [oraclelinux]='https://github.com/oracle/docker'
  58. [perl]='https://github.com/Perl/docker-perl'
  59. [photon]='https://github.com/frapposelli/photon-docker-image'
  60. [r-base]='https://github.com/rocker-org/rocker'
  61. [rakudo]='https://github.com/perl6/docker'
  62. [registry]='https://github.com/docker/docker-registry'
  63. [rethinkdb]='https://github.com/stuartpb/rethinkdb-dockerfiles'
  64. [rocket.chat]='https://github.com/RocketChat/Docker.Official.Image'
  65. [ros]='https://github.com/osrf/docker_images'
  66. [sentry]='https://github.com/getsentry/docker-sentry'
  67. [solr]='https://github.com/docker-solr/solr'
  68. [sonarqube]='https://github.com/SonarSource/docker-sonarqube'
  69. [sourcemage]='https://github.com/vaygr/docker-sourcemage'
  70. [swarm]='https://github.com/docker/swarm-library-image'
  71. [thrift]='https://github.com/ahawkins/docker-thrift'
  72. [ubuntu-debootstrap]='https://github.com/tianon/docker-brew-ubuntu-debootstrap'
  73. [ubuntu-upstart]='https://github.com/tianon/dockerfiles'
  74. [ubuntu]='https://github.com/tianon/docker-brew-ubuntu-core'
  75. [websphere-liberty]='https://github.com/WASdev/ci.docker'
  76. )
  77. dockerLatest="$(curl -fsSL 'https://get.docker.com/latest')"
  78. for repo in "${repos[@]}"; do
  79. if [ -x "$repo/update.sh" ]; then
  80. ( set -x; "$repo/update.sh" )
  81. fi
  82. if [ -e "$repo/content.md" ]; then
  83. gitRepo="${otherRepos[$repo]}"
  84. if [ -z "$gitRepo" ]; then
  85. gitRepo="https://github.com/docker-library/$repo"
  86. fi
  87. mailingList="$(cat "$repo/mailing-list.md" 2>/dev/null || true)"
  88. if [ "$mailingList" ]; then
  89. mailingList=" $mailingList "
  90. else
  91. mailingList=' '
  92. fi
  93. dockerVersions="$(cat "$repo/docker-versions.md" 2>/dev/null || cat "$helperDir/docker-versions.md")"
  94. userFeedback="$(cat "$repo/user-feedback.md" 2>/dev/null || cat "$helperDir/user-feedback.md")"
  95. license="$(cat "$repo/license.md" 2>/dev/null || true)"
  96. if [ "$license" ]; then
  97. license=$'\n\n''# License'$'\n\n'"$license"
  98. fi
  99. logo=
  100. logoFile=
  101. for f in png svg; do
  102. if [ -e "$repo/logo.$f" ]; then
  103. logoFile="$repo/logo.$f"
  104. break
  105. fi
  106. done
  107. if [ "$logoFile" ]; then
  108. logoCommit="$(git log -1 --format='format:%H' -- "$logoFile" 2>/dev/null || true)"
  109. [ "$logoCommit" ] || logoCommit='master'
  110. if [ "${logoFile##*.}" = 'svg' ]; then
  111. logo="![logo](https://rawgit.com/docker-library/docs/$logoCommit/$logoFile)"
  112. else
  113. logo="![logo](https://raw.githubusercontent.com/docker-library/docs/$logoCommit/$logoFile)"
  114. fi
  115. fi
  116. compose=
  117. composeYml=
  118. if [ -f "$repo/docker-compose.yml" ]; then
  119. compose="$(cat "$repo/compose.md" 2>/dev/null || cat "$helperDir/compose.md")"
  120. composeYml=$'```yaml\n'"$(cat "$repo/docker-compose.yml")"$'\n```'
  121. fi
  122. deprecated=
  123. if [ -f "$repo/deprecated.md" ]; then
  124. deprecated=$'# **DEPRECATED**\n\n'
  125. deprecated+="$(cat "$repo/deprecated.md")"
  126. deprecated+=$'\n\n'
  127. fi
  128. { echo -n "$deprecated"; cat "$helperDir/template.md"; } > "$repo/README.md"
  129. echo ' TAGS => generate-dockerfile-links-partial.sh'
  130. partial="$("$helperDir/generate-dockerfile-links-partial.sh" "$repo")"
  131. [ "$partial" ]
  132. replace_field "$repo" 'TAGS' "$partial"
  133. echo ' CONTENT => '"$repo"'/content.md'
  134. replace_field "$repo" 'CONTENT' "$(cat "$repo/content.md")"
  135. echo ' VARIANT => variant.sh'
  136. replace_field "$repo" 'VARIANT' "$("$helperDir/variant.sh" "$repo")"
  137. # has to be after CONTENT because it's contained in content.md
  138. echo " LOGO => $logo"
  139. replace_field "$repo" 'LOGO' "$logo" '\s*'
  140. echo ' COMPOSE => '"$repo"'/compose.md'
  141. replace_field "$repo" 'COMPOSE' "$compose"
  142. echo ' COMPOSE-YML => '"$repo"'/docker-compose.yml'
  143. replace_field "$repo" 'COMPOSE-YML' "$composeYml"
  144. echo ' DOCKER-VERSIONS => '"$repo"'/docker-versions.md'
  145. replace_field "$repo" 'DOCKER-VERSIONS' "$dockerVersions"
  146. echo ' DOCKER-LATEST => "'"$dockerLatest"'"'
  147. replace_field "$repo" 'DOCKER-LATEST' "$dockerLatest"
  148. echo ' LICENSE => '"$repo"'/license.md'
  149. replace_field "$repo" 'LICENSE' "$license"
  150. echo ' USER-FEEDBACK => '"$repo"'/user-feedback.md'
  151. replace_field "$repo" 'USER-FEEDBACK' "$userFeedback"
  152. echo ' MAILING-LIST => '"$repo"'/mailing-list.md'
  153. replace_field "$repo" 'MAILING-LIST' "$mailingList" '\s*'
  154. echo ' REPO => "'"$repo"'"'
  155. replace_field "$repo" 'REPO' "$repo"
  156. echo ' GITHUB-REPO => "'"$gitRepo"'"'
  157. replace_field "$repo" 'GITHUB-REPO' "$gitRepo"
  158. echo
  159. else
  160. echo >&2 "skipping $repo: missing repo/content.md"
  161. fi
  162. done