1、如果是官方包:
下載src.rpm,解壓后得到源碼及spec文件;覆蓋源碼,解決依賴;直接打包
rpmbuild -ba xxxx.spec
2、沒有官方包:
使用rpmbuild打包
編寫spec
vi xxx.spec
Name: hellorpm #名字為源碼tar.gz 包的名字
Version: 1.0.0 #版本號(hào),?定要與tar.gz包的?致哦
Release: 1%{?dist} #釋出號(hào),也就是第?次制作rpm
Summary: helloword #描述信息/軟件包簡介,最好不超過50字符
License: GPL #許可,GPL還是BSD等
URL: #?定義該信息,可以寫?個(gè)?址
Packager: abel
Source0: %{name}-%{version}.tar.gz
#定義?到的source,也就是你的源碼
BuildRoot: %_topdir/BUILDROOT
#這個(gè)是軟件make install 的測(cè)試安裝?錄.
BuildRequires: gcc,make #制作過程中?到的軟件包
Requires: python-apscheduler >= 2.1.2-1.el7,python-daemon >= 1.6-1.el7 #軟件運(yùn)?依
賴的軟件包,也可以指定最低版本如 bash >= 1.1.1
%description #描述,隨便寫
%prep #打包開始
%setup -q #這個(gè)作?靜默模式解壓并cd
%build #編譯制作階段,主要?的就是編譯,如果不?編譯就為空
./configure \
%{?_smp_mflags} #make后?的意思是:如果就多處理器的話make時(shí)并?編譯
%install #安裝階段//安裝之前需初始化安裝?錄
rm -rf %{buildroot} #先刪除原來的安裝的,如果你不是第?次安裝的話
cp -rp %_topdir/BUILD/%{name}-%{version}/* $RPM_BUILD_ROOT
#將需要需要打包的?件從BUILD ?件夾中拷?到BUILDROOT?件夾下。
#下?的?步pre、post、preun、postun 沒必要可以不寫
%pre #rpm安裝前制?的腳本
%post #安裝后執(zhí)?的腳本//安裝之后需要執(zhí)?的動(dòng)作
cp /usr/local/httpd/bin/apachectl /etc/init.d/myhttpd
sed -i '1a # chkconfig: 2345 85 15' /etc/init.d/myhttpd
%preun #卸載前執(zhí)?的腳本//卸載該rpm包所執(zhí)?的?些操作
/etc/init.d/myhttpd stop
%postun #卸載后執(zhí)?的腳本
%clean #清理段,刪除buildroot
rm -rf %{buildroot}
%files #rpm要包含的?件//安裝之后?成的?件
%defattr (-,root,root,-) #設(shè)定默認(rèn)權(quán)限,如果下?沒有指定權(quán)限,則繼承默認(rèn)
/etc/hello/word/helloword.c #將你需要打包的?件或?錄寫下來
/usr/local/httpd/bin/*
%dir /usr/local/httpd/logs
%doc /usr/local/httpd/man/*
%doc /usr/local/httpd/manual/*
###