- add python3 subpackage

This commit is contained in:
Daniel J Walsh 2010-05-06 15:50:55 +00:00
parent 1088cc0705
commit fc28aa840f
2 changed files with 121 additions and 4 deletions

View File

@ -0,0 +1,44 @@
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index 7acf63d..cdd8388 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -1,9 +1,15 @@
+# Support building the Python bindings multiple times, against various Python
+# runtimes (e.g. Python 2 vs Python 3) by optionally prefixing the build
+# targets with "PYPREFIX":
+PYTHON ?= python
+PYPREFIX ?=
+
# Installation directories.
PREFIX ?= $(DESTDIR)/usr
LIBDIR ?= $(PREFIX)/lib
SHLIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
-PYLIBVER ?= $(shell python -c 'import sys;print "python%d.%d" % sys.version_info[0:2]')
+PYLIBVER ?= $(shell $(PYTHON) -c 'import sys;print("python%d.%d" % sys.version_info[0:2])')
PYINC ?= /usr/include/${PYLIBVER}
PYLIBDIR ?= $(LIBDIR)/${PYLIBVER}
RUBYLIBVER ?= $(shell ruby -e 'print RUBY_VERSION.split(".")[0..1].join(".")')
@@ -34,9 +40,9 @@ SWIGIF= semanageswig_python.i
SWIGRUBYIF= semanageswig_ruby.i
SWIGCOUT= semanageswig_wrap.c
SWIGRUBYCOUT= semanageswig_ruby_wrap.c
-SWIGLOBJ:= $(patsubst %.c,%.lo,$(SWIGCOUT))
+SWIGLOBJ:= $(patsubst %.c,$(PYPREFIX)%.lo,$(SWIGCOUT))
SWIGRUBYLOBJ:= $(patsubst %.c,%.lo,$(SWIGRUBYCOUT))
-SWIGSO=_semanage.so
+SWIGSO=$(PYPREFIX)_semanage.so
SWIGFILES=$(SWIGSO) semanage.py
SWIGRUBYSO=_rubysemanage.so
LIBSO=$(TARGET).$(LIBVERSION)
@@ -132,7 +138,9 @@ install: all
install-pywrap: pywrap
test -d $(PYLIBDIR)/site-packages || install -m 755 -d $(PYLIBDIR)/site-packages
- install -m 755 $(SWIGFILES) $(PYLIBDIR)/site-packages
+ install -m 755 $(SWIGSO) $(PYLIBDIR)/site-packages/_semanage.so
+ install -m 755 semanage.py $(PYLIBDIR)/site-packages
+
install-rubywrap: rubywrap
test -d $(RUBYINSTALL) || install -m 755 -d $(RUBYINSTALL)

View File

@ -1,9 +1,14 @@
%global with_python3 1
%define libsepolver 2.0.37-1
%define libselinuxver 2.0.0-1
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
Summary: SELinux binary policy manipulation library
Name: libsemanage
Version: 2.0.45
Release: 3%{?dist}
Release: 4%{?dist}
License: LGPLv2+
Group: System Environment/Libraries
Source: http://www.nsa.gov/selinux/archives/libsemanage-%{version}.tgz
@ -11,10 +16,19 @@ Patch: libsemanage-rhat.patch
URL: http://www.selinuxproject.org
Source1: semanage.conf
# Add support to src/Makefile to support building the python bindings multiple
# times, against different Python runtimes:
Patch1: libsemanage-2.0.45-support-multiple-python-builds.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libselinux-devel >= %{libselinuxver} swig ustr-devel
BuildRequires: libsepol-devel >= %{libsepolver}
BuildRequires: python-devel bison flex bzip2-devel
%if 0%{?with_python3}
BuildRequires: python3-devel
%endif # if with_python3
Requires: bzip2-libs
%description
@ -60,20 +74,67 @@ Requires: libsemanage = %{version}-%{release}
The libsemanage-python package contains the python bindings for developing
SELinux management applications.
%if 0%{?with_python3}
%package python3
Summary: semanage python 3 bindings for libsemanage
Group: Development/Libraries
Requires: libsemanage = %{version}-%{release}
%description python3
The libsemanage-python3 package contains the python 3 bindings for developing
SELinux management applications.
%endif # if with_python3
%prep
%setup -q
%patch -p1 -b .rhat
%patch1 -p2 -b .support-multiple-python-builds
%build
# To support building the Python wrapper against multiple Python runtimes
# Define a function, for how to perform a "build" of the python wrapper against
# a specific runtime:
BuildPythonWrapper() {
BinaryName=$1
Prefix=$2
# Perform the build from the upstream Makefile:
make \
PYTHON=$BinaryName PYPREFIX=$Prefix \
CFLAGS="%{optflags}" LIBDIR="%{_libdir}" SHLIBDIR="%{_lib}" \
pywrap
}
make clean
make CFLAGS="%{optflags}" swigify
make CFLAGS="%{optflags}" LIBDIR="%{_libdir}" SHLIBDIR="%{_lib}" all pywrap
make CFLAGS="%{optflags}" LIBDIR="%{_libdir}" SHLIBDIR="%{_lib}" all
BuildPythonWrapper %{__python} python2
%if 0%{?with_python3}
BuildPythonWrapper %{__python3} python3
%endif # with_python3
%install
InstallPythonWrapper() {
BinaryName=$1
Prefix=$2
make \
PYTHON=$BinaryName PYPREFIX=$Prefix \
DESTDIR="${RPM_BUILD_ROOT}" LIBDIR="${RPM_BUILD_ROOT}%{_libdir}" SHLIBDIR="${RPM_BUILD_ROOT}/%{_libdir}" \
install-pywrap
}
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}/%{_libdir}
mkdir -p ${RPM_BUILD_ROOT}%{_includedir}
make DESTDIR="${RPM_BUILD_ROOT}" LIBDIR="${RPM_BUILD_ROOT}%{_libdir}" SHLIBDIR="${RPM_BUILD_ROOT}/%{_libdir}" install install-pywrap
make DESTDIR="${RPM_BUILD_ROOT}" LIBDIR="${RPM_BUILD_ROOT}%{_libdir}" SHLIBDIR="${RPM_BUILD_ROOT}/%{_libdir}" install
InstallPythonWrapper %{__python} python2
%if 0%{?with_python3}
InstallPythonWrapper %{__python3} python3
%endif # with_python3
cp %{SOURCE1} ${RPM_BUILD_ROOT}/etc/selinux/semanage.conf
ln -sf %{_libdir}/libsemanage.so.1 ${RPM_BUILD_ROOT}/%{_libdir}/libsemanage.so
@ -103,9 +164,21 @@ rm -rf ${RPM_BUILD_ROOT}
%files python
%defattr(-,root,root)
%{_libdir}/python*/site-packages/*
%{python_sitearch}/_semanage.so
%{python_sitearch}/semanage.py*
%if 0%{?with_python3}
%files python3
%defattr(-,root,root)
%{python3_sitearch}/_semanage.so
%{python3_sitearch}/semanage.py*
%endif # if with_python3
%changelog
* Tue Apr 27 2010 David Malcolm <dmalcolm@redhat.com> - 2.0.45-4
- add python3 subpackage
* Wed Apr 7 2010 Dan Walsh <dwalsh@redhat.com> - 2.0.45-3
- Fix -devel package to point at the correct shared library