update.sh 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. [crux]='https://github.com/therealprologic/docker-crux'
  24. [debian]='https://github.com/tianon/docker-brew-debian'
  25. [docker-dev]='https://github.com/docker/docker'
  26. [fedora]='https://github.com/lsm5/docker-brew-fedora'
  27. [hipache]='https://github.com/dotcloud/hipache'
  28. [hylang]='https://github.com/hylang/hy'
  29. [jenkins]='https://github.com/cloudbees/jenkins-ci.org-docker'
  30. [jruby]='https://github.com/cpuguy83/docker-jruby'
  31. [neurodebian]='https://github.com/neurodebian/dockerfiles'
  32. [nginx]='https://github.com/nginxinc/docker-nginx'
  33. [opensuse]='https://github.com/openSUSE/docker-containers-build'
  34. [perl]='https://github.com/Perl/docker-perl'
  35. [registry]='https://github.com/docker/docker-registry'
  36. [ubuntu-debootstrap]='https://github.com/tianon/docker-brew-ubuntu-debootstrap'
  37. [ubuntu-upstart]='https://github.com/tianon/dockerfiles'
  38. [ubuntu]='https://github.com/tianon/docker-brew-ubuntu-core'
  39. )
  40. for repo in "${repos[@]}"; do
  41. if [ -x "$repo/update.sh" ]; then
  42. ( set -x; "$repo/update.sh" )
  43. fi
  44. if [ -e "$repo/content.md" ]; then
  45. gitRepo="${otherRepos[$repo]}"
  46. if [ -z "$gitRepo" ]; then
  47. gitRepo="https://github.com/docker-library/$repo"
  48. fi
  49. mailingList="$(cat "$repo/mailing-list.md" 2>/dev/null || true)"
  50. if [ "$mailingList" ]; then
  51. mailingList=" $mailingList "
  52. else
  53. mailingList=' '
  54. fi
  55. license="$(cat "$repo/license.md" 2>/dev/null || true)"
  56. if [ "$license" ]; then
  57. license=$'\n\n''# License'$'\n\n'"$license"
  58. fi
  59. logo=
  60. if [ -e "$repo/logo.png" ]; then
  61. logo="![logo](https://raw.githubusercontent.com/docker-library/docs/master/$repo/logo.png)"
  62. fi
  63. cp -v README-template.md "$repo/README.md"
  64. echo ' TAGS => ./generate-dockerfile-links-partial.sh'
  65. replace_field "$repo" 'TAGS' "$(./generate-dockerfile-links-partial.sh "$repo")"
  66. echo ' CONTENT => '"$repo"'/content.md'
  67. replace_field "$repo" 'CONTENT' "$(cat "$repo/content.md")"
  68. # has to be after CONTENT because it's contained in content.md
  69. echo " LOGO => $logo"
  70. replace_field "$repo" 'LOGO' "$logo" '\s*'
  71. echo ' LICENSE => '"$repo"'/license.md'
  72. replace_field "$repo" 'LICENSE' "$license"
  73. echo ' MAILING_LIST => "'"$mailingList"'"'
  74. replace_field "$repo" 'MAILING_LIST' "$mailingList" '\s*'
  75. echo ' REPO => "'"$gitRepo"'"'
  76. replace_field "$repo" 'REPO' "$gitRepo"
  77. echo
  78. else
  79. echo >&2 "skipping $repo: missing repo/content.md"
  80. fi
  81. done