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

1 Answer 1


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.

  • how to build the spec file regarding my example
    – yael
    Apr 9, 2011 at 23:01
  • what you mean about rpmbuild tool ?
    – yael
    Apr 9, 2011 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, 2011 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .