update.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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/md5/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. [swarm]='https://github.com/docker/swarm-library-image'
  55. [thrift]='https://github.com/ahawkins/docker-thrift'
  56. [ubuntu-debootstrap]='https://github.com/tianon/docker-brew-ubuntu-debootstrap'
  57. [ubuntu-upstart]='https://github.com/tianon/dockerfiles'
  58. [ubuntu]='https://github.com/tianon/docker-brew-ubuntu-core'
  59. [websphere-liberty]='https://github.com/WASdev/ci.docker'
  60. )
  61. dockerLatest="$(curl -sSL 'https://get.docker.com/latest')"
  62. for repo in "${repos[@]}"; do
  63. if [ -x "$repo/update.sh" ]; then
  64. ( set -x; "$repo/update.sh" )
  65. fi
  66. if [ -e "$repo/content.md" ]; then
  67. gitRepo="${otherRepos[$repo]}"
  68. if [ -z "$gitRepo" ]; then
  69. gitRepo="https://github.com/docker-library/$repo"
  70. fi
  71. mailingList="$(cat "$repo/mailing-list.md" 2>/dev/null || true)"
  72. if [ "$mailingList" ]; then
  73. mailingList=" $mailingList "
  74. else
  75. mailingList=' '
  76. fi
  77. dockerVersions="$(cat "$repo/docker-versions.md" 2>/dev/null || cat "$helperDir/docker-versions.md")"
  78. userFeedback="$(cat "$repo/user-feedback.md" 2>/dev/null || cat "$helperDir/user-feedback.md")"
  79. license="$(cat "$repo/license.md" 2>/dev/null || true)"
  80. if [ "$license" ]; then
  81. license=$'\n\n''# License'$'\n\n'"$license"
  82. fi
  83. logo=
  84. if [ -e "$repo/logo.png" ]; then
  85. logo="![logo](https://raw.githubusercontent.com/docker-library/docs/master/$repo/logo.png)"
  86. fi
  87. compose=
  88. composeYml=
  89. if [ -f "$repo/docker-compose.yml" ]; then
  90. compose="$(cat "$repo/compose.md" 2>/dev/null || cat "$helperDir/compose.md")"
  91. composeYml="$(sed 's/^/\t/' "$repo/docker-compose.yml")"
  92. fi
  93. cp -v "$helperDir/template.md" "$repo/README.md"
  94. echo ' TAGS => generate-dockerfile-links-partial.sh'
  95. replace_field "$repo" 'TAGS' "$("$helperDir/generate-dockerfile-links-partial.sh" "$repo")"
  96. echo ' CONTENT => '"$repo"'/content.md'
  97. replace_field "$repo" 'CONTENT' "$(cat "$repo/content.md")"
  98. echo ' VARIANT => variant.sh'
  99. replace_field "$repo" 'VARIANT' "$("$helperDir/variant.sh" "$repo")"
  100. # has to be after CONTENT because it's contained in content.md
  101. echo " LOGO => $logo"
  102. replace_field "$repo" 'LOGO' "$logo" '\s*'
  103. echo ' COMPOSE => '"$repo"'/compose.md'
  104. replace_field "$repo" 'COMPOSE' "$compose"
  105. echo ' COMPOSE-YML => '"$repo"'/docker-compose.yml'
  106. replace_field "$repo" 'COMPOSE-YML' "$composeYml"
  107. echo ' DOCKER-VERSIONS => '"$repo"'/docker-versions.md'
  108. replace_field "$repo" 'DOCKER-VERSIONS' "$dockerVersions"
  109. echo ' DOCKER-LATEST => "'"$dockerLatest"'"'
  110. replace_field "$repo" 'DOCKER-LATEST' "$dockerLatest"
  111. echo ' LICENSE => '"$repo"'/license.md'
  112. replace_field "$repo" 'LICENSE' "$license"
  113. echo ' USER-FEEDBACK => '"$repo"'/user-feedback.md'
  114. replace_field "$repo" 'USER-FEEDBACK' "$userFeedback"
  115. echo ' MAILING-LIST => '"$repo"'/mailing-list.md'
  116. replace_field "$repo" 'MAILING-LIST' "$mailingList" '\s*'
  117. echo ' REPO => "'"$repo"'"'
  118. replace_field "$repo" 'REPO' "$repo"
  119. echo ' GITHUB-REPO => "'"$gitRepo"'"'
  120. replace_field "$repo" 'GITHUB-REPO' "$gitRepo"
  121. echo
  122. else
  123. echo >&2 "skipping $repo: missing repo/content.md"
  124. fi
  125. done