Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I create some scripts under my Linux machine RedHat-Linux-OS-5.3

the following scripts home directory is /root/dir

And the scripts are:


And some lib files are under /lib as the following


my question I want to create RPM that include my scripts and my lib files !

For example

After I performed (rpm installation) :

rpm -i SOME_RPM.rpm

All scripts will be created under /root/dir directory (include directory creation)

And all my lib files will created under /lib directory

Please advice how to create this RPM hopefully it will be step by step (because I read some documents regarding RPM Build package, and it’s hard to understand them

share|improve this question

The most basic bit is that you need the rpmbuild tool and you need to write a spec file. I have the following script that takes a spec file and a tree as it would look installed on the target machine:


set -e


[ -e ${BASEDIR} ] || BASEDIR=/usr/src/redhat/BUILD

BASENAME=$(grep -E '^Name:' $SPECFILE | awk '{ print $2 }')
VERSION=$(grep -E '^Version:' $SPECFILE | awk '{ print $2 }')
RELEASE=$(grep -E '^Release:' $SPECFILE | awk '{ print $2 }')

rm -rf ${BUILDROOT}


rpmbuild --buildroot=${BUILDROOT} -bb $SPECFILE

For details on spec files, see RPM spec specification.

share|improve this answer
how to build the spec file regarding my example – yael Apr 9 '11 at 23:01
what you mean about rpmbuild tool ? – yael Apr 9 '11 at 23:14
Google will happily answer both those queries, I'm sure. For writing RPM specs particularly, you need a lot more information than can be readily supplied in a stackexchange post. – Bittrance Apr 11 '11 at 12:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.