rpm package to create a sub-practice

rpm package in time, you can create a sub-package, so you can clearly split package, the following is a practical combination of official documentation to learn.

Ready condition

You need to install rpmdevtools

spec file

  • content
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"
% For 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
 
 
  • Brief Description of the
    sub-packages by %package <name>format statement, the default name generated for the 父-子name we can -ndeclare their own
    for pre, post stage, we can define your own script, such as the above pre stage

Build && effect

  • Construct
 
rpmbuild -ba foo-2.7.spec

effect

Is being performed (% build): / bin / sh -e /usr/local/var/tmp/rpm-tmp.j3G7re
+ umask 022
+ cd /Users/dalong/rpmbuild/BUILD
+ cat
+ cat
+ cat
+ cat
+ exit 0
Is being performed (% 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
With files: 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
With files: 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
With files: 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
With files: 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
Check the unpacked files: /usr/local/Cellar/rpm/4.14.1/lib/rpm/check-files /Users/dalong/rpmbuild/BUILDROOT/foo-2.7-1.x86_64
I have written to: /Users/dalong/rpmbuild/SRPMS/foo-2.7-1.src.rpm
I have written to: /Users/dalong/rpmbuild/RPMS/x86_64/foo-2.7-1.x86_64.rpm
I have written to: /Users/dalong/rpmbuild/RPMS/x86_64/foo-server-2.7-1.x86_64.rpm
I have written to: /Users/dalong/rpmbuild/RPMS/x86_64/foo-client-2.7-1.x86_64.rpm
I have written to: /Users/dalong/rpmbuild/RPMS/x86_64/bazlib-5.6-1.x86_64.rpm
Is being performed (% 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
 
  • View rpm package information
    generated by default file storage path ~/rpmbuild/RPMS/x86_64
    generated content
 
├── 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
 

View a packet of information

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...

Explanation

The above is a simple to learn, practice, we need to add more of the actual project configuration, but also need to consider the distribution. . . . A lot of things

Reference material

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 

Guess you like

Origin www.linuxidc.com/Linux/2019-11/161333.htm