Merge ~bryanfraschetti/ubuntu/+source/landscape-client:lp2087852-focal into ubuntu/+source/landscape-client:ubuntu/focal-devel

Proposed by Bryan Fraschetti
Status: Needs review
Proposed branch: ~bryanfraschetti/ubuntu/+source/landscape-client:lp2087852-focal
Merge into: ubuntu/+source/landscape-client:ubuntu/focal-devel
Diff against target: 195 lines (+173/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/2087852-feat-manage-ubuntu-sources-glob.patch (+165/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Mitch Burton (community) Disapprove
Lukas Märdian (community) Approve
git-ubuntu import Pending
Review via email: mp+483094@code.launchpad.net

Commit message

SRU: Include DEB822 sources when applying profiles

Include upstream commit that adds support for DEB822 sources files when
applying repository profiles. The bug report LP: #2087852 outlines that
in the current implementation only .list files are supported which
prevents customers from customizing their archive sources as intended

To post a comment you must log in.
ae86177... by Bryan Fraschetti

Fix DEP-3 nit and Remove Upstream Cosmetic Changes

Per Ubuntu Sponsor team's advisory, I have removed some changes from the
upstream commit which redefined some variables such as "sources1" to
source1. This should make the SRU more palatable for the SRU team

Revision history for this message
Lukas Märdian (slyon) wrote :

Same as Jammy: https://code.launchpad.net/~bryanfraschetti/ubuntu/+source/landscape-client/+git/landscape-client/+merge/483095

I'll be fixing the nitpicks, especially the version string! (23.02-0ubuntu1~20.04.6).

LGTM.

review: Approve
Revision history for this message
Mitch Burton (mitchburton) wrote :
review: Disapprove

Unmerged commits

ae86177... by Bryan Fraschetti

Fix DEP-3 nit and Remove Upstream Cosmetic Changes

Per Ubuntu Sponsor team's advisory, I have removed some changes from the
upstream commit which redefined some variables such as "sources1" to
source1. This should make the SRU more palatable for the SRU team

6985afc... by Bryan Fraschetti

SRU: Include DEB822 sources when applying profiles

Include upstream commit that adds support for DEB822 sources files when
applying repository profiles. The bug report LP: #2087852 outlines that
in the current implementation only .list files are supported which
prevents customers from customizing their archive sources as intended

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 86246ae..11d7aaf 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+landscape-client (23.02-0ubuntu1~20.04.5ubuntu1) focal; urgency=medium
7+
8+ * d/p/2087852-feat-manage-ubuntu-sources-glob.patch: include DEB822 formatted sources
9+ when managing apt sources by regex matching .sources files (LP: #2087852)
10+
11+ -- Bryan Fraschetti <bryan.fraschetti@canonical.com> Fri, 14 Mar 2025 21:29:38 +0000
12+
13 landscape-client (23.02-0ubuntu1~20.04.5) focal; urgency=medium
14
15 * d/p/0002-fix-locale-error.path: revert previous fix for #1827857, as
16diff --git a/debian/patches/2087852-feat-manage-ubuntu-sources-glob.patch b/debian/patches/2087852-feat-manage-ubuntu-sources-glob.patch
17new file mode 100644
18index 0000000..9e4fbf8
19--- /dev/null
20+++ b/debian/patches/2087852-feat-manage-ubuntu-sources-glob.patch
21@@ -0,0 +1,165 @@
22+Subject: feat: add support for .sources when applying repository profiles
23+
24+ This is the backport of an upstream commit which added support to manage
25+ ubuntu sources in DEB822 format (.sources files) alongside the one-liner
26+ format (.list files). The bug reported is outlined in LP: #2087852.
27+
28+Origin: upstream, https://github.com/canonical/landscape-client/commit/556f87c2819b218029ba0a13e2b2ceddfbec3e6b
29+Bug-Ubuntu: https://bugs.launchpad.net/landscape-client/+bug/2087852
30+Last-Update: 2025-04-02
31+Author: Jan Dhillon <jan.dhillon@canonical.com>
32+
33+diff --git a/landscape/client/manager/aptsources.py b/landscape/client/manager/aptsources.py
34+index 866c6ba..4aa9e26 100644
35+--- a/landscape/client/manager/aptsources.py
36++++ b/landscape/client/manager/aptsources.py
37+@@ -25,6 +25,11 @@ class AptSources(ManagerPlugin):
38+ SOURCES_LIST_D = "/etc/apt/sources.list.d"
39+ TRUSTED_GPG_D = "/etc/apt/trusted.gpg.d"
40+
41++ """
42++ Valid file patterns for one-line and Deb822-style sources, respectively.
43++ """
44++ SOURCES_LIST_D_FILE_PATTERNS = ["*.list", "*.sources"]
45++
46+ def register(self, registry):
47+ super(AptSources, self).register(registry)
48+ registry.register_message("apt-sources-replace",
49+@@ -120,8 +125,12 @@ class AptSources(ManagerPlugin):
50+ if os.path.isfile(saved_sources):
51+ shutil.move(saved_sources, self.SOURCES_LIST)
52+
53+- for filename in glob.glob(os.path.join(self.SOURCES_LIST_D, "*.list")):
54+- shutil.move(filename, "%s.save" % filename)
55++ for pattern in self.SOURCES_LIST_D_FILE_PATTERNS:
56++ filenames = glob.glob(
57++ os.path.join(self.SOURCES_LIST_D, pattern)
58++ )
59++ for filename in filenames:
60++ shutil.move(filename, f"{filename}.save")
61+
62+ for source in sources:
63+ filename = os.path.join(self.SOURCES_LIST_D,
64+diff --git a/landscape/client/manager/tests/test_aptsources.py b/landscape/client/manager/tests/test_aptsources.py
65+index a4d2cd8..4f872a6 100644
66+--- a/landscape/client/manager/tests/test_aptsources.py
67++++ b/landscape/client/manager/tests/test_aptsources.py
68+@@ -212,15 +212,27 @@ class AptSourcesTests(LandscapeTest):
69+
70+ def test_rename_sources_list_d(self):
71+ """
72+- The sources files in sources.list.d are renamed to .save when a message
73+- is received.
74++ The sources files (.list, .sources) in sources.list.d
75++ are renamed to .save when a message is received
76++ if config says to manage them, which is the default.
77+ """
78+- with open(os.path.join(self.sourceslist.SOURCES_LIST_D, "file1.list"),
79+- "w") as sources1:
80++ FILE_1_LIST = os.path.join(
81++ self.sourceslist.SOURCES_LIST_D, "file1.list"
82++ )
83++
84++ FILE_2_SOURCES = os.path.join(
85++ self.sourceslist.SOURCES_LIST_D, "file2.sources"
86++ )
87++ with open(
88++ FILE_1_LIST,
89++ "w"
90++ ) as sources1:
91+ sources1.write("ok\n")
92+
93+- with open(os.path.join(self.sourceslist.SOURCES_LIST_D,
94+- "file2.list.save"), "w") as sources2:
95++ with open(
96++ FILE_2_SOURCES,
97++ "w"
98++ ) as sources2:
99+ sources2.write("ok\n")
100+
101+ self.manager.dispatch_message(
102+@@ -228,18 +240,18 @@ class AptSourcesTests(LandscapeTest):
103+ "operation-id": 1})
104+
105+ self.assertFalse(
106+- os.path.exists(
107+- os.path.join(self.sourceslist.SOURCES_LIST_D, "file1.list")))
108++ os.path.exists(FILE_1_LIST),
109++ )
110++
111++ self.assertFalse(os.path.exists(FILE_2_SOURCES))
112+
113+ self.assertTrue(
114+- os.path.exists(
115+- os.path.join(self.sourceslist.SOURCES_LIST_D,
116+- "file1.list.save")))
117++ os.path.exists(f"{FILE_1_LIST}.save"),
118++ )
119+
120+ self.assertTrue(
121+- os.path.exists(
122+- os.path.join(self.sourceslist.SOURCES_LIST_D,
123+- "file2.list.save")))
124++ os.path.exists(f"{FILE_2_SOURCES}.save"),
125++ )
126+
127+ def test_create_landscape_sources(self):
128+ """
129+@@ -289,6 +301,57 @@ class AptSourcesTests(LandscapeTest):
130+
131+ self.assertCountEqual(keys, gpg_keys)
132+
133++ def test_does_not_rename_sources_list_d(self):
134++ """
135++ The sources files (.list, .sources) in sources.list.d
136++ are not renamed to .save when a message is received
137++ if config says not to manage them
138++ """
139++ FILE_3_LIST = os.path.join(
140++ self.sourceslist.SOURCES_LIST_D, "file3.list"
141++ )
142++
143++ FILE_4_SOURCES = os.path.join(
144++ self.sourceslist.SOURCES_LIST_D, "file4.sources"
145++ )
146++ with open(
147++ FILE_3_LIST,
148++ "w",
149++ ) as source3:
150++ source3.write("ok\n")
151++ with open(
152++ FILE_4_SOURCES,
153++ "w",
154++ ) as source4:
155++ source4.write("ok\n")
156++
157++ self.manager.config.manage_sources_list_d = False
158++ self.manager.dispatch_message(
159++ {
160++ "type": "apt-sources-replace",
161++ "sources": [],
162++ "gpg-keys": [],
163++ "operation-id": 1,
164++ },
165++ )
166++
167++ self.assertTrue(
168++ os.path.exists(FILE_3_LIST),
169++ )
170++
171++ self.assertTrue(
172++ os.path.exists(FILE_4_SOURCES),
173++ )
174++
175++ self.assertFalse(
176++ os.path.exists(f"{FILE_3_LIST}.save"),
177++ )
178++
179++ self.assertFalse(
180++ os.path.exists(f"{FILE_4_SOURCES}.save"),
181++ )
182++
183++
184+ def test_run_reporter(self):
185+ """
186+ After receiving a message, L{AptSources} triggers a reporter run to
187diff --git a/debian/patches/series b/debian/patches/series
188index 1d2050f..118a765 100644
189--- a/debian/patches/series
190+++ b/debian/patches/series
191@@ -1,3 +1,4 @@
192 0001-start-service-during-config.patch
193 add-non-filtered-interfaces-to-the-api-response.patch
194 0002-fix-locale-error.patch
195+2087852-feat-manage-ubuntu-sources-glob.patch

Subscribers

People subscribed via source and target branches