1、如果是官方包:
下載src.rpm,解壓后得到源碼及spec文件胸囱;覆蓋源碼,解決依賴瀑梗;直接打包
rpmbuild -ba xxxx.spec
2烹笔、沒有官方包:
使用rpmbuild打包
編寫spec
vi xxx.spec
Name: hellorpm #名字為源碼tar.gz 包的名字
Version: 1.0.0 #版本號,?定要與tar.gz包的?致哦
Release: 1%{?dist} #釋出號抛丽,也就是第?次制作rpm
Summary: helloword #描述信息/軟件包簡介谤职,最好不超過50字符
License: GPL #許可,GPL還是BSD等
URL: #?定義該信息,可以寫?個?址
Packager: abel
Source0: %{name}-%{version}.tar.gz
#定義?到的source亿鲜,也就是你的源碼
BuildRoot: %_topdir/BUILDROOT
#這個是軟件make install 的測試安裝?錄.
BuildRequires: gcc,make #制作過程中?到的軟件包
Requires: python-apscheduler >= 2.1.2-1.el7,python-daemon >= 1.6-1.el7 #軟件運?依
賴的軟件包允蜈,也可以指定最低版本如 bash >= 1.1.1
%description #描述,隨便寫
%prep #打包開始
%setup -q #這個作?靜默模式解壓并cd
%build #編譯制作階段蒿柳,主要?的就是編譯饶套,如果不?編譯就為空
./configure \
%{?_smp_mflags} #make后?的意思是:如果就多處理器的話make時并?編譯
%install #安裝階段//安裝之前需初始化安裝?錄
rm -rf %{buildroot} #先刪除原來的安裝的,如果你不是第?次安裝的話
cp -rp %_topdir/BUILD/%{name}-%{version}/* $RPM_BUILD_ROOT
#將需要需要打包的?件從BUILD ?件夾中拷?到BUILDROOT?件夾下垒探。
#下?的?步pre妓蛮、post、preun圾叼、postun 沒必要可以不寫
%pre #rpm安裝前制?的腳本
%post #安裝后執(zhí)?的腳本//安裝之后需要執(zhí)?的動作
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,-) #設定默認權限蛤克,如果下?沒有指定權限捺癞,則繼承默認
/etc/hello/word/helloword.c #將你需要打包的?件或?錄寫下來
/usr/local/httpd/bin/*
%dir /usr/local/httpd/logs
%doc /usr/local/httpd/man/*
%doc /usr/local/httpd/manual/*
###