python 2.7カスタムRPMコンパイル[メモ]

12151 ワード

要求
python 2.7をコンパイルする
インストール先
実行可能ファイル位置/apps/svr/python 27
その他のライブラリファイル、ヘッダファイル、docインストール場所/apps/lib/python 27
対応ソースpython-2.7.5.tar.gz
 
python-2.7_を参照centOS5.8.specファイル
%define _topdir %(echo `cd ..; pwd`)
%define binsuffix 27
%define pybasever 2.7
%define version 2.7.5
%define name python
%define release 20140124vipclound.centOS58
############# edit by terry ############
%define _prefix                 /apps
%define _exec-prefix            /apps
%define _bindir                 /apps/svr/python27
%define _sbindir                /apps/svr/python27
%define _sysconfdir             /apps/conf
%define _includedir             /apps/lib
%define _libexecdir             /apps/lib
%define _infodir                /apps/lib
%define _oldincludedir          /apps/lib
%define _libdir                 /apps/lib
%define _defaultdocdir          /apps/lib

%define config_include_docs no

############# edit by terry ############

Name: %{name}%{binsuffix}
Version: %{version}
Release: 20140121.vipclound.el5
Summary: An interpreted, interactive, object-oriented programming language.
Group: Development/Languages
Source0: http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.bz2


License: PSF
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)


AutoReq: no
Provides: python(abi) = %{pybasever}


BuildRequires: autoconf
BuildRequires: bzip2
BuildRequires: bzip2-devel
BuildRequires: db4-devel
BuildRequires: expat-devel
BuildRequires: findutils
BuildRequires: gcc-c++
BuildRequires: glibc-devel
BuildRequires: make
BuildRequires: openssl-devel
BuildRequires: pkgconfig
BuildRequires: readline-devel
BuildRequires: sqlite-devel
BuildRequires: tar
BuildRequires: zlib-devel


%description
Python is an interpreted, interactive, object-oriented programming
language.  It incorporates modules, exceptions, dynamic typing, very high
level dynamic data types, and classes. Python combines remarkable power
with very clear syntax. It has interfaces to many system calls and
libraries, as well as to various window systems, and is extensible in C or
C++. It is also usable as an extension language for applications that need
a programmable interface.  Finally, Python is portable: it runs on many
brands of UNIX, on PCs under Windows, MS-DOS, and OS/2, and on the
Mac.


%package devel
Summary: The libraries and header files needed for Python extension development.
Requires: %{name} = %{version}-%{release}
Group: Development/Libraries


%description devel
The Python programming language's interpreter can be extended with
dynamically loaded extensions and can be embedded in other programs.
This package contains the header files and libraries needed to do
these types of tasks.


Install python-devel if you want to develop Python extensions.  The
python package will also need to be installed.  You'll probably also
want to install the python-docs package, which contains Python
documentation.


%prep
%setup -n Python-%{version}



%build
%configure \
        --enable-ipv6 \
        --enable-unicode=ucs4 \
        --enable-shared \
        --with-system-ffi \
        --with-system-expat \

%{__make} %{?_smp_mflags}




%install
[ -d $RPM_BUILD_ROOT ] && rm -fr $RPM_BUILD_ROOT


%{__make} altinstall DESTDIR=$RPM_BUILD_ROOT
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}-config
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/2to3
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/idle
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/pydoc
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/smtpd.py
%{__rm} -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig/
%{__ln_s} %{_libdir}/python2.7/config $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/config
%{__ln_s} %{_libdir}/python2.7/lib-dynload $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/lib-dynload


#      ldconfig      
mkdir -p $RPM_BUILD_ROOT/apps/conf/python27
touch $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/python2.7/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf



#      man file        RPM
gzip -c $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1 >> $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1.gz

######
# POST
######

%post
#        
mv /apps/lib/libpython2.7.so.1.0 /apps/lib/python2.7/.
ln -s  /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so

#      (   )    MAN FILE
rm -rf %{_libdir}/libpython2.7.so.1.0
rm -rf %{_libdir}/libpython2.7.so
rm -rf /%{_libdir}/man1

mkdir /apps/svr/python -p

ln -s /apps/svr/python27/python2.7 /apps/svr/python/python


%postun
rm -rf /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so
rm -rf /apps/svr/python/python

%post  devel
#      
mv /apps/include/python2.7/pyconfig.h /apps/lib/python2.7/.

total=`ls /apps/include/ | wc -l`
if [ $total -eq 1 ]
then
   rm -rf /apps/include
fi

%postun devel
rm -rf /apps/lib/python2.7/pyconfig.h



%clean
%{__rm} -rf $RPM_BUILD_ROOT




%files
%defattr(-,root,root,-)
%{_prefix}/lib/python2.7/*
%{_libdir}/python2.7/lib-dynload/*
%{_libdir}/libpython2.7.so*
%{_bindir}/python2.7*
# %{_mandir}/man1/python2.7.1
%{_bindir}/2to3
%{_bindir}/idle
%{_bindir}/pydoc
%{_bindir}/smtpd.py
%{_mandir}/man1/python2.7.1
%config(noreplace) /apps/conf/python27/python27.conf

#   /apps/svr/python27/2to3
#   /apps/svr/python27/idle
#   /apps/svr/python27/pydoc
#   /apps/svr/python27/smtpd.py


%doc
%{_mandir}/man1/python2.7.1.gz


%files devel
%defattr(-,root,root,-)
%{_prefix}/include/python2.7/*
%{_libdir}/python2.7/config/*


%changelog
* Mon Jan 21 2014 Terry Tsang <[email protected]> - 2.7.5-1
- Initial RPM release

 
python-2.7_centOS5.8.spec      /usr/src/redhat/SPECS/

python-2.7.5.tar.gz      /usr/src/redhat/SOURCES/

 
コンパイル方法
rpm -bb python-2.7_centOS5.8.spec

 
 
python-2.7_を参照centOS6.5.specファイル
%define _topdir %(echo `cd ..; pwd`)
%define binsuffix 27
%define pybasever 2.7
%define version 2.7.5
%define name python
%define release 20140124vipclound.centOS65

############# edit by terry ############
%define _prefix                 /apps
%define _exec-prefix            /apps
%define _bindir                 /apps/svr/python27
%define _sbindir                /apps/svr/python27
%define _sysconfdir             /apps/conf
%define _includedir             /apps/lib
%define _libexecdir             /apps/lib
%define _infodir                /apps/lib
%define _oldincludedir          /apps/lib
%define _libdir                 /apps/lib
%define _defaultdocdir          /apps/lib
#%define _mandir                /apps/lib

%define config_include_docs no

############# edit by terry ############

Name: %{name}%{binsuffix}
Version: %{version}
Release: 20140121.vipclound.el6
Summary: An interpreted, interactive, object-oriented programming language.
Group: Development/Languages
Source0: http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.bz2


License: PSF
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)


AutoReq: no
Provides: python(abi) = %{pybasever}


BuildRequires: autoconf
BuildRequires: bzip2
BuildRequires: bzip2-devel
BuildRequires: db4-devel
BuildRequires: expat-devel
BuildRequires: findutils
BuildRequires: gcc-c++
BuildRequires: glibc-devel
# BuildRequires: gmp-devel
# BuildRequires: libffi-devel
# BuildRequires: libGL-devel
# BuildRequires: libX11-devel
BuildRequires: make
# BuildRequires: ncurses-devel
BuildRequires: openssl-devel
BuildRequires: pkgconfig
BuildRequires: readline-devel
BuildRequires: sqlite-devel
BuildRequires: tar
# BuildRequires: tcl-devel
# BuildRequires: tix-devel
# BuildRequires: tk-devel
BuildRequires: zlib-devel


%description
Python is an interpreted, interactive, object-oriented programming
language.  It incorporates modules, exceptions, dynamic typing, very high
level dynamic data types, and classes. Python combines remarkable power
with very clear syntax. It has interfaces to many system calls and
libraries, as well as to various window systems, and is extensible in C or
C++. It is also usable as an extension language for applications that need
a programmable interface.  Finally, Python is portable: it runs on many
brands of UNIX, on PCs under Windows, MS-DOS, and OS/2, and on the
Mac.


%package devel
Summary: The libraries and header files needed for Python extension development.
Requires: %{name} = %{version}-%{release}
Group: Development/Libraries


%description devel
The Python programming language's interpreter can be extended with
dynamically loaded extensions and can be embedded in other programs.
This package contains the header files and libraries needed to do
these types of tasks.


Install python-devel if you want to develop Python extensions.  The
python package will also need to be installed.  You'll probably also
want to install the python-docs package, which contains Python
documentation.


%prep
%setup -n Python-%{version}



%build
%configure \
        --enable-ipv6 \
        --enable-unicode=ucs4 \
        --enable-shared \
        --with-system-ffi \
        --with-system-expat \

%{__make} %{?_smp_mflags}


%install
[ -d $RPM_BUILD_ROOT ] && rm -fr $RPM_BUILD_ROOT


%{__make} altinstall DESTDIR=$RPM_BUILD_ROOT
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}-config
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/2to3
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/idle
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/pydoc
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/smtpd.py
%{__rm} -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig/
%{__ln_s} %{_libdir}/python2.7/config $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/config
%{__ln_s} %{_libdir}/python2.7/lib-dynload $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/lib-dynload


#      ldconfig      
mkdir -p $RPM_BUILD_ROOT/apps/conf/python27
touch $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/python2.7/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf



#      man file        RPM
gzip -c $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1 >> $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1.gz

######
# POST
######

%post
#        
mv /apps/lib/libpython2.7.so.1.0 /apps/lib/python2.7/.
ln -s  /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so

#      (   )    MAN FILE
rm -rf %{_libdir}/libpython2.7.so.1.0
rm -rf %{_libdir}/libpython2.7.so
rm -rf /%{_libdir}/man1

mkdir /apps/svr/python -p

ln -s /apps/svr/python27/python2.7 /apps/svr/python/python


%postun
rm -rf /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so
rm -rf /apps/svr/python/python

%post  devel
#      
mv /apps/include/python2.7/pyconfig.h /apps/lib/python2.7/.

total=`ls /apps/include/ | wc -l`
if [ $total -eq 1 ]
then
   rm -rf /apps/include
fi

%postun devel
rm -rf /apps/lib/python2.7/pyconfig.h



%clean
%{__rm} -rf $RPM_BUILD_ROOT




%files
%defattr(-,root,root,-)
%{_prefix}/lib/python2.7/*
%{_libdir}/python2.7/lib-dynload/*
%{_libdir}/libpython2.7.so*
%{_bindir}/python2.7*
# %{_mandir}/man1/python2.7.1
%{_bindir}/2to3
%{_bindir}/idle
%{_bindir}/pydoc
%{_bindir}/smtpd.py
%{_mandir}/man1/python2.7.1
%{_bindir}/smtpd.pyc
%{_bindir}/smtpd.pyo
%config(noreplace) /apps/conf/python27/python27.conf

#   /apps/svr/python27/2to3
#   /apps/svr/python27/idle
#   /apps/svr/python27/pydoc
#   /apps/svr/python27/smtpd.py


%doc
%{_mandir}/man1/python2.7.1.gz


%files devel
%defattr(-,root,root,-)
%{_prefix}/include/python2.7/*
%{_libdir}/python2.7/config/*


%changelog
* Mon Jan 21 2014 Terry Tsang <[email protected]> - 2.7.5-1
- Initial RPM release

 
python-2.7_centOS65.spec      /root/rpmbuild/SPECS/

python-2.7.5.tar.gz      /root/rpmbuild/SOURCES/

 
コンパイル方法
rpm -bb python-2.7_centOS65.spec