update.sh 5.0 KB

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