Here is a memo about RPM building in Linux environment.
First is necessary an RPM-based distribution. The most famous are Fedora and CentOS.

Let’s suppose you want to build your RPMs in the folder $RPMREPO.
You need first the correct folder tree for package creation.
mkdir $RPMREPO
cp -r /usr/src/redhat/* $RPMREPO

Then what is necessary is a spec file (Ex: spec_file.spec). It contains all the directives necessary to create the package.
You may find examples of spec files in RedHat SVN repositories like the one of PostgreSQL 9.0 package.
With a spec file, you may need a PAM file (Ex: file.pam), containing data like:
#%PAM-1.0
auth include password-auth
account include password-auth

Don’t forget that you also need a tarball (Ex: foo.tar.gz) or something equivalent containing the code.
Then copy the PAM file and the tarball inside $RPMREPO/SOURCES.
cp file.pam foo.tar.gz $RPMREPO/SOURCES
Copy the spec file to the correct folder.
cp spec_file.spec $RPMREPO/SPECS

Before building an RPM, it is necessary to set a file called .rpmmacros located in $HOME directory.
echo "%_topdir $RPMREPO" > $HOME/.rpmmacros

Then you can create the RPM with this command, assuming spec, pam and tarball files are correct.
rpmbuild -ba spec_file.spec

If no error occurred, SRPM file is located in $RPMREPO/SRPMS, RPM packages are located in $RPMREPO/RPMS/x86_64.

Here are some additional useful commands.
You can also build a RPM package from a SRPM file.
rpmbuild --rebuild $SRPM_FILE

Check content of an RPM file.
rpm -qpl $RPM_FILE

Export files of an RPM package.
rpm2cpio $RPM_FILE | cpio -idv

Sometimes you have to face some formats that are not installed by default in Ubuntu environments.
And it may be a problem if you cannot extract such archives.

Fortunately, there are some free applications provided with your distribution.
If you are not using Ubuntu, you can find debian or rpm packages easily.
In order to do that, there is this useful RPM package searcher
or this Debian package searcher.

For Ubuntu, which is well… Debian based… (But it uses an APT system to manage its distribution packages)
Here is how to install those packages with commands (geek-mode).
To install rar format manager:
sudo apt-get install unrar-free
To install 7z format manager:
sudo apt-get install p7zip

Or for beginners you can find the packages in the software package center.
For that you have just to make a research with p7zip and unrar-free for each application in the Ubuntu Software Center in the Application tab of your menu bar.

To decompress a file with p7zip, you have to do the following command:
7z x $FILE_NAME
$FILE_NAME being the name of your 7z file.

To decompress a file with unrar-free, you have to do the following command:
unrar-free x $FILE_NAME
$FILE_NAME being the name of your rar file.

©2010-2013 Michael Paquier All content is ©Copyright of Otacoo.com 2010-2013. Privacy Policy - Terms of Use