update.sh 5.1 KB

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