Repository management with zypper in Opensuse 11.1

suse.png

A quick how to for using zypper to manage repositories in Opensuse.

You can specify existing repositories by their number in the list produced by zypper lr, alias, or URI. When using the numbers, make sure you always check zypper lr first, as the numbers may change after you made some changes to the repositories.

Listing Defined Repositories

repos or lr

Example output:

$ zypper lr
# | Alias                 | Name                  | Enabled | Refresh
--+-----------------------+-----------------------+---------+--------
1 | packman               | Packman 11.1          | Yes     | No
2 | fate                  | fate                  | No      | No
3 | openSUSE-11.1-Updates | Updates for 11.1      | Yes     | Yes
4 | repo-oss              | openSUSE-11.1-Oss     | Yes     | No
5 | repo-non-oss          | openSUSE-11.1-Non-Oss | Yes     | No
6 | repo-debug            | openSUSE-11.1-Debug   | No      | No

Other examples:

zypper lr -u       # to include also repo URI in the table
zypper lr -d       # to include several other repo properties in the table
zypper lr -P       # to include also repo priority and sort the list by it
zypper lr -e my    # export all repository definitions into file named 'my.repo'

Adding Repositories

addrepo or ar

Before any packages can be installed at least one repository must be defined. To add a repository, use the addrepo command:

Example output:

$ zypper ar http://download.videolan.org/pub/vlc/SuSE/11.1 vlc
Adding repository 'vlc' [done]
Repository 'vlc' successfully added
Enabled: Yes
Autorefresh: No
URI: http://download.videolan.org/pub/vlc/SuSE/11.1

Other examples:

zypper ar http://download.opensuse.org/repositories/X11:/XGL/openSUSE_11.1/X11:XGL.repo  # via .repo file
zypper ar -c ftp://some.download.site myalias   # probe the repository upon adding
zypper ar my/dir/with/rpms local                # add your local directory with rpm files as repository

See also Libzypp/URI for the list of supported media types and URIs.

Refreshing Repositories

refresh or ref

After adding of a repository or when a repository becomes out of date, it needs to be refreshed. This mean downloading package metadata from it and preprocessing the data into .solv cache for quick reading.

$ zypper refresh
Downloading repository 'Packman 11.1' metadata [done]
Building repository 'Packman 11.1' cache [done]
Downloading repository 'Updates for 11.1' metadata [done]
Building repository 'Updates for 11.1' cache [done]
Repository 'openSUSE-11.1-Oss' is up to date.
All repositories have been refreshed.

If autorefresh is enabled for a repository, you don’t need to worry about refreshing, it happens automatically when needed. However, some people prefer to be in control when the refresh takes place (e.g. to avoid waiting for the refresh to complete when you only wanted to see ‘zypper info krusader’), so they disable autorefresh. See man zypper for more details.

Other examples:

zypper ref packman main  # you can also specify which repositories to refresh
zypper ref -f upd        # force refresh of the 'upd' repository

Removing Repositories

removerepo or rr

$ zypper rr vlc 1 23 foo
Repository 23 not found by alias, number or URI.
Repository foo not found by alias, number or URI.
Removing repository 'repo-debug' [done]
Repository 'repo-debug' has been removed.
Removing repository 'vlc' [done]
Repository 'vlc' has been removed.

Modifying Repositories

modifyrepo or mr

Disable repository #6:

$ zypper mr -d 6
Repository 'repo-non-oss' has been sucessfully disabled.

Enable autorefresh and rpm files caching for ‘packman’ repository and set its priority to 70:

$ zypper mr -rk -p 70 packman
Autorefresh has been enabled for repository 'packman'.
RPM files caching has been enabled for repository 'packman'.
Repository 'packman' priority has been set to 70.

Disable RPM files caching for all repositories:

$ zypper mr -Ka
Nothing to change for repository 'local'.
RPM files caching has been disabled for repository 'packman'.
Nothing to change for repository 'fate'.
Nothing to change for repository 'upd'.
Nothing to change for repository 'repo-oss'.
Nothing to change for repository 'repo-non-oss'.

Enable RPM files caching for all repositories:

$ zypper mr -ka
RPM files caching has been enabled for repository 'repo-non-oss'.
RPM files caching has been enabled for repository 'Main Repository (OSS)'.
RPM files caching has been enabled for repository 'Main Repository (NON-OSS)'.
RPM files caching has been enabled for repository 'openSUSE-11.1-Updates'.

Renaming Repositories

renamerepo or nr

$ zypper nr 3 upd
Repository 'openSUSE-11.1-Updates' renamed to 'upd'.

This command is currently only able to change the alias of the repository. If you wish to change the displayed name of the repository, take a look at the mr command.

Keep the aliases short and simple for an easy use as arguments of commands and –repo options. Using an alias is safer than using repo number (since that may change and you can easily make a mistake) and easier than using URI (since they are long, leaving you with copy-and-paste).

Export/Import Repositories

repos –export or lr -e

You can export your complete repository list to a file and import it later or on another machine.

zypper lr --export backups/repos/foo.repo
zypper ar backups/repos/foo.repo

Related Posts

Comments are closed.