Monday, June 14, 2010

How to build RPMs from source SRPMS

Following are the steps for root installation.

Pre-requisite :

Following are the package to be installed which provides the build enviroment and create neccessary directory.

rpm-buld
rpm-devel

Step 1. rpm -ivh package.src.rpm

Step 2. cd /usr/src/redhat/SPECS

Step 3. rpmbuild -bb filename.spec [ --bb - only rpm ]
[ --ba - create rpm and source rpm]

Above command will compile the source code and generate the rpm in the following directory.

/usr/src/redhat/RPMS/i386

For non-root users , the following are the steps to be followed to build RPM

-----------------------------------------------------------------------------


1. Create the following directory hierarchy under your home directory

rpm
|-- BUILD
|-- RPMS
| `-- i386
|-- SOURCES
|-- SPECS
`-- SRP

2. Set the environment variable

echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros

which tells the rpm manager that user wants the above location to build RPM

Then follow the steps1, 2 and 3 in root-installation.

Tuesday, June 8, 2010

Linux Commands

-->
chown:

Regular users cannot change the ownership of a file, root can only do that. Group can be changed by regular user to the group which the users belongs to.

Example : chown filename

To allow non-root users to change the owner of a file, change the suid of the chown command as given below

chmod u+s chown

Editing a file inline
--------------------------

sed -i 's/suman/siddhanth/g' testfile

perl -i.bak -pe 's/suman/siddhanth/g' testfile