update.sh 6.2 KB

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