@@ -131,23 +131,25 @@ def get_latest_released_debian_source_package_list(d):
package_names |= get_debian_style_source_package_list(url, "updates", d)
return latest, package_names
-def find_latest_ubuntu_release(url, d):
+def find_latest_ubuntu_release(d):
"""
- Find the latest listed Ubuntu release on the given ubuntu/dists/ URL.
-
- To avoid matching development releases look for distributions that have
- updates, so the resulting distro could be any supported release.
+ Find the latest supported Ubuntu release, from the list of releases
+ that do-release-upgrade reads. The releases are listed oldest first.
"""
- url += "?C=M;O=D" # Descending Sort by Last Modified
- for link in get_links_from_url(url, d):
- if "-updates" in link:
- distro = link.replace("-updates", "")
- return distro
- return "_NotFound_"
+ latest = "_NotFound_"
+ dist = None
+ listing = create_socket("https://changelogs.ubuntu.com/meta-release", d).read().decode("utf-8")
+ for line in listing.splitlines():
+ key, _, value = line.partition(":")
+ if key == "Dist":
+ dist = value.strip()
+ elif key == "Supported" and value.strip() == "1" and dist:
+ latest = dist
+ return latest
def get_latest_released_ubuntu_source_package_list(d):
"Returns list of all the name os packages in the latest ubuntu distro"
- latest = find_latest_ubuntu_release("http://archive.ubuntu.com/ubuntu/dists/", d)
+ latest = find_latest_ubuntu_release(d)
url = "http://archive.ubuntu.com/ubuntu/dists/%s/main/source/Sources.gz" % latest
package_names = get_debian_style_source_package_list(url, "main", d)
url = "http://archive.ubuntu.com/ubuntu/dists/%s-updates/main/source/Sources.gz" % latest
@@ -31,6 +31,32 @@ class TestDebianStyleSourcePackageList(TestCase):
def test_xz(self):
self.check("http://example.com/Sources.xz", lzma.compress(SOURCES))
+META_RELEASE = b"""Dist: noble
+Name: Noble Numbat
+Version: 24.04.5 LTS
+Supported: 1
+
+Dist: questing
+Name: Questing Quokka
+Version: 25.10
+Supported: 0
+
+Dist: resolute
+Name: Resolute Raccoon
+Version: 26.04.1 LTS
+Supported: 1
+
+Dist: zzz
+Name: Not supported any more
+Version: 99.10
+Supported: 0
+"""
+
+class TestFindLatestUbuntuRelease(TestCase):
+ def test_latest_supported(self):
+ with mock.patch.object(oe.distro_check, "create_socket", return_value=io.BytesIO(META_RELEASE)):
+ self.assertEqual(oe.distro_check.find_latest_ubuntu_release(None), "resolute")
+
class TestCreateDistroPackagesList(TestCase):
def test_skip_failed_distro(self):
"""
find_latest_ubuntu_release() asked the archive for its dists/ listing newest first and took the first *-updates entry, but the archive ignores the sort and lists the oldest first, so Ubuntu was always xenial. Read the release list that do-release-upgrade uses instead, and take the last supported release. Tested against changelogs.ubuntu.com and archive.ubuntu.com: resolute, with main and updates packages. [YOCTO #16509] AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- meta/lib/oe/distro_check.py | 26 ++++++++++--------- .../oeqa/selftest/cases/oelib/distro_check.py | 26 +++++++++++++++++++ 2 files changed, 40 insertions(+), 12 deletions(-)