update.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/bash
  2. set -e
  3. cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. repos=( "$@" )
  5. if [ ${#repos[@]} -eq 0 ]; then
  6. repos=( */ )
  7. fi
  8. repos=( "${repos[@]%/}" )
  9. replace_field() {
  10. repo="$1"
  11. field="$2"
  12. content="$3"
  13. extraSed="${4:-}"
  14. sed_escaped_value="$(echo "$content" | sed 's/[\/&]/\\&/g')"
  15. sed_escaped_value="${sed_escaped_value//$'\n'/\\n}"
  16. sed -ri "s/${extraSed}%%${field}%%${extraSed}/$sed_escaped_value/g" "$repo/README.md"
  17. }
  18. declare -A otherRepos=(
  19. [busybox]='https://github.com/jpetazzo/docker-busybox'
  20. [centos]='https://github.com/CentOS/sig-cloud-instance-images'
  21. [cirros]='https://github.com/ewindisch/docker-cirros'
  22. [clojure]='https://github.com/Quantisan/docker-clojure'
  23. [crate]='https://github.com/crate/docker-crate'
  24. [crux]='https://github.com/therealprologic/docker-crux'
  25. [debian]='https://github.com/tianon/docker-brew-debian'
  26. [docker-dev]='https://github.com/docker/docker'
  27. [fedora]='https://github.com/lsm5/docker-brew-fedora'
  28. [haskell]='https://github.com/darinmorrison/docker-haskell'
  29. [hipache]='https://github.com/dotcloud/hipache'
  30. [hylang]='https://github.com/hylang/hy'
  31. [jenkins]='https://github.com/cloudbees/jenkins-ci.org-docker'
  32. [jruby]='https://github.com/cpuguy83/docker-jruby'
  33. [mageia]='https://github.com/juanluisbaptiste/docker-brew-mageia'
  34. [maven]='https://github.com/carlossg/docker-maven'
  35. [mono]='https://github.com/mono/docker'
  36. [neurodebian]='https://github.com/neurodebian/dockerfiles'
  37. [nginx]='https://github.com/nginxinc/docker-nginx'
  38. [node]='https://github.com/joyent/docker-node'
  39. [odoo]='https://github.com/odoo/docker'
  40. [opensuse]='https://github.com/openSUSE/docker-containers-build'
  41. [oraclelinux]='https://github.com/oracle/docker-images'
  42. [perl]='https://github.com/Perl/docker-perl'
  43. [r-base]='https://github.com/rocker-org/rocker'
  44. [registry]='https://github.com/docker/docker-registry'
  45. [rethinkdb]='https://github.com/stuartpb/rethinkdb-dockerfiles'
  46. [thrift]='https://github.com/ahawkins/docker-thrift'
  47. [ubuntu-debootstrap]='https://github.com/tianon/docker-brew-ubuntu-debootstrap'
  48. [ubuntu-upstart]='https://github.com/tianon/dockerfiles'
  49. [ubuntu]='https://github.com/tianon/docker-brew-ubuntu-core'
  50. )
  51. dockerLatest="$(curl -sSL 'https://get.docker.com/latest')"
  52. for repo in "${repos[@]}"; do
  53. if [ -x "$repo/update.sh" ]; then
  54. ( set -x; "$repo/update.sh" )
  55. fi
  56. if [ -e "$repo/content.md" ]; then
  57. gitRepo="${otherRepos[$repo]}"
  58. if [ -z "$gitRepo" ]; then
  59. gitRepo="https://github.com/docker-library/$repo"
  60. fi
  61. mailingList="$(cat "$repo/mailing-list.md" 2>/dev/null || true)"
  62. if [ "$mailingList" ]; then
  63. mailingList=" $mailingList "
  64. else
  65. mailingList=' '
  66. fi
  67. dockerVersions="$(cat "$repo/docker-versions.md" 2>/dev/null || cat 'docker-versions.md')"
  68. userFeedback="$(cat "$repo/user-feedback.md" 2>/dev/null || cat 'user-feedback.md')"
  69. license="$(cat "$repo/license.md" 2>/dev/null || true)"
  70. if [ "$license" ]; then
  71. license=$'\n\n''# License'$'\n\n'"$license"
  72. fi
  73. logo=
  74. if [ -e "$repo/logo.png" ]; then
  75. logo="![logo](https://raw.githubusercontent.com/docker-library/docs/master/$repo/logo.png)"
  76. fi
  77. cp -v README-template.md "$repo/README.md"
  78. echo ' TAGS => ./generate-dockerfile-links-partial.sh'
  79. replace_field "$repo" 'TAGS' "$(./generate-dockerfile-links-partial.sh "$repo")"
  80. echo ' CONTENT => '"$repo"'/content.md'
  81. replace_field "$repo" 'CONTENT' "$(cat "$repo/content.md")"
  82. # has to be after CONTENT because it's contained in content.md
  83. echo " LOGO => $logo"
  84. replace_field "$repo" 'LOGO' "$logo" '\s*'
  85. echo ' DOCKER-VERSIONS => '"$repo"'/docker-versions.md'
  86. replace_field "$repo" 'DOCKER-VERSIONS' "$dockerVersions"
  87. echo ' DOCKER-LATEST => "'"$dockerLatest"'"'
  88. replace_field "$repo" 'DOCKER-LATEST' "$dockerLatest"
  89. echo ' LICENSE => '"$repo"'/license.md'
  90. replace_field "$repo" 'LICENSE' "$license"
  91. echo ' USER-FEEDBACK => '"$repo"'/user-feedback.md'
  92. replace_field "$repo" 'USER-FEEDBACK' "$userFeedback"
  93. echo ' MAILING-LIST => '"$repo"'/mailing-list.md'
  94. replace_field "$repo" 'MAILING-LIST' "$mailingList" '\s*'
  95. echo ' REPO => "'"$repo"'"'
  96. replace_field "$repo" 'REPO' "$repo"
  97. echo ' GITHUB-REPO => "'"$gitRepo"'"'
  98. replace_field "$repo" 'GITHUB-REPO' "$gitRepo"
  99. echo
  100. else
  101. echo >&2 "skipping $repo: missing repo/content.md"
  102. fi
  103. done