mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 06:56:17 -05:00
Merge pull request #717 from yuezk/fix/release-publication-metadata
fix: verify current distribution metadata
This commit is contained in:
3 files changed
+29
-15
No files matched your search
@@ -22,7 +22,6 @@ pkgbase = globalprotect-openconnect-git
|
|||||||
makedepends = librsvg
|
makedepends = librsvg
|
||||||
makedepends = cargo
|
makedepends = cargo
|
||||||
depends = webkit2gtk-4.1
|
depends = webkit2gtk-4.1
|
||||||
depends = libappindicator-gtk3
|
|
||||||
depends = libsecret
|
depends = libsecret
|
||||||
depends = libxml2
|
depends = libxml2
|
||||||
depends = zlib
|
depends = zlib
|
||||||
|
|||||||
@@ -39,14 +39,6 @@ class RepositoryTests(unittest.TestCase):
|
|||||||
with self.assertRaises(publication.Pending):
|
with self.assertRaises(publication.Pending):
|
||||||
publication.rpm_packages("https://repo")
|
publication.rpm_packages("https://repo")
|
||||||
|
|
||||||
def test_copr_same_version_from_another_build_does_not_pass(self):
|
|
||||||
primary = ET.fromstring('''<metadata xmlns="http://linux.duke.edu/metadata/common"><package>
|
|
||||||
<name>globalprotect-openconnect</name><arch>x86_64</arch><version ver="3.0.1" rel="1.fc44"/>
|
|
||||||
<location href="011106217-globalprotect-openconnect/package.rpm"/></package></metadata>''')
|
|
||||||
with patch.object(publication, "rpm_packages", return_value=primary):
|
|
||||||
params = ("https://repo", "globalprotect-openconnect", "3.0.1", "x86_64", lambda release: True)
|
|
||||||
self.assertTrue(publication.rpm_present(*params, build_id=11106217))
|
|
||||||
self.assertFalse(publication.rpm_present(*params, build_id=11106218))
|
|
||||||
|
|
||||||
|
|
||||||
class LaunchpadTests(unittest.TestCase):
|
class LaunchpadTests(unittest.TestCase):
|
||||||
@@ -138,6 +130,25 @@ class OBSTests(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class CoprTests(unittest.TestCase):
|
class CoprTests(unittest.TestCase):
|
||||||
|
def test_migrated_repository_matches_exact_build_manifest(self):
|
||||||
|
checker = publication.Copr(arguments(build_id=42))
|
||||||
|
build = {"ownername": "yuezk", "projectname": "globalprotect-openconnect",
|
||||||
|
"state": "succeeded", "source_package": {"name": "globalprotect-openconnect", "version": "3.0.1-1"},
|
||||||
|
"chroots": ["fedora-44-x86_64"], "repo_url": "https://repo"}
|
||||||
|
status = {"state": "succeeded", "result_url": "https://results/42/"}
|
||||||
|
package = {"name": "globalprotect-openconnect", "version": "3.0.1", "release": "1.fc44", "arch": "x86_64"}
|
||||||
|
primary = ET.fromstring('''<metadata xmlns="http://linux.duke.edu/metadata/common"><package>
|
||||||
|
<name>globalprotect-openconnect</name><arch>x86_64</arch><version ver="3.0.1" rel="1.fc44"/>
|
||||||
|
<location href="Packages/g/globalprotect-openconnect-3.0.1-1.fc44.x86_64.rpm"/></package></metadata>''')
|
||||||
|
with patch.object(publication, "api", side_effect=[build, status, {"packages": [package]}]), \
|
||||||
|
patch.object(publication, "rpm_packages", return_value=primary):
|
||||||
|
self.assertIn("1 targets built and published", checker.check())
|
||||||
|
package["release"] = "1.fc45"
|
||||||
|
with patch.object(publication, "api", side_effect=[build, status, {"packages": [package]}]), \
|
||||||
|
patch.object(publication, "rpm_packages", return_value=primary):
|
||||||
|
with self.assertRaisesRegex(publication.Pending, "Waiting for Copr build 42"):
|
||||||
|
checker.check()
|
||||||
|
|
||||||
def test_unselected_chroot_cannot_be_hidden_by_verification(self):
|
def test_unselected_chroot_cannot_be_hidden_by_verification(self):
|
||||||
checker = publication.Copr(arguments(build_id=42, chroots=["fedora-44-x86_64"]))
|
checker = publication.Copr(arguments(build_id=42, chroots=["fedora-44-x86_64"]))
|
||||||
build = {"ownername": "yuezk", "projectname": "globalprotect-openconnect",
|
build = {"ownername": "yuezk", "projectname": "globalprotect-openconnect",
|
||||||
|
|||||||
@@ -84,17 +84,14 @@ def rpm_packages(base_url):
|
|||||||
return ET.fromstring(unpack(content, location))
|
return ET.fromstring(unpack(content, location))
|
||||||
|
|
||||||
|
|
||||||
def rpm_present(base_url, package, version, arch, release_matches, build_id=None):
|
def rpm_present(base_url, package, version, arch, release_matches):
|
||||||
namespace = {"rpm": "http://linux.duke.edu/metadata/common"}
|
namespace = {"rpm": "http://linux.duke.edu/metadata/common"}
|
||||||
for entry in rpm_packages(base_url).findall("rpm:package", namespace):
|
for entry in rpm_packages(base_url).findall("rpm:package", namespace):
|
||||||
info = entry.find("rpm:version", namespace)
|
info = entry.find("rpm:version", namespace)
|
||||||
location = entry.find("rpm:location", namespace).get("href")
|
|
||||||
if (entry.findtext("rpm:name", namespaces=namespace) != package or
|
if (entry.findtext("rpm:name", namespaces=namespace) != package or
|
||||||
entry.findtext("rpm:arch", namespaces=namespace) != arch or
|
entry.findtext("rpm:arch", namespaces=namespace) != arch or
|
||||||
info.get("ver") != version or not release_matches(info.get("rel", ""))):
|
info.get("ver") != version or not release_matches(info.get("rel", ""))):
|
||||||
continue
|
continue
|
||||||
if build_id is not None and not re.search(rf"(?:^|/)0*{build_id}-", location):
|
|
||||||
continue
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -254,9 +251,16 @@ class Copr:
|
|||||||
raise Pending(f"Copr {chroot}: {status['state']}; {link}")
|
raise Pending(f"Copr {chroot}: {status['state']}; {link}")
|
||||||
base = build["repo_url"].rstrip("/") + "/" + chroot
|
base = build["repo_url"].rstrip("/") + "/" + chroot
|
||||||
arch = chroot.rsplit("-", 1)[1]
|
arch = chroot.rsplit("-", 1)[1]
|
||||||
|
packages = api(urljoin(status["result_url"], "results.json"))["packages"]
|
||||||
|
package = next((item for item in packages
|
||||||
|
if item["name"] == args.package and item["version"] == args.version
|
||||||
|
and item["arch"] == arch
|
||||||
|
and (item["release"] == args.revision
|
||||||
|
or item["release"].startswith(args.revision + "."))), None)
|
||||||
|
if package is None:
|
||||||
|
raise Failed(f"Copr build {args.build_id} has no requested package for {chroot}")
|
||||||
if not rpm_present(base, args.package, args.version, arch,
|
if not rpm_present(base, args.package, args.version, arch,
|
||||||
lambda release: release == args.revision or release.startswith(args.revision + "."),
|
lambda release: release == package["release"]):
|
||||||
build_id=args.build_id):
|
|
||||||
raise Pending(f"Waiting for Copr build {args.build_id} in {base}")
|
raise Pending(f"Waiting for Copr build {args.build_id} in {base}")
|
||||||
return f"Copr build {args.build_id}: {len(build['chroots'])} targets built and published; {link}"
|
return f"Copr build {args.build_id}: {len(build['chroots'])} targets built and published; {link}"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user