update.sh 7.4 KB

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