launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #22436
[Merge] lp:~cjwatson/launchpad/pocket-chroot-from-livefs-build into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/pocket-chroot-from-livefs-build into lp:launchpad.
Commit message:
Add DistroArchSeries.setChrootFromBuild, allowing setting a chroot from a file produced by a livefs build.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/pocket-chroot-from-livefs-build/+merge/344912
Ideally we'd make PocketChroot be a history table so that rolling back is easy; but that isn't precluded by this change, and can be done later. I wanted to have a quick and easy way to take advantage of the work in https://code.launchpad.net/~cjwatson/livecd-rootfs/buildd/+merge/344767.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/pocket-chroot-from-livefs-build into lp:launchpad.
=== modified file 'lib/lp/_schema_circular_imports.py'
--- lib/lp/_schema_circular_imports.py 2017-01-09 17:53:16 +0000
+++ lib/lp/_schema_circular_imports.py 2018-05-01 19:02:49 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Update the interface schema values due to circular imports.
@@ -489,6 +489,8 @@
# IDistroArchSeries
patch_reference_property(IDistroArchSeries, 'main_archive', IArchive)
+patch_plain_parameter_type(
+ IDistroArchSeries, 'setChrootFromBuild', 'livefsbuild', ILiveFSBuild)
# IGitRef
patch_reference_property(IGitRef, 'repository', IGitRepository)
=== modified file 'lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py'
--- lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py 2018-02-01 18:44:21 +0000
+++ lib/lp/soyuz/browser/tests/test_distroarchseries_webservice.py 2018-05-01 19:02:49 +0000
@@ -13,8 +13,12 @@
)
from zope.security.management import endInteraction
+from lp.services.features.testing import FeatureFixture
+from lp.soyuz.interfaces.livefs import LIVEFS_FEATURE_FLAG
from lp.testing import (
+ api_url,
launchpadlib_for,
+ login_as,
TestCaseWithFactory,
ws_object,
)
@@ -118,3 +122,39 @@
self.assertTrue(ws_das.chroot_url.endswith(expected_file))
ws_das.removeChroot()
self.assertIsNone(ws_das.chroot_url)
+
+ def test_setChrootFromBuild(self):
+ self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"}))
+ das = self.factory.makeDistroArchSeries()
+ build = self.factory.makeLiveFSBuild()
+ build_url = api_url(build)
+ login_as(build.livefs.owner)
+ lfas = []
+ for filename in (
+ "livecd.ubuntu-base.rootfs.tar.gz",
+ "livecd.ubuntu-base.manifest"):
+ lfa = self.factory.makeLibraryFileAlias(filename=filename)
+ lfas.append(lfa)
+ build.addFile(lfa)
+ user = das.distroseries.distribution.main_archive.owner
+ webservice = launchpadlib_for("testing", user)
+ ws_das = ws_object(webservice, das)
+ ws_das.setChrootFromBuild(
+ livefsbuild=build_url, filename="livecd.ubuntu-base.rootfs.tar.gz")
+ self.assertEqual(lfas[0], das.getChroot())
+
+ def test_setChrootFromBuild_random_user(self):
+ # Random users are not allowed to set chroots from a livefs build.
+ self.useFixture(FeatureFixture({LIVEFS_FEATURE_FLAG: "on"}))
+ das = self.factory.makeDistroArchSeries()
+ build = self.factory.makeLiveFSBuild()
+ build_url = api_url(build)
+ login_as(build.livefs.owner)
+ build.addFile(self.factory.makeLibraryFileAlias(
+ filename="livecd.ubuntu-base.rootfs.tar.gz"))
+ user = self.factory.makePerson()
+ webservice = launchpadlib_for("testing", user, version='devel')
+ ws_das = ws_object(webservice, das)
+ self.assertRaises(
+ Unauthorized, ws_das.setChrootFromBuild,
+ livefsbuild=build_url, filename="livecd.ubuntu-base.rootfs.tar.gz")
=== modified file 'lib/lp/soyuz/interfaces/distroarchseries.py'
--- lib/lp/soyuz/interfaces/distroarchseries.py 2015-05-13 09:37:29 +0000
+++ lib/lp/soyuz/interfaces/distroarchseries.py 2018-05-01 19:02:49 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Distribution architecture series interfaces."""
@@ -186,6 +186,16 @@
The SHA-1 checksum must match the chroot file.
"""
+ @operation_parameters(
+ # Really ILiveFSBuild, patched in _schema_circular_imports.py.
+ livefsbuild=Reference(
+ Interface, title=_("Live filesystem build"), required=True),
+ filename=TextLine(title=_("Filename"), required=True))
+ @export_write_operation()
+ @operation_for_version("devel")
+ def setChrootFromBuild(livefsbuild, filename):
+ """Set the chroot tarball from a live filesystem build."""
+
@export_write_operation()
@operation_for_version("devel")
def removeChroot():
=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
--- lib/lp/soyuz/model/distroarchseries.py 2015-07-08 16:05:11 +0000
+++ lib/lp/soyuz/model/distroarchseries.py 2018-05-01 19:02:49 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -194,6 +194,10 @@
raise InvalidChrootUploaded("Chroot upload checksums do not match")
self.addOrUpdateChroot(lfa)
+ def setChrootFromBuild(self, livefsbuild, filename):
+ """See `IDistroArchSeries`."""
+ self.addOrUpdateChroot(livefsbuild.getFileByName(filename))
+
def removeChroot(self):
"""See `IDistroArchSeries`."""
self.addOrUpdateChroot(None)
Follow ups