制作rpm包

一、RPM打patch

1、把patch文件放入SOURCES中

2、修改SPECS中的XXX.spec,把下图中箭头的部分都要写上,这里是一个

 

 

 

 3、最后安装rmp包的时候如果有问题加上--force参数,sudo rpm -ivh xxx.x86_64.rpm --force

二、RMP包制作流程

1、创建spec模板文件

rpmdev-newspec xxx.spec

2、spec模板示例

Name:           client
Version:        1.0.1
Release:        1%{?dist}
Summary:       system activate client

License:        GPL
URL:            
Source0:        %{name}.orig.tar.gz
# 编译依赖
BuildRequires:  cmake
BuildRequires:  qt5-qtbase-gui
BuildRequires:  qt5-qtbase-devel 
BuildRequires:  polkit-qt5-1-devel
# 运行依赖
#Requires:
%description %prep %setup -n %{name} %build cmake . make -j4 %install rm -rf $RPM_BUILD_ROOT %make_install %files /usr/bin/* /usr/share/polkit-1/actions/ /usr/share/dbus-1/system.d/ /usr/share/dbus-1/system-services/ /usr/share/applications/ %changelog * Thu Aug 31 2023 redflag -

3、生成打包目录结构

#使用命令创建打包目录结构   路径为:home/rpmbuild
rpmdev-setuptree

# 目录树
rpmbuild
    - BUILD           // 编译时用到的暂存目录
    - RPMS            // 打包后生成的 rpm 包会放在这里
    - SOURCES         // 源码压缩包
    - SPECS           // 放 xx.spec 文件
    - SRPMS           // 打包后生成的 srpm 包会放在这里

4、压缩源码包到rpmbuild/SOURCES目录下

tar -czvf client.orig.tar.gz client
cp client.orig.tar.gz ~/rpmbuild/SOURCES

5、使用rpmbuild打包

// 不加--nodebuginfo没法生成包,加了之后有了,但没有debuginf版本的rpm包
rpmbuild -bb rpm/xxx.spec  --nodebuginfo

6、rmp相关的命令网上自行百度

1. rpm --rebuilddb 这个命令是用来重建RPM包数据库的

7、https://anolis.gitee.io/docs/articles/306-instruction-manual-of-rpmbuild.html

posted @ 2021-09-26 21:20  徐沛东  阅读(273)  评论(0编辑  收藏  举报