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
=== modified file 'Makefile'
--- Makefile 2012-09-05 07:43:32 +0000
+++ Makefile 2012-10-05 14:20:31 +0000
@@ -1,5 +1,8 @@
1PYC_PATTERN?=*.pyc1PYC_PATTERN?=*.pyc
2all: client conf/utah/bootspeed-preseed.cfg conf/utah/bridged-network-vm.xml conf/utah/config manpages2all: python-jsonschema client conf/utah/bootspeed-preseed.cfg conf/utah/bridged-network-vm.xml conf/utah/config manpages
3
4python-jsonschema:
5 apt-get download python-jsonschema
36
4client:7client:
5 [ -d "client" ] || mkdir client8 [ -d "client" ] || mkdir client
@@ -30,4 +33,4 @@
30 rm -f utah-*33 rm -f utah-*
31 cd docs && make clean34 cd docs && make clean
3235
33.PHONY: client clean manpages36.PHONY: python-jsonschema client clean manpages
3437
=== modified file 'debian/control'
--- debian/control 2012-09-14 11:11:38 +0000
+++ debian/control 2012-10-05 14:20:31 +0000
@@ -3,7 +3,8 @@
3X-Python-Version: >= 2.53X-Python-Version: >= 2.5
4Priority: optional4Priority: optional
5Maintainer: Max Brustkern <max@canonical.com>5Maintainer: Max Brustkern <max@canonical.com>
6Build-Depends: debhelper (>= 7.0.50~), devscripts, python-all, python-sphinx6Build-Depends: debhelper (>= 7.0.50~), devscripts,
7 python-all, python-sphinx, python-jsonschema (>= 0.5~)
7Standards-Version: 3.9.38Standards-Version: 3.9.3
8Homepage: https://code.launchpad.net/utah9Homepage: https://code.launchpad.net/utah
9Vcs-Bzr: https://code.launchpad.net/utah10Vcs-Bzr: https://code.launchpad.net/utah
1011
=== modified file 'debian/utah.install'
--- debian/utah.install 2012-09-26 15:20:13 +0000
+++ debian/utah.install 2012-10-05 14:20:31 +0000
@@ -2,4 +2,4 @@
2conf/utah etc2conf/utah etc
3examples usr/share/utah3examples usr/share/utah
4utah-client_*_all.deb usr/share/utah4utah-client_*_all.deb usr/share/utah
55python-jsonschema_*_all.deb usr/share/utah
66
=== modified file 'utah/provisioning/provisioning.py'
--- utah/provisioning/provisioning.py 2012-10-03 10:50:29 +0000
+++ utah/provisioning/provisioning.py 2012-10-05 14:20:31 +0000
@@ -17,6 +17,7 @@
17import paramiko17import paramiko
18import re18import re
19import apt.cache19import apt.cache
20from glob import glob
2021
21from utah.iso import ISO22from utah.iso import ISO
22from utah.preseed import Preseed23from utah.preseed import Preseed
@@ -256,6 +257,21 @@
256 self.logger.debug('Client deb path is ' + debpath)257 self.logger.debug('Client deb path is ' + debpath)
257 return debpath258 return debpath
258259
260 def getjsonschemadeb(self):
261 """
262 Return the path of the .deb file for the python-jsonschema installed
263 as part of the main package.
264 """
265 debpath = os.path.join('/usr', 'share', 'utah')
266 deb_file_glob = os.path.join(debpath, 'python-jsonschema_*_all.deb')
267 deb_files = glob(deb_file_glob)
268 if not deb_files:
269 raise UTAHProvisioningException('python-jsonschema package file '
270 'not found in {path}\n'
271 .format(path=debpath))
272 deb_file = deb_files[0]
273 return deb_file
274
259 def installclient(self):275 def installclient(self):
260 """276 """
261 Install the utah-client package on the277 Install the utah-client package on the
@@ -263,36 +279,37 @@
263 """279 """
264 self.logger.info('Installing client deb on machine')280 self.logger.info('Installing client deb on machine')
265 tmppath = os.path.normpath('/tmp')281 tmppath = os.path.normpath('/tmp')
266 clientdeb = self.getclientdeb()282 debs = [self.getjsonschemadeb(), self.getclientdeb()]
267 try:283 for deb in debs:
268 self.uploadfiles([clientdeb], tmppath)
269 except UTAHProvisioningException as err:
270 try:284 try:
271 for myfile in err.files:285 self.uploadfiles([deb], tmppath)
272 if 'utah-client' in myfile:286 except UTAHProvisioningException as err:
273 raise UTAHProvisioningException('Client file not '287 try:
274 + 'found; UTAH was probably updated '288 for myfile in err.files:
275 + 'during the run. Please try again.',289 if deb in myfile:
276 retry=True)290 raise UTAHProvisioningException('File not '
277 raise err291 'found: ' + deb + '; UTAH was probably '
278 except AttributeError:292 'updated during the run. '
279 raise err293 'Please try again.', retry=True)
280 if self.run('export DEBIAN_FRONTEND=noninteractive ; while '294 raise err
281 + '(fuser /var/lib/dpkg/lock >/dev/null 2>&1) ; do echo '295 except AttributeError:
282 + '"Waiting for dpkg lock to become available" ; sleep 10 ; '296 raise err
283 + 'done ; dpkg -i ' + os.path.join(tmppath,
284 os.path.split(self.getclientdeb())[1])
285 + ' || apt-get -y -f install', root=True) != 0:
286 raise UTAHProvisioningException('Failed to install client')
287297
288 remote_clientdeb = os.path.join(tmppath, os.path.basename(clientdeb))298 remote_deb = os.path.join(tmppath, os.path.basename(deb))
289 install_command = ('DEBIAN_FRONTEND=noninteractive '299 install_command = (
290 'gdebi -n -q {}'300 'DEBIAN_FRONTEND=noninteractive; '
291 .format(remote_clientdeb))301 'while (fuser /var/lib/dpkg/lock >/dev/null 2>&1); '
292 returncode, stdout, stderr = self.run(install_command, root=True)302 'do '
293 if (returncode != 0303 'echo "Waiting for dpkg lock to become available"; '
294 or re.search(r'script returned error exit status \d+', stderr)):304 'sleep 10; '
295 raise UTAHProvisioningException('Failed to install client\n')305 'done ; '
306 'gdebi -n -q {}'
307 .format(remote_deb))
308 returncode, stdout, stderr = self.run(install_command, root=True)
309 if (returncode != 0 or
310 re.search(r'script returned error exit status \d+',
311 stderr)):
312 raise UTAHProvisioningException('Failed to install client\n')
296313
297 def _provision(self):314 def _provision(self):
298 """315 """
@@ -757,9 +774,6 @@
757mkdir -p /target/etc/utah774mkdir -p /target/etc/utah
758echo "{uuid}" > /target/etc/utah/uuid775echo "{uuid}" > /target/etc/utah/uuid
759echo "{user}" >> /target/etc/utah/users776echo "{user}" >> /target/etc/utah/users
760
761# Add stable PPA to get latest python-jsonschema version
762chroot /target sh -c 'add-apt-repository -y ppa:utah/stable; apt-get update'
763""".format(user=config.user, uuid=self.uuid))777""".format(user=config.user, uuid=self.uuid))
764 latecommand.close()778 latecommand.close()
765779

Subscribers

People subscribed via source and target branches