RPM and YUM

Create User in RPM Package

In building an RPM .spec file, I wanted to create a user during pre-installation. So I had:

%pre
/usr/sbin/useradd -d /home/project/userid userid

This would fail if the directory "/home/project/" doesn't exist. My way to get aound this is to add a mkdir:

%pre
mkdir -p /home/project
/usr/sbin/useradd -d /home/project/userid userid

Newer Software Versions in CentOS

In general, the software version in CentOS are behind. It's just the way CentOS and Red Hat operate. They aim for long term support and stability.

But if you have to use a newer software package, you may find that some newer packages in CentOS's test repository, as listed in this page Available Repositories for CentOS. For CentOS 5 testing packages, you can find them in CentOS Test Repos.

YUM Download Source RPM

How do I yum install SRPM from CentOS/Red Hat site, instead of manually download the srpm from one of the ftp website?

Install yum-utils

# yum install yum-utils

Yum and RPM Tips

Get the dependency

If the package is already installed, use "rpm -qR <package-name>" to get the list of packages that this package depends on. For example:

$ rpm -qR openldap

If the package is not yet installed, use "yum  deplist <package-name>" to get the list of packages that this package depends on. For example:

Signing RPM Packages

The chapter Signing Packages in Maximum RPM explains clearly on how to sign RPM packages.

There are a few things to note though. In the page http://www.rpm.org/max-rpm/s1-rpm-pgp-getting-ready.html, it asked to put the gpg key name name path into rpmrc. This has changed. You have to put the following into ~/.rpmmacros:

Create RPMs

Packages to install before we can create RPM packages:

# yum install rpm-build redhat-rpm-config  

(The package redhat-rpm-config is for rpmbuild build macros and helper scripts needed to build SRPMs targeted on CentOS)

Other packages needed for compiling :

# yum install make gcc

References:

 

Create Local Repository

Prepare GPG key

 

Create the repository

This will show you how to create the repository over http.

First create directory structure on the server, say server1:

[root@server1 ~]# mkdir -p /var/www/repo/CentOS/4/local/i386/RPMS

If createrepo is not already installed, as it will not be by default, install it.