Solaris/SUNWPython.spec
author dc144907
Thu, 06 Apr 2006 12:28:12 +0000
changeset 7018 33bfc89d2a99
parent 6339 b61cd69d2984
child 7021 c53a3aae2301
permissions -rw-r--r--
2006-04-06 Damien Carbery <[email protected]> * SUNWPython.spec: Add SUNWgdbm and SUNWgmp to Requires after check-deps.pl run. * SUNWgnome-vfs.spec: Add SUNWopenssl-libraries/include to Build/Requires after check-deps.pl run.

#
# spec file for package SUNWPython
#
# includes module(s): Python
#
# Copyright (c) 2004-2005 Sun Microsystems, Inc.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
%include Solaris.inc

%define p23_version        2.3.3
%define p23_subdir         sfw
%define p23_prefix         %{_basedir}/%{p23_subdir}
%define p23_bindir         %{p23_prefix}/bin
%define p23_libdir         %{p23_prefix}/lib
%define p23_includedir     %{p23_prefix}/include
%define p23_sysconfdir     /etc
%define p23_datadir        %{p23_prefix}/share
%define p23_mandir         %{p23_datadir}/man

Name:                    SUNWPython
Summary:                 The Python interpreter, libraries and utilities
Version:                 2.4.2
SUNW_BaseDir:            %{_basedir}
BuildRoot:               %{_tmppath}/%{name}-%{version}-build
Source:                  http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.bz2
Source1:                 http://www.python.org/ftp/python/%{p23_version}/Python-%{p23_version}.tar.bz2
Patch1:                  Python-01-solaris-lib-dirs.diff
Patch2:                  Python-02-pycc.diff
Patch31:                 Python233-01-solaris-lib-dirs.diff

%include default-depend.inc
BuildRequires: SUNWTk
BuildRequires: SUNWTcl
BuildRequires: SUNWlexpt
BuildRequires: SUNWsfwhea
Requires: SUNWPython-share
Requires: SUNWopenssl-libraries
Requires: SUNWTk
Requires: SUNWTcl
Requires: SUNWlexpt
Requires: SUNWxwplt
Requires: SUNWbzip
Requires: SUNWlibmsr
Requires: SUNWlibms
Requires: SUNWzlib
Requires: SUNWgdbm
Requires: SUNWgmp

%package share
Summary:                 The Python interperer, libraries and utilities - platform independent files, /usr/sfw/share
SUNW_BaseDir:            %{_basedir}
%include default-depend.inc

%package devel
Summary:                 The Python interpreter, libraries and utilities - develper files - platform dependent, /usr filesystem
%include default-depend.inc
Requires: SUNWPython
Requires: SUNWscpu

%prep
%setup -q -c -n %name-%version
%setup -q -D -T -b 1 -c -n %name-%version
cd Python-%{version}
%patch1 -p1
%patch2 -p1
cd ..
cd Python-%{p23_version}
%patch31 -p1

%build
cd Python-%{p23_version}
CPUS=`/usr/sbin/psrinfo | grep on-line | wc -l | tr -d ' '`
if test "x$CPUS" = "x" -o $CPUS = 0; then
    CPUS=1
fi
export CXXFLAGS="%cxx_optflags"
%if %cc_is_gcc
export CFLAGS="%optflags"
%else
# -xregs=no%%frameptr breaks the build of Python 2.4.1
export CFLAGS=`echo '%optflags' | sed -e 's/-xregs=no%%frameptr//'`
%endif
export OPT=$CFLAGS
export BASECFLAGS=
export LD_RUN_PATH="/usr/sfw/lib"
export LDFLAGS="-z ignore"
export CPP="$CC -E"
./configure --prefix=%{p23_prefix} \
  --libdir=%{p23_libdir} \
  --mandir=%{p23_mandir} \
  --datadir=%{p23_datadir} \
  --infodir=%{p23_datadir}/info \
  --enable-shared \
  --disable-static

make -j$CPUS
unset LD_RUN_PATH

cd ../Python-%{version}
./configure --prefix=%{_prefix} \
  --libdir=%{_libdir} \
  --mandir=%{_mandir} \
  --datadir=%{_datadir} \
  --infodir=%{_datadir}/info \
  --enable-shared \
  --disable-static

# These #define's break the build with gcc and cause problems when
# building c99 compliant python modules
perl -pi -e "s/^#define _POSIX_C_SOURCE/\/\//" pyconfig.h
perl -pi -e "s/^#define _XOPEN_SOURCE/\/\//" pyconfig.h
perl -pi -e "s/^#define _XOPEN_SOURCE_EXTENDED/\/\//" pyconfig.h

make -j$CPUS

%install
[ "$RPM_BUILD_ROOT" != "" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT
cd Python-%{p23_version}
make install DESTDIR=$RPM_BUILD_ROOT

cd ../Python-%{version}
make install DESTDIR=$RPM_BUILD_ROOT

# the pycc script is a C/C++ compiler wrapper to be used in
# the distutils Makefile
install -m 755 -D pycc $RPM_BUILD_ROOT%{_libdir}/python2.4/pycc
(cd $RPM_BUILD_ROOT%{_libdir}/python2.4; ln -s pycc pyCC)
perl -pi -e 's|^(CC=\s*)/.*$|$1%{_libdir}/python2.4/pycc|' \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile
perl -pi -e 's|^(CXX=\s*)/.*$|$1%{_libdir}/python2.4/pyCC|' \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile
perl -pi -e 's|^(INSTALL=\s*)/.*$|$1install|' \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile
perl -pi -e 's|^(OPT=\s*).*$|$1-DNDEBUG|' \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile
perl -pi -e 's|^(RUNSHARED=\s*).*$|$1|' \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile
perl -pi -e "s|^(CONFIG_ARGS=\s*.*'CC=)[^']*('.*)\$|\$1%{_libdir}/python2.4/pycc\$2|" \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile
perl -pi -e "s|^(CONFIG_ARGS=\s*.*'CFLAGS=)[^']*('.*)\$|\$1\$2|" \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile
perl -pi -e "s|^(CONFIG_ARGS=\s*.*'CPP=)[^']*('.*)\$|\$1%{_libdir}/python2.4/pycc -E\$2|" \
    $RPM_BUILD_ROOT%{_libdir}/python2.4/config/Makefile

# search for vendor packages in /usr/lib/python<version>/vendor-packages
echo "import site; site.addsitedir('%{_libdir}/python2.4/vendor-packages')" \
    > $RPM_BUILD_ROOT%{_libdir}/python2.4/site-packages/vendor-packages.pth
mkdir -p $RPM_BUILD_ROOT%{_libdir}/python2.4/vendor-packages

cd $RPM_BUILD_ROOT%{_bindir} && rm python  && ln -s python2.4 python
cd $RPM_BUILD_ROOT%{p23_bindir} && rm python  && ln -s ../../bin/python2.4 python

# don't ship python2.3 development bits:
rm -rf $RPM_BUILD_ROOT%{p23_includedir}
rm -rf $RPM_BUILD_ROOT%{p23_libdir}/python2.3/config
rm -rf $RPM_BUILD_ROOT%{p23_libdir}/python2.3/distutils
rm -rf $RPM_BUILD_ROOT%{p23_libdir}/python2.3/test

# delete stuff that doesn't build on Solaris:
rm -f $RPM_BUILD_ROOT%{_libdir}/python?.?/config/lib*.a
rm -rf $RPM_BUILD_ROOT%{_libdir}/python?.?/curses
rm -rf $RPM_BUILD_ROOT%{p23_libdir}/python2.3/curses
rm -rf $RPM_BUILD_ROOT%{_libdir}/python?.?/bsddb
rm -rf $RPM_BUILD_ROOT%{p23_libdir}/python2.3/bsddb
rm -f $RPM_BUILD_ROOT%{_libdir}/python?.?/lib-dynload/_curses*failed.so
rm -f $RPM_BUILD_ROOT%{p23_libdir}/python2.3/lib-dynload/_curses*failed.so

echo deleting pyo files
find $RPM_BUILD_ROOT -name '*.pyo' -exec rm {} \;

echo fixing python binary name/path in python scripts:
cat > %{_builddir}/%name-%version/is_python_script <<EOF
#!/bin/sh

head -1 \$1 | egrep -s '^#!.*python$'
EOF
chmod +x %{_builddir}/%name-%version/is_python_script

cat > %{_builddir}/%name-%version/set_python_interpreter <<EOF
#!/bin/bash
interp=\$1
fname=\$2
line1=\$(head -1 \$fname)
echo "Changing '\$line1' to '\$interp' (\$fname)";
chmod u+w \$fname
sed -e "1s,^#!.*,#! \$interp," \$fname > \$fname.update-interp && \
    cat \$fname.update-interp > \$fname && \
    rm -f \$fname.update-interp || \
    echo WARNING: set_python_interpreter failed for \$fname
EOF
chmod +x %{_builddir}/%name-%version/set_python_interpreter

find $RPM_BUILD_ROOT%{p23_libdir} -type f -exec %{_builddir}/%name-%version/is_python_script {} \; -exec %{_builddir}/%name-%version/set_python_interpreter %{p23_bindir}/python2.3 {} \;
find $RPM_BUILD_ROOT%{_libdir} -type f -exec %{_builddir}/%name-%version/is_python_script {} \; -exec %{_builddir}/%name-%version/set_python_interpreter %{_bindir}/python2.4 {} \;

%{?pkgbuild_postprocess: %pkgbuild_postprocess -v -c "%{version}:%{jds_version}:%{name}:$RPM_ARCH:%(date +%%Y-%%m-%%d):%{support_level}" $RPM_BUILD_ROOT}

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr (-, root, bin)
%dir %attr (0755, root, bin) %{p23_prefix}
%dir %attr (0755, root, bin) %{p23_bindir}
%{p23_bindir}/*
%dir %attr (0755, root, bin) %{_bindir}
%{_bindir}/*
%dir %attr (0755, root, bin) %{_libdir}
%{_libdir}/python?.?/LICENSE.txt
%{_libdir}/python?.?/*.py*
%{_libdir}/python?.?/*.doc
%{_libdir}/python?.?/compiler
%{_libdir}/python?.?/email
%{_libdir}/python?.?/encodings
%{_libdir}/python?.?/hotshot
%{_libdir}/python?.?/idlelib
%{_libdir}/python?.?/lib-dynload
%{_libdir}/python?.?/lib-old
%{_libdir}/python?.?/lib-tk
%{_libdir}/python?.?/logging
%{_libdir}/python?.?/plat-*
%{_libdir}/python?.?/site-packages
%{_libdir}/python?.?/vendor-packages
%{_libdir}/python?.?/xml
%{_libdir}/lib*.so*
%dir %attr (0755, root, bin) %{p23_libdir}
%{p23_libdir}/*

%files share
%defattr (-, root, bin)
%dir %attr (0755, root, bin) %{p23_prefix}
%dir %attr(0755, root, sys) %{_datadir}
%dir %attr(0755, root, bin) %{p23_datadir}
%dir %attr(0755, root, bin) %{_mandir}
%dir %attr(0755, root, bin) %{_mandir}/*
%{_mandir}/*/*
%dir %attr(0755, root, bin) %{p23_mandir}
%dir %attr(0755, root, bin) %{p23_mandir}/*
%{p23_mandir}/*/*

%files devel
%defattr (-, root, bin)
%dir %attr (0755, root, bin) %{_includedir}
%{_includedir}/*
%{_libdir}/python?.?/config
%{_libdir}/python?.?/distutils
%{_libdir}/python?.?/test
%{_libdir}/python?.?/py[cC][cC]

%changelog
* Thu Apr  6 2006 - [email protected]
- Add SUNWgdbm and SUNWgmp to Requires after check-deps.pl run.
* Sun Oct 30 2005 - [email protected]
- change interpreter in python scripts to full path to the appropriate
  version (/usr/bin/python2.4 or /usr/sfw/bin/python2.3), fixes 6318475
- set the C/C++ compiler in the distutils Makefile to the pycc/pyCC
  wrapper scripts, fixes 6247860
* Fri Oct 28 2005 - [email protected]
- update to 2.4.2
- build shared libpython and remove the static one, fixes 6199942
- remove XOPEN/POSIX defines from pyconfig.h: fixes 6240077
- add missing dependencies, fixes 6318436
* Tue Sep 27 2005 - [email protected]
- omit some unnecessary compiler flags
- remove .pyo files
- add a pth file to site-packages that tells python to search for modules
  in the vendor-packages directory too
- change default permissions to root:bin.
* Wed Oct 19 2005 - [email protected]
- Add another missing runtime dependency, SUNWlibmsr, fixes 6208617.
- Move Pyrex to SUNWPython-extra.spec file.
* Tue Sep 20 2005 - [email protected]
- move python 2.4.1 to /usr and keep python 2.3 in /usr/sfw for backcompat
- omit -xregs=no%frameptr as it breaks the build
* Fri Aug 26 2005 - [email protected]
- update to 2.4.1
* Tue Aug 02 2005 - [email protected]
- added SUNWsfwhea build dependency needed for expat headers
* Tue Aug 02 2005 - [email protected]
- Add SUNWlexpt dependency as the Expat library is required for building.
* Fri Jul 29 2005 - [email protected]
- Add missing runtime dependencies, fixes 6208617.
* Sun Nov 14 2004 - [email protected]
- add /usr/sfw/lib to RPATH
* Fri Oct 22 2004 - [email protected]
- remove bsddb bits (won't work without bsd db itself), fixes 6176600
* Sat Oct 02 2004 - [email protected]
- added %pkgbuild_postprocess
* Sat Sep 18 2004 - [email protected]
- move to /usr/sfw
* Tue Jun 22 2004 - [email protected]
- changed install location to /usr/lib and /usr/bin
* Fri Mar 05 2005 - [email protected]
- remove package root def'n
* Thu Mar 04 2004 - [email protected]
- initial version added to CVS