Skip to content
Fabio Mucciante edited this page Oct 3, 2022 · 26 revisions

Welcome to the Zypper-Upgraderepo wiki!

Zypper-Upgraderepo is a command line application which detects, and when possible solves, the problems related to the URLs of the configured repositories.

It comes in handy especially during the openSUSE Leap upgrade process, because some URL might slightly change and the only message we get with a standard repository upgrade is an URL not found error.

Besides this main checking feature, for current and next version repositories, it also provides commands to:

  • check the repositories for a whatever version in the list of known versions;
  • backup the whole list of repositories;
  • upgrade the repositories all at once taking in account the URLs to override manually;
  • check for the status of the current distribution.

There are also options for:

  • print only invalid, enabled, or a list of repositories identified by their number;
  • visualize the data as a table (default), a report or an ini file structure;
  • sort the results by repository alias (default), name, priority;
  • run in quiet mode displaying only error messages.

Checking repositories

With a view to distro upgrade, the repository check operation mainly helps to discover which repositories are ready for the upgrade reporting those URLs not working as expected, i.e. Not Found or even Redirected.

Check for the current version

Checking the current repositories can be useful also to detect failures during a normal update process:

$ zypper-upgraderepo --check-current

A table with four columns will show:

  • The status;
  • The repository number;
  • The repository name;
  • Whether enabled or not;
  • A hint explaining, if possible, how to replace the invalid URL.

The status can be reported using one of these symbols:

  • [V]: Everything works as expected;
  • [W]: The URL has been redirected, the printed URL should be replaced with the printed one;
  • [E]: The URL is invalid, the application will try to find an alternative.

When the error can't be fixed either manually or with the help of this script, it's better to disable the repository before the next update starts, or even remove it if totally unneeded.

Check for the next version

Before upgrading the current system we can check the status of the repository's URLs for the next version, which are interpolated simply by replacing the current version of openSUSE Leap with the newer.

$ zypper-upgraderepo --check-next

The table's result will show the same columns seen before.

Check for the last version

Although it's not recommended to upgrade to a not consecutive version, there are situations when is the only thing we can do, for save time or because the other repositories are just missing. With that option we can check directly for the latest stable version:

$ zypper-upgraderepo --check-last

Check for a different version

Last but not least it's possible to check for one of the released versions, not necessarily the next or the last, be careful with this kind of upgrade though.

$ zypper-upgraderepo --check-for 15.0

Override one or more URLs

When the checking procedure fails we can inject the suggested URL or the one discovered by ourself, then repeat the procedure to validate the configuration and finally upgrade them.

There are two ways to override the URLs:

  1. Using the --override-url option;
  2. Exporting the results as an ini file, apply the changes, and reimport it.

Using the --override-url option

To replace the invalid URLs on the fly we can make use of the --override-url option followed by the repository number and the new URL with a comma , separating them:

$ zypper-upgraderepo --check-next --override-url 4,http://domain.org/new-path/version/

Export to the ini file

When the number of faling URLs grows, there is a more comfortable way to override them:

  • export on an ini file the invalid repositories using the --ini option;
    $ zypper-upgraderepo --check-next --only-invalid --only-enabled --ini > ~/output.ini
    
  • edit it and fix the URLs filling the url field;
    $ vi ~/output.ini
    
  • load that file to the next check and upgrade procedure.
    $ zypper-upgraderepo --check-next --load-overrides ~/output.ini
    $ sudo zypper-upgraderepo --upgrade --load-overrides ~/output.ini
    

In the example below we can see an example of the ini output:

[repository_1]
name=Packman_Leap_15.2
alias=Packman_Leap_15.2
url=http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_15.2/
old_url=http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_15.1/
priority=99
enabled=Yes
status=Ok

The most important fields are those labeled as old_url and url, the former is pretty obvious, the second represents the upgraded URL. When the new version repository can't be found, the last key will be left empty and a commented section will suggest what to do.

When URLs aren't found there is no suggested_url field, this happens when a repository, usually those not criticals, hasn't been upgraded, but that doesn't mean that will never be:

[repository_5]
name=Hardware tools (openSUSE_Leap_15.2)
alias=hardware
old_url=http://download.opensuse.org/repositories/hardware/openSUSE_Leap_15.1/
# The interpolated URL is invalid, try overriding with the one suggested
# in the fields below or find it manually starting from the old_url.
# The alternatives are:
# 1. Waiting for a repository upgrade;
# 2. Change the provider for the related installed packages;
# 3. Disable the repository putting the enabled status to 'No'.
#
url=
priority=99
enabled=Yes
status=Not Found
hint=Can't find a valid alternative, try manually!

In the example below the URL to replace has been found and a confirmation is required, manually overriding the url field with the suggested_url makes the job done:

[repository_11]
name=openSUSE_Leap_15.4_Graphics
alias=openSUSE_Leap_15.4_Graphics
old_url=http://download.opensuse.org/repositories/graphics/openSUSE_Leap_15.3/
# The interpolated URL is invalid, try overriding with the one suggested
# in the fields below or find it manually starting from the old_url.
# The alternatives are:
# 1. Waiting for a repository upgrade;
# 2. Change the provider for the related installed packages;
# 3. Disable the repository putting the enabled status to 'No'.
#
url=
priority=99
enabled=Yes
status=Not Found
hint=Override with this one
suggested_url=http://download.opensuse.org/repositories/graphics/15.4/

As you can see the old_url slightly change in the last part, but enough to make a simple interpolation procedure fail.

Backup

Before making any permanent change to the repository's list a backup is highly recommended.

The single-file backup

Zypper itself allows to backup the list of repositories creating a single file:

$ zypper lr -e ~/backup.repo

And restore it with:

$ sudo zypper ar ~/backup.repo

The multiple file backup

When, for some reason, you want to make a 1:1 backup of all the repositories installed, the --backup operation comes in help:

$ zypper-upgraderepo --backup ~

A tgz archive will be placed in the home folder with a squeezed date-time info in the filename.

To restore the list just extract the archive:

$ sudo tar -xvf ~/repos-backup...tgz -C /

Upgrade

After all the repositories have been successfully checked it's time to upgrade their reference before launching the sudo zypper dup command.

Upgrade to the next version

Upgrading the repositories to the next version is as easy as typing:

$ sudo zypper-upgraderepo --upgrade

This replaces the manual edit accomplished with the zypper mr ... command, making it quicker.

Of course, to replace the failing URLs previously detected we can make use of the --override-url option again:

$ sudo zypper-upgraderepo --upgrade \
    --override-url 2,http://domain.org/correct/path/15.0/ \
    --override-url 3,http://anotherdomain.org/another-path/15.0

Or load the output file once it has been fixed using the --load-overrides option:

$ sudo zypper-upgraderepo --upgrade --load-overrides ~/output.ini

Upgrade to the last version

As seen for the --check-last operation, there is an operation that allows jumping directly to the last version without upgrading to the next.

$ sudo zypper-ugraderepo --upgrade-to-last

This practice is highly discouraged, and it is always better to upgrade version by version till the last.

Useless to mention that --upgrade-to-last and --upgrade achieve the same task when the next version is also the last.

Upgrade to a custom version

Upgrading to a custom version instead of the next or the last is allowed by the --upgrade-to <VERSION> operation:

$ sudo zypper-upgraderepo --upgrade-to 15.0

Of course, only existing openSUSE versions will be allowed, don't forget to check the availability of the relative repositories before upgrade or downgrade!

Reset

If you accidentally upgraded your repositories and forgot to create a backup of them, this operation will reset the changes to the current openSUSE Leap version:

$ zypper-upgraderepo --reset

Check the status

This operation has been added with the 1.6.0 release, to be honest for scripting purposes, and prints the status of our current openSUSE Leap distribution in terms of version:

$ zypper-upgraderepo --status

It helps to understand either how many versions our distro is back or if it is currently aligned to the last stable version available.

Other options

From time to time other options have been added for scripting or general purposes that might be useful to know.

General options

--allow-unstable : Appends the unstable underworking release in the internal stable releases list.

--no-name : Don't change the repository name.

--no-alias : Don't change the repository alias.

--no-hint : Don't find an alternative URL.

--exit-on-fail : For scripting purposes, exit when the first error is raised emitting an error code.

--timeout <SECONDS> : Change the waiting time for the answer from the repository server before raising a timeout error.

Filtering options

--only-enabled : Check or upgrade only enabled repositories.

--only-repo <NUMBER>[,NUMBER2,...] : Check only the repositories specified by their comma-separated number.

--only-invalid : Show only invalid repositories.

--only-protocols <PROTOCOL>[,<PROTOCOL2>,...] : Filter for a list of protocols (http, https, dir).

View options

--sort-by-alias / --sort-by-name / --sort-by-priority : Sort the repositories by either alias (default), name or priority.

--ini : Export the checking result as ini file.

--quiet : Show only an error message when something wrong happens.

--report : Show the results as a report adding other details.

Wrap up

To summarize this is the list of operations I execute to upgrade my system:

  1. First of all, if you have unneeded repositories remove or disable them, remove or fix also the wrong repository's URLs using the --check-current operation:

    $ zypper-upgraderepo --check-current
    
  2. Be sure to update the system to the latest packages:

    $ sudo zypper up
    
  3. If you have a brtfs filesystem check this section: Move /var/cache to a separate subvolume, otherwise go to the next step

  4. Check for the next version repositories:

    $ zypper-upgraderepo --check-next
    
  5. If no error occurred then make a backup and upgrade them, otherwise try to apply a fix as discussed above:

    $ zypper-upgraderepo --backup ~
    $ sudo zypper-upgraderepo --upgrade
    
  6. I prefer to download all the packages first:

    $ sudo zypper dup --download-only
    
  7. Once all packages are downloaded, logout from the graphical session and login to one of the textual sessions available (i.e. CTRL+ALT+F1), then start the third init level:

    # init 3
    
  8. Finish the upgrade process:

    # zypper --no-refresh dup
    
  9. Reboot and you are done!

    # reboot now
    

Resources

Clone this wiki locally