Simplest Enterprise Continuous Integration Solutions

Saturday, July 28, 2012

Enterprise Linux: Build a binary RPM package

# Build el5 RPM from el5 OS

# root setup rpm build requires RPMs - redhat-rpm-config, rpm-build on EL5:

[root@linux.el5.x86_64-rpm-server ~]# uname -a
Linux linux64-rpm-server 2.6.32-100.0.19.el5 #1 SMP Fri Sep 17 17:51:41 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@linux.el5.x86_64-rpm-server ~]# rpmbuild --version
RPM version 4.4.2.3
[root@linux.el5.x86_64-rpm-server ~]# yum install redhat-rpm-config
Loaded plugins: security
Setting up Install Process
Package redhat-rpm-config-8.0.45-32.0.1.el5.noarch already installed and latest version
Nothing to do
[root@linux.el5.x86_64-rpm-server ~]# yum install rpm-build
Loaded plugins: security
Setting up Install Process
Package rpm-build-4.4.2.3-18.el5.x86_64 already installed and latest version
Nothing to do

# none root user (i.e. rpm_build_user) setup RPM build environment:

su - rpm_build_user
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ mkdir -p ~/rpmbuild/RPMS/{noarch,i686,x86_64} 
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ rpm --eval '%{_sourcedir}'
/home/rpm_build_user/rpmbuild/SOURCES

# RPM spec file example

#
# spec file for package 'name' (version 'v')
#
# The software is released as specified below.
#
Name: <software_name>
Version: <software_version>
Release: <software_release>%{?dist}
Summary: <software_name>
Vendor: <vendor_name>
License: <Commercial | Free>
URL: <vendor_url>
Group: <Server | Application>
BuildArch: <noarch | i686 | x86_64>
Prefix: /usr/local

%description
This RPM contains <software_name> from <vendor_name>

%pre

%post

%preun

%files
%defattr(-,root,root)
%doc

/usr/local/<software_name>

%changelog
* Sat Jul 28 2012 <rpm_build_user> <rpm_build_user@rpm_build_user.com>
- Initial Spec File

# RPM spec file location

[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ find /home/rpm_build_user/rpmbuild
/home/rpm_build_user/rpmbuild
/home/rpm_build_user/rpmbuild/RPMS
/home/rpm_build_user/rpmbuild/RPMS/x86_64
/home/rpm_build_user/rpmbuild/RPMS/i386
/home/rpm_build_user/rpmbuild/RPMS/noarch
/home/rpm_build_user/rpmbuild/BUILD
/home/rpm_build_user/rpmbuild/SOURCES
/home/rpm_build_user/rpmbuild/SPECS
/home/rpm_build_user/rpmbuild/SPECS/<software_name>.spec
/home/rpm_build_user/rpmbuild/SRPMS

# build RPM binary package

[rpm_build_user@linux.el5.x86_64-rpm-server ~]$ rpmbuild -bb /home/rpm_build_user/rpmbuild/SPECS/<software_name>.spec --target <noarch|i686|x86_64>
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.27208
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.27208
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.27208
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: <software_name>-<software_version>-<software_release>
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
Wrote: /home/rpm_build_user/rpmbuild/RPMS/noarch/<software_name>-<software_version>-<software_release>.<noarch | i686 | x86_64>.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.88637
+ umask 022
+ cd /home/rpm_build_user/rpmbuild/BUILD
+ exit 0

# query installed rpm package information

[root@linux.el5.x86_64-dev-server ~]# rpm -qi <software_name>
Name        : <software_name>  Relocations: /usr/local
Version     : <software_version>                             Vendor: <vendor_name>
Release     : <software_release>                             Build Date: Sat 28 Jul 2012 03:28:58 PM EDT
Install Date: Sat 28 Jul 2012 03:32:54 PM EDT      Build Host: linux.el5.x86_64-rpm-server
Group       : <Server | Application>                        Source RPM: <software_name>-<software_version>-<software_release>.<noarch | i686 | x86_64>.src.rpm
Size        : 17173222                         License: <Commercial | Free>
Signature   : (none)
URL         : <vendor_url>
Summary     : <software_name>-<software_version>-<software_release>.<noarch | i686 | x86_64>
Description :
This RPM contains <software_name> from <vendor_name>

No comments:

Post a Comment