First ever rpm, how are files extracted from the rpm and where do they go?

Ignacio Valdes ivaldes at
Wed Feb 11 15:41:41 UTC 2009

I understand all of the build and stuff, it just does not seem to
apply to what mine is doing. The package I have is not C based at all
and requires a great deal of post processing (300 line shell script)
to install it on the target machine. The difficulty is for example on
the target machine needs to end up in
/opt/myfirstrpm/bin/ and has to be run through sed
first to take into account local parameters. Getting into the rpm is not the issue, getting it out of
myfirst.rpm through sed and into
/opt/myfirstrpm/bin/ is the issue. I understand
that probably the processing needs to go into %post but how is extracted from rpm, and where it goes so that
I may process it with sed first is opaque to me right now.

-- IV

>  Then when you install
> the RPM, it handles that part of opening and positioning the files.

On Wed, Feb 11, 2009 at 2:00 AM, Paul Johnson <pauljohn32 at> wrote:
> On Tue, Feb 10, 2009 at 11:01 PM, Ignacio Valdes <ivaldes at> wrote:
>> Hi all,
>> I have a package that I've built the rpm for that doesn't install.
>> Let's call it myfirst.rpm. It consists of 3 tar.gz files, 2 doc files,
>> and some shell scripts. The files are listed in %files and the package
>> builds into a rpm that is consistent with the files being in the rpm.
>> The desired behavior for the rpm is that rpm -i myfirst rpm results in
>> the 3 tar.gz files, 2 doc files and some shell scripts are unpacked
>> from the rpm and then the %post script goes to work on them to process
>> and move them to their ultimate locations in /opt.
>> I have the script that does the installation in %post but it is
>> unclear to me how to unpack the files in the rpm package so tha tthe
>> %post script can work on them. How does one do this and where do they
>> go when they are unpacked. For instance, if I have myfirst.rpm in
>> /root, and I do a rpm -i myfirst.rpm how does one direct the files in
>> %files to come out of the rpm and on that first unpack from the rpm,
>> where does rpm put them?
>> I've read multiple fine manuals but it is unclear how to get rpm to
>> extract the files and the location that the %post operates on those
>> extracted files.
>> -- IV
> You are going at this wrong-headedly.  You do the work of installing
> the files and then the rpm build process packages them for you. You do
> not do builds in the post phase of the spec file.
> Take any RPM from your distro and look in there "rpm -qilp
> whatever.rpm" you'll see the list of files to be installed there.  Not
> generally tar.gz files.
> I recall learning how to do this from the Maximum RPM book, but if you
> just download a few SRPM files from a distribution, install them, and
> then experiment with building them, then you will see what's going on.
>  At least you should look at some spec files.  They have "parts" where
> the code is untarred, configured, made, installed, and packaged. The
> setup and configure put stuff in to a build directory, and then when
> you do the install part, the files are moved to a "target" location
> (the "buildroot") where they sit until the "files" option in the spec
> file is processed and the rpm itself is built.   Then when you install
> the RPM, it handles that part of opening and positioning the files.
> In case you have something as simple as just copying some files out of
> a tarball, you can just use a cp command in the install section of the
> spec file. I'm looking around for the simplest possible example of a
> spec file, here's an old one from a file manager called "xfe".  The
> makeinstall part puts files in the buildroot, and then the rpm
> includes those files when it is done.
> Name:           xfe
> Version:        0.66
> Summary: X File Explorer (Xfe) is a filemanager for X.
> Release: 1fdr1
> License: GPL
> Group: File tools
> Requires: fox >= 1.0 libpng >= 1.0
> BuildRequires: fox-devel >= 1.0 libpng-devel >= 1.0
> Source: %{name}-%{version}.tar.gz
> Packager: Roland Baudin <roland65 at>
> BuildRoot: %{_tmppath}/%{name}-buildroot
> %description
> X File Explorer (Xfe) is a filemanager for X. It is based on the
> popular X Win Commander, which is
> discontinued. Xfe is desktop independent and is written with the C++
> Fox Toolkit. It has Windows Commander
> or MS-Explorer look and is very fast and simple. The main features
> are: file associations,
> mount/umount devices, directory tree for quick cd, change file attributes, auto
> save registry, compressed archives view/creation/extraction and much more.
> %prep
> %setup -q
> %build
> %configure --with-included-gettext --with-static=no
> make
> %install
> rm -rf %{buildroot}
> %makeinstall
> if [ -f %{buildroot}%{_datadir}/locale/locale.alias ]; then
>        rm %{buildroot}%{_datadir}/locale/locale.alias
> fi
> %clean
> rm -rf %{buildroot}
> %files
> %defattr(-,root,root)
> %{_bindir}/*
> %{_libdir}/foxicons
> %{_libdir}/foxrc
> %{_datadir}/pixmaps/*
> %{_datadir}/locale/*/LC_MESSAGES/
> %{_mandir}/man1/*
> --
> Paul E. Johnson
> Professor, Political Science
> 1541 Lilac Lane, Room 504
> University of Kansas
> _______________________________________________
> Rpm-list mailing list
> Rpm-list at

More information about the Rpm-list mailing list