Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Adding a helper file to an RPM

Posted on 2004-11-29
Medium Priority
Last Modified: 2013-11-13
Hi all,

I am trying to create an RPM for the Emulex 2.01g drivers for our kernel. The base RPM works fine, but I am now trying to include a helper script in the RPM. This script lives outside the driver source, as I wan't to preserve the emulex tarball.

I tried including
Source: updateinitrd.sh
in my spec file, but it died because it tries to unpack all source files during the RPM creation.

I then tried just adding the file where I do the other installs, but instead of doing
install -m $RPM_BUILD_ROOT/blah
I did
install -m /usr/src/redhat/SOURCES/updateinitrd.sh /usr/local/bin

This works fine, and the file then appears in my binary RPM and is installed at installation time.

The problem I have is that the file is _NOT_ included in the resulting source RPM, so rebuilding the source RPM means finding this file and manually copying it into place.

Can anyone advise a solution for this ?
Question by:Anonymouslemming
  • 2

Expert Comment

ID: 12702698
Is updateinitrd.sh listed as one of the sources in the .spec header as well as located in the SOURCES directory from out of which you are working?

For instance:

Source0: <baseurl>/%{name}-%{version}.tar.gz
Source1: updateinitrd.sh

Later down in %install you should have something like this

install -m %{SOURCE1} /usr/local/bin

Now, when you build the sources it should get included inside the srpm as well.  At least that's the theory.  It's been a while since I did something like that ;)

Author Comment

ID: 12704461
As I said in my question, if I include updateinitrd.sh as a Source statement in the SPEC file, it tries to untar it, so it fails with an error.

Accepted Solution

tykeal earned 2000 total points
ID: 12707781
Ahh... sorry missed that part.

I take it your doing a fairly by the book %prep section?

You can do something along the following instead for your %prep

%setup -T -b 0

If you don't specify a -T to the %setup macro it tries to unpack _all_ sources.  The -b <n> then specifies a particular source to unpack.  If you've multiple sources in there that you need to unpack you can either spell each one out on it's own line, or do a basic bash loop inside the spec file as it's just a bash script anyway ;)

Also, you might want to look through http://www.rpm.org/max-rpm/.  It's old, but very good for the basics.  The particular secion of the book in question is http://www.rpm.org/max-rpm/s1-rpm-inside-macros.html

The other thing you might want to do is look through spec files that others have done.  Whenever I'm trying to do something new for me with RPM I tend to look through the spec files for rpms hosted by www.freshrpms.net and other third party apt repository maintainers.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question