rpm包的制作
需求:最近要制作一個rpm包,通過源碼(python)
方案:利用rpmbuild實現,編寫 相應spec腳本
首先下載源碼文件python
然后打成tar包,放到新建的用戶目錄下 /user/lib
我們這里需要利用rpmbuild來建立,在此之前需要安裝sudo yum install rpm-build
用下面的命令創建必要的文件夾,其中BUILD是用來保存打包過程中生成的臨時文件用的;RPMS用來保存生成的二進制RPM包;SOURCES用來保存打包用的源文件(包括壓縮文件);SPECS用來保存.spec腳本;SRPMS用來保存生成的源代碼rpm包。
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}將打好的tar包放到SOURCES目錄下
開始編寫spec腳本
1、創建一個相關包的python.spec腳本,會生成相關的模板配置
2、具體腳本內容如下:
Name: AB Version: 1.0.0 Release: 1%{?dist} Summary: Design firstlyGroup: Applications/Internet License: GPL URL: www.first.com Source0: AB.tar BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: gcc,gcc-c++,openssl-devel%define python_path /tmp/python/ %define etc_path /tmp/etc/ %define config_file c.cont%description Design firstly #在執行rpm時完成相關文件資源的預處理 %prep tar -cvf ../SOURCES/%{Source0} ../SOURCES/*.txt if [ ! -d "%{path_path}"]; then mkdir "%{path_path}" fi if [ ! -d "%{etc_path}"]; then mkdir "%{etc_path}" fi tar -xvf ../SOURCES/%{Source0} -C %{python_path}%build cp ../SOURCES/%{config_file} %{etc_path} chmod 755 /tmp/etc/%{config_file}
./configure
make%install make install
%clean rm -rf %{buildroot}%files %doc #在執行rpm -e AB時卸載文件 %postun if [ "$1" = "0" ]; then echo 'uninstall start...'rm -rf %{python_path} %{etc_path}echo 'uninstall done!' fi%changelog
?
??
轉載于:https://www.cnblogs.com/zx-bob-123/p/7978196.html
總結
- 上一篇: JS编程建议——52:建议使用splic
- 下一篇: python2 安装 MySQL-py