From 71e03ed8a9fea30d38e330324b40faa859112714e01e84bc73f3569e7056f870 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 12 Feb 2018 11:57:39 +0000 Subject: [PATCH] Build python2 and python3 packages OBS-URL: https://build.opensuse.org/package/show/devel:tools/pam_wrapper?expand=0&rev=12 --- ....3-build-python2-and-python3-modules.patch | 159 ++++++++++++++++++ pam_wrapper.changes | 5 + pam_wrapper.spec | 36 +++- 3 files changed, 192 insertions(+), 8 deletions(-) create mode 100644 pam_wrapper-1.0.3-build-python2-and-python3-modules.patch diff --git a/pam_wrapper-1.0.3-build-python2-and-python3-modules.patch b/pam_wrapper-1.0.3-build-python2-and-python3-modules.patch new file mode 100644 index 0000000..2e5b7af --- /dev/null +++ b/pam_wrapper-1.0.3-build-python2-and-python3-modules.patch @@ -0,0 +1,159 @@ +From 9beb9f9aaa223864128fd8222f0f92ba8ae697b7 Mon Sep 17 00:00:00 2001 +From: Andreas Schneider +Date: Wed, 22 Nov 2017 15:27:44 +0100 +Subject: [PATCH 1/2] cmake: Improve PAM_WRAPPER_LOACATION + +Signed-off-by: Andreas Schneider +Reviewed-by: Ralph Boehme +--- + src/CMakeLists.txt | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 713625b..76a87d6 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -74,8 +74,4 @@ if (PYTHONLIBS_FOUND) + endif() + + # This needs to be at the end +-if (POLICY CMP0026) +- cmake_policy(SET CMP0026 OLD) +-endif() +-get_target_property(PAM_WRAPPER_LOCATION pam_wrapper LOCATION) +-set(PAM_WRAPPER_LOCATION ${PAM_WRAPPER_LOCATION} PARENT_SCOPE) ++set(PAM_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}pam_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE) +-- +2.16.1 + + +From 84cd3dac56dbcb5815867b02876bb99759aecfd9 Mon Sep 17 00:00:00 2001 +From: Andreas Schneider +Date: Mon, 12 Feb 2018 12:01:22 +0100 +Subject: [PATCH 2/2] cmake: Build python2 and python3 modules if possible + +Signed-off-by: Andreas Schneider +--- + CMakeLists.txt | 5 ----- + src/CMakeLists.txt | 4 +--- + src/python/CMakeLists.txt | 15 ++------------- + src/python/python2/CMakeLists.txt | 23 +++++++++++++++++++++++ + src/python/python3/CMakeLists.txt | 23 +++++++++++++++++++++++ + 5 files changed, 49 insertions(+), 21 deletions(-) + create mode 100644 src/python/python2/CMakeLists.txt + create mode 100644 src/python/python3/CMakeLists.txt + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f03a137..af00610 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -46,11 +46,6 @@ macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source buil + set(CMAKE_THREAD_PREFER_PTHREADS ON) + find_package(Threads) + +-find_package(PythonInterp) +-set(Python_ADDITIONAL_VERSIONS 2.6 2.7 3.3 3.4 3.6) +-find_package(PythonLibs) +-find_package(PythonSiteLibs) +- + # config.h checks + include(ConfigureChecks.cmake) + configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 76a87d6..e3a1efd 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -69,9 +69,7 @@ install(TARGETS pamtest + ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) + + add_subdirectory(modules) +-if (PYTHONLIBS_FOUND) +- add_subdirectory(python) +-endif() ++add_subdirectory(python) + + # This needs to be at the end + set(PAM_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}pam_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE) +diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt +index cbee2a6..3394a84 100644 +--- a/src/python/CMakeLists.txt ++++ b/src/python/CMakeLists.txt +@@ -1,15 +1,4 @@ + project(pypamtest C) + +-include_directories(${CMAKE_BINARY_DIR}) +-include_directories(${pam_wrapper-headers_DIR}) +-include_directories(${PYTHON_INCLUDE_DIR}) +- +-python_add_module(pypamtest pypamtest.c) +-target_link_libraries(pypamtest pamtest ${PYTHON_LIBRARY}) +- +-install( +- TARGETS +- pypamtest +- DESTINATION +- ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB} +-) ++add_subdirectory(python2) ++add_subdirectory(python3) +diff --git a/src/python/python2/CMakeLists.txt b/src/python/python2/CMakeLists.txt +new file mode 100644 +index 0000000..c258d9e +--- /dev/null ++++ b/src/python/python2/CMakeLists.txt +@@ -0,0 +1,23 @@ ++project(python2-pamtest C) ++ ++unset(PYTHON_EXECUTABLE CACHE) ++ ++set(Python_ADDITIONAL_VERSIONS 2.7 2.6) ++find_package(PythonLibs) ++find_package(PythonInterp) ++find_package(PythonSiteLibs) ++ ++if (PYTHONLIBS_FOUND) ++ include_directories(${CMAKE_BINARY_DIR}) ++ include_directories(${pam_wrapper-headers_DIR}) ++ include_directories(${PYTHON_INCLUDE_DIR}) ++ ++ python_add_module(python2-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c) ++ target_link_libraries(python2-pamtest pamtest ${PYTHON_LIBRARY}) ++ set_target_properties(python2-pamtest PROPERTIES OUTPUT_NAME "pypamtest") ++ ++ install(TARGETS ++ python2-pamtest ++ DESTINATION ++ ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}) ++endif() +diff --git a/src/python/python3/CMakeLists.txt b/src/python/python3/CMakeLists.txt +new file mode 100644 +index 0000000..19a5459 +--- /dev/null ++++ b/src/python/python3/CMakeLists.txt +@@ -0,0 +1,23 @@ ++project(python3-pamtest C) ++ ++unset(PYTHON_EXECUTABLE CACHE) ++ ++set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6) ++find_package(PythonLibs) ++find_package(PythonInterp) ++find_package(PythonSiteLibs) ++ ++if (PYTHONLIBS_FOUND) ++ include_directories(${CMAKE_BINARY_DIR}) ++ include_directories(${pam_wrapper-headers_DIR}) ++ include_directories(${PYTHON_INCLUDE_DIR}) ++ ++ python_add_module(python3-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c) ++ target_link_libraries(python3-pamtest pamtest ${PYTHON_LIBRARY}) ++ set_target_properties(python3-pamtest PROPERTIES OUTPUT_NAME "pypamtest") ++ ++ install(TARGETS ++ python3-pamtest ++ DESTINATION ++ ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}) ++endif() +-- +2.16.1 + diff --git a/pam_wrapper.changes b/pam_wrapper.changes index 4ffa3a9..87d1958 100644 --- a/pam_wrapper.changes +++ b/pam_wrapper.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Feb 12 11:56:57 UTC 2018 - asn@cryptomilk.org + +- Build python2 and python3 packages + ------------------------------------------------------------------- Sun Feb 4 09:31:44 UTC 2018 - asn@cryptomilk.org diff --git a/pam_wrapper.spec b/pam_wrapper.spec index 60497ac..cb01287 100644 --- a/pam_wrapper.spec +++ b/pam_wrapper.spec @@ -1,7 +1,7 @@ # # spec file for package pam_wrapper # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -35,13 +35,16 @@ Url: http://cwrap.org/ Source0: https://ftp.samba.org/pub/cwrap/%{name}-%{version}.tar.gz Source1: %{name}-rpmlintrc +# PATCH-FIX-UPSTREAM Build python2 and python3 modules if possible +Patch0: pam_wrapper-1.0.3-build-python2-and-python3-modules.patch + BuildRequires: cmake BuildRequires: doxygen BuildRequires: libcmocka-devel BuildRequires: pam-devel -BuildRequires: pkg-config -BuildRequires: python-devel BuildRequires: python-rpm-macros +BuildRequires: pkgconfig(python2) +BuildRequires: pkgconfig(python3) Recommends: pkg-config Recommends: cmake @@ -89,13 +92,26 @@ Group: Development/Libraries/C and C++ %description -n libpamtest-devel-doc Documentation for libpamtest development. -%package -n python-libpamtest +%package -n python2-libpamtest +Summary: A python wrapper for libpamtest +Group: Development/Libraries/C and C++ +Requires: libpamtest0 = %{version}-%{release} +Requires: pam_wrapper = %{version}-%{release} +Obsoletes: python-libpamtest +Provides: python-libpamtest + +%description -n python2-libpamtest +If you plan to develop python tests for a PAM module, you can use this +library, which simplifies testing of modules. This subpackage includes +the header files for libpamtest + +%package -n python3-libpamtest Summary: A python wrapper for libpamtest Group: Development/Libraries/C and C++ Requires: libpamtest0 = %{version}-%{release} Requires: pam_wrapper = %{version}-%{release} -%description -n python-libpamtest +%description -n python3-libpamtest If you plan to develop python tests for a PAM module, you can use this library, which simplifies testing of modules. This subpackage includes the header files for libpamtest @@ -103,6 +119,8 @@ the header files for libpamtest %prep %setup -q +%patch0 -p1 + %build %cmake \ -DUNIT_TESTING=ON @@ -160,8 +178,10 @@ popd %defattr(-,root,root) %doc build/doc/html -%files -n python-libpamtest -%defattr(-,root,root,-) -%{python_sitearch}/pypamtest.so +%files -n python2-libpamtest +%{python2_sitearch}/pypamtest.so + +%files -n python3-libpamtest +%{python3_sitearch}/pypamtest.so %changelog