Merge lp:~sergiusens/snapcraft/1502449 into lp:~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 230
Merged at revision: 231
Proposed branch: lp:~sergiusens/snapcraft/1502449
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 45 lines (+18/-10)
1 file modified
snapcraft/cmds.py (+18/-10)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/1502449
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+273330@code.launchpad.net

Commit message

Build packages failing to install on the host or not found should be the cause of of a failure

Description of the change

I didn't write a unit test for this as I noticed I was mocking the world.

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
John Lenton (chipaca) wrote :

Ah, oops. inline.

lp:~sergiusens/snapcraft/1502449 updated
230. By Sergio Schvezov

Build packages failing to install on the host or not found should be the cause of of a failure

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snapcraft/cmds.py'
2--- snapcraft/cmds.py 2015-10-02 18:25:33 +0000
3+++ snapcraft/cmds.py 2015-10-04 20:03:53 +0000
4@@ -294,16 +294,7 @@
5 cmds = common.COMMAND_ORDER[0:common.COMMAND_ORDER.index(cmds[0]) + 1]
6
7 config = _load_config()
8-
9- # Install local packages that we need
10- if config.build_tools:
11- newPackages = []
12- for checkpkg in config.build_tools:
13- if subprocess.call(['dpkg-query', '-s', checkpkg], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0:
14- newPackages.append(checkpkg)
15- if newPackages:
16- print("Installing required packages on the host system: " + ", ".join(newPackages))
17- subprocess.call(['sudo', 'apt-get', '-y', 'install'] + newPackages, stdout=subprocess.DEVNULL)
18+ _install_build_packages(config.build_tools)
19
20 # clean the snap dir before Snapping
21 snap_clean = False
22@@ -343,6 +334,23 @@
23 return subprocess.check_call(args, **kwargs)
24
25
26+def _install_build_packages(packages):
27+ new_packages = []
28+ for check_pkg in packages:
29+ if subprocess.call(['dpkg-query', '-s', check_pkg], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0:
30+ new_packages.append(check_pkg)
31+ if new_packages:
32+ logger.info('Installing required packages on the host system')
33+ try:
34+ _check_call(
35+ ['sudo', 'apt-get', '-y', 'install'] + new_packages,
36+ stdout=subprocess.DEVNULL)
37+ except subprocess.CalledProcessError:
38+ logger.error('Could not find all the "build-packages" required '
39+ 'in snapcraft.yaml')
40+ sys.exit(1)
41+
42+
43 def _load_config():
44 global _config
45 if _config:

Subscribers

People subscribed via source and target branches