diff --git a/0001-Support-new-PARTITION_TYPE-features-from-parted-3.5-.patch b/pyparted-3.12.0-partition-types.patch similarity index 58% rename from 0001-Support-new-PARTITION_TYPE-features-from-parted-3.5-.patch rename to pyparted-3.12.0-partition-types.patch index 9ba3c03..075c18e 100644 --- a/0001-Support-new-PARTITION_TYPE-features-from-parted-3.5-.patch +++ b/pyparted-3.12.0-partition-types.patch @@ -1,47 +1,6 @@ -From e99993d1b80105906fdeecafc308e272b93a96c9 Mon Sep 17 00:00:00 2001 -From: Adam Williamson -Date: Mon, 20 Jun 2022 11:00:54 -0700 -Subject: [PATCH] Support new PARTITION_TYPE features from parted 3.5 (#91) - -This adds constants for the new PARTITION_TYPE features added -in parted 3.5 (commit 61b3a9733c0e0a79ccc43096642d378c8706add6 ) -and adjusts the disk type tests to test for them correctly. - -Note this relies on being able to evaluate the -PED_DISK_TYPE_LAST_FEATURE macro at preprocessor time, which is -not the case with current upstream parted. See -https://github.com/dcantrell/pyparted/issues/91#issuecomment-1160788315 -for full details on this. The existing attempts to add constants -based on PED_PARTITION_LAST_FLAG in the same manner also do not -work with current upstream parted. - -Signed-off-by: Adam Williamson ---- - src/_pedmodule.c | 5 +++++ - src/parted/__init__.py | 8 ++++++++ - tests/test__ped_disktype.py | 18 +++++++++++++++--- - 3 files changed, 28 insertions(+), 3 deletions(-) - -diff --git a/src/_pedmodule.c b/src/_pedmodule.c -index 2d8ee1c..080e716 100644 ---- a/src/_pedmodule.c -+++ b/src/_pedmodule.c -@@ -685,6 +685,11 @@ MOD_INIT(_ped) { - PyModule_AddIntConstant(m, "DISK_TYPE_EXTENDED", PED_DISK_TYPE_EXTENDED); - PyModule_AddIntConstant(m, "DISK_TYPE_PARTITION_NAME", PED_DISK_TYPE_PARTITION_NAME); - -+#if PED_DISK_TYPE_LAST_FEATURE > 2 -+ PyModule_AddIntConstant(m, "DISK_TYPE_PARTITION_TYPE_ID", PED_DISK_TYPE_PARTITION_TYPE_ID); -+ PyModule_AddIntConstant(m, "DISK_TYPE_PARTITION_TYPE_UUID", PED_DISK_TYPE_PARTITION_TYPE_UUID); -+#endif -+ - /* add PedFileSystemType as _ped.FileSystemType */ - if (PyType_Ready(&_ped_FileSystemType_Type_obj) < 0) - return MOD_ERROR_VAL; -diff --git a/src/parted/__init__.py b/src/parted/__init__.py -index ef049ee..2397b84 100644 ---- a/src/parted/__init__.py -+++ b/src/parted/__init__.py +diff -up pyparted-3.12.0/src/parted/__init__.py.orig pyparted-3.12.0/src/parted/__init__.py +--- pyparted-3.12.0/src/parted/__init__.py.orig 2022-03-07 12:38:56.000000000 -0500 ++++ pyparted-3.12.0/src/parted/__init__.py 2022-06-21 15:05:10.318939409 -0400 @@ -217,6 +217,14 @@ from _ped import DISK_GPT_PMBR_BOOT from _ped import DISK_TYPE_EXTENDED from _ped import DISK_TYPE_PARTITION_NAME @@ -57,26 +16,52 @@ index ef049ee..2397b84 100644 from _ped import EXCEPTION_TYPE_INFORMATION from _ped import EXCEPTION_TYPE_WARNING from _ped import EXCEPTION_TYPE_ERROR -diff --git a/tests/test__ped_disktype.py b/tests/test__ped_disktype.py -index 8b768a3..0867d37 100755 ---- a/tests/test__ped_disktype.py -+++ b/tests/test__ped_disktype.py -@@ -68,18 +68,30 @@ class DiskTypeCheckFeatureTestCase(RequiresDiskTypes): +diff -up pyparted-3.12.0/src/_pedmodule.c.orig pyparted-3.12.0/src/_pedmodule.c +--- pyparted-3.12.0/src/_pedmodule.c.orig 2022-03-07 12:49:11.000000000 -0500 ++++ pyparted-3.12.0/src/_pedmodule.c 2022-06-21 15:04:57.863977820 -0400 +@@ -685,6 +685,14 @@ MOD_INIT(_ped) { + PyModule_AddIntConstant(m, "DISK_TYPE_EXTENDED", PED_DISK_TYPE_EXTENDED); + PyModule_AddIntConstant(m, "DISK_TYPE_PARTITION_NAME", PED_DISK_TYPE_PARTITION_NAME); + ++#if PED_DISK_TYPE_LAST_FEATURE > 2 ++ PyModule_AddIntConstant(m, "DISK_TYPE_PARTITION_TYPE_ID", PED_DISK_TYPE_PARTITION_TYPE_ID); ++#endif ++ ++#if PED_DISK_TYPE_LAST_FEATURE > 4 ++ PyModule_AddIntConstant(m, "DISK_TYPE_PARTITION_TYPE_UUID", PED_DISK_TYPE_PARTITION_TYPE_UUID); ++#endif ++ + /* add PedFileSystemType as _ped.FileSystemType */ + if (PyType_Ready(&_ped_FileSystemType_Type_obj) < 0) + return MOD_ERROR_VAL; +diff -up pyparted-3.12.0/tests/test__ped_disktype.py.orig pyparted-3.12.0/tests/test__ped_disktype.py +--- pyparted-3.12.0/tests/test__ped_disktype.py.orig 2018-01-12 13:31:40.000000000 -0500 ++++ pyparted-3.12.0/tests/test__ped_disktype.py 2022-06-21 15:04:57.863977820 -0400 +@@ -63,11 +63,22 @@ class DiskTypeCheckFeatureTestCase(Requi + self.assertTrue(self.disktype[name].check_feature(_ped.DISK_TYPE_EXTENDED)) + self.assertFalse(self.disktype[name].check_feature(_ped.DISK_TYPE_PARTITION_NAME)) + ++ if hasattr(_ped, "DISK_TYPE_PARTITION_TYPE_ID"): ++ self.assertTrue(self.disktype[name].check_feature(_ped.DISK_TYPE_PARTITION_TYPE_ID)) ++ ++ if hasattr(_ped, "DISK_TYPE_PARTITION_TYPE_UUID"): ++ self.assertFalse(self.disktype[name].check_feature(_ped.DISK_TYPE_PARTITION_TYPE_UUID)) ++ + # The following types support DISK_TYPE_PARTITION_NAME + for name in ['amiga', 'gpt', 'mac', 'pc98']: self.assertFalse(self.disktype[name].check_feature(_ped.DISK_TYPE_EXTENDED)) self.assertTrue(self.disktype[name].check_feature(_ped.DISK_TYPE_PARTITION_NAME)) -- # The following types support all features -+ # The following types support both features ++ # The following types support DISK_TYPE_PARTITION_TYPE_UUID ++ for name in ['gpt']: ++ if hasattr(_ped, "DISK_TYPE_PARTITION_TYPE_UUID"): ++ self.assertTrue(self.disktype[name].check_feature(_ped.DISK_TYPE_PARTITION_TYPE_UUID)) ++ + # The following types support all features for name in ['dvh']: self.assertTrue(self.disktype[name].check_feature(_ped.DISK_TYPE_EXTENDED)) - self.assertTrue(self.disktype[name].check_feature(_ped.DISK_TYPE_PARTITION_NAME)) +@@ -75,11 +86,20 @@ class DiskTypeCheckFeatureTestCase(Requi -+ # With parted 3.5+, msdos supports PED_DISK_TYPE_PARTITION_TYPE_ID -+ # and gpt supports PED_DISK_TYPE_PARTITION_TYPE_UUID -+ if hasattr(_ped, "DISK_TYPE_PARTITION_TYPE_ID"): -+ self.assertTrue(self.disktype["msdos"].check_feature(_ped.DISK_TYPE_PARTITION_TYPE_ID)) -+ self.assertTrue(self.disktype["gpt"].check_feature(_ped.DISK_TYPE_PARTITION_TYPE_UUID)) -+ class DiskTypeStrTestCase(RequiresDiskTypes): def runTest(self): - self.assertEqual(str(self.disktype['msdos']), '_ped.DiskType instance --\n name: msdos features: 1') @@ -84,17 +69,17 @@ index 8b768a3..0867d37 100755 + self.assertEqual(str(self.disktype['msdos']), '_ped.DiskType instance --\n name: msdos features: 5') + else: + self.assertEqual(str(self.disktype['msdos']), '_ped.DiskType instance --\n name: msdos features: 1') ++ self.assertEqual(str(self.disktype['aix']), '_ped.DiskType instance --\n name: aix features: 0') self.assertEqual(str(self.disktype['sun']), '_ped.DiskType instance --\n name: sun features: 0') self.assertEqual(str(self.disktype['amiga']), '_ped.DiskType instance --\n name: amiga features: 2') - self.assertEqual(str(self.disktype['gpt']), '_ped.DiskType instance --\n name: gpt features: 2') ++ + if hasattr(_ped, "DISK_TYPE_PARTITION_TYPE_UUID"): + self.assertEqual(str(self.disktype['gpt']), '_ped.DiskType instance --\n name: gpt features: 10') + else: + self.assertEqual(str(self.disktype['gpt']), '_ped.DiskType instance --\n name: gpt features: 2') ++ self.assertEqual(str(self.disktype['mac']), '_ped.DiskType instance --\n name: mac features: 2') self.assertEqual(str(self.disktype['bsd']), '_ped.DiskType instance --\n name: bsd features: 0') self.assertEqual(str(self.disktype['pc98']), '_ped.DiskType instance --\n name: pc98 features: 2') --- -2.36.1 - diff --git a/pyparted.spec b/pyparted.spec index fb34fea..fff5a38 100644 --- a/pyparted.spec +++ b/pyparted.spec @@ -34,7 +34,7 @@ Summary: Python module for GNU parted Name: pyparted Epoch: 1 Version: 3.12.0 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2+ URL: https://github.com/dcantrell/pyparted @@ -46,8 +46,7 @@ Source3: trustdb.gpg # Support new disk type features from parted 3.5: # https://bugzilla.redhat.com/show_bug.cgi?id=2098792 # https://github.com/dcantrell/pyparted/issues/91 -# https://github.com/dcantrell/pyparted/pull/92 -Patch0: 0001-Support-new-PARTITION_TYPE-features-from-parted-3.5-.patch +Patch0: pyparted-3.12.0-partition-types.patch BuildRequires: make BuildRequires: gcc @@ -157,6 +156,11 @@ popd %endif %changelog +* Tue Jun 21 2022 David Cantrell - 1:3.12.0-5 +- Patch pyparted to handle PED_DISK_TYPE_PARTITION_TYPE_ID for the + msdos disk type and PED_DISK_TYPE_PARTITION_TYPE_UUID for the gpt + label (#2098792) + * Mon Jun 20 2022 Adam Williamson - 1:3.12.0-4 - Backport PR #92 to fix tests with parted 3.5 (#2098792)