You'll need the following components to build an RPM package: A workstation or a virtual machine running an RPM-based distribution, such RHEL or Fedora. Software to build the package. Source code to package.
Building the rpm I find it easiest to create a link to the actual spec file in that directory so that it can be edited in the development directory and there is no need to copy it to the SPECS directory. Make the SPECS directory your pwd, then create the link. Run the following command to build the rpm.
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 :
mkdir -p ~/rpmbuild/{RPMS,SRPMS,BUILD,SOURCES,SPECS,tmp}
cat <<EOF >~/.rpmmacros
%_topdir %(echo $HOME)/rpmbuild
%_tmppath %{_topdir}/tmp
EOF
cd ~/rpmbuild
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/
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
rpmbuild -ba SPECS/toybinprog.spec
And that's all.
Hope this help
As an application distributor, fpm sounds perfect for your needs. There is an example here which shows how to package an app from source. FPM can produce both deb files and RPM files.
https://github.com/genereese/togo-rpm
The project has a Quick-Start guide and I was able to create a basic RPM in less than 3 minutes.
1) Create the project directory using the script:
$ togo project create foobar; cd foobar
2) Make your desired directory structure under ./root and copy your files into it:
$ mkdir -p root/etc; cp /path/to/foobar.conf root/etc/
$ mkdir -p root/usr/bin; cp /path/to/foobar root/usr/bin/
3) Exclude system-owned directories from your RPM's ownership:
$ togo file exclude root/etc root/usr/bin
4) (OPTIONAL) Modify the generated spec to change your package description/dependencies/version/whatever, etc.:
$ vi spec/header
5) Build the RPM:
$ togo build package
-and your RPM is spit out into the ./rpms directory.
Similarly, I needed to create an rpm with just a few files. Since these files were source controlled, and because it seemed silly, I didn't want to go through taring them up just to have rpm untar them. I came up with the following:
Set up your environment:
mkdir -p ~/rpm/{BUILD,RPMS}
echo '%_topdir %(echo "$HOME")/rpm' > ~/.rpmmacros
Create your spec file, foobar.spec, with the following contents:
Summary: Foo to the Bar
Name: foobar
Version: 0.1
Release: 1
Group: Foo/Bar
License: FooBarPL
Source: %{expand:%%(pwd)}
BuildRoot: %{_topdir}/BUILD/%{name}-%{version}-%{release}
%description
%{summary}
%prep
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/bin
mkdir -p $RPM_BUILD_ROOT/etc
cd $RPM_BUILD_ROOT
cp %{SOURCEURL0}/foobar ./usr/bin/
cp %{SOURCEURL0}/foobar.conf ./etc/
%clean
rm -r -f "$RPM_BUILD_ROOT"
%files
%defattr(644,root,root)
%config(noreplace) %{_sysconfdir}/foobar.conf
%defattr(755,root,root)
%{_bindir}/foobar
Build your rpm:
rpmbuild -bb foobar.spec
There's a little hackery there specifying the 'source' as your current directory, but it seemed far more elegant then the alternative, which was to, in my case, write a separate script to create a tarball, etc, etc.
Note: In my particular situation, my files were arranged in folders according to where they needed to go, like this:
./etc/foobar.conf
./usr/bin/foobar
and so the prep section became:
%prep
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
cd $RPM_BUILD_ROOT
tar -cC %{SOURCEURL0} --exclude 'foobar.spec' -f - ./ | tar xf -
Which is a little cleaner.
Also, I happen to be on a RHEL5.6 with rpm versions 4.4.2.3, so your mileage may vary.
Easy way to build rpm package from binary (these steps were tested with Fedora 18):
1) First you have to install rpmdevtools, so run these commands (attention: run as normal user)
$ sudo yum install rpmdevtools rpmlint
$ rpmdev-setuptree
2) In the ~/rpmbuild/SPECS folder create new file: package_name.spec
3) Open it with an editor (like gedit) and write this:
Name: package_name
Version: 1.0
Release: 1
Summary: Short description (first char has to be uppercase)
License: GPL
URL: www. your_website/
BuildRequires: package_required >= (or ==, or <=) 1.0.3 (for example)
%description
Description with almost 79 characters (first char has to be uppercase)
#This is a comment (just as example)
%files
/usr/bin/binary_file.bin
/usr/share/applications/package_name.desktop
/usr/share/pixmaps/package_name.png
%changelog
* date Packager's Name <packager's_email> version-revision
- Summary of changes
#For more details see: docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/Packagers_Guide/sect-Packagers_Guide-Creating_a_Basic_Spec_File.html
4) Make ~/rpmbuild/BUILDROOT/package_name-version-release.i386 and reproduce the paths where the files will be placed So in this case for example create:
5) Put in these folders the files that you want insert in the package:
usr/share/pixmaps/package_name.png is the icon of binary usr/share/applications/package_name.desktop are the rules to insert the program in the menu entries
6) package_name.desktop must be like this:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=example
GenericName=Short description
Comment=Comment of the application
Exec=package_name
Icon=package_name
Terminal=false
Categories=System;
Categories are these: standards.freedesktop.org/menu-spec/latest/apa.html
7) Run $ rpmbuild -bb ~/rpmbuild/SPECS/package_name.spec
8) Your package was built into ~/rpmbuild/RPMS folder
if you install this package it's install:
Thanks to: losurs.org/docs/tips/redhat/binary-rpms
For more details to build rpm take a look at this link.
GUI java software to build rpm: https://sourceforge.net/projects/javarpmbuilder/
If make config
works for your program or you have a shell script which copies your two files to the appropriate place you can use checkinstall. Just go to the directory where your makefile is in and call it with the parameter -R
(for RPM) and optionally with the installation script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With