The test uses FPM to package the source code of Python3 into RPM to install
First, the basic Environment 1, on the basis of tvm-base, copy an image for tvm-rpm to test. 2, Network: eth0:host-only (for virtual intranet, manually fixed IP, so from the host can directly connect to this VM) Eth1:nat (for Sisu network, dynamic IP) [[email protected] ~]# Ip a s dev eth0 |grep global inet 192.168.56.253/24 brd 192.168.56.255 scope global eth0[[email protected] ~]# ip a s dev eth1 |grep global inet 10.0.3.15/24 brd 10.0.3.255 scope global eth1 3. Configuring Yum sources [[email protected] ~]# mv /etc/yum.repos.d/CentOS* /tmp/ && echo ' 192.168.56.254 mirrors.office.test ' >> /etc/hosts && wget http:// mirrors.office.test/centos/local-office.repo -o /etc/yum.repos.d/local-office.repo && yum makecache[[email protected] ~]# yum update[[email protected] ~]# reboot[[email protected] ~]# mv centos-* /etc/yum.repos.d/ /tmp/Second, Configuring the FPM Environment 1, installing Ruby and fpm[[email protected] ~]# yum install ruby rubygems Ruby-devel Replace the source of the gem: [[email protected] ~]# gem sources --remove http:// rubygems.org/ [[email protected] ~]# gem sources -a http:// mirrors.aliyun.com/rubygems/[[email protected] ~]# gem sources -a https:// Ruby.taobao.org/[[email protected] ~]# gem sources -l*** current sources ***http://mirrors.aliyun.com/rubygems/https://ruby.taobao.org/[[email protected] ~]# gem -v1.3.7[[email protected] ~]# ruby -vruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] installation fpm[[email protected] ~]# gem install fpm -v[[email protected] ~]# fpm --version1.3.32, FPM parameter reference: HTTPS://GITHUB.COM/JORDANSISSEL/FPM/WIKI%&NBSP;FPM&NBSP;-S&NBSP;<SOURCE&NBSP;TYPE>&NBSP;-T <target type> [options]-s Source Format-t Target Format-n Package Name-v version value, actual version number--iteration release value, release serial number--epoch &nbsP; epoch value--vendor manufacturer--maintainer Maintainer--description Description--url Software Home--workdir &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;FPM working Directory-d Dependent Packages--directories recursively specifies that the directory is marked as belonging to this package-c switch to the specified directory-p output to the specified path--force Force overwrite file--after-install file Scripts that are executed after the package is installed--before-install file The script that is executed before the package is installed--after-remove file script executed after package removal--before-remove file scripts executed before the package removal--after-upgrade file Package upgrade script executed after--before-upgrade file package upgrade script executed before-e Building before editing the spec file three, packaging the source code of Python3 into RPM to install 1, configure the package required to compile the Python environment [[email protected] ~]# mkdir / data/{download,rpms}[[email protected] ~]# rpm -uvh http://dl.fedoraproject.org/pub/ epel/epel-release-latest-6.noarch.rpm[[email protected] ~]# rpm -uvh http:// rpms.famillecollet.com/enterprise/remi-release-6.rpm[[email protected] ~]# yum -y groupinstall "Development tools" [[email protected] ~]# yum -y install openssl-devel readline-devel bzip2-devel sqlite-devel zlib-devel ncurses-devel Db4-devel expat-devel Download the latest Python source package: [[email protected] ~]# wget https:// www.python.org/ftp/python/3.4.3/python-3.4.3.tgz -o /data/download/python-3.4.3.tgz[[email Protected] ~]# cd /data/download/[[email&nbsP;protected] download]# tar xf python-3.4.3.tgz [[email protected] download ]# cd python-3.4.3[[email protected] python-3.4.3]# [[email protected] python-3.4.3]# export dir_py_src_install=/data/rpms/python-3.4.3[[email protected] python-3.4.3]# export dir_py_rpm_install=/usr/local[[email protected] python-3.4.3]# export ldflags= "-wl,-rpath=${dir_py_rpm_install}/lib ${ldflags}" [[email protected] python-3.4.3]# ./configure --prefix=${dir_py_rpm_install}[[email protected] python-3.4.3]# make[[email protected] python-3.4.3]# make install destdir=${dir_py_src_install }[[EMAIL&NBSP;PROTECTED]&NBSP;PYTHON-3.4.3]#&NBSP;CD&NBSP, .... Let's take a look at the resulting directories and files: [[email protected] python-3.4.3]# cd /data/rpms[[email protected] python-3.4.3]# ls python-3.4.3/usr/local/bin include&Nbsp; lib share2, start packing [[Email protected] 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 {:p ath=> "/data/rpms/pkgs/ python3-3.4.3-1.el6.x86_64.rpm "} Let's take a look at the contents of the package: [[email protected] rpms]# rpm -qpi pkgs/ python3-3.4.3-1.el6.x86_64.rpm name : python3 Relocations: / Version : 3.4.3 vendor: python software foundationrelease : 1.el6 Build Date: Wed 15 Jul 2015 04:55:17 PM cstinstall date: (not installed) build host: tvm-rpmgroup : default Source RPM: python3-3.4.3-1.el6.src.rpmSize : 126285890 License: unknownsignature : (none) packager : pcurl : https://www.python.org/downloads/release/python-343/summary : use fpm to make a pkg for python-3.4.3description :use fpm to make a pkg for python-3.4.33, installation test 1) before installation: [[Email protected] rpms]# ls /usr/local/{bin,include,lib,share/man}/usr/local/bin:/usr/local/include:/usr/local/lib:/usr/local/share/ Man/man1:2) Start Installation: [[email protected] rpms]# rpm -ivh pkgs/python3-3.4.3-1.el6.x86_64. rpm preparing... ########################################### [100%] 1:python3 ########################## ################# [100%][[email protected] rpms]# rpm -qa |grep python3python3-3.4.3-1.el6.x86_643) after installation: [[ Email protected] 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 Execute Python command to view version:[[email protected] 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) Uninstall: [[email protected] rpms]# rpm -e python3-3.4.3-1.el6.x86_64 &NBSP;&NBSP;&NBSP;[[EMAIL&NBSP;PROTECTED]&NBSP;RPMS]#&NBSP;LS&NBSP;/USR/LOCAL/{BIN,INCLUDE,LIB,SHARE/MAN/MAN1} /usr/local/bin:/usr/local/include:/usr/local/lib:/usr/local/share/man/man1: In line with expectations. Four, TODO1, packaging a few other things, such as php,zabbix-agent, their own scripts and so on. Zyxw, reference 1, FPM/WIKIHTTPS://GITHUB.COM/JORDANSISSEL/FPM/WIKI2, use FPM create Python rpm Pack HTTP://THEO.IM/BLOG/2014/05/16/USE-FPM-TO-CREATE-PYTHON-RPM-PACKAGES/3, quickly generate RPM packages using FPM https://linux.cn/ Article-3184-1.html
The test uses FPM to package the source code of Python3 into RPM to install