How to use Synaptic to install RPM packages stored on your hard disk

publicado 30/05/2005, Última modificación 26/06/2013

Hi, everyone! Turns out the best available frontend to install RPMs in Fedora Core and RPM-based distributions, hands down, is Synaptic. Being apt-based, it has amazing dependency resolution capabilities, performs painless installation of RPMs, has a very nice and searchable package listing, and can fetch packages from the Internet and check for newly created packages really fast.

But often, the packages you want to install are on your hard disk, and installing them manually can be a time-consuming and daunting task. Here's how to make this task easier. This recipe requires that you have access to the root account on your computer, the apt package previously installed (including genpkglist) and Synaptic.

Building a listing for Synaptic

First, make yourself root. Then create a file named aptrepo in your /etc/cron.daily directory. In this file, put the following code:

#!/bin/bash

SWFOLDER="/path/to/where/I/have/my/RPMS"
APTBASE="$SWFOLDER"/apt
TARGET="$APTBASE/RPMS".local

rm -rf "$TARGET"
mkdir -p "$TARGET"
mkdir -p "$APTBASE"/base
find "$SWFOLDER" -name '*rpm' -a -type f -a -not -path "$TARGET" -print0\
 | xargs -0 -n 1 -i ln -s --backup t {} "$TARGET"
genpkglist "$APTBASE" local

(Due to some obscure bug in this Weblog, I need to ask you: please disregard all backslashes that appear before each double quote.) Adjust SWFOLDER to point to your software folder. Then make the script executable, and test-run it. If everything goes well, there simply should be no output (silence is king!).

Telling APT to use the list

Now for the apt configuration, create /etc/apt/sources.list.d/local.list with the following contents:

rpm file:///path/to/where/I/have/my/RPMS apt local

And now you're ready to start Synaptic or run apt-get from your terminal window. Make sure you update the listings (with apt-get update or the Update button in Synaptic), and voilà, you'll have your packages available on a nice, searchable, accessible list! Furthermore, every morning at around four o'clock, the listing will be refreshed. You can refresh the list manually whenever you feel like by running the aptrepo command by yourself.

How does this stuff work?

Simple: find creates a cache (composed of links to files) from all of your RPMs. Then, genpkglist builds a listing for apt-get and Synaptic to use. Every night, this cache is regenerated.

Caveat: you might want to beware: RPM seems to have problems to install packages stored in folders with spaces on their names. I will heartily recommend, then, that the path to your software folder do not contain spaces at all.