python 3のソースコードをfpmでrpmにパッケージしてインストールするテスト


python 3のソースコードをfpmでrpmにパッケージしてインストールするテスト
 、    
1、 tvm-base-centos66    ,       tvm-rpm   。
2、  :
eth0:host-only(      ,    IP,               vm)
eth1:NAT(     ,  IP)
[root@tvm-rpm ~]# cd /etc/sysconfig/network-scripts/
[root@tvm-rpm network-scripts]# cat ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.56.253
PREFIX=24
GATEWAY=192.168.56.1
DNS1=192.168.56.254

[root@tvm-rpm network-scripts]# cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
DNS1=192.168.56.254

 、  fpm  
1、  ruby fpm
[root@tvm-rpm ~]# yum install ruby rubygems ruby-devel

  gem  :
[root@tvm-rpm ~]# gem sources --remove http://rubygems.org/ 
[root@tvm-rpm ~]# gem sources -a http://mirrors.aliyun.com/rubygems/
[root@tvm-rpm ~]# gem sources -a https://ruby.taobao.org/
[root@tvm-rpm ~]# gem sources -l
*** CURRENT SOURCES ***

http://mirrors.aliyun.com/rubygems/
https://ruby.taobao.org/


[root@tvm-rpm ~]# gem -v
1.3.7
[root@tvm-rpm ~]# ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]

  fpm
[root@tvm-rpm ~]# gem install fpm -V
[root@tvm-rpm ~]# fpm --version
1.3.3

2、fpm   
  :https://github.com/jordansissel/fpm/wiki
% fpm -s <source type> -t <target type> [options]
-s                             
-t                              
-n                            
-v                          version ,     
--iteration                 release ,     
--epoch                     epoch 
--vendor                      
--maintainer                   
--description                 
--url                           
--workdir                   fpm    
-d                                
--directories                              
-C                                  
-p                                  
--force                           

--after-install FILE                 
--before-install FILE                
--after-remove FILE                  
--before-remove FILE                 
--after-upgrade FILE                 
--before-upgrade FILE                

-e                          building   spec  


 、 python3      rpm   
1、    python      
[root@tvm-rpm ~]# mkdir /data/{download,rpms}
      epel :
[root@tvm-rpm ~]# mv /etc/yum.repos.d/*.repo /tmp/ \
&& wget http://mirrors.office.test/local-office.repo -O /etc/yum.repos.d/local-office.repo \
&& yum clean all \
&& yum makecache

 :        epel ,      :
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

[root@tvm-rpm ~]# yum -y groupinstall "Development tools"
[root@tvm-rpm ~]# yum -y install openssl-devel readline-devel bzip2-devel sqlite-devel zlib-devel ncurses-devel db4-devel expat-devel

     python   :
[root@tvm-rpm ~]# wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz -O /data/download/Python-3.4.3.tgz
[root@tvm-rpm ~]# cd /data/download/
[root@tvm-rpm download]# tar xf Python-3.4.3.tgz 
[root@tvm-rpm download]# cd Python-3.4.3
[root@tvm-rpm Python-3.4.3]# 
[root@tvm-rpm Python-3.4.3]# export DIR_PY_SRC_INSTALL=/data/rpms/Python-3.4.3
[root@tvm-rpm Python-3.4.3]# export DIR_PY_RPM_INSTALL=/usr/local

[root@tvm-rpm Python-3.4.3]# export LDFLAGS="-Wl,-rpath=${DIR_PY_RPM_INSTALL}/lib ${LDFLAGS}"
[root@tvm-rpm Python-3.4.3]# ./configure --prefix=${DIR_PY_RPM_INSTALL}
[root@tvm-rpm Python-3.4.3]# make
[root@tvm-rpm Python-3.4.3]# make install DESTDIR=${DIR_PY_SRC_INSTALL}
[root@tvm-rpm Python-3.4.3]# cd ..

      ,          :
[root@tvm-rpm Python-3.4.3]# cd /data/rpms
[root@tvm-rpm Python-3.4.3]# ls Python-3.4.3/usr/local/
bin  include  lib  share


2、    
[root@tvm-rpm Python-3.4.3]# fpm -s dir -t rpm \
    -n python3 \
    -v '3.4.3' \
    --iteration '1.el6' \
    --epoch '0' \
    --vendor ' Python Software Foundation' \
    --maintainer 'PC' \
    --description 'use fpm to make a pkg for python-3.4.3' \
    --url 'https://www.python.org/downloads/release/python-343/' \
    --workdir /data/rpms \
    -p /data/rpms/pkgs/ \
    -C ${DIR_PY_SRC_INSTALL} \
    --directories=${DIR_PY_RPM_INSTALL}/lib \
    --directories=${DIR_PY_RPM_INSTALL}/include \
    -d 'openssl' \
    -d 'bzip2' \
    -d 'zlib' \
    -d 'expat' \
    -d 'db4' \
    -d 'sqlite' \
    -d 'ncurses' \
    -d 'readline' \
Created package {:path=>"/data/rpms/pkgs/python3-3.4.3-1.el6.x86_64.rpm"}

         :
[root@tvm-rpm rpms]# rpm -qpi pkgs/python3-3.4.3-1.el6.x86_64.rpm 
Name        : python3                      Relocations: / 
Version     : 3.4.3                             Vendor: Python Software Foundation
Release     : 1.el6                         Build Date: Wed 15 Jul 2015 04:55:17 PM CST
Install Date: (not installed)               Build Host: tvm-rpm
Group       : default                       Source RPM: python3-3.4.3-1.el6.src.rpm
Size        : 126285890                        License: unknown
Signature   : (none)
Packager    : PC
URL         : https://www.python.org/downloads/release/python-343/
Summary     : use fpm to make a pkg for python-3.4.3
Description :
use fpm to make a pkg for python-3.4.3


3、    
1)   :
[root@tvm-rpm rpms]# ls /usr/local/{bin,include,lib,share/man}
/usr/local/bin:

/usr/local/include:

/usr/local/lib:

/usr/local/share/man/man1:

2)    :
[root@tvm-rpm rpms]# rpm -ivh pkgs/python3-3.4.3-1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:python3                ########################################### [100%]
[root@tvm-rpm rpms]# rpm -qa |grep python3
python3-3.4.3-1.el6.x86_64

3)   :
[root@tvm-rpm rpms]# ls /usr/local/{bin,include,lib,share/man/man1}
/usr/local/bin:
2to3  2to3-3.4  easy_install-3.4  idle3  idle3.4  pip3  pip3.4  pydoc3  pydoc3.4  python3  python3.4  python3.4-config  python3.4m  python3.4m-config  python3-config  pyvenv  pyvenv-3.4

/usr/local/include:
python3.4m

/usr/local/lib:
libpython3.4m.a  pkgconfig  python3.4

/usr/local/share/man/man1:
python3.1  python3.4.1

  python  ,    :
[root@tvm-rpm rpms]# python3 -c "import sys; print(sys.version)"
3.4.3 (default, Jul 15 2015, 14:40:59) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]

4)  :
[root@tvm-rpm rpms]# rpm -e python3-3.4.3-1.el6.x86_64           
[root@tvm-rpm rpms]# ls /usr/local/{bin,include,lib,share/man/man1}
/usr/local/bin:

/usr/local/include:

/usr/local/lib:

/usr/local/share/man/man1:


    。


 、TODO
1、         ,  yum      。
[root@tvm-rpm pkgs]# cd /data/rpms/pkgs/
[root@tvm-rpm pkgs]# fpm -s dir -t rpm \
    -a 'x86_64' \
    -n 'office-repo-latest' \
    -v '6' \
    --iteration '1.el6' \
    --epoch '0' \
    --vendor 'pc@office' \
    --maintainer 'PC' \
    --description 'provide file: [local-office.repo] for local users. include: centos-base, eple, user-define rpms' \
    /etc/yum.repos.d/local-office.repo 
    
Created package {:path=>"office-repo-latest-6-1.el6.noarch.rpm"}

[root@tvm-rpm pkgs]# rpm -qpl office-repo-latest-6-1.el6.x86_64.rpm 
/etc/yum.repos.d/local-office.repo
[root@tvm-rpm pkgs]# rpm -qpi office-repo-latest-6-1.el6.x86_64.rpm  
Name        : office-repo-latest           Relocations: / 
Version     : 6                                 Vendor: pc@office
Release     : 1.el6                         Build Date: Thu 06 Aug 2015 04:53:26 PM CST
Install Date: (not installed)               Build Host: tvm-rpm
Group       : default                       Source RPM: office-repo-latest-6-1.el6.src.rpm
Size        : 2392                             License: unknown
Signature   : (none)
Packager    : PC
URL         : http://example.com/no-uri-given
Summary     : provide file: [local-office.repo] for local users. include: centos-base, eple, user-define rpms
Description :
provide file: [local-office.repo] for local users. include: centos-base, eple, user-define rpms

  1:              
[root@tvm-test ~]# mv /etc/yum.repos.d/local-office.repo /tmp/
  :
[root@tvm-test ~]# rpm -ivh office-repo-latest-6-1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:office-repo-latest     ########################################### [100%]
[root@tvm-test ~]# diff /etc/yum.repos.d/local-office.repo /tmp/local-office.repo 


  2:            yum      。
[root@tvm-yum ~]# mv office-repo-latest-6-1.el6.x86_64.rpm /data/yum/repo/
       1    :
[root@tvm-test ~]# rpm -qa |grep office
office-repo-latest-6-1.el6.x86_64
[root@tvm-test ~]# rpm -e office-repo-latest-6-1.el6.x86_64
  :
[root@tvm-test ~]# rpm -ivh http://mirrors.office.test/office-repo-latest-6-1.el6.x86_64.rpm
Retrieving http://mirrors.office.test/office-repo-latest-6-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:office-repo-latest     ########################################### [100%]
[root@tvm-test ~]# diff /etc/yum.repos.d/local-office.repo /tmp/local-office.repo    


2、      monit
1)        binary
[root@tvm-pkgs rpms]# mkdir monit && cd monit
[root@tvm-pkgs monit]# wget https://mmonit.com/monit/dist/binary/5.14/monit-5.14-linux-x64.tar.gz
[root@tvm-pkgs monit]# tar zxvf monit-5.14-linux-x64.tar.gz 
monit-5.14/
monit-5.14/bin/
monit-5.14/bin/monit
monit-5.14/COPYING
monit-5.14/conf/
monit-5.14/conf/monitrc
monit-5.14/man/
monit-5.14/man/man1/
monit-5.14/man/man1/monit.1
[root@tvm-pkgs monit]# cd monit-5.14
[root@tvm-pkgs monit-5.14]# ll bin/ conf/ man/man1/
bin/:
total 2688
-rwxr-xr-x 1 root root 2752045 Jun  9 18:18 monit

conf/:
total 12
-rw------- 1 root root 11220 Jun  9 18:18 monitrc

man/man1/:
total 132
-rw-r--r-- 1 root root 131280 Jun  9 18:18 monit.1

        :
[root@tvm-pkgs monit-5.14]# cp -a bin/monit /usr/bin/  
[root@tvm-pkgs monit-5.14]# cp -a conf/monitrc /etc/
[root@tvm-pkgs monit-5.14]# cp -a man/man1/monit.1 /usr/share/man/man1/

        :
[root@tvm-pkgs monit-5.14]# ll init.d/
total 4
-rwxr-xr-x 1 root root 1272 Jun  5  2014 monit
[root@tvm-pkgs monit-5.14]# cp -a init.d/monit /etc/init.d/

    :
[root@tvm-pkgs monit-5.14]# mkdir /etc/monit.d
      :
[root@tvm-pkgs monit-5.14]# grep ^[^#] /etc/monitrc
set daemon  120
   with start delay 240 
set logfile /var/log/monit
include /etc/monit.d/*

2)  
[root@tvm-rpm monit-5.14]# cd /data/rpms/pkgs/
[root@tvm-pkgs pkgs]# fpm -s dir -t rpm \
    -a 'x86_64' \
    -n 'monit' \
    -v '5.14' \
    --iteration '1.el6' \
    --epoch '0' \
    --vendor 'pc@office' \
    --maintainer 'PC' \
    --description 'monit-5.14 for local users' \
    /usr/bin/monit \
    /etc/monitrc \
    /etc/monit.d \
    /usr/share/man/man1/monit.1 \
    /etc/init.d/monit

Created package {:path=>"monit-5.14-1.el6.x86_64.rpm"}

[root@tvm-pkgs pkgs]# rpm -qpl monit-5.14-1.el6.x86_64.rpm 
/etc/init.d/monit
/etc/monit.d
/etc/monitrc
/usr/bin/monit
/usr/share/man/man1/monit.1
[root@tvm-pkgs pkgs]# rpm -qpi monit-5.14-1.el6.x86_64.rpm  
Name        : monit                        Relocations: / 
Version     : 5.14                              Vendor: pc@office
Release     : 1.el6                         Build Date: Fri 28 Aug 2015 06:00:57 PM CST
Install Date: (not installed)               Build Host: tvm-pkgs
Group       : default                       Source RPM: monit-5.14-1.el6.src.rpm
Size        : 2895915                          License: unknown
Signature   : (none)
Packager    : PC
URL         : http://example.com/no-uri-given
Summary     : monit-5.14 for local users
Description :
monit-5.14 for local users

  1:              
[root@tvm-test ~]# rpm -Uvh monit-5.14-1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:monit                  ########################################### [100%]

[root@tvm-test ~]# service monit start
Starting monit: Starting Monit 5.14 daemon
Monit start delay set -- pause for 240s
                                                           [  OK  ]
[root@tvm-test ~]# chkconfig monit on


  :
[root@tvm-test ~]# rpm -e monit-5.14-1.el6.x86_64
[root@tvm-test ~]# ls /usr/bin/monit /etc/monitrc 
ls: cannot access /usr/bin/monit: No such file or directory
ls: cannot access /etc/monitrc: No such file or directory

    ,     。

  2:      yum    
[root@tvm-yum x86_64]# pwd
/data/yum/repo/office/6/x86_64
  rpm ,  repo:
[root@tvm-yum x86_64]# createrepo .
Spawning worker 0 with 30 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

  :
[root@tvm-test ~]# yum makecache
[root@tvm-test ~]# yum install monit
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package monit.x86_64 0:5.14-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
 Package                     Arch                         Version                           Repository                    Size
===============================================================================================================================
Installing:
 monit                       x86_64                       5.14-1.el6                        office                       1.2 M

Transaction Summary
===============================================================================================================================
Install       1 Package(s)

Total download size: 1.2 M
Installed size: 2.8 M
Is this ok [y/N]: y
Downloading Packages:
monit-5.14-1.el6.x86_64.rpm                                                                             | 1.2 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : monit-5.14-1.el6.x86_64                                                                                     1/1 
  Verifying  : monit-5.14-1.el6.x86_64                                                                                     1/1 

Installed:
  monit.x86_64 0:5.14-1.el6                                                                                                    

Complete!


ZYXW、  
1、fpm/wiki
https://github.com/jordansissel/fpm/wiki
2、   FPM    Python   RPM  
http://theo.im/blog/2014/05/16/use-fpm-to-create-python-rpm-packages/
3、  FPM    RPM 
https://linux.cn/article-3184-1.html