launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #21987
[Merge] lp:~cjwatson/launchpad-buildd/is-package-available-virtual into lp:launchpad-buildd
Colin Watson has proposed merging lp:~cjwatson/launchpad-buildd/is-package-available-virtual into lp:launchpad-buildd.
Commit message:
Make Backend.is_package_available handle the case where the requested
package name is purely virtual.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/is-package-available-virtual/+merge/333104
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad-buildd/is-package-available-virtual into lp:launchpad-buildd.
=== modified file 'debian/changelog'
--- debian/changelog 2017-11-01 11:17:44 +0000
+++ debian/changelog 2017-11-01 23:05:53 +0000
@@ -12,6 +12,8 @@
* Raise more useful exceptions when LXD.copy_in or LXD.copy_out fail.
* Make Backend.run implementations print command output if echo and
get_output are both true.
+ * Make Backend.is_package_available handle the case where the requested
+ package name is purely virtual.
-- Colin Watson <cjwatson@xxxxxxxxxx> Fri, 08 Sep 2017 13:42:17 +0100
=== modified file 'lpbuildd/target/backend.py'
--- lpbuildd/target/backend.py 2017-11-01 11:17:44 +0000
+++ lpbuildd/target/backend.py 2017-11-01 23:05:53 +0000
@@ -152,10 +152,10 @@
"""
try:
with open("/dev/null", "w") as devnull:
- self.run(
+ output = self.run(
["apt-cache", "show", package],
- stdout=devnull, stderr=devnull)
- return True
+ get_output=True, stderr=devnull)
+ return output.startswith("Package:")
except subprocess.CalledProcessError:
return False
=== modified file 'lpbuildd/target/tests/test_chroot.py'
--- lpbuildd/target/tests/test_chroot.py 2017-09-08 15:57:18 +0000
+++ lpbuildd/target/tests/test_chroot.py 2017-11-01 23:05:53 +0000
@@ -271,18 +271,24 @@
def test_is_package_available(self):
self.useFixture(EnvironmentVariable("HOME", "/expected/home"))
processes_fixture = self.useFixture(FakeProcesses())
- test_proc_infos = iter([{}, {"returncode": 100}])
+ test_proc_infos = iter([
+ {"stdout": io.BytesIO(b"Package: snapd\n")},
+ {"returncode": 100},
+ {"stderr": io.BytesIO(b"N: No packages found\n")},
+ ])
processes_fixture.add(lambda _: next(test_proc_infos), name="sudo")
self.assertTrue(
Chroot("1", "xenial", "amd64").is_package_available("snapd"))
self.assertFalse(
Chroot("1", "xenial", "amd64").is_package_available("nonexistent"))
+ self.assertFalse(
+ Chroot("1", "xenial", "amd64").is_package_available("virtual"))
expected_args = [
["sudo", "/usr/sbin/chroot",
"/expected/home/build-1/chroot-autobuild",
"linux64", "apt-cache", "show", package]
- for package in ("snapd", "nonexistent")
+ for package in ("snapd", "nonexistent", "virtual")
]
self.assertEqual(
expected_args,
=== modified file 'lpbuildd/target/tests/test_lxd.py'
--- lpbuildd/target/tests/test_lxd.py 2017-11-01 11:13:36 +0000
+++ lpbuildd/target/tests/test_lxd.py 2017-11-01 23:05:53 +0000
@@ -593,17 +593,23 @@
def test_is_package_available(self):
processes_fixture = self.useFixture(FakeProcesses())
- test_proc_infos = iter([{}, {"returncode": 100}])
+ test_proc_infos = iter([
+ {"stdout": io.BytesIO(b"Package: snapd\n")},
+ {"returncode": 100},
+ {"stderr": io.BytesIO(b"N: No packages found\n")},
+ ])
processes_fixture.add(lambda _: next(test_proc_infos), name="lxc")
self.assertTrue(
LXD("1", "xenial", "amd64").is_package_available("snapd"))
self.assertFalse(
LXD("1", "xenial", "amd64").is_package_available("nonexistent"))
+ self.assertFalse(
+ LXD("1", "xenial", "amd64").is_package_available("virtual"))
expected_args = [
["lxc", "exec", "lp-xenial-amd64", "--",
"linux64", "apt-cache", "show", package]
- for package in ("snapd", "nonexistent")
+ for package in ("snapd", "nonexistent", "virtual")
]
self.assertEqual(
expected_args,