天天看點

rpm建構流程學習總結

rpm建構流程

學習連結:

b站馬哥: ​​https://www.bilibili.com/video/BV1ai4y1N7gp​​

RedHat:

​​https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/8/html/packaging_and_distributing_software/index​​

introduction section

prep section |解壓,宏,

%prep

%setup

build section

%build

install section

%install

clean section

%clean

rm -rf %{buildroot}

腳本段 在install之後

%pre 安裝前

%post 安裝後

%preun 解除安裝前

%postun 解除安裝後

file section

%file

SOURCES |源碼包,Unzip to BUILD

SPEC | .spec檔案

BUILD |解壓到該目錄

BUILDROOT |安裝軟體後,以該目錄為根生成的路徑 files[] 把buildroot裡有用的部分拿出來,放到rpm裡 最後clean會清除 buildroot、build

RPMS

SRPMS

BuildRequires

制作軟體包需要的依賴 gcc binutils

Requires

安裝軟體包需要的依賴

release 指第幾次制作,跟version無關

制作過程:

rpm build:首先解壓SOURCE裡的檔案到BUILD,在BUILD裡生成一個子目錄,編譯過程會跳到子目錄裡去執行./config/make,編譯之後安裝,不是安裝到系統上,而是安裝到一個臨時目錄中去,install安裝到buildroot目錄下,把buildroot目錄當作作業系統目錄。下一步:file section ,rpm 指令根據file section中列出的檔案,把BUILD目錄中的那些file檔案壓縮成rpm包。打包完成後執行clean過程,清除BUILDROOT和BUILD目錄。

BUILDROOT裡除了debug的檔案,其他的都必須做進rpm包

解壓到BUILD,cd進去,設定一些環境變量,設定一些宏,為編譯做準備

%setup 像是prep的擴充

-q 靜默模式 不顯示過程

./configure

--etcdir="%{_sysconfdir}"

--mandir="%{_mandir}"

--il8n="0"

--scrip="0"

%{_make} %{?_smp_mflags} ==>對稱多處理器上,可以加快編譯過程

%{__rm} -rf %{buildroot} 删除之前安裝的,沒有也不影響

%{__make} install DESTDIR="%{buildroot}"

%find_lang %{name}

在buildroot目錄下會生成一堆

6。 %clean

%{__rm} -rf %{buildroot}

清理此前制作過程中的buildroot

%defattr(-,root,root,-) 權限

%doc 文檔

%config %{_sysconfigdir}/axelrc 配置檔案

/usr/local/bin/axel

%dir 目錄

%conf(noraplace) 指的是新的配置檔案是否替換,如果原來的舊的配置沒有修改,會替換,修改了,不會替換,會把原來的改成比如xxx.conf.orig,再去生成新的。

usr/src下的debug是不用包含進來的

%attr(0755, root, root) /etc/rc.d/init.d/nginx %attr表示單個屬性,如果不這樣寫,會繼承預設屬性

rpmbuild --showrc|grep _tmppath

-ba all ==> bb + bs

-bb 表示制作二進制格式的rpm包

-bc %build

-bp %prep

-bi %install

-bl check 有多餘的檔案或者檔案沒有被放到rpm包裡都會error。==>

Check the listing of filee for the RPM and generate errors if the buildroot is missing any of the file to be installed.

-bs 表示制作源碼格式的rpm包 src.rpm

netstat -tnlp 檢視端口

rpm -ivh xxx.rpm 安裝

rpm -qi xxx.rpm 檢視rpm包資訊

rpm -e xxx.rpm 解除安裝

rpm -Uvh xxx.rpm

繼續閱讀