@@ -22,7 +22,11 @@ def get_links_from_url(url, d):
soup = BeautifulSoup(create_socket(url,d), "html.parser", parse_only=SoupStrainer("a"))
hyperlinks = []
for line in soup.find_all('a', href=True):
- hyperlinks.append(line['href'].strip('/'))
+ href = line['href']
+ # Some listings (e.g. MirrorCache) link to "./name/"
+ if href.startswith('./'):
+ href = href[2:]
+ hyperlinks.append(href.strip('/'))
return hyperlinks
def find_latest_numeric_release(url, d):
@@ -84,12 +88,30 @@ def get_latest_released_fedora_source_package_list(d):
package_names |= get_source_package_list_from_url_by_letter("http://archive.fedoraproject.org/pub/fedora/linux/updates/%s/SRPMS/" % latest, "updates", d)
return latest, package_names
+def find_latest_opensuse_leap_release(url, d):
+ "Find the latest Leap release on the given url, ignoring Leap 42.x, which came before 15.0"
+ releases = []
+ for link in get_links_from_url(url, d):
+ try:
+ version = tuple(int(n) for n in link.split("."))
+ except ValueError:
+ continue
+ if version[0] != 42:
+ releases.append((version, link))
+ return max(releases)[1] if releases else "_NotFound_"
+
def get_latest_released_opensuse_source_package_list(d):
"Returns list of all the name os packages in the latest opensuse distro"
- latest = find_latest_numeric_release("http://download.opensuse.org/source/distribution/leap", d)
+ from urllib.error import HTTPError
+ latest = find_latest_opensuse_leap_release("http://download.opensuse.org/source/distribution/leap/", d)
- package_names = get_source_package_list_from_url("http://download.opensuse.org/source/distribution/leap/%s/repo/oss/suse/src/" % latest, "main", d)
- package_names |= get_source_package_list_from_url("http://download.opensuse.org/update/leap/%s/oss/src/" % latest, "updates", d)
+ package_names = get_source_package_list_from_url("http://download.opensuse.org/source/distribution/leap/%s/repo/oss/src/" % latest, "main", d)
+ # Leap 16 has no separate update repository
+ try:
+ package_names |= get_source_package_list_from_url("http://download.opensuse.org/update/leap/%s/oss/src/" % latest, "updates", d)
+ except HTTPError as e:
+ if e.code != 404:
+ raise
return latest, package_names
def get_latest_released_clear_source_package_list(d):
@@ -57,6 +57,25 @@ class TestFindLatestUbuntuRelease(TestCase):
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 TestOpenSUSE(TestCase):
+ LISTING = b"""<a href="../">..</a> <a href="./15.0-Current/">15.0-Current/</a>
+<a href="./15.6/">15.6/</a> <a href="./16.0/">16.0/</a> <a href="./42.3/">42.3/</a>"""
+
+ def test_links_relative_to_current_directory(self):
+ try:
+ from bs4 import BeautifulSoup, SoupStrainer
+ except ImportError:
+ self.skipTest("bs4 is not available")
+ with mock.patch.object(oe.distro_check, "create_socket", return_value=io.BytesIO(self.LISTING)):
+ links = oe.distro_check.get_links_from_url("http://example.com/leap/", None)
+ self.assertEqual(links, ["..", "15.0-Current", "15.6", "16.0", "42.3"])
+
+ def test_latest_leap_release(self):
+ # Leap 42.x came before 15.0
+ links = ["..", "15.0-Current", "15.6", "16.0", "16.1", "42.2", "42.3", "42.3-Current"]
+ with mock.patch.object(oe.distro_check, "get_links_from_url", return_value=links):
+ self.assertEqual(oe.distro_check.find_latest_opensuse_leap_release("http://example.com/leap/", None), "16.1")
+
class TestCreateDistroPackagesList(TestCase):
def test_skip_failed_distro(self):
"""
download.opensuse.org's listings now link to "./15.6/", which find_latest_numeric_release() couldn't parse, so the Leap URLs had an empty release and failed with HTTP 404. Accept "./" links, ignore Leap 42.x (which came before 15.0), read the source RPMs from repo/oss/src/, where they now are, and allow for there being no update repository, as for Leap 16. Tested against download.opensuse.org: Leap 16.1 is fetched again. [YOCTO #16510] AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- meta/lib/oe/distro_check.py | 30 ++++++++++++++++--- .../oeqa/selftest/cases/oelib/distro_check.py | 19 ++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-)