天天看點

rpm安裝包的制作rpm安裝包的制作

rpm安裝包的制作

  1. 裝包
  2. 配置檔案說明
  3. 打包
  4. spec檔案詳解
  5. 簡單的打包案例

本實驗在Ubuntu 20.04.1 LTS(Ubuntu Kylin)上進行操作,當然别的系統也行

1.裝包(rpmbuild工具在安裝完rpm之後就會有)

sudo apt-get install rpm
           

2.生成rpmbuild工作目錄

[email protected]:~$ tree rpmbuild/
rpmbuild/
├── BUILD
├── BUILDROOT
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
           
  • BUILD:源代碼解壓後放的位置,将會在這個目錄下進行制作
  • BUILDROOT:假跟,在install階段的時候會安裝這個目錄下,是以這個目錄下的檔案,才是真正的目錄檔案。打包完成後,将會删除此目錄
  • RPMS:存放生成的二進制包
  • SOURCES:打包的資源,源碼包或更新檔檔案
  • SPECS:制作安裝包的規則檔案
  • SRPMS:存放生成的源碼包,也就是SRC格式的安裝包(SRC就不涉及到平台了)

3.打包

rpmbuild -bp xx.spec  #隻執行spec的%pre段(解開源碼包并打更新檔,即制作準備)
rpmbuild -bc xx.spec  #隻執行spec的%pre和%build段(準備并編譯)
rpmbuild -bi xx.spec  #執行spec的%pre、%build、%install(準備編譯并安裝)
rpmbuild -bl xx.spec  #檢查%spec中的%file段
rpmbuild -ba xx.spec  #制作源碼和二進制包(*.rpm和*.src.rpm)
rpmbuild -bb xx.spec  #隻做二進制包(*.rpm)
rpmbuild -bs xx.spec  #隻做源碼包(*.src.rpm)

           

4.spec檔案詳解

#定義包名和版本,可在下方調用
%define name 
%define version  
Name: jingjing   
Version: 1.0.0
Release: 1
Summary: ceshi
Vendor: jingxiang
#軟體分組或類别
Group: Unknown
#軟體授權方式
License: GPL
URL: Unknown
#源代碼包,可以用Source1、Source2表示,下面可用%{source1}、%{source2}調用
Source0: teach.tar.gz
Buildarch: noarch
#BuildRequires:
#該rpm包所依賴的軟體包名稱
#Requires:
%description
this is my first product software
%prep
%setup -q
%build
#将軟體安裝到虛拟根目錄中,這裡install隻要為下面的files服務的
%install
mkdir -p $RPM_BUILD_ROOT/mnt/jingjing
cp -rf * $RPM_BUILD_ROOT/mnt/jingjing
%clean
rm -rf $RPM_BUILD_ROOT
#定義那些目錄或檔案被打編寫到rpm中
%files
/mnt/jingjing/*
%doc
#變更日志,注意星期和月份用英文的前三個字母
%changelog
* Sun Aug 02 2020 jingxiang [email protected] -1.0.0-1
  only test
           

擴充:

Group

類别:

軟體包所屬類别,具體類别有:
Amusements/Games (娛樂/遊戲)
Amusements/Graphics(娛樂/圖形)
Applications/Archiving (應用/文檔)
Applications/Communications(應用/通訊)
Applications/Databases (應用/資料庫)
Applications/Editors (應用/編輯器)
Applications/Emulators (應用/仿真器)
Applications/Engineering (應用/工程)
Applications/File (應用/檔案)
Applications/Internet (應用/網際網路)
Applications/Multimedia(應用/多媒體)
Applications/Productivity (應用/産品)
Applications/Publishing(應用/印刷)
Applications/System(應用/系統)
Applications/Text (應用/文本)
Development/Debuggers (開發/調試器)
Development/Languages (開發/語言)
Development/Libraries (開發/函數庫)
Development/System (開發/系統)
Development/Tools (開發/工具)
Documentation (文檔)
System Environment/Base(系統環境/基礎)
System Environment/Daemons (系統環境/守護)
System Environment/Kernel (系統環境/核心)
System Environment/Libraries (系統環境/函數庫)
System Environment/Shells (系統環境/接口)
User Interface/Desktops(使用者界面/桌面)
User Interface/X (使用者界面/X視窗)
User Interface/X Hardware Support (使用者界面/X硬體支援)
           

file

字段

%files
%ifarch x86_64
/mnt/jingjing/*
%else
/mnt/other/*
%endif
           

一鍵制作rpm腳本下載下傳:

https://blog.csdn.net/qq_44839276/article/details/107037946

pdf檔案下載下傳:

https://github.com/zhd-haodong/Ebook