Skip to content

Instantly share code, notes, and snippets.

@FauxFaux
Last active May 13, 2023 20:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FauxFaux/9686f285102bbaa59d63 to your computer and use it in GitHub Desktop.
Save FauxFaux/9686f285102bbaa59d63 to your computer and use it in GitHub Desktop.
What does Ubuntu's do-release-upgrade script actually do?

Ubuntu encourage upgrading between releases by running a command, instead of by manually editing sources and getting on with it. This tool's name is do-release-upgrade, and I believe it should just be doing:

sed -i 's/wily/xenial/g' /etc/apt/sources.list /etc/apt/sources.list.d/*

This command does not explain what it wants to do, or why it is doing anything. It has, in the past:

  • Disabled repos I was using, and hence broken the software in them.
  • Dropped the network on a remote machine which I was accessing over SSH.
  • Hung unresumably due to network conditions.

This makes me unhappy. Let's see what it actually does:

% python3 -m trace --trace =do-release-upgrade 2>&1 | fgrep -A3 \"http:
MetaRelease.py(106):         base_uri = "http://changelogs.ubuntu.com/"
MetaRelease.py(107):         self.METARELEASE_URI = base_uri + "meta-release"
MetaRelease.py(108):         self.METARELEASE_URI_LTS = base_uri + "meta-release-lts"
MetaRelease.py(109):         self.METARELEASE_URI_UNSTABLE_POSTFIX = "-development"

First, it downloads some metadata over plain http. The metadata contains the URL to the random binary we're going to execute:

% curl -s http://changelogs.ubuntu.com/meta-release-lts-development | sed -n '1,/xenial/d; /UpgradeTool:/p'
UpgradeTool: http://archive.ubuntu.com/ubuntu/dists/xenial/main/dist-upgrader-all/current/xenial.tar.gz

This tar appears to have been built from:

https://bazaar.launchpad.net/~ubuntu-core-dev/ubuntu-release-upgrader/trunk/files

... which contains plenty of metadata, about what to do. For example,

I do not know how those packages would be removed otherwise, unless they were originally marked as "automatically installed", and are now obsolete? This seems unlikely to have happened.

So, maybe the tool has non-zero value. I think I'd rather just have the list of packages, though, thanks...

@mikbuch
Copy link

mikbuch commented May 21, 2022

A very interesting observation, indeed. I recently had problems with do-release-upgrade upgrade for EOL Ubuntu 20.10. The official documentation says to manually change sources lists and download and run the specific UpgradeTool. I wonder if we could improve the way do-release-upgrade.

So, maybe the tool has non-zero value. I think I'd rather just have the list of packages, though, thanks...

The value I see is the abstraction for the user. However, I agree that this tool can be improved.


Interestingly, the discussion on what do-release-upgrade actually do goes back as long as 8 years back: https://askubuntu.com/questions/409555/what-does-do-release-upgrade-really-do

@mikbuch
Copy link

mikbuch commented May 21, 2022

If someone would be interested, I think I found the source code and the repository from where do-release-upgrade comes from:

(do-release-upgrade's source code): https://git.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/tree/do-release-upgrade

References:

(How did I get there)

http://manpages.ubuntu.com/manpages/jammy/man8/do-release-upgrade.8.html => https://launchpad.net/ubuntu/jammy/+package/ubuntu-release-upgrader-core => https://launchpad.net/ubuntu/+source/ubuntu-release-upgrader/1:22.04.10

@mikbuch
Copy link

mikbuch commented May 21, 2022

My case is somehow different from yours, @FauxFaux, so I created my own "issue" as a gist here: https://gist.github.com/mikbuch/2c349e1281c69818b48893a460c5accb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment