rpm 子包创建实践

rpm 在打包的时候,可以创建子包,这样可以清晰的进行软件包的拆分,以下是结合官方文档学习的一个实践。

预备条件

需要安装rpmdevtools

spec 文件

Name: foo

Version: 2.7

Release: 1

License: apache

Summary: dalong demo rpm subpacakge

Group: dalong/dalong

%description

This is the long description of the foo app, and the baz library needed to

build it...

%package server

Summary: The foo server

Group: dalong/dalong

%description server

This is the long description for the foo server...

%package client

Summary: The foo client

Group: dalong/dalong

%description client

This is the long description for the foo client...

%package -n bazlib

Version: 5.6

Summary: The baz library

Group: dalong/dalong

%description -n bazlib

This is the long description for the bazlib...

%pre

echo "This is the foo package preinstall script"

%build

cat > main.sh <<EOF

#!/bin/sh

echo "main"

EOF

cat > server.sh <<EOF

#!/bin/sh

echo "server"

EOF

cat > client.sh <<EOF

#!/bin/sh

echo "client"

EOF

cat > bazlib.sh <<EOF

#!/bin/sh

echo "bazlib"

EOF

%install

mkdir -p %{buildroot}/usr/local/

install -m 755 main.sh %{buildroot}/usr/local/main.sh

install -m 755 server.sh %{buildroot}/usr/local/server.sh

install -m 755 client.sh %{buildroot}/usr/local/client.sh

install -m 755 bazlib.sh %{buildroot}/usr/local/bazlib.sh

%pre server

echo "This is the foo-server subpackage preinstall script"

%pre client

echo "This is the foo-client subpackage preinstall script"

%pre -n bazlib

echo "This is the bazlib subpackage preinstall script"

%files

/usr/local/main.sh

%files server

/usr/local/server.sh

%files client

/usr/local/client.sh

%files -n bazlib

/usr/local/bazlib.sh

 
 

构建&&效果

  • 构建
 
rpmbuild -ba foo-2.7.spec

效果

正在执行(%build):/bin/sh -e /usr/local/var/tmp/rpm-tmp.j3G7re

+ umask 022

+ cd /Users/dalong/rpmbuild/BUILD

+ cat

+ cat

+ cat

+ cat

+ exit 0

正在执行(%install):/bin/sh -e /usr/local/var/tmp/rpm-tmp.Maa2R7

+ umask 022

+ cd /Users/dalong/rpmbuild/BUILD

+ mkdir -p /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64/usr/local/

+ install -m 755 main.sh /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64/usr/local/main.sh

+ install -m 755 server.sh /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64/usr/local/server.sh

+ install -m 755 client.sh /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64/usr/local/client.sh

+ install -m 755 bazlib.sh /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64/usr/local/bazlib.sh

+ /usr/local/Cellar/rpm/4.14.1/lib/rpm/brp-compress

+ /usr/local/Cellar/rpm/4.14.1/lib/rpm/brp-strip /usr/bin/strip

+ /usr/local/Cellar/rpm/4.14.1/lib/rpm/brp-strip-static-archive /usr/bin/strip

+ /usr/local/Cellar/rpm/4.14.1/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump

处理文件:foo-2.7-1.x86_64

Provides: foo = 2.7-1 foo(x86-64) = 2.7-1

Requires(interp): /bin/sh

Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1

Requires(pre): /bin/sh

Requires: /bin/sh

处理文件:foo-server-2.7-1.x86_64

Provides: foo-server = 2.7-1 foo-server(x86-64) = 2.7-1

Requires(interp): /bin/sh

Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1

Requires(pre): /bin/sh

Requires: /bin/sh

处理文件:foo-client-2.7-1.x86_64

Provides: foo-client = 2.7-1 foo-client(x86-64) = 2.7-1

Requires(interp): /bin/sh

Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1

Requires(pre): /bin/sh

Requires: /bin/sh

处理文件:bazlib-5.6-1.x86_64

Provides: bazlib = 5.6-1 bazlib(x86-64) = 5.6-1

Requires(interp): /bin/sh

Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1

Requires(pre): /bin/sh

Requires: /bin/sh

检查未打包文件:/usr/local/Cellar/rpm/4.14.1/lib/rpm/check-files /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64

已写至:/Users/dalong/rpmbuild/SRPMS/foo-2.7-1.src.rpm

已写至:/Users/dalong/rpmbuild/RPMS/x86_64/foo-2.7-1.x86_64.rpm

已写至:/Users/dalong/rpmbuild/RPMS/x86_64/foo-server-2.7-1.x86_64.rpm

已写至:/Users/dalong/rpmbuild/RPMS/x86_64/foo-client-2.7-1.x86_64.rpm

已写至:/Users/dalong/rpmbuild/RPMS/x86_64/bazlib-5.6-1.x86_64.rpm

正在执行(%clean):/bin/sh -e /usr/local/var/tmp/rpm-tmp.wO2CmJ

+ umask 022

+ cd /Users/dalong/rpmbuild/BUILD

+ /bin/rm -rf /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64

+ exit 0

 

  • 查看rpm 包信息
    默认生成的文件存储路径~/rpmbuild/RPMS/x86_64
    生成的内容
 
├── bazlib-5.6-1.x86_64.rpm

├── foo-2.7-1.x86_64.rpm

├── foo-client-2.7-1.x86_64.rpm

└── foo-server-2.7-1.x86_64.rpm

 

查看一个包的信息

rpm -qip foo-client-2.7-1.x86_64.rpm

Name : foo-client

Version : 2.7

Release : 1

Architecture: x86_64

Install Date: (not installed)

Group : dalong/dalong

Size : 24

License : apache

Signature : (none)

Source RPM : foo-2.7-1.src.rpm

Build Date : 日 11/ 3 09:39:07 2019

Build Host : dalongrong.local

Relocations : (not relocatable)

Summary : The foo client

Description :

This is the long description for the foo client...

说明

以上是一个简单的学习,实际中我们需要结合实际项目添加更多的配置,同时还需要考虑分发。。。。好多事情

参考资料

https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch10s04s02.html 
http://ftp.rpm.org/max-rpm/s1-rpm-subpack-spec-file-changes.html 

rpm 子包创建实践

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

栗子博客 软件 rpm 子包创建实践 https://www.lizi.tw/soft/16988.html

常见问题
  • 1、杰齐1.7仅适用于PHP5.2 2、需Zend支持 3、尽量使用宝塔面板 4、尽量使用Windows 系统,关关对Linux支持不太友好。
查看详情

相关文章

评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

rpm 子包创建实践-海报

分享本文封面