update.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/bin/bash
  2. set -e
  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. [busybox]='https://github.com/jpetazzo/docker-busybox'
  23. [centos]='https://github.com/CentOS/sig-cloud-instance-images'
  24. [cirros]='https://github.com/ewindisch/docker-cirros'
  25. [clojure]='https://github.com/Quantisan/docker-clojure'
  26. [crate]='https://github.com/crate/docker-crate'
  27. [crux]='https://github.com/therealprologic/docker-crux'
  28. [debian]='https://github.com/tianon/docker-brew-debian'
  29. [docker-dev]='https://github.com/docker/docker'
  30. [fedora]='https://github.com/lsm5/docker-brew-fedora'
  31. [glassfish]='https://github.com/aws/aws-eb-glassfish'
  32. [haskell]='https://github.com/freebroccolo/docker-haskell'
  33. [hipache]='https://github.com/dotcloud/hipache'
  34. [hylang]='https://github.com/hylang/hy'
  35. [iojs]='https://github.com/iojs/docker-iojs'
  36. [irssi]='https://github.com/jfrazelle/irssi'
  37. [jenkins]='https://github.com/cloudbees/jenkins-ci.org-docker'
  38. [jetty]='https://github.com/appropriate/docker-jetty'
  39. [jruby]='https://github.com/cpuguy83/docker-jruby'
  40. [mageia]='https://github.com/juanluisbaptiste/docker-brew-mageia'
  41. [maven]='https://github.com/carlossg/docker-maven'
  42. [mono]='https://github.com/mono/docker'
  43. [neurodebian]='https://github.com/neurodebian/dockerfiles'
  44. [nginx]='https://github.com/nginxinc/docker-nginx'
  45. [node]='https://github.com/joyent/docker-node'
  46. [odoo]='https://github.com/odoo/docker'
  47. [opensuse]='https://github.com/openSUSE/docker-containers-build'
  48. [oraclelinux]='https://github.com/oracle/docker'
  49. [perl]='https://github.com/Perl/docker-perl'
  50. [r-base]='https://github.com/rocker-org/rocker'
  51. [rakudo]='https://github.com/perl6/docker'
  52. [registry]='https://github.com/docker/docker-registry'
  53. [rethinkdb]='https://github.com/stuartpb/rethinkdb-dockerfiles'
  54. [sonarqube]='https://github.com/SonarSource/docker-sonarqube'
  55. [swarm]='https://github.com/docker/swarm-library-image'
  56. [thrift]='https://github.com/ahawkins/docker-thrift'
  57. [ubuntu-debootstrap]='https://github.com/tianon/docker-brew-ubuntu-debootstrap'
  58. [ubuntu-upstart]='https://github.com/tianon/dockerfiles'
  59. [ubuntu]='https://github.com/tianon/docker-brew-ubuntu-core'
  60. [websphere-liberty]='https://github.com/WASdev/ci.docker'
  61. )
  62. dockerLatest="$(curl -sSL 'https://get.docker.com/latest')"
  63. for repo in "${repos[@]}"; do
  64. if [ -x "$repo/update.sh" ]; then
  65. ( set -x; "$repo/update.sh" )
  66. fi
  67. if [ -e "$repo/content.md" ]; then
  68. gitRepo="${otherRepos[$repo]}"
  69. if [ -z "$gitRepo" ]; then
  70. gitRepo="https://github.com/docker-library/$repo"
  71. fi
  72. mailingList="$(cat "$repo/mailing-list.md" 2>/dev/null || true)"
  73. if [ "$mailingList" ]; then
  74. mailingList=" $mailingList "
  75. else
  76. mailingList=' '
  77. fi
  78. dockerVersions="$(cat "$repo/docker-versions.md" 2>/dev/null || cat "$helperDir/docker-versions.md")"
  79. userFeedback="$(cat "$repo/user-feedback.md" 2>/dev/null || cat "$helperDir/user-feedback.md")"
  80. license="$(cat "$repo/license.md" 2>/dev/null || true)"
  81. if [ "$license" ]; then
  82. license=$'\n\n''# License'$'\n\n'"$license"
  83. fi
  84. logo=
  85. if [ -e "$repo/logo.png" ]; then
  86. logo="![logo](https://raw.githubusercontent.com/docker-library/docs/master/$repo/logo.png)"
  87. fi
  88. compose=
  89. composeYml=
  90. if [ -f "$repo/docker-compose.yml" ]; then
  91. compose="$(cat "$repo/compose.md" 2>/dev/null || cat "$helperDir/compose.md")"
  92. composeYml="$(sed 's/^/\t/' "$repo/docker-compose.yml")"
  93. fi
  94. cp -v "$helperDir/template.md" "$repo/README.md"
  95. echo ' TAGS => generate-dockerfile-links-partial.sh'
  96. replace_field "$repo" 'TAGS' "$("$helperDir/generate-dockerfile-links-partial.sh" "$repo")"
  97. echo ' CONTENT => '"$repo"'/content.md'
  98. replace_field "$repo" 'CONTENT' "$(cat "$repo/content.md")"
  99. echo ' VARIANT => variant.sh'
  100. replace_field "$repo" 'VARIANT' "$("$helperDir/variant.sh" "$repo")"
  101. # has to be after CONTENT because it's contained in content.md
  102. echo " LOGO => $logo"
  103. replace_field "$repo" 'LOGO' "$logo" '\s*'
  104. echo ' COMPOSE => '"$repo"'/compose.md'
  105. replace_field "$repo" 'COMPOSE' "$compose"
  106. echo ' COMPOSE-YML => '"$repo"'/docker-compose.yml'
  107. replace_field "$repo" 'COMPOSE-YML' "$composeYml"
  108. echo ' DOCKER-VERSIONS => '"$repo"'/docker-versions.md'
  109. replace_field "$repo" 'DOCKER-VERSIONS' "$dockerVersions"
  110. echo ' DOCKER-LATEST => "'"$dockerLatest"'"'
  111. replace_field "$repo" 'DOCKER-LATEST' "$dockerLatest"
  112. echo ' LICENSE => '"$repo"'/license.md'
  113. replace_field "$repo" 'LICENSE' "$license"
  114. echo ' USER-FEEDBACK => '"$repo"'/user-feedback.md'
  115. replace_field "$repo" 'USER-FEEDBACK' "$userFeedback"
  116. echo ' MAILING-LIST => '"$repo"'/mailing-list.md'
  117. replace_field "$repo" 'MAILING-LIST' "$mailingList" '\s*'
  118. echo ' REPO => "'"$repo"'"'
  119. replace_field "$repo" 'REPO' "$repo"
  120. echo ' GITHUB-REPO => "'"$gitRepo"'"'
  121. replace_field "$repo" 'GITHUB-REPO' "$gitRepo"
  122. echo
  123. else
  124. echo >&2 "skipping $repo: missing repo/content.md"
  125. fi
  126. done