mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 06:14:03 +00:00
qubes/src/heads: Update Heads versioning
Signed-off-by: Norbert Kamiński <norbert.kaminski@3mdeb.com>
This commit is contained in:
parent
cf9ebdb703
commit
c81094f0ba
@ -33,14 +33,12 @@ class FwupdHeads:
|
|||||||
"""
|
"""
|
||||||
Checks if Qubes works under heads
|
Checks if Qubes works under heads
|
||||||
"""
|
"""
|
||||||
if "heads" in self.dom0_hwids_info:
|
if "Heads" in self.dom0_hwids_info:
|
||||||
self.heads_version = None
|
self.heads_version = None
|
||||||
hwids = self.dom0_hwids_info.split("\n")
|
hwids = self.dom0_hwids_info.split("\n")
|
||||||
for line in hwids:
|
for line in hwids:
|
||||||
if line.startswith("BiosVersion: CBET4000 "):
|
if "Heads" in line:
|
||||||
self.heads_version = line.replace(
|
self.heads_version = line.split("Heads-v")[1]
|
||||||
"BiosVersion: CBET4000 ", ""
|
|
||||||
).replace(" heads", "")
|
|
||||||
else:
|
else:
|
||||||
print("Device is not running under the heads firmware!!")
|
print("Device is not running under the heads firmware!!")
|
||||||
print("Exiting...")
|
print("Exiting...")
|
||||||
|
@ -906,7 +906,6 @@ class QubesFwupdmgr(FwupdHeads, FwupdUpdate, FwupdReceiveUpdates):
|
|||||||
whonix -- Flag enforces downloading the metadata updates via Tor
|
whonix -- Flag enforces downloading the metadata updates via Tor
|
||||||
metadata_url -- Use custom metadata from the url
|
metadata_url -- Use custom metadata from the url
|
||||||
"""
|
"""
|
||||||
self._check_fwupdtool_version()
|
|
||||||
if metadata_url:
|
if metadata_url:
|
||||||
custom_metadata_name = metadata_url.replace(FWUPD_DOWNLOAD_PREFIX, "")
|
custom_metadata_name = metadata_url.replace(FWUPD_DOWNLOAD_PREFIX, "")
|
||||||
self.metadata_file = os.path.join(
|
self.metadata_file = os.path.join(
|
||||||
@ -988,7 +987,7 @@ def main():
|
|||||||
print("Exiting...")
|
print("Exiting...")
|
||||||
exit(1)
|
exit(1)
|
||||||
if "--device=" in arg:
|
if "--device=" in arg:
|
||||||
device = arg.replace("--board=", "")
|
device = arg.replace("--device=", "")
|
||||||
|
|
||||||
if sys.argv[1] == "get-updates":
|
if sys.argv[1] == "get-updates":
|
||||||
q.get_updates_qubes(usbvm=sys_usb)
|
q.get_updates_qubes(usbvm=sys_usb)
|
||||||
|
@ -36,19 +36,18 @@ class TestQubesFwupdHeads(unittest.TestCase):
|
|||||||
|
|
||||||
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
|
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
|
||||||
def test_get_hwids(self):
|
def test_get_hwids(self):
|
||||||
self.q._check_fwupdtool_version()
|
|
||||||
self.q._get_hwids()
|
self.q._get_hwids()
|
||||||
self.assertNotEqual(self.q.dom0_hwids_info, "")
|
self.assertNotEqual(self.q.dom0_hwids_info, "")
|
||||||
|
|
||||||
def test_gather_firmware_version_empty(self):
|
def test_gather_firmware_version_empty(self):
|
||||||
self.q.dom0_hwids_info = ""
|
self.q.dom0_hwids_info = ""
|
||||||
return_code = self.q._gather_firmware_version()
|
return_code = self.q._gather_firmware_version()
|
||||||
self.assertEqual(return_code, 2)
|
self.assertEqual(return_code, self.qfwupd.EXIT_CODES["NOTHING_TO_DO"])
|
||||||
|
|
||||||
def test_gather_firmware_version(self):
|
def test_gather_firmware_version(self):
|
||||||
self.q.dom0_hwids_info = "BiosVersion: CBET4000 0.2.2 heads"
|
self.q.dom0_hwids_info = "CBET4000 Heads-v0.2.2-917-g19f0e65"
|
||||||
self.q._gather_firmware_version()
|
self.q._gather_firmware_version()
|
||||||
self.assertEqual(self.q.heads_version, "0.2.2")
|
self.assertEqual(self.q.heads_version, "0.2.2-917-g19f0e65")
|
||||||
|
|
||||||
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
|
@unittest.skipUnless("qubes" in platform.release(), "Requires Qubes OS")
|
||||||
def test_parse_metadata(self):
|
def test_parse_metadata(self):
|
||||||
@ -64,13 +63,14 @@ class TestQubesFwupdHeads(unittest.TestCase):
|
|||||||
self.q.metadata_info = HEADS_XML
|
self.q.metadata_info = HEADS_XML
|
||||||
self.q.heads_version = "heads"
|
self.q.heads_version = "heads"
|
||||||
return_code = self.q._parse_heads_updates("x230")
|
return_code = self.q._parse_heads_updates("x230")
|
||||||
self.assertEqual(return_code, 0)
|
self.assertEqual(return_code, self.qfwupd.EXIT_CODES["SUCCESS"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.q.heads_update_url,
|
self.q.heads_update_url,
|
||||||
"https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab",
|
"https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab",
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.q.heads_update_sha, "1a54e69ca2b58d1218035115d481480eaf4c66e4"
|
self.q.heads_update_sha,
|
||||||
|
"ba519a7a5d8136c8ade0cf0c775c58f3165f42798ff631c3f57f075897ef1586",
|
||||||
)
|
)
|
||||||
self.assertEqual(self.q.heads_update_version, "0.2.3")
|
self.assertEqual(self.q.heads_update_version, "0.2.3")
|
||||||
|
|
||||||
@ -78,19 +78,20 @@ class TestQubesFwupdHeads(unittest.TestCase):
|
|||||||
self.q.metadata_info = HEADS_XML
|
self.q.metadata_info = HEADS_XML
|
||||||
self.q.heads_version = "0.2.3"
|
self.q.heads_version = "0.2.3"
|
||||||
return_code = self.q._parse_heads_updates("x230")
|
return_code = self.q._parse_heads_updates("x230")
|
||||||
self.assertEqual(return_code, 2)
|
self.assertEqual(return_code, self.qfwupd.EXIT_CODES["NOTHING_TO_DO"])
|
||||||
|
|
||||||
def test_check_heads_updates_lower_version(self):
|
def test_check_heads_updates_lower_version(self):
|
||||||
self.q.metadata_info = HEADS_XML
|
self.q.metadata_info = HEADS_XML
|
||||||
self.q.heads_version = "0.2.2"
|
self.q.heads_version = "0.2.2"
|
||||||
return_code = self.q._parse_heads_updates("x230")
|
return_code = self.q._parse_heads_updates("x230")
|
||||||
self.assertEqual(return_code, 0)
|
self.assertEqual(return_code, self.qfwupd.EXIT_CODES["SUCCESS"])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.q.heads_update_url,
|
self.q.heads_update_url,
|
||||||
"https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab",
|
"https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab",
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.q.heads_update_sha, "1a54e69ca2b58d1218035115d481480eaf4c66e4"
|
self.q.heads_update_sha,
|
||||||
|
"ba519a7a5d8136c8ade0cf0c775c58f3165f42798ff631c3f57f075897ef1586",
|
||||||
)
|
)
|
||||||
self.assertEqual(self.q.heads_update_version, "0.2.3")
|
self.assertEqual(self.q.heads_update_version, "0.2.3")
|
||||||
|
|
||||||
@ -98,7 +99,9 @@ class TestQubesFwupdHeads(unittest.TestCase):
|
|||||||
def test_copy_heads_firmware(self):
|
def test_copy_heads_firmware(self):
|
||||||
qmgr = self.qfwupd.QubesFwupdmgr()
|
qmgr = self.qfwupd.QubesFwupdmgr()
|
||||||
self.q.heads_update_url = "https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab"
|
self.q.heads_update_url = "https://fwupd.org/downloads/e747a435bf24fd6081b77b6704b39cec5fa2dcf62e0ca6b86d8a6460121a1d07-heads_coreboot_x230-v0_2_3.cab"
|
||||||
self.q.heads_update_sha = "1a54e69ca2b58d1218035115d481480eaf4c66e4"
|
self.q.heads_update_sha = (
|
||||||
|
"ba519a7a5d8136c8ade0cf0c775c58f3165f42798ff631c3f57f075897ef1586"
|
||||||
|
)
|
||||||
self.q.heads_update_version = "0.2.3"
|
self.q.heads_update_version = "0.2.3"
|
||||||
qmgr._download_firmware_updates(
|
qmgr._download_firmware_updates(
|
||||||
self.q.heads_update_url, self.q.heads_update_sha
|
self.q.heads_update_url, self.q.heads_update_sha
|
||||||
@ -109,7 +112,7 @@ class TestQubesFwupdHeads(unittest.TestCase):
|
|||||||
if os.path.exists(heads_boot_path):
|
if os.path.exists(heads_boot_path):
|
||||||
shutil.rmtree(heads_boot_path)
|
shutil.rmtree(heads_boot_path)
|
||||||
ret_code = self.q._copy_heads_firmware(qmgr.arch_path)
|
ret_code = self.q._copy_heads_firmware(qmgr.arch_path)
|
||||||
self.assertNotEqual(ret_code, self.qfwupd.EXIT_CODES["NO_UPDATES"])
|
self.assertNotEqual(ret_code, self.qfwupd.EXIT_CODES["NOTHING_TO_DO"])
|
||||||
firmware_path = os.path.join(heads_boot_path, "firmware.rom")
|
firmware_path = os.path.join(heads_boot_path, "firmware.rom")
|
||||||
self.assertTrue(os.path.exists(firmware_path))
|
self.assertTrue(os.path.exists(firmware_path))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user