<<

Packaging system

RPM vs Seth Kenlon

ince most of the used on happens to come along with the sys- a GNU Linux system is free to use, tem they install. Sshare, and modify, it was common when Linux was first being developed to RPM install software straight from raw source In addition to and many others, Fe- code. As Linux became more popular with dora and openSUSE all use RPM for applica- people not interested in the finer points tion installation. Getting an RPM is typically of building applications with Makefiles done in two different ways; from the distribu- and , a packaging system was tion’s online RPM servers (“repositories”) or created by , known as RPM from third-party sites. (“RPM ”). It provided a The first option is the most secure, way for users to quickly install applica- since Linux distributions typically check tions with pre-built packages from distributors like Red Hat. The developers of the distribution also developed a pack- aging system, called APT (“Ad- vanced Packaging Tool”), that would not only install an application but would also install all of the support libraries and smaller programs that the application replies on in order to run. Since APT was developed, the same improvements have been in- corporated into RPM (actually, into its user-friendly frontend, (“Yel- low Dog Updater, Modified”). Even though both methods of in- stalling applications have the same purpose, they are both in wide use. Since the tools are intricately woven into the way a is built and functions, a user generally uses whatever manager Figure 1. Adding new applications to a Linux desktop is easy www.linuxidentity.com/us/ 13 Packaging system

If your distribution does not offer an RPM for an application that you need, you can still check trusted re- positories, such as rpmfusion.org or ccrma.stanford.edu/planetccrma/ software/ for Fedora, or packman. links2linux.org for openSUSE. These repositories have a history with the community and are well-respected, trusted, and reliable. Many people would never think of running their distribution without a few extra un- official repositories, and few would feel safe going out onto the Internet to unknown sites and allowing those sites to install software on their computers. Building an RPM RPMs, having been around for so Figure 2. Adding the rpmfusion.org repository for even more apps on Fe- long and being the choice of one dora 15 of the most popular Linux distribu- tions, are ubiquitous online. Some their RPM files carefully. It is also which you can pick and choose ap- software projects, when packaging the easier option to support, since pealing applications to install on their software, do not provide an the major Linux distributions are your Linux computer. Each RPM RPM but do include a .spec in well-known for updating applica- contains a “spec” file, detailing the . With this .spec file, tions on a regular basis, whereas what version of the application you can actually construct your own RPMs installed from random third it will install and also what other personal RPM with only a few com- parties don’t necessarily come with smaller applications will need to mands in a terminal. any guarantee of a reasonable, be installed in order for it to func- First, of course, you’d need to much less timely, upgrade path. tion. Of course, you won’t have to download the source code (that is, The easiest way to access a worry about any of these details; the actual raw code that makes up distibution’s RPM repository is Package Kit or YaST will resolve the application, and not an through either Package Kit in Fedo- the dependencies by installing the file). These usually come in the for ra or YaST in openSUSE. These are necessary programs, and then the of a ..gz or .tar.bz2 archive, or both, essentially, app stores from application itself. sometimes a . archive. Then you should set your system up for building RPM packages by in- stalling the necessary tools:

$ su # yum groupinstall ↵ “Development Tools” # yum install rpmdevtools

This installs the necessary software to compile the code you’ve down- loaded into a running application, and the tools necessary to construct an RPM installer file. Now you can create a clean environment in which to build the RPM:

$ cd ~ && $ rpmdev-setuptree

This will create a new folder in Figure 3. When all else fails, you can build your own installer packages your user directory, called rpm-

14 Linux Identity Pack Packaging system

build, with folders inside of that called BUILD, , RPMS, SOURCES, SPECS, and SRPMS. Happily, you don’t actually need to know what any of that means in order to use it. Next, you must unzip or untar the source code directory; keep in mind that not all source code will include a .spec file, but we’ll assume for this article that the software (let’s call it “foo”, like the gurus do) in our example does.

$ tar -xf foo-0.1.tar.gz && cd ↵ foo-0.1 $ cp foobar-0.1.spec ~/ ↵ rpmbuild/SPECS $ mv ../foobar-0.1.tar.bz2 ~/ ↵ rpmbuild/SOURCES Figure 4. Using the One software store to install .deb packages This places all the code in the proper location, so now all you using Debian, or the If you can’t find an application need to do is run the RPM build Software Store on Ubuntu. Find an that suits your needs in the distribu- commands: application that you want to install, tion’s repositories, then of course and click the install button. This au- there are trusted third-party reposi- $ cd ./rpmbuild/SPECS tomatically downloads the .deb file, tories just as on Fedora and open- $ rpmbuild -ba foobar- 0.1.spec processes it in order to install de- SUSE. Ubuntu has its “multiverse” pendent support libraries, and then repositories as well as PPA reposi- You’ll get to watch some code scroll installs the application itself. You’ll tories, which are run and managed by your screen as the raw data is find the launcher for that application by individuals in the community. converted into an executable appli- in the Application in GNOME, Debian has a number of reposito- cation. Once that’s finished, you’re the Mint menu on , the ries, one of the most common being free to install the RPM onto your Application screen on Ubuntu. debian-multimedia.org for multime- system.

$ cd ../RPMS/$(uname -m) $ su # yum localinstall foobar-0 ↵ .1.$(uname -m).rpm DEB The .deb is used by most if not all Debian deriva- tive distributions, usually with the installation itself occurring through APT. The DEB format is dependent upon a “control file” which is much like the .spec file of an RPM pack- age, as it defines what software is required in order for your target ap- plication to run, provides a descrip- tion of what you are about to install, and so on. Installing a .deb is the same, basically, as an RPM file. Launch your package manager, which may be the frontend if you are Figure 5. Using Debian to install .deb files www.linuxidentity.com/us/ 15 Packaging system

dia codecs and kg-..debian. sudo -i ./foo-0.1.rpm And for a .deb: org for KDE’s desktop environment. Converting RPM to DEB Downloading RPM and DEB to RPM sudo ‘dpkg -i ./foo-0.1.deb’ and DEB Files In the event that an application The only caveat here are the de- Downloading a .deb or .rpm file you feel you must have is avail- pendencies. Sometimes, because outside of trusted repositories is, able in only one format and that the installer package was really of course, not necessarily recom- one format is not the one you intended for, say, Ubuntu, but mended, but there are times when it need, then you can try to convert you wish to install it on Fedora, is something you will want to do. For between the two package formats the conversion will work but the instance, you might find that your fa- with a command line tool called package’s effort to ensure that vorite application has just released “”. your system has all the required a new version with exciting new fea- Alien is a very simple tool to use, software will fail. To avoid this, tures that you need to have. Rather and the process is the same as in- you can look at what the system than waiting for your repository to stalling a package from the com- requirements are and manually in- get that version of the application, mand line, with one extra step. stall the dependencies from your you might go to the application’s site First, download the package you repository, and then install the and download the .deb or .rpm that wish to install. Now you have the converted package. they themselves have released. package on your desktop or in your The end result is that you have a Downloads folder, so you need to RPM vs DEB .deb or .rpm file sitting on your desk- convert it to a format that your dis- While some people will tell you top or in your Downloads folder; how tribution will understand. that rpm-based distributions are do you install it? If it is currently a .deb file and difficult to use, or that deb-based Happily, with either an .rpm or you wish to have an .rpm: distributions are too confusing, .deb file, you can simply double- and so on, the truth of the matter click on the file and the operating alien -r foo-0.1.deb is that there really is no difference. system will offer to install it via your The two formats do the same usual package manager. If this does If it is currently a .rpm file and you thing: ensure that an application not happen, then you can also do it wish to have a .deb: that you wish to install will run on from the command line. your computer, and then install the For an .rpm file: alien -d foo-0.1.rpm application. The applications that you use su -c ‘rpm -i ./foo-0.1.rpm’ And then install as normal; for an to install the packages may differ .rpm: a little; yum checks for updates And for a .deb file, you can use this unless you tell it not to, while ap- command: su -c ‘rpm -i ./foo-0.1.rpm’ titude requires a manual update of its cache, and so on, but in the end it all works toward the same goal. There are other methods of in- stalling software; some prefer com- piling from source code, others use scripting tools like SlackBuilds, and still others use new paradigms altogether. The important thing is that you find applications from trusted sources, and use common sense when installing from un- known sites. Properly managed, your Linux computer will remain a secure, finely-tuned , with the ability to install and unin- stall with far greater efficiency and precision than you previous operating systems ever did, so en- joy your rpm, or your deb, or raw Figure 6. Many applications have both RPM and DEB packages available code. from their homepage

16 Linux Identity Pack