tags:

views:

586

answers:

5

I just want to create an RPM file to distribute my Linux binary "foobar", with only a couple of dependencies. It has a config file, /etc/foobar.conf and should be installed in /usr/bin/foobar.

Unfortunately the documentation for RPM is 27 chapters long and I really don't have a day to sit down and read this, because I am also busy making .deb and EXE installers for other platforms.

Stackoverflow: What is the absolute minimum I have to do to create an RPM? Assume the foobar binary and foobar.conf are in the current working directory.

+2  A: 

RPMs are usually built from source, not the binaries.

You need to write the spec file that covers how to configure and compile your application; also, which files to include in your RPM.

A quick glance at the manual shows that most of what you need is covered in Chapter 8 -- also, as most RPM-based distributions have sources available, there's literally a zillion of examples of different approaches you could look at.

andri
A: 

This can't be the only way? I'm also looking to do exactly this, i've built a completely cross platform app without using a makefile, but it has some system dependencies, surely i must be able to make an RPM or a DEB file that just makes sure the dep's are installed and copies my app to /usr/bin or something i specify?

DavidG
I've done this for .deb and it's dead simple. I can't believe RPM doesn't have a way.
Steve Hanov
omf. making a simple .deb is sooo easy. dpkg -b <directory> ... as long as u have a really simple control file. RPMs need to work like that.
DavidG
A: 

"How to create an RPM package" is a good write-up on RPM's (Fedora docs)

webwesen
+5  A: 

I often do binary rpm per packaging proprietary apps - also moster as websphere - on linux. So my experience could be useful also a you, besides that it would better to do a TRUE RPM if you can. But i digress.

So the a basic step for packaging your (binary) program is as follow - in which i suppose the program is toybinprog with version 1.0, have a conf to be installed in /etc/toybinprog/toybinprog.conf and have a bin to be installed in /usr/bin called tobinprog :

1. create your rpm build env for RPM < 4.6,4.7

mkdir -p ~/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}

cat <<EOF >~/.rpmmacros
%_topdir   %(echo $HOME)/rpmbuild
%_tmppath  %{_topdir}/tmp
EOF

cd ~/rpmbuild

2. create the tarball of your project

mkdir toybinprog-1.0
mkdir -p toybinprog-1.0/usr/bin
mkdir -p toybinprog-1.0/etc/toybinprog
install -m 755 toybinprog toybinprog-1.0/usr/bin
install -m 644 toybinprog.conf toybinprog-1.0/etc/toybinprog/

tar -zcvf toybinprog-1.0.tar.gz toybinprog-1.0/

3. Copy to the sources dir

cp toybinprog-1.0.tar.gz SOURCES/

cat <<EOF > SPECS/toybinprog.spec
    # Don't try fancy stuff like debuginfo, which is useless on binary-only
    # packages. Don't strip binary too
    # Be sure buildpolicy set to do nothing
    %define        __spec_install_post %{nil}
    %define          debug_package %{nil}
    %define        __os_install_post %{_dbpath}/brp-compress

    Summary: A very simple toy bin rpm package
    Name: toybinprog
    Version: 1.0
    Release: 1
    License: GPL+
    Group: Development/Tools
    SOURCE0 : %{name}-%{version}.tar.gz
    URL: http://toybinprog.company.com/

    BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

    %description
    %{summary}

    %prep
    %setup -q

    %build
    # Empty section.

    %install
    rm -rf %{buildroot}
    mkdir -p  %{buildroot}

    # in builddir
    cp -a * %{buildroot}


    %clean
    rm -rf %{buildroot}


    %files
    %defattr(-,root,root,-)
    %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
    %{_bindir}/*

    %changelog
    * Thu Apr 24 2009  Elia Pinto <[email protected]> 1.0-1
    - First Build


    EOF

4. build the source and the binary rpm

rpmbuild -ba SPECS/toybinprog.spec

And that's all.

Hope this help

devzero2000
A: 

You can certainly install pre-compiled binaries in an RPM if you do not want to make the source available, however that is really the only reason you wouldn't want to build the source via the RPM spec. Commercial companies do it all the time.

I wrote up what I think is a pretty good article on RPM packaging here:

derks