The shortest method to getting started :-
Code:
$ sudo yum install rpm-build rpmdevtools rpmlint
...
$ rpmdev-setuptree
This will create the directory ~/rpmbuild with several subdirs:
- SPECS ( spec files go here )
- SOURCES ( tar.gz etc go here )
- BUILD ( temp dir for unpacking/patching sources )
- RPMS ( finished packages will be under here in arch specific subdirs )
- SRPMS ( if you opt to build src.rpm's they will be under here )
The rpmdevtools package provides several spec file templates:
/etc/rpmdevtools/spectemplate-R.spec
/etc/rpmdevtools/spectemplate-dummy.spec
/etc/rpmdevtools/spectemplate-lib.spec
/etc/rpmdevtools/spectemplate-minimal.spec
/etc/rpmdevtools/spectemplate-ocaml.spec
/etc/rpmdevtools/spectemplate-perl.spec
/etc/rpmdevtools/spectemplate-php-pear.spec
/etc/rpmdevtools/spectemplate-python.spec
/etc/rpmdevtools/spectemplate-ruby.spec
The minimal template is ideal for generating an rpm from a 'configure/make/make install' type tarball, on Fedora this is the default.
Code:
cd ~/rpmbuild
cp /path/to/myapp-1.0.0.tar.gz SOURCES/
vi SPECS/myapp.spec
.. should open a new file based on the minimal template. Simply supply the missing details.
Name, Version and Summary - pretty straight forward
Group - find a matching category in /usr/share/doc/rpm-xxx/GROUPS
License, URL - pretty straight forward
Source0 - I usually use %{name}-%{version}.tar.gz, make sure that myapp-1.0.0.tar.gz is named accordingly
BuildRequires - what the package needs to compile, comma separated ( gcc, make, ... )
Requires - what the package depends on to function, comma separated
Description - pretty straight forward
skip down to the %files section, you will need to add all the files that the package will provide, you can specify a directory to include all files under it
eg.
Code:
%files
%defattr(-,root,root,-)
/opt/myapp
/etc/rc.d/init.d/myapp
The %defattr macro determines the default permissions and ownership for all files. When building an rpm where the source has a makefile, the file permissions are most likely already correct. If you need to override them just modify like so:
Code:
%files
%defattr(-,root,root,-)
/opt/myapp
%attr(755,root,root) /etc/rc.d/init.d/myapp
The %doc directive works well when your source has documentation in it's root dir, it will place the files under /usr/share/doc/myapp-1.0.0/.
eg.
Code:
%doc CHANGES
%doc INSTALL
Add an entry to the %changelog section like so: (taken from initscripts.spec)
Code:
* Fri Feb 07 1997 Erik Troan <ewt@redhat.com>
- Added usernetctl wrapper for user mode ifup and ifdown's and man page
- Rewrote ppp and slip kill and retry code
- Added doexec and man page
Save your spec file and exit vi.
First build attempt:
Code:
rpmbuild -ba SPECS/myapp.spec
If all goes well, it should tell you that it has written 2 files, a src.rpm and an .rpm
You can run 'rpmbuild -b?' to only perform specific sections ( helps when troubleshooting), please see the man page.
Once you have a successful build try running rpmlint:
Code:
rpmlint SPECS/myapp.spec
Take the output with a grain of salt, but sometimes it helps.
If you're having trouble it can also help to download someone else's src.rpm, install it and take a look at their spec file
Hope this helps, my fingers are worn out
cheers