Blob Blame History Raw
commit bf5bd64438a5ffbc6083853c96ff5078450b5eaa
Author: David Cantrell <dcantrell@redhat.com>
Date:   Thu Mar 17 16:28:32 2011 -1000

    Add support for PED_PARTITION_LEGACY_BOOT flag.
    
    This is currently in the master branch for upstream parted and is part
    of the parted package in Fedora rawhide.  The latest stable release of
    parted is 2.3.  Since we cannot depend on the library version to know if
    PED_PARTITION_LEGACY_BOOT is defined, add in a special check for that
    constant and enable it in _ped and parted if it's present.

diff --git a/configure.ac b/configure.ac
index 8517a5f..e70ebe8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@ dnl Red Hat, Inc.
 dnl
 dnl Red Hat Author(s): David Cantrell <dcantrell@redhat.com>
 
-m4_define(libparted_required_version, 2.2)
+m4_define(libparted_required_version, 2.3)
 m4_define(python_required_version, 2.7)
 
 AC_PREREQ(2.59)
@@ -46,5 +46,6 @@ AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers or library)
 
 dnl Check for GNU parted
 AM_CHECK_LIBPARTED(libparted_required_version)
+AM_CHECK_PED_PARTITION_LEGACY_BOOT
 
 AC_OUTPUT
diff --git a/m4/libparted.m4 b/m4/libparted.m4
index 375cf40..6f16d96 100644
--- a/m4/libparted.m4
+++ b/m4/libparted.m4
@@ -36,3 +36,13 @@ LIBPARTED_LIBS="$(pkg-config --libs libparted)"
 
 LIBPARTED_VERSION=$1
 ])
+
+dnl Check for PED_PARTITION_LEGACY_BOOT in parted header files
+AC_DEFUN([AM_CHECK_PED_PARTITION_LEGACY_BOOT],[
+    AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[#include <parted/parted.h]],
+                         [[int flag = PED_PARTITION_LEGACY_BOOT;]])],
+        [AC_DEFINE([HAVE_PED_PARTITION_LEGACY_BOOT], [1],
+                   [Define if libparted has 'PED_PARTITION_LEGACY_BOOT' constant.])],
+        [])
+])
diff --git a/src/_pedmodule.c b/src/_pedmodule.c
index 6e426e4..85dc54d 100644
--- a/src/_pedmodule.c
+++ b/src/_pedmodule.c
@@ -492,6 +492,9 @@ PyMODINIT_FUNC init_ped(void) {
     PyModule_AddIntConstant(m, "PARTITION_APPLE_TV_RECOVERY", PED_PARTITION_APPLE_TV_RECOVERY);
     PyModule_AddIntConstant(m, "PARTITION_BIOS_GRUB", PED_PARTITION_BIOS_GRUB);
     PyModule_AddIntConstant(m, "PARTITION_DIAG", PED_PARTITION_DIAG);
+#ifdef HAVE_PED_PARTITION_LEGACY_BOOT
+    PyModule_AddIntConstant(m, "PARTITION_LEGACY_BOOT", PED_PARTITION_LEGACY_BOOT);
+#endif
 
     PyModule_AddIntConstant(m, "DISK_CYLINDER_ALIGNMENT", PED_DISK_CYLINDER_ALIGNMENT);
 
diff --git a/src/parted/__init__.py b/src/parted/__init__.py
index 474825f..dc631b6 100644
--- a/src/parted/__init__.py
+++ b/src/parted/__init__.py
@@ -109,6 +109,10 @@ from _ped import PARTITION_MSFT_RESERVED
 from _ped import PARTITION_APPLE_TV_RECOVERY
 from _ped import PARTITION_BIOS_GRUB
 from _ped import PARTITION_DIAG
+try:
+    from _ped import PARTITION_LEGACY_BOOT
+except ImportError:
+    pass
 
 from _ped import DISK_CYLINDER_ALIGNMENT