update.sh 3.5 KB

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