Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

/root/dir/rfg.sh
/root/dir/ener.pl
/root/dir/wnr.sh

And some lib files are under /lib as the following

/lib/lib1.so    
/lib/lib2.so
/lib/lib3.so

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

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:

#!/bin/bash

set -e

SPECFILE=$1
shift
SOURCEDIR=$1

BASEDIR=/usr/src/rpm/BUILD
[ -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 }')
BUILDROOT=${BASEDIR}/${BASENAME}-${VERSION}-${RELEASE}

rm -rf ${BUILDROOT}
cp -r ${SOURCEDIR} ${BUILDROOT}

export SOURCEDIR 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

 
discard

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.