openSUSE Repository Forwarder

This site (r.opensu.se) provides a simple but potentially useful service by redirecting short URLs to the openSUSE package repositories on download.opensuse.org and Packman, e.g. for using in identi.ca/twitter posts or on IRC instead of (albeit even shorter) generic URL shortening services.

Examples

The URL …   redirects to …
http://r.opensu.se/shells http://download.opensuse.org/repositories/shells
http://r.opensu.se/network:utilities http://download.opensuse.org/repositories/network:/utilities
http://r.opensu.se/devel:tools:scm:svn http://download.opensuse.org/repositories/devel:/tools:/scm:/svn
http://r.opensu.se/packman http://packman.inode.at/packman/suse

openSUSE version subdirectories

All those repository URLs follow the same convention, having subdirectories for individual distribution versions (e.g. openSUSE_11.3, openSUSE_11.2, openSUSE_Factory, etc…).

Those can be referred to using simply the version (11.3 instead of openSUSE_11.3), or using the single letter "f" for openSUSE_Factory:

The URL …   redirects to …
http://r.opensu.se/shells/11.3 http://d….o….o…/r…/shells/openSUSE_11.3
http://r.opensu.se/network:utilities/f http://d….o….o…/r…/network:/utilities/openSUSE_Factory
http://r.opensu.se/packman/11.3 http://packman.inode.at/suse/11.3

Repo files

Another convention is that all those repositories, below the distribution version subdirectory as depicted above, have a .repo file that can be easily used in zypper to add that repository as a package source (using zypper ar -r).

Such URLs to .repo files can be shortened too, simply by appending /repo or /r at the end of the URL:

The URL …   redirects to …
http://r.opensu.se/shells/11.3/r http://d….o….o…/r…/shells/openSUSE_11.3/shells.repo
http://r.opensu.se/network:utilities/f/r http://d….o….o…/r…/network:/utilities/openSUSE_Factory/network:utilities.repo
http://r.opensu.se/packman/11.3/r http://packman.inode.at/suse/11.3/packman.repo

When using zypper

Since openSUSE 11.1, both zypper and YaST use the excellent download application aria2c to download repository metadata and RPM files.

They also send a request header that contains the version of the openSUSE distribution it is running on.

The repository redirector can take advantage of that header, and it does so when the distribution version is not explicitly passed as part of the URL, as shown in the following table.

http://r.opensu.se/network:utilities/11.3/r
explicit indication of the openSUSE version: 11.3, and the request header will not be analyzed
http://r.opensu.se/network:utilities/r
no explicit indication of an openSUSE release: the redirector will attempt to parse the request header sent by zypper and YaST to determine the openSUSE version automatically

Adding a repository

Based on the above, in order to give someone the shortest possible command to add a repository, do as in the examples below:

As an alternative, which might feel a bit more natural to write for some, you may also specify .repo instead of /r or /repo, e.g. like this:

If you are using an alternative downloader (such as curl, e.g. by setting and exporting the environment variable ZYPP_ARIA2C=0, then you must explicitly specify the openSUSE version, as in the following examples because, unfortunately, the curl backend does not send the openSUSE version as a header:

Testing

In order to test or even verify what this redirection service would give you back, e.g. to zypper, you can use the very versatily curl and a HEAD request (you also have to pass the -L command-line option to allow curl to follow HTTP redirects):

To make such tests with automatic distribution detection, you must set the User-Agent HTTP header in curl, because this is what zypper sends, and what is used to automatically determine for which distribution the HTTP request is made:

To see the content of the .repo file, make an actual GET request instead of HEAD by dropping the command-line option -I:

As you may have noted above, you don't need to specify the -L option to see the content of .repo files. This is because the redirector proxies requests for .repo files instead of redirecting, as it is required to work properly with zypper and YaST2. Basically, this means that when a request for a .repo file comes in, the redirector rewrites the request to the upstream URL, makes an HTTP request of its own and serves back the content to your request:

zypper r.opensu.se
zypper ar -r http://r.opensu.se/packman.repo -->
--> GET http://packman.inode.at/suse/11.3/packman.repo
<-- content of the .repo file
<-- content of the .repo file

Source code

The source code is currently in my git repository at gitorious.