Merge lp:~javier.collado/utah/bug1042895 into lp:utah

Proposed by Javier Collado
Status: Merged
Merged at revision: 699
Proposed branch: lp:~javier.collado/utah/bug1042895
Merge into: lp:utah
Diff against target: 152 lines (+53/-35)
4 files modified
Makefile (+5/-2)
debian/control (+2/-1)
debian/utah.install (+1/-1)
utah/provisioning/provisioning.py (+45/-31)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1042895
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Review via email: mp+128185@code.launchpad.net

Description of the change

This branch adds a few changes on top of lp:~nuclearbob/utah/internal-jsonschema to get the python-jsonschema package into the utah package at build time instead of at installation time. This means that when utah package is installed, the server can install the client in a machine that doesn't have access to the PPA where the python-jsonschema is available.

For more information, have a look at the discussion in this merge proposal:
https://code.launchpad.net/~nuclearbob/utah/internal-jsonschema/+merge/121891

For a log of of a successful build, have a look at this link (explanation below):
https://launchpadlibrarian.net/118421199/buildlog_ubuntu-precise-i386.utah_0.4ubuntu70-rev698~precise1~ppa2_BUILDING.txt.gz

The build above happened in my PPA (ppa:javier.collado/ppa) with a dependency to the utah stable ppa (ppa:utah/stable). In the log it can be seen that the PPA is added to the sources:
RUN: /usr/share/launchpad-buildd/slavebin/override-sources-list ['override-sources-list', '17aa1ff55999741047f67cee641dfd0183a08439', 'deb http://ppa.launchpad.net/javier.collado/ppa/ubuntu precise main', 'deb http://ppa.launchpad.net/utah/stable/ubuntu precise main', 'deb http://ftpmaster.internal/ubuntu precise main restricted universe multiverse', 'deb http://ftpmaster.internal/ubuntu precise-security main restricted universe multiverse', 'deb http://ftpmaster.internal/ubuntu precise-updates main restricted universe multiverse']
Overriding sources.list in build-17aa1ff55999741047f67cee641dfd0183a08439

Later, the build-depends in the packages is retrieved:
Build-Depends: debhelper (>= 7.0.50~), devscripts, python-all, python-sphinx, python-jsonschema (>= 0.5~)

and the right version of the package is installed:
Setting up python-jsonschema (0.5-0~ppa1) ...

When the package builds, the Makefile commands get the binary package to make it available for the packaging:
apt-get download python-jsonschema
Get:1 Downloading python-jsonschema 0.5-0~ppa1 [10.3 kB]
Fetched 10.3 kB in 0s (0 B/s)

For the utah PPAs, since the package is available in both of them, the configuration to add a PPA dependency won't be needed as the PPA in which the package is build seems to be added automatically to the sources, so there shouldn't be any problem in building the package in any of them.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

I'm still reviewing this, but on lines 41-43 of the merge, a number of dependencies are added to utah which are also dependencies of utah-client (bzr, git, python-yaml.) I think we had a previous merge where we determined that dependencies of utah-client don't also need to be dependencies of utah, since utah depends on utah-client. I'm guessing this was branched off before that happened. If it would be helpful to find the old merge, let me know, and I can do that.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

From what I understand, the recommended syntax in the .install file in the debian directory does not have a leading slash on absolute paths so that different build environments can put the file in a correct relative path if necessary. If the package built correctly, it's not a big deal, but for consistency it might be good to remove the slash from debian/utah.install on line 56 of the merge.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Finally, is the prerm script necessary? Shouldn't package removal take care of that file? If we do need that prerm, is there a reason we need it only for the jsonschema deb and not for the utah-client deb?

I like the rest of it. Let me know what you think about those points, and we can get those tests working again.

review: Needs Information
lp:~javier.collado/utah/bug1042895 updated
699. By Javier Collado

Reverted utah dependencies as they are in the dev branch

700. By Javier Collado

Removed initial slash from path

701. By Javier Collado

Added missing comma

702. By Javier Collado

Removed prerm script

The .deb file is already removed by apt, so there's no need to remove it manually

Revision history for this message
Javier Collado (javier.collado) wrote :

@Max

Thanks for your review because those were three good catches.

1. Dependencies
I've removed them to match what we currently have in the dev branch. dpkg-dev was in the merge, but isn't in the dev branch. Do you know if we're actually using anything from there?

2. Absolute path in .install files
I've never read the official documentation, but I've always seen relative paths as you said.

3. prerm script
That's correct, the prerm script is no longer needed. Just for my own curiosity I tried to removed the package and didn't get any error. Anyway, without the script everything works exactly the same way.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

1. I think at one point I was trying to use dpkg-architecture to grab the arch, but we get that from uname now, so I don't think dpkg-dev is needed. A quick look through the sources shows us only using the dpkg command itself, and not any of the dpkg-* stuff in dpkg-dev, so I'm going to go ahead and merge without that. Maybe we can get those jobs working today!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-09-05 07:43:32 +0000
3+++ Makefile 2012-10-05 14:20:31 +0000
4@@ -1,5 +1,8 @@
5 PYC_PATTERN?=*.pyc
6-all: client conf/utah/bootspeed-preseed.cfg conf/utah/bridged-network-vm.xml conf/utah/config manpages
7+all: python-jsonschema client conf/utah/bootspeed-preseed.cfg conf/utah/bridged-network-vm.xml conf/utah/config manpages
8+
9+python-jsonschema:
10+ apt-get download python-jsonschema
11
12 client:
13 [ -d "client" ] || mkdir client
14@@ -30,4 +33,4 @@
15 rm -f utah-*
16 cd docs && make clean
17
18-.PHONY: client clean manpages
19+.PHONY: python-jsonschema client clean manpages
20
21=== modified file 'debian/control'
22--- debian/control 2012-09-14 11:11:38 +0000
23+++ debian/control 2012-10-05 14:20:31 +0000
24@@ -3,7 +3,8 @@
25 X-Python-Version: >= 2.5
26 Priority: optional
27 Maintainer: Max Brustkern <max@canonical.com>
28-Build-Depends: debhelper (>= 7.0.50~), devscripts, python-all, python-sphinx
29+Build-Depends: debhelper (>= 7.0.50~), devscripts,
30+ python-all, python-sphinx, python-jsonschema (>= 0.5~)
31 Standards-Version: 3.9.3
32 Homepage: https://code.launchpad.net/utah
33 Vcs-Bzr: https://code.launchpad.net/utah
34
35=== modified file 'debian/utah.install'
36--- debian/utah.install 2012-09-26 15:20:13 +0000
37+++ debian/utah.install 2012-10-05 14:20:31 +0000
38@@ -2,4 +2,4 @@
39 conf/utah etc
40 examples usr/share/utah
41 utah-client_*_all.deb usr/share/utah
42-
43+python-jsonschema_*_all.deb usr/share/utah
44
45=== modified file 'utah/provisioning/provisioning.py'
46--- utah/provisioning/provisioning.py 2012-10-03 10:50:29 +0000
47+++ utah/provisioning/provisioning.py 2012-10-05 14:20:31 +0000
48@@ -17,6 +17,7 @@
49 import paramiko
50 import re
51 import apt.cache
52+from glob import glob
53
54 from utah.iso import ISO
55 from utah.preseed import Preseed
56@@ -256,6 +257,21 @@
57 self.logger.debug('Client deb path is ' + debpath)
58 return debpath
59
60+ def getjsonschemadeb(self):
61+ """
62+ Return the path of the .deb file for the python-jsonschema installed
63+ as part of the main package.
64+ """
65+ debpath = os.path.join('/usr', 'share', 'utah')
66+ deb_file_glob = os.path.join(debpath, 'python-jsonschema_*_all.deb')
67+ deb_files = glob(deb_file_glob)
68+ if not deb_files:
69+ raise UTAHProvisioningException('python-jsonschema package file '
70+ 'not found in {path}\n'
71+ .format(path=debpath))
72+ deb_file = deb_files[0]
73+ return deb_file
74+
75 def installclient(self):
76 """
77 Install the utah-client package on the
78@@ -263,36 +279,37 @@
79 """
80 self.logger.info('Installing client deb on machine')
81 tmppath = os.path.normpath('/tmp')
82- clientdeb = self.getclientdeb()
83- try:
84- self.uploadfiles([clientdeb], tmppath)
85- except UTAHProvisioningException as err:
86+ debs = [self.getjsonschemadeb(), self.getclientdeb()]
87+ for deb in debs:
88 try:
89- for myfile in err.files:
90- if 'utah-client' in myfile:
91- raise UTAHProvisioningException('Client file not '
92- + 'found; UTAH was probably updated '
93- + 'during the run. Please try again.',
94- retry=True)
95- raise err
96- except AttributeError:
97- raise err
98- if self.run('export DEBIAN_FRONTEND=noninteractive ; while '
99- + '(fuser /var/lib/dpkg/lock >/dev/null 2>&1) ; do echo '
100- + '"Waiting for dpkg lock to become available" ; sleep 10 ; '
101- + 'done ; dpkg -i ' + os.path.join(tmppath,
102- os.path.split(self.getclientdeb())[1])
103- + ' || apt-get -y -f install', root=True) != 0:
104- raise UTAHProvisioningException('Failed to install client')
105+ self.uploadfiles([deb], tmppath)
106+ except UTAHProvisioningException as err:
107+ try:
108+ for myfile in err.files:
109+ if deb in myfile:
110+ raise UTAHProvisioningException('File not '
111+ 'found: ' + deb + '; UTAH was probably '
112+ 'updated during the run. '
113+ 'Please try again.', retry=True)
114+ raise err
115+ except AttributeError:
116+ raise err
117
118- remote_clientdeb = os.path.join(tmppath, os.path.basename(clientdeb))
119- install_command = ('DEBIAN_FRONTEND=noninteractive '
120- 'gdebi -n -q {}'
121- .format(remote_clientdeb))
122- returncode, stdout, stderr = self.run(install_command, root=True)
123- if (returncode != 0
124- or re.search(r'script returned error exit status \d+', stderr)):
125- raise UTAHProvisioningException('Failed to install client\n')
126+ remote_deb = os.path.join(tmppath, os.path.basename(deb))
127+ install_command = (
128+ 'DEBIAN_FRONTEND=noninteractive; '
129+ 'while (fuser /var/lib/dpkg/lock >/dev/null 2>&1); '
130+ 'do '
131+ 'echo "Waiting for dpkg lock to become available"; '
132+ 'sleep 10; '
133+ 'done ; '
134+ 'gdebi -n -q {}'
135+ .format(remote_deb))
136+ returncode, stdout, stderr = self.run(install_command, root=True)
137+ if (returncode != 0 or
138+ re.search(r'script returned error exit status \d+',
139+ stderr)):
140+ raise UTAHProvisioningException('Failed to install client\n')
141
142 def _provision(self):
143 """
144@@ -757,9 +774,6 @@
145 mkdir -p /target/etc/utah
146 echo "{uuid}" > /target/etc/utah/uuid
147 echo "{user}" >> /target/etc/utah/users
148-
149-# Add stable PPA to get latest python-jsonschema version
150-chroot /target sh -c 'add-apt-repository -y ppa:utah/stable; apt-get update'
151 """.format(user=config.user, uuid=self.uuid))
152 latecommand.close()
153

Subscribers

People subscribed via source and target branches