-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
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.
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.
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.
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.
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
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
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:
- Using the
--override-url
option; - Exporting the results as an ini file, apply the changes, and reimport it.
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/
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.
Before making any permanent change to the repository's list a backup is highly recommended.
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
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 /
After all the repositories have been successfully checked it's time to upgrade their reference before launching
the sudo zypper dup
command.
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
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.
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!
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
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.
From time to time other options have been added for scripting or general purposes that might be useful to know.
--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.
--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).
--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.
To summarize this is the list of operations I execute to upgrade my system:
-
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
-
Be sure to update the system to the latest packages:
$ sudo zypper up
-
If you have a
brtfs
filesystem check this section: Move /var/cache to a separate subvolume, otherwise go to the next step -
Check for the next version repositories:
$ zypper-upgraderepo --check-next
-
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
-
I prefer to download all the packages first:
$ sudo zypper dup --download-only
-
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
-
Finish the upgrade process:
# zypper --no-refresh dup
-
Reboot and you are done!
# reboot now
- Project page on FreeAptitude
- Under the hood of zypper_upgraderepo gem
- Upgrading openSUSE with zypper
- zypper-upgraderepo 1.2 news on openSUSE Lizards
- My tutorial translated in spanish by openSUSE Mexico team
- My tutorial translated in greek by Efstathios Iosifidis
- Small tutorial on openSUSE Lizards
- zypper-upgraderepo-plugin use this gem as zypper subcommand