update.sh 7.1 KB

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