Merge ~kxuan/launchpad-buildd:add-lb-ubuntu-images-repo into launchpad-buildd:master

Proposed by Zhaoxuan Zhai
Status: Needs review
Proposed branch: ~kxuan/launchpad-buildd:add-lb-ubuntu-images-repo
Merge into: launchpad-buildd:master
Diff against target: 133 lines (+80/-0)
4 files modified
lpbuildd/livefs.py (+3/-0)
lpbuildd/target/build_livefs.py (+8/-0)
lpbuildd/target/tests/test_build_livefs.py (+57/-0)
lpbuildd/tests/test_livefs.py (+12/-0)
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+464879@code.launchpad.net

Description of the change

buildlivefs: support passing LB_UBUNTU_IMAGES_REPO into the environment

LB_UBUNTU_IMAGES_REPO is required by users who wants to build image with their own image definition.

To post a comment you must log in.

Unmerged commits

17de74b... by Zhaoxuan Zhai

buildlivefs: support passing LB_UBUNTU_IMAGES_REPO into the environment

LB_UBUNTU_IMAGES_REPO is required by users who use their own image
definition.

Signed-off-by: Zhai Zhaoxuan <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lpbuildd/livefs.py b/lpbuildd/livefs.py
2index 6e8da92..0e336f1 100644
3--- a/lpbuildd/livefs.py
4+++ b/lpbuildd/livefs.py
5@@ -37,6 +37,7 @@ class LiveFilesystemBuildManager(DebianBuildManager):
6 self.repo_snapshot_stamp = extra_args.get("repo_snapshot_stamp")
7 self.cohort_key = extra_args.get("cohort-key")
8 self.debug = extra_args.get("debug", False)
9+ self.lb_ubuntu_images_repo = extra_args.get("lb_ubuntu_images_repo")
10
11 super().initiate(files, chroot, extra_args)
12
13@@ -68,6 +69,8 @@ class LiveFilesystemBuildManager(DebianBuildManager):
14 args.extend(["--repo-snapshot-stamp", self.repo_snapshot_stamp])
15 if self.cohort_key:
16 args.extend(["--cohort-key", self.cohort_key])
17+ if self.lb_ubuntu_images_repo:
18+ args.extend(["--lb-ubuntu-images-repo", self.lb_ubuntu_images_repo])
19 try:
20 snap_store_proxy_url = self._builder._config.get(
21 "proxy", "snapstore"
22diff --git a/lpbuildd/target/build_livefs.py b/lpbuildd/target/build_livefs.py
23index ed94328..05d66e5 100644
24--- a/lpbuildd/target/build_livefs.py
25+++ b/lpbuildd/target/build_livefs.py
26@@ -109,6 +109,12 @@ class BuildLiveFS(SnapStoreOperationMixin, Operation):
27 action="store_true",
28 help="enable detailed live-build debugging",
29 )
30+ parser.add_argument(
31+ "--lb-ubuntu-images-repo",
32+ dest="lb_ubuntu_images_repo",
33+ metavar="LB_UBUNTU_IMAGES_REPO",
34+ help="specify the location of image definition for ubuntu-image"
35+ )
36
37 def install(self):
38 deps = ["livecd-rootfs"]
39@@ -191,6 +197,8 @@ class BuildLiveFS(SnapStoreOperationMixin, Operation):
40 lb_env["EXTRA_PPAS"] = " ".join(self.args.extra_ppas)
41 if self.args.extra_snaps:
42 lb_env["EXTRA_SNAPS"] = " ".join(self.args.extra_snaps)
43+ if self.args.lb_ubuntu_images_repo:
44+ lb_env["LB_UBUNTU_IMAGES_REPO"] = self.args.lb_ubuntu_images_repo
45 if self.args.http_proxy:
46 proxy_dict = {
47 "http_proxy": self.args.http_proxy,
48diff --git a/lpbuildd/target/tests/test_build_livefs.py b/lpbuildd/target/tests/test_build_livefs.py
49index ad220c3..012356f 100644
50--- a/lpbuildd/target/tests/test_build_livefs.py
51+++ b/lpbuildd/target/tests/test_build_livefs.py
52@@ -440,3 +440,60 @@ class TestBuildLiveFS(TestCase):
53 build_livefs = parse_args(args=args).operation
54 build_livefs.backend.run = FailBuild()
55 self.assertEqual(RETCODE_FAILURE_BUILD, build_livefs.run())
56+
57+ def test_build_with_lb_ubuntu_images(self):
58+ args = [
59+ "buildlivefs",
60+ "--backend=fake",
61+ "--series=noble",
62+ "--arch=arm64",
63+ "--project=ubuntu-cpc",
64+ "1",
65+ "--lb-ubuntu-images-repo=http://example.com/git-repo.git",
66+ ]
67+ build_livefs = parse_args(args=args).operation
68+ build_livefs.build()
69+ self.assertThat(
70+ build_livefs.backend.run.calls,
71+ MatchesListwise(
72+ [
73+ RanBuildCommand(["rm", "-rf", "auto", "local"]),
74+ RanBuildCommand(["mkdir", "-p", "auto"]),
75+ RanBuildCommand(
76+ [
77+ "ln",
78+ "-s",
79+ "/usr/share/livecd-rootfs/live-build/auto/config",
80+ "auto/",
81+ ]
82+ ),
83+ RanBuildCommand(
84+ [
85+ "ln",
86+ "-s",
87+ "/usr/share/livecd-rootfs/live-build/auto/build",
88+ "auto/",
89+ ]
90+ ),
91+ RanBuildCommand(
92+ [
93+ "ln",
94+ "-s",
95+ "/usr/share/livecd-rootfs/live-build/auto/clean",
96+ "auto/",
97+ ]
98+ ),
99+ RanBuildCommand(["lb", "clean", "--purge"]),
100+ RanBuildCommand(
101+ ["lb", "config"],
102+ PROJECT="ubuntu-cpc",
103+ ARCH="arm64",
104+ SUITE="noble",
105+ LB_UBUNTU_IMAGES_REPO="http://example.com/git-repo.git",
106+ ),
107+ RanBuildCommand(
108+ ["lb", "build"], PROJECT="ubuntu-cpc", ARCH="arm64"
109+ ),
110+ ]
111+ ),
112+ )
113diff --git a/lpbuildd/tests/test_livefs.py b/lpbuildd/tests/test_livefs.py
114index 25eea06..a5cc69f 100644
115--- a/lpbuildd/tests/test_livefs.py
116+++ b/lpbuildd/tests/test_livefs.py
117@@ -214,3 +214,15 @@ class TestLiveFilesystemBuildManagerIteration(TestCase):
118 }
119 ),
120 )
121+
122+ @defer.inlineCallbacks
123+ def test_build_with_lb_ubuntu_images(self):
124+ yield self.startBuild(
125+ args={
126+ "lb_ubuntu_images_repo": "http://example.com/git-repo.git",
127+ },
128+ options=[
129+ "--lb-ubuntu-images-repo",
130+ "http://example.com/git-repo.git",
131+ ],
132+ )
133\ No newline at end of file

Subscribers

People subscribed via source and target branches