RPM packages are a great way of packaging and distributing software, unfortunately some stand alone software is distributed as a zip or tar file to be installed that way. By converting these into an RPM you can use your package manager as a distribution and removal tool. For this example we will be creating an RPM for the Example Software.
- The first thing to do is install the RPM development tools, you should only require rpmbuild.
- Create a folder to be used as a RPM development area and then create a file called .rpmmacros in your home folder that contains the following line: %_topdir <your build folder>
- Set up your RPM build area by creating the following folders – BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
- Get a copy of your tar.gz or zipped software and place it in the SOURCES directory.
- Now the key part of this is to create the .spec file as this describes the build and installation part of the RPM.
- Create a new file in the SPECS folder called example.spec, fill it out with the following information –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
%define _prefix /usr/bin/example # Your desired installation folder for the software Name: example Version: 1.0 Release: 1%{?dist} Summary: Example software for creating examples Group: Applications/System URL: http://www.example.com BuildRoot: %{_tmppath}/%{name} BuildArch: x86_64 License: Redistributable, no modification permitted Source: http://example.com/example-1.tar.gz # The web location for the source file, not required but the Name and Version values must match the file name. %description %prep %setup -q %build %install install -d %{buildroot}%{_prefix} # Create a directory for installation tar cf - . | (cd %{buildroot}%{_prefix}; tar xfp -) # rpmbuild will extract the tar.gz file, we must then copy the files to our build area and preserve file structure. %clean rm -rf %{buildroot}%{_prefix} %files %defattr(-,user,usergroup,-) # Modify for your requirements %dir %{_prefix} %{_prefix}/* %doc %changelog |
- After your spec file is created run rpmbuild -bb ./SPECS/example.spec – fix any errors that are produced, most likely problems will come from getting the correct version/name and target architecture.
- Find your completed RPM in ./RPMS/<ARCH>
Done!
Questions? Comments?