dfarrell07

0001-Add-script-for-downstreaming-new-releases.patch

Oct 27th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. From 3e8722334cd36ca97f2562204c767c959d7ef8a7 Mon Sep 17 00:00:00 2001
  2. From: Daniel Farrell <[email protected]>
  3. Date: Thu, 27 Oct 2016 23:58:09 -0400
  4. Subject: [PATCH] Add script for downstreaming new releases
  5.  
  6. Automation of manual process documented in Mike's OpenDaylight Packaging
  7. for Dummies Google Doc. Clones downstream repo, adds upstream remote,
  8. pushes code at given upstream release to given downstream product
  9. branch, pushes new upstream tags to downstream repo.
  10.  
  11. Signed-off-by: Daniel Farrell <[email protected]>
  12. ---
  13. scripts/downstream_code.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++
  14. 1 file changed, 81 insertions(+)
  15. create mode 100755 scripts/downstream_code.sh
  16.  
  17. diff --git a/scripts/downstream_code.sh b/scripts/downstream_code.sh
  18. new file mode 100755
  19. index 0000000..19c4051
  20. --- /dev/null
  21. +++ b/scripts/downstream_code.sh
  22. @@ -0,0 +1,81 @@
  23. +#!/usr/bin/env bash
  24. +# Script to downstream ODL upstream releases to downstream product branches
  25. +
  26. +# Options:
  27. +# -x: Echo commands
  28. +# -e: Fail on errors
  29. +# -o pipefail: Fail on errors in scripts this calls, give stacktrace
  30. +set -ex -o pipefail
  31. +
  32. +# Default variables, update as needed
  33. +declare -a projects=("aaa" "controller" "dlux" "lispflowmapping" "mdsal"
  34. + "netconf" "netvirt" "neutron" "odlparent" "openflowjava"
  35. + "openflowplugin" "ovsdb" "sfc" "yangtools")
  36. +tag="boron"
  37. +branch="rhos-10.0-patches"
  38. +username="dfarrell"
  39. +
  40. +###############################################################################
  41. +# Downstream a project at a given upstream tag to a given downstream branch.
  42. +# Re-running is okay, git pushes just report "everything is up-to-date".
  43. +# Globals:
  44. +# None
  45. +# Arguments:
  46. +# project: Project to update, should match git repo naming (netvirt, sfc)
  47. +# tag: Upstream release tag to checkout and push downstream (boron, boron-sr1)
  48. +# branch: Downstream branch to push new release code to (rhos-10.0-patches)
  49. +# username: Red Hat Kerberos ID, assumes SSH configured in downstream Gerrit
  50. +# Returns:
  51. +# None
  52. +###############################################################################
  53. +downstream_project_at_tag_to_branch()
  54. +{
  55. + project=$1
  56. + tag=$2
  57. + branch=$3
  58. + username=$4
  59. +
  60. + # Clone downstream repo
  61. + if [ ! -d "odl-$project" ]; then
  62. + git clone ssh://"$username"@code.engineering.redhat.com:22/odl-"$project".git
  63. + else
  64. + echo "Directory odl-$project already exists, using it"
  65. + fi
  66. +
  67. + # Enter downstream repo
  68. + pushd "odl-$project"
  69. +
  70. + # Add upstream as git remote
  71. + if ! git remote | grep -q odl-upstream; then
  72. + git remote add odl-upstream https://git.opendaylight.org/gerrit/p/"$project".git
  73. + else
  74. + echo "Upstream remote for $project already exists, using it"
  75. + fi
  76. +
  77. + # Fetch latest commits, branches and tags from upstream
  78. + git fetch --tags odl-upstream
  79. +
  80. + # Checkout code at given upstream tag on given local branch
  81. + if ! git branch | grep -q "$branch"; then
  82. + git checkout release/"$tag" -b "$branch"
  83. + else
  84. + echo "Local branch $branch already exists, using it"
  85. + git checkout "$branch"
  86. + git checkout release/"$tag"
  87. + fi
  88. +
  89. + # Push code at given upstream tag to given downstream branch
  90. + # Force, because we want exactly the upstream code. If we've checked
  91. + # out code at a different upstream tag on this downstream branch before,
  92. + # we'll have a commit to change POM SNAPSHOT versions to releases
  93. + # versions (Boron-SR1). This commit doesn't get merged into master
  94. + # because master should always use SNAPSHOTS, and later tags are made
  95. + # from master, so later tags will not have these version bump commits.
  96. + # Git will fail with errors about non-fast-forward merge and commands like:
  97. + # git log refs/remotes/origin/rhos-10.0-patches ^refs/tags/release/boron-sr1
  98. + # will show a single "Release Boron" commit". We want to remove the old
  99. + # POM snap->rel version changes, replacing them with ones for new tag.
  100. + git push -u origin "$branch" -f
  101. +
  102. + # Push all new upstream tags downstream
  103. + git push --tags origin
  104. +
  105. + # Return to original directory
  106. + popd
  107. +}
  108. +
  109. +# Iterate over all projects, downstreaming each
  110. +for project in "${projects[@]}"
  111. +do
  112. + downstream_project_at_tag_to_branch "$project" "$tag" "$branch" "$username"
  113. +done
  114. --
  115. 2.7.4
Add Comment
Please, Sign In to add comment