Merge ~mpontillo/maas:release-package-distros-and-signature into maas:master

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: edac8ae9c1fdf906837453fd5499057af67bc2d9
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~mpontillo/maas:release-package-distros-and-signature
Merge into: maas:master
Diff against target: 312 lines (+229/-20)
4 files modified
.gitignore (+3/-0)
utilities/create-deb-repo (+111/-0)
utilities/pbuilder-setup (+48/-0)
utilities/release-build (+67/-20)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+327511@code.launchpad.net

Commit message

Enhancements to package build scripts

 * Allow seleciton of distribution when running release-package script.
 * Use BASH_SOURCE to determine the runtime directory.
 * Update maintiner e-mail address before signing.
 * Update .gitignore for debian/ tree integration.
 * Drive-by fix to use proper argument to select commit.
 * Use exit trap to clean up changelog.
 * Add a script to set up pbuilder-dist for each supported distribution.
 * Add a script to create .debs for each platform, and a Debian repository
   in a format that can be served via HTTP.

To post a comment you must log in.
80397cf... by Mike Pontillo

Fix usage.

8de8b37... by Mike Pontillo

Use exit trap to clean up changelog.

799900f... by Mike Pontillo

Add a script to set up pbuilder-dist.

095886c... by Mike Pontillo

Check for a few more development tools.

1be606e... by Mike Pontillo

Add a script to create an HTTP-accessible Debian repository.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

lgtm! comment inline though!

review: Approve
edac8ae... by Mike Pontillo

Add --keep-changelog option to release-build script.

Revision history for this message
Mike Pontillo (mpontillo) wrote :

Thanks for the review.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitignore b/.gitignore
2index 54fa9ea..8b7f183 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -15,6 +15,7 @@
6 /.idea/scopes
7 /.idea/workspace.xml
8 /.installed.cfg
9+/.pybuild/
10 /.noseids
11 /.run
12 /.run-e2e
13@@ -24,6 +25,8 @@
14 /coverage
15 /coverage.xml
16 /db
17+/debian/build/
18+/debian/debhelper-build-stamp
19 /develop-eggs
20 /dist
21 /docs/api.rst
22diff --git a/maas_2.3.0~alpha1-6157-g52d1d0e.orig.tar.gz b/maas_2.3.0~alpha1-6157-g52d1d0e.orig.tar.gz
23new file mode 100644
24index 0000000..96d335b
25Binary files /dev/null and b/maas_2.3.0~alpha1-6157-g52d1d0e.orig.tar.gz differ
26diff --git a/utilities/create-deb-repo b/utilities/create-deb-repo
27new file mode 100755
28index 0000000..cea33c0
29--- /dev/null
30+++ b/utilities/create-deb-repo
31@@ -0,0 +1,111 @@
32+#!/bin/bash -e
33+
34+# Uses the output of the 'release-build' script to create Debian packages.
35+# Also signs the packages, scans them, and prepares an archive that can be
36+# hosted with HTTP.
37+
38+ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
39+cd "$ROOTDIR"
40+BUILDDIR=$ROOTDIR/build_pkg
41+if [ ! -d $BUILDDIR ]; then
42+ echo "[!] You must run the 'release-build' script first."
43+fi
44+PBUILDFOLDER=${PBUILDFOLDER:-$HOME/pbuilder}
45+
46+usage () {
47+ DISTRO_ARGS=$(distro-info --supported | sed 's/^/[--/g' | sed 's/$/]/' | tr '\n' ' ')
48+ echo "Usage:"
49+ echo " $0 $DISTRO_ARGS"
50+ exit 1
51+}
52+
53+DEFAULT_DISTROS="$(ubuntu-distro-info --supported)"
54+PACKAGE_DISTROS=""
55+
56+for arg in "$@"; do
57+ if [ "$arg" = "-h" -o "$arg" = "--help" ]; then
58+ usage
59+ fi
60+ if echo "$arg" | grep -q "^--"; then
61+ distro="$(echo "$arg" | sed 's/^--//')"
62+ if echo $DEFAULT_DISTROS | grep -q $distro; then
63+ PACKAGE_DISTROS="$PACKAGE_DISTROS $distro"
64+ fi
65+ shift
66+ fi
67+done
68+
69+if [ "$PACKAGE_DISTROS" = "" ]; then
70+ PACKAGE_DISTROS="$DEFAULT_DISTROS"
71+fi
72+
73+scan_packages () {
74+ # Create a repository that can be hosted with HTTP. Based loosely on:
75+ # https://help.ubuntu.com/community/CreateAuthenticatedRepository
76+ cd $PBUILDFOLDER/$1_result
77+ echo ""
78+ echo "MAAS versions in distribution '$1':"
79+ ls -1 *.deb | cut -f2 -d_ | sort -u | sed 's/^/ /g'
80+ echo ""
81+ echo ""
82+ dpkg-sig --sign builder *.deb
83+ mkdir -p ../archive/dists/$1/main/binary-amd64
84+ cp -fl *.deb ../archive/dists/$1/main/binary-amd64
85+ cd ../archive
86+ dpkg-scanpackages -m dists/$1/main/binary-amd64 | tee dists/$1/main/binary-amd64/Packages
87+ cat dists/$1/main/binary-amd64/Packages | gzip --fast > dists/$1/main/binary-amd64/Packages.gz
88+ apt-ftparchive release dists/$1 | tee dists/$1/Release
89+ rm -f dists/$1/InRelease
90+ gpg --digest-algo sha512 --clearsign -o dists/$1/InRelease dists/$1/Release
91+ rm -f dists/$1/Release.gpg
92+ gpg --digest-algo sha512 -abs -o dists/$1/Release.gpg dists/$1/Release
93+}
94+
95+distro=xenial
96+if echo "$PACKAGE_DISTROS" | grep -q "$distro"; then
97+ version=16.04
98+ cd $BUILDDIR
99+ pbuilder-dist $distro build $(ls -1rt *.dsc | grep "~$version" | tail -1)
100+ scan_packages $distro
101+fi
102+
103+distro=yakkety
104+if echo "$PACKAGE_DISTROS" | grep -q "$distro"; then
105+ version=16.10
106+ cd $BUILDDIR
107+ pbuilder-dist $distro build $(ls -1rt *.dsc | grep "~$version" | tail -1)
108+ scan_packages $distro
109+fi
110+
111+distro=zesty
112+if echo "$PACKAGE_DISTROS" | grep -q "$distro"; then
113+ version=17.04
114+ cd $BUILDDIR
115+ pbuilder-dist $distro build $(ls -1rt *.dsc | grep "~$version" | tail -1)
116+ scan_packages $distro
117+fi
118+
119+distro=artful
120+if echo "$PACKAGE_DISTROS" | grep -q "$distro"; then
121+ version=17.10
122+ cd $BUILDDIR
123+ pbuilder-dist $distro build $(ls -1rt *.dsc | grep "~$version" | tail -1)
124+ scan_packages $distro
125+fi
126+
127+cd $PBUILDFOLDER/archive
128+echo ""
129+echo "Public signing key (use with 'apt-key add'):"
130+gpg --armor --export "$DEBEMAIL" | tee pubkey
131+
132+echo ""
133+echo "You should be able to use the result as a repository by running:"
134+echo " cd $PBUILDFOLDER/archive && python3 -m http.server"
135+echo ""
136+echo "Then adding [one of] the following to the target machine's apt sources:"
137+for ip in $(ip r | grep -o 'src.*' | awk '{ print $2}'); do
138+ echo " deb http://$ip:8000/ <distro> main"
139+done
140+echo ""
141+echo "... and adding the key as follows:"
142+echo " curl http://<repository-ip>:8000/pubkey | apt-key add -"
143diff --git a/utilities/pbuilder-setup b/utilities/pbuilder-setup
144new file mode 100755
145index 0000000..f34c35d
146--- /dev/null
147+++ b/utilities/pbuilder-setup
148@@ -0,0 +1,48 @@
149+#!/bin/bash -e
150+
151+errors=0
152+if [ -z "$DEBEMAIL" ]; then
153+ echo '[!] Set your $DEBEMAIL to an e-mail address matching your GPG key.' 1>&2
154+ let errors=$errors+1
155+fi
156+
157+if [ -z "$DEBNAME" ]; then
158+ echo '[!] Set your $DEBNAME to your full name.' 1>&2
159+ let errors=$errors+1
160+fi
161+
162+if [ $errors -gt 0 ]; then
163+ exit 1
164+fi
165+
166+MISSING=""
167+if [ ! -x /usr/bin/pbuilder-dist ]; then
168+ MISSING="$MISSING ubuntu-dev-tools"
169+fi
170+
171+if [ ! -x /usr/bin/dpkg-scanpackages ]; then
172+ MISSING="$MISSING dpkg-dev"
173+fi
174+
175+if [ ! -x /usr/bin/dpkg-sig ]; then
176+ MISSING="$MISSING dpkg-sig"
177+fi
178+
179+if [ "$MISSING" != "" ]; then
180+ sudo apt-get install -yu $MISSING
181+fi
182+
183+
184+# MAAS doesn't support building on Trusty, so don't bother with it.
185+DISTRIBUTIONS="$(distro-info --supported | grep -v trusty)"
186+
187+PBUILDFOLDER=${PBUILDFOLDER:-$HOME/pbuilder}
188+
189+for distro in $DISTRIBUTIONS; do
190+ if [ -f $PBUILDFOLDER/$distro-base.tgz ]; then
191+ pbuilder-dist $distro update
192+ else
193+ pbuilder-dist $distro create
194+ fi
195+done
196+
197diff --git a/utilities/release-build b/utilities/release-build
198index 007627d..36a21f9 100755
199--- a/utilities/release-build
200+++ b/utilities/release-build
201@@ -1,29 +1,63 @@
202-#!/bin/sh -e
203+#!/bin/bash -e
204
205-ROOTDIR=$(pwd)
206+ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
207+cd "$ROOTDIR"
208 BUILDDIR=$ROOTDIR/build_pkg
209 if [ ! -d $BUILDDIR ]; then
210 mkdir $BUILDDIR
211 fi
212
213-error() {
214- echo "ERROR: $@" >&2
215- exit 1
216-}
217-
218 usage () {
219+ DISTRO_ARGS=$(distro-info --supported | sed 's/^/[--/g' | sed 's/$/]/' | tr '\n' ' ')
220 echo "Usage:"
221- echo " $0 [commit (defaults to HEAD)]"
222+ echo " $0 $DISTRO_ARGS \\"
223+ echo " [--keep-changelog] [commit (defaults to HEAD)]"
224 exit 1
225 }
226
227+DEFAULT_DISTROS="$(ubuntu-distro-info --supported | grep -v trusty)"
228+PACKAGE_DISTROS=""
229+KEEP_CHANGELOG=0
230+
231+for arg in "$@"; do
232+ if [ "$arg" = "-h" -o "$arg" = "--help" ]; then
233+ usage
234+ fi
235+ if echo "$arg" | grep -q "^--"; then
236+ option="$(echo "$arg" | sed 's/^--//')"
237+ if [ "$option" = "keep-changelog" ]; then
238+ KEEP_CHANGELOG=1
239+ fi
240+ if echo $DEFAULT_DISTROS | grep -q $option; then
241+ PACKAGE_DISTROS="$PACKAGE_DISTROS $option"
242+ fi
243+ shift
244+ fi
245+done
246+
247+if [ "$PACKAGE_DISTROS" = "" ]; then
248+ PACKAGE_DISTROS="$DEFAULT_DISTROS"
249+fi
250+
251 if [ -z "$1" ]; then
252 echo "WARNING: No commit specified, using HEAD instead"
253 COMMIT="HEAD"
254 else
255- COMMIT="$2"
256+ COMMIT="$1"
257 fi
258
259+function cleanup {
260+ # Revert any unstaged temporary changes to the changelog.
261+ cd "$ROOTDIR"
262+ if [ $KEEP_CHANGELOG -eq 0 ]; then
263+ git checkout -- debian/changelog
264+ fi
265+}
266+trap cleanup EXIT
267+
268+# Ensure the maintainer e-mail address is set, so that signing works properly.
269+dch -a "" --release-heuristic log --nomultimaint
270+
271 PKG=$(head -n1 debian/changelog | awk '{print $1}')
272 MAJOR_VER=$(head -n 1 debian/changelog | sed 's/^.*(//' | sed 's/).*//' | sed 's/-.*//')
273 REV_COUNT=$(git rev-list --count $COMMIT)
274@@ -49,14 +83,27 @@ cd $BUILDDIR
275 tar zxvf ${PKG}_${FULL_VER}.orig.tar.gz
276 cd "${PKG}-${FULL_VER}.orig/"
277 cp -r $ROOTDIR/debian .
278-sed -i "s/) UNRELEASED;/~16.04.1) xenial;/i" debian/changelog
279-debuild -S -sa
280-sed -i "s/~16.04.1) xenial;/~16.10.1) yakkety;/" debian/changelog
281-debuild -S
282-sed -i "s/~16.10.1) yakkety;/~17.04.1) zesty;/" debian/changelog
283-debuild -S
284-sed -i "s/~17.04.1) zesty;/~17.10.1) artful;/" debian/changelog
285-debuild -S
286-
287-cd $ROOTDIR
288-sed -i "s/${FULL_VER}-0ubuntu1/${MAJOR_VER}-0ubuntu1/i" debian/changelog
289+
290+if echo "$PACKAGE_DISTROS" | grep -q "xenial"; then
291+ cp $ROOTDIR/debian/changelog debian/changelog
292+ sed -i "s/) UNRELEASED;/~16.04.1) xenial;/i" debian/changelog
293+ debuild -S -sa
294+fi
295+
296+if echo "$PACKAGE_DISTROS" | grep -q "yakkety"; then
297+ cp $ROOTDIR/debian/changelog debian/changelog
298+ sed -i "s/) UNRELEASED;/~16.10.1) yakkety;/" debian/changelog
299+ debuild -S
300+fi
301+
302+if echo "$PACKAGE_DISTROS" | grep -q "zesty"; then
303+ cp $ROOTDIR/debian/changelog debian/changelog
304+ sed -i "s/) UNRELEASED;/~17.04.1) zesty;/" debian/changelog
305+ debuild -S
306+fi
307+
308+if echo "$PACKAGE_DISTROS" | grep -q "artful"; then
309+ cp $ROOTDIR/debian/changelog debian/changelog
310+ sed -i "s/) UNRELEASED;/~17.10.1) artful;/" debian/changelog
311+ debuild -S
312+fi

Subscribers

People subscribed via source and target branches