Merge lp:~nskaggs/juju-release-tools/make-pr-tarball into lp:juju-release-tools

Proposed by Nicholas Skaggs
Status: Merged
Merged at revision: 337
Proposed branch: lp:~nskaggs/juju-release-tools/make-pr-tarball
Merge into: lp:juju-release-tools
Diff against target: 229 lines (+131/-63)
4 files modified
build-juju-source.bash (+56/-0)
check-source-depends.bash (+16/-0)
make-pr-tarball.bash (+53/-0)
make-release-tarball.bash (+6/-63)
To merge this branch: bzr merge lp:~nskaggs/juju-release-tools/make-pr-tarball
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+305370@code.launchpad.net

Description of the change

This adds a new script that tweaks make-release-tarball slightly. I'd like to just expand the current script, but as you'll note by diffing the two this one has a one line difference in where the location of the tarball is adding an additional difference beyond the checkout.

It would be useful to migrate away from needing those 4 args in make-release-tarball and to use this logic instead. However, but I'm not sure what will happen longer term. For now, leaving this PR for comment. This is installed currently and in use as-is for the developer workflow experiments. I don't anticipate merging anything until we've solidified those experiments.

To post a comment you must log in.
337. By Nicholas Skaggs

Fix path

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

This is the final version.

338. By Nicholas Skaggs

Add breakouts and common script points; add echos to original script

Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you. I have some comments and suggestions inline. Can we get this merged quickly so that we get a day runs with these changes in place before the release.

review: Approve (code)
339. By Nicholas Skaggs

use source instead of .

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'build-juju-source.bash'
2--- build-juju-source.bash 1970-01-01 00:00:00 +0000
3+++ build-juju-source.bash 2016-09-21 13:29:20 +0000
4@@ -0,0 +1,56 @@
5+echo "Getting and updating juju-core dependencies to the required versions."
6+GOPATH=$WORK go get -v github.com/rogpeppe/godeps
7+GODEPS=$WORK/bin/godeps
8+if [[ ! -f $GODEPS ]]; then
9+ echo "! Could not install godeps."
10+ exit 1
11+fi
12+GOPATH=$WORK $GODEPS -u "$WORKPACKAGE/dependencies.tsv"
13+
14+# Remove godeps, and non-free data
15+echo "Removing godeps and non-free data."
16+rm -rf $WORK/src/github.com/rogpeppe/godeps
17+rm -rf $WORK/src/github.com/kisielk
18+rm -rf $WORK/src/code.google.com/p/go.net/html/charset/testdata/
19+rm -f $WORK/src/code.google.com/p/go.net/html/charset/*test.go
20+rm -rf $WORK/src/golang.org/x/net/html/charset/testdata/
21+rm -f $WORK/src/golang.org/x/net/html/charset/*test.go
22+rm -rf $WORK/src/github.com/prometheus/procfs/fixtures
23+# Remove backup files that confuse lintian.
24+echo "Removing backup files"
25+find $WORK/src/ -type f -name *.go.orig -delete
26+
27+# Validate the go src tree against dependencies.tsv
28+echo "Validating dependencies.tsv"
29+$SCRIPT_DIR/check_dependencies.py --delete-unknown --ignore $PACKAGE \
30+ "$WORKPACKAGE/dependencies.tsv" "$WORK/src"
31+
32+# Apply patches against the whole source tree from the juju project
33+echo "Applying Patches"
34+if [[ -d "$WORKPACKAGE/patches" ]]; then
35+ $SCRIPT_DIR/apply_patches.py "$WORKPACKAGE/patches" "$WORK/src"
36+fi
37+
38+# Run juju's fmt and vet script on the source after finding the right version
39+echo "Running format and checking build"
40+if [[ $(lsb_release -sc) == "trusty" ]]; then
41+ CHECKSCRIPT=./scripts/verify.bash
42+ if [[ ! -f $WORKPACKAGE/scripts/verify.bash ]]; then
43+ CHECKSCRIPT=./scripts/pre-push.bash
44+ fi
45+ (cd $WORKPACKAGE && GOPATH=$WORK $CHECKSCRIPT)
46+fi
47+
48+# Remove binaries and build artefacts
49+echo "Removing binaries and build artifacts"
50+rm -r $WORK/bin
51+if [[ -d $WORK/pkg ]]; then
52+ rm -r $WORK/pkg
53+fi
54+
55+echo "Rename to proper release version"
56+VERSION=$(sed -n 's/^const version = "\(.*\)"/\1/p' \
57+ $WORKPACKAGE/version/version.go)
58+
59+# Change the generic release to the proper juju-core version.
60+mv $WORK $TMP_DIR/juju-core_${VERSION}/
61
62=== added file 'check-source-depends.bash'
63--- check-source-depends.bash 1970-01-01 00:00:00 +0000
64+++ check-source-depends.bash 2016-09-21 13:29:20 +0000
65@@ -0,0 +1,16 @@
66+check_deps() {
67+ echo "Phase 0: Checking requirements."
68+ has_deps=1
69+ which bzr || has_deps=0
70+ which git || has_deps=0
71+ which hg || has_deps=0
72+ which go || has_deps=0
73+ if [[ $has_deps == 0 ]]; then
74+ echo "Install bzr, hg, git, and golang."
75+ exit 2
76+ fi
77+}
78+
79+
80+test $# -ge 1 || usage
81+check_deps
82
83=== added file 'make-pr-tarball.bash'
84--- make-pr-tarball.bash 1970-01-01 00:00:00 +0000
85+++ make-pr-tarball.bash 2016-09-21 13:29:20 +0000
86@@ -0,0 +1,53 @@
87+#!/bin/bash
88+
89+# Assemble a source tree using git to checkout the revision,
90+# then go to get the package deps, then godeps to pin the versions/
91+# Lastly create a release tarball from the tree.
92+set -e
93+
94+unset GOPATH
95+unset GOBIN
96+
97+DEFAULT_GIT_JUJU_CORE="https://github.com/juju/juju.git"
98+PACKAGE="github.com/juju/juju"
99+
100+SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd )
101+
102+usage() {
103+ echo "usage: $0 <GIT_PR> [GIT_REPO]"
104+ echo " GIT_PR: The juju core PR number to build"
105+ echo " GIT_REPO: The juju core git repo; defaults to $DEFAULT_GIT_JUJU_CORE"
106+ exit 1
107+}
108+
109+# check build dependencies
110+source "$SCRIPT_DIR/check-source-depends.bash"
111+
112+GIT_PR=$1
113+JUJU_CORE_REPO=${2:-$DEFAULT_GIT_JUJU_CORE}
114+
115+HERE=$(pwd)
116+TMP_DIR=$(mktemp -d --tmpdir=$HERE)
117+mkdir $TMP_DIR/RELEASE
118+WORK=$TMP_DIR/RELEASE
119+WORKPACKAGE=$WORK/src/$PACKAGE
120+
121+echo "Getting juju core from $JUJU_CORE_REPO."
122+mkdir -p $WORKPACKAGE
123+git clone $JUJU_CORE_REPO $WORKPACKAGE
124+cd $WORKPACKAGE
125+echo "Checking out PR revision."
126+git fetch --tags $JUJU_CORE_REPO +refs/pull/$GIT_PR/merge:refs/remotes/origin-pull/pull/$GIT_PR/merge
127+MERGE_COMMIT=$(git rev-parse refs/remotes/origin-pull/pull/$GIT_PR/merge^{commit})
128+git checkout -f $MERGE_COMMIT
129+
130+# Build juju in directory
131+source "$SCRIPT_DIR/build-juju-source"
132+
133+# Tar it up.
134+echo "Creating build tarball"
135+cd $TMP_DIR
136+TARFILE=$HERE/juju-core_${VERSION}.tar.gz
137+tar cfz $TARFILE --exclude .hg --exclude .git --exclude .bzr juju-core_${VERSION}
138+
139+echo "Successfully created tarball: $TARFILE"
140
141=== modified file 'make-release-tarball.bash'
142--- make-release-tarball.bash 2016-08-30 13:54:11 +0000
143+++ make-release-tarball.bash 2016-09-21 13:29:20 +0000
144@@ -23,19 +23,8 @@
145 exit 1
146 }
147
148-
149-check_deps() {
150- echo "Phase 0: Checking requirements."
151- has_deps=1
152- which bzr || has_deps=0
153- which git || has_deps=0
154- which hg || has_deps=0
155- which go || has_deps=0
156- if [[ $has_deps == 0 ]]; then
157- echo "Install bzr, hg, git, and golang."
158- exit 2
159- fi
160-}
161+# check build dependencies
162+source "$SCRIPT_DIR/check-source-depends.bash"
163
164
165 test $# -ge 1 || usage
166@@ -83,59 +72,13 @@
167 fi
168 cd $HERE
169
170-echo "Getting and updating juju-core dependencies to the required versions."
171-GOPATH=$WORK go get -v github.com/rogpeppe/godeps
172-GODEPS=$WORK/bin/godeps
173-if [[ ! -f $GODEPS ]]; then
174- echo "! Could not install godeps."
175- exit 1
176-fi
177-GOPATH=$WORK $GODEPS -u "$WORKPACKAGE/dependencies.tsv"
178-
179-# Remove godeps, and non-free data
180-rm -rf $WORK/src/github.com/rogpeppe/godeps
181-rm -rf $WORK/src/github.com/kisielk
182-rm -rf $WORK/src/code.google.com/p/go.net/html/charset/testdata/
183-rm -f $WORK/src/code.google.com/p/go.net/html/charset/*test.go
184-rm -rf $WORK/src/golang.org/x/net/html/charset/testdata/
185-rm -f $WORK/src/golang.org/x/net/html/charset/*test.go
186-rm -rf $WORK/src/github.com/prometheus/procfs/fixtures
187-# Remove backup files that confuse lintian.
188-find $WORK/src/ -type f -name *.go.orig -delete
189-
190-# Validate the go src tree against dependencies.tsv
191-$SCRIPT_DIR/check_dependencies.py --delete-unknown --ignore $PACKAGE \
192- "$WORKPACKAGE/dependencies.tsv" "$WORK/src"
193-
194-# Apply patches against the whole source tree from the juju project
195-if [[ -d "$WORKPACKAGE/patches" ]]; then
196- $SCRIPT_DIR/apply_patches.py "$WORKPACKAGE/patches" "$WORK/src"
197-fi
198-
199-# Run juju's fmt and vet script on the source after finding the right version
200-if [[ $(lsb_release -sc) == "trusty" ]]; then
201- CHECKSCRIPT=./scripts/verify.bash
202- if [[ ! -f $WORKPACKAGE/scripts/verify.bash ]]; then
203- CHECKSCRIPT=./scripts/pre-push.bash
204- fi
205- (cd $WORKPACKAGE && GOPATH=$WORK $CHECKSCRIPT)
206-fi
207-
208-# Remove binaries and build artefacts
209-rm -r $WORK/bin
210-if [[ -d $WORK/pkg ]]; then
211- rm -r $WORK/pkg
212-fi
213-
214-VERSION=$(sed -n 's/^const version = "\(.*\)"/\1/p' \
215- $WORKPACKAGE/version/version.go)
216-
217-# Change the generic release to the proper juju-core version.
218-mv $WORK $TMP_DIR/juju-core_${VERSION}/
219+# Build juju in directory
220+source "$SCRIPT_DIR/build-juju-source"
221
222 # Tar it up.
223+echo "Creating build tarball"
224 TARFILE=$(pwd)/juju-core_${VERSION}.tar.gz
225 cd $TMP_DIR
226 tar cfz $TARFILE --exclude .hg --exclude .git --exclude .bzr juju-core_${VERSION}
227
228-echo "release tarball: $TARFILE"
229+echo "Successfully created tarball: $TARFILE"

Subscribers

People subscribed via source and target branches