update.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. [opensuse]='https://github.com/openSUSE/docker-containers-build'
  33. [perl]='https://github.com/Perl/docker-perl'
  34. [registry]='https://github.com/docker/docker-registry'
  35. [ubuntu-debootstrap]='https://github.com/tianon/docker-brew-ubuntu-debootstrap'
  36. [ubuntu-upstart]='https://github.com/tianon/dockerfiles'
  37. [ubuntu]='https://github.com/tianon/docker-brew-ubuntu-core'
  38. )
  39. for repo in "${repos[@]}"; do
  40. if [ -x "$repo/update.sh" ]; then
  41. ( set -x; "$repo/update.sh" )
  42. fi
  43. if [ -e "$repo/content.md" ]; then
  44. gitRepo="${otherRepos[$repo]}"
  45. if [ -z "$gitRepo" ]; then
  46. gitRepo="https://github.com/docker-library/$repo"
  47. fi
  48. mailingList="$(cat "$repo/mailing-list.md" 2>/dev/null || true)"
  49. if [ "$mailingList" ]; then
  50. mailingList=" $mailingList "
  51. else
  52. mailingList=' '
  53. fi
  54. license="$(cat "$repo/license.md" 2>/dev/null || true)"
  55. if [ "$license" ]; then
  56. license=$'\n\n''# License'$'\n\n'"$license"
  57. fi
  58. cp -v README-template.md "$repo/README.md"
  59. echo ' TAGS => ./generate-dockerfile-links-partial.sh'
  60. replace_field "$repo" 'TAGS' "$(./generate-dockerfile-links-partial.sh "$repo")"
  61. echo ' CONTENT => '"$repo"'/content.md'
  62. replace_field "$repo" 'CONTENT' "$(cat "$repo/content.md")"
  63. echo ' LICENSE => '"$repo"'/license.md'
  64. replace_field "$repo" 'LICENSE' "$license"
  65. echo ' MAILING_LIST => "'"$mailingList"'"'
  66. replace_field "$repo" 'MAILING_LIST' "$mailingList" '\s*'
  67. echo ' REPO => "'"$gitRepo"'"'
  68. replace_field "$repo" 'REPO' "$gitRepo"
  69. echo
  70. else
  71. echo >&2 "skipping $repo: missing repo/content.md"
  72. fi
  73. done