Adding a helper file to an RPM

Posted on 2004-11-29
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
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/ /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
    LVL 1

    Expert Comment

    Is 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

    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 ;)
    LVL 5

    Author Comment

    As I said in my question, if I include as a Source statement in the SPEC file, it tries to untar it, so it fails with an error.
    LVL 1

    Accepted Solution

    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  It's old, but very good for the basics.  The particular secion of the book in question is

    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 and other third party apt repository maintainers.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Among others, I monitor the Windows Installer zone and Installer zone. I find that many of the questions could be answered much more quickly if a Windows Installer verbose log were submitted with the question.   However, I do not always have t…
    I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension ( This reminded me of questions tha…
    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.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now