Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From 3e8722334cd36ca97f2562204c767c959d7ef8a7 Mon Sep 17 00:00:00 2001
- From: Daniel Farrell <[email protected]>
- Date: Thu, 27 Oct 2016 23:58:09 -0400
- Subject: [PATCH] Add script for downstreaming new releases
- Automation of manual process documented in Mike's OpenDaylight Packaging
- for Dummies Google Doc. Clones downstream repo, adds upstream remote,
- pushes code at given upstream release to given downstream product
- branch, pushes new upstream tags to downstream repo.
- Signed-off-by: Daniel Farrell <[email protected]>
- ---
- scripts/downstream_code.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++
- 1 file changed, 81 insertions(+)
- create mode 100755 scripts/downstream_code.sh
- diff --git a/scripts/downstream_code.sh b/scripts/downstream_code.sh
- new file mode 100755
- index 0000000..19c4051
- --- /dev/null
- +++ b/scripts/downstream_code.sh
- @@ -0,0 +1,81 @@
- +#!/usr/bin/env bash
- +# Script to downstream ODL upstream releases to downstream product branches
- +
- +# Options:
- +# -x: Echo commands
- +# -e: Fail on errors
- +# -o pipefail: Fail on errors in scripts this calls, give stacktrace
- +set -ex -o pipefail
- +
- +# Default variables, update as needed
- +declare -a projects=("aaa" "controller" "dlux" "lispflowmapping" "mdsal"
- + "netconf" "netvirt" "neutron" "odlparent" "openflowjava"
- + "openflowplugin" "ovsdb" "sfc" "yangtools")
- +tag="boron"
- +branch="rhos-10.0-patches"
- +username="dfarrell"
- +
- +###############################################################################
- +# Downstream a project at a given upstream tag to a given downstream branch.
- +# Re-running is okay, git pushes just report "everything is up-to-date".
- +# Globals:
- +# None
- +# Arguments:
- +# project: Project to update, should match git repo naming (netvirt, sfc)
- +# tag: Upstream release tag to checkout and push downstream (boron, boron-sr1)
- +# branch: Downstream branch to push new release code to (rhos-10.0-patches)
- +# username: Red Hat Kerberos ID, assumes SSH configured in downstream Gerrit
- +# Returns:
- +# None
- +###############################################################################
- +downstream_project_at_tag_to_branch()
- +{
- + project=$1
- + tag=$2
- + branch=$3
- + username=$4
- +
- + # Clone downstream repo
- + if [ ! -d "odl-$project" ]; then
- + git clone ssh://"$username"@code.engineering.redhat.com:22/odl-"$project".git
- + else
- + echo "Directory odl-$project already exists, using it"
- + fi
- +
- + # Enter downstream repo
- + pushd "odl-$project"
- +
- + # Add upstream as git remote
- + if ! git remote | grep -q odl-upstream; then
- + git remote add odl-upstream https://git.opendaylight.org/gerrit/p/"$project".git
- + else
- + echo "Upstream remote for $project already exists, using it"
- + fi
- +
- + # Fetch latest commits, branches and tags from upstream
- + git fetch --tags odl-upstream
- +
- + # Checkout code at given upstream tag on given local branch
- + if ! git branch | grep -q "$branch"; then
- + git checkout release/"$tag" -b "$branch"
- + else
- + echo "Local branch $branch already exists, using it"
- + git checkout "$branch"
- + git checkout release/"$tag"
- + fi
- +
- + # Push code at given upstream tag to given downstream branch
- + # Force, because we want exactly the upstream code. If we've checked
- + # out code at a different upstream tag on this downstream branch before,
- + # we'll have a commit to change POM SNAPSHOT versions to releases
- + # versions (Boron-SR1). This commit doesn't get merged into master
- + # because master should always use SNAPSHOTS, and later tags are made
- + # from master, so later tags will not have these version bump commits.
- + # Git will fail with errors about non-fast-forward merge and commands like:
- + # git log refs/remotes/origin/rhos-10.0-patches ^refs/tags/release/boron-sr1
- + # will show a single "Release Boron" commit". We want to remove the old
- + # POM snap->rel version changes, replacing them with ones for new tag.
- + git push -u origin "$branch" -f
- +
- + # Push all new upstream tags downstream
- + git push --tags origin
- +
- + # Return to original directory
- + popd
- +}
- +
- +# Iterate over all projects, downstreaming each
- +for project in "${projects[@]}"
- +do
- + downstream_project_at_tag_to_branch "$project" "$tag" "$branch" "$username"
- +done
- --
- 2.7.4
Add Comment
Please, Sign In to add comment