rpm源码包
src.rpm包含spec
方案一
先安装,然后在rpmbuild目录直接可以查看文件
准备
mkdir /root/rpmbuild
cat<<EOF> /root/.rpmmacros
%_topdir /root/rpmbuild
EOF
安装
方案二
不用安装 ,使用rpm2cpio
提取rpm包spec文件到当前目录
rpm2cpio rpm包名.src.rpm | cpio -civ '*.spec'
rpm包
没有源码包,只能从rpm包提取,使用rpmrebuild
注意:基于rpm包获取的信息生成,实际运行可能会有问题
① 安装所需工具
yum install epel-release centos-release -y
yum install -y rpmrebuild rpmdevtools rpm-build rpm cpio
② 创建目录并进入
rpmdev-setuptree
cd rpmbuild/
③ 下载rpm包到当前目录
yumdownloader rpm包名
包查找:
https://pkgs.org/
https://mirrors.tuna.tsinghua.edu.cn/centos-vault/
④ 获取rpm包中的.spec文件
rpmrebuild -e -p --notest-install rpm包名.rpm
这时会打开到该rpm包的spec文件为一个临时文件,用vim打开的,使用vim的另存为(shift+:),(w 文件名)保存到当前目录
⑥ 提取rpm包所有文件到当前目录
rpm2cpio rpm包名.rpm | cpio -div
⑦ 修改spec文件,去除rpmrebuild头部
vim rpm包名.spec
⑧ 将spec文件移至SPECS目录
mv rpm包名.spec SPECS/
⑨ 通过SPEC文件打包
rpmbuild -bb SPECS/rpm包名.spec
⑩ 根据报错创建目录
mkdir BUILDROOT/rpm新包名/
⑪ 源文件移至BUILDROOT目录
mv usr BUILDROOT/rpm新包名/
⑫ 通过spec文件打包
rpmbuild -bb SPECS/rpm包名.spec
⑬ 查看RPMS下的新rpm文件
tree RPMS/
查看包依赖
使用yum
yum deplist rpm包名
使用rpm
rpm -qpR rpm包名.rpm
spce文件参数:
不自动查找软件所需的共享库与其提供的共享库
Autoreqprov: no
Autoreq
: 此域用于指示RPM是否自动查找软件所需的共享库。仅当域值为no或0时,RPM不执行find-requires程序,否则均执行该程序。
Autoprov
: 此域用于指示RPM是否自动查找软件提供的共享库。仅当域值为no或0时,RPM不执行find-provides程序,否则均执行该程序。
Autoreqprov
: 此域用于指示RPM是否自动查找软件所需的共享库与其提供的共享库。仅当域值为no或0时,RPM不执行find-requires与find-provides两个程序。此域相当于同时设定Autoreq与Autoprov域值为指定之值。
注: 上述三个域在描述文件中,它们之间因为顺序的不同而结果会有所不同,一般以最后一个为准。
refe
https://stackoverflow.com/questions/5613954/extract-the-spec-file-from-rpm-package
https://blog.packagecloud.io/eng/2015/10/13/inspect-extract-contents-rpm-packages/
https://blog.csdn.net/u012373815/article/details/73257754
https://blog.csdn.net/jk775800/article/details/88643440
https://blog.csdn.net/wf1982/article/details/6636157