Skip to content
Fabio Mucciante edited this page Jan 31, 2022 · 26 revisions

Welcome to the ZypperUpgraderepo wiki!

ZypperUpgraderepo was born to check the repository availability in order to facilitate the upgrade process of the openSUSE Leap distribution using the zypper dup command, but also to discover errors in the URLs reference.

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

  • check for an arbitrary version in the list of supported versions (next, last, something in the middle);
  • back up the whole list of repositories;
  • upgrade the repositories all at once;
  • check the status of the current distribution.

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 updating process:

$ zypper-upgraderepo --check-current

A table with four columns will show:

  • The status;
  • The related repository number;
  • The repository name;
  • Whether enabled or not;
  • A hint explaining, when 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, a hint will be printed where possible giving an alternative URL.

When the error can't be fixed either manually or with the help of this script, is better to disable it 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 is not recommended to upgrade missing some versions we might want to be able to know whether or not the repositories are available also for the latest stable version:

$ zypper-upgraderepo --check-last

Check for a different version

Last but not least also a custom (valid) version of openSUSE's repository can be checked to jump from one version to another:

$ zypper-upgraderepo --check-for 15.0

Override one or more URLs

When the checking procedure fails we can repeat it overriding the bad URLs with the suggested or self-discovered ones and check for them again.

There are two ways to override the URLs:

  1. Using the --override-url option;
  2. Exporting the checking result as ini file, applying the changes, and reimporting 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 comma , separated:

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

Export to the ini file

When the number of URLs to fix grows, there is another way to override the failing repositories which might result in more comfortable:

  • export on an ini structured files the invalid repositories using the --ini option;
    $ zypper-upgraderepo --check-next --only-invalid --only-enabled --ini > ~/output.ini
    
  • edit it and fix the URLs;
    $ vi ~/output.ini
    
  • reload 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
    

Below is an example of the output file structure correctly upgraded:

[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

Two fields describe the old_url and the new url, when the new URL can't be interpolated for any reason, that last key will be left empty and a commented section might suggest what to do:

[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!

Backup

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

The single-file backup

Zypper itself allows to back up 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 versions is as easy as typing:

$ sudo zypper-upgraderepo --upgrade

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

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 reload 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-to-next 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 give you a hand to reset the changes:

$ 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 with minor relevance but that might be useful.

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