Automate Ubuntu dependency baseline generation#824
Automate Ubuntu dependency baseline generation#824Aayushman-nvm wants to merge 14 commits intoprecice:masterfrom
Conversation
|
This pull request has been mentioned on preCICE Forum on Discourse. There might be relevant details there: https://precice.discourse.group/t/introduction-website-modernization/2852/1 |
MakisH
left a comment
There was a problem hiding this comment.
Thank you for contributing! We are still discussing in #617, but this PR already does something useful in the respective direction, and I think we can merge it independently of the conclusion.
This PR addresses #617 by automatically generating a list of relevant packages provided in an Ubuntu release with a Python script. A manually-triggered CI workflow executes that script and checks the respective YAML file into this repository.
The Python script executes an apt-cache policy for each package in a Docker container, which might be a bit overkill, but works. Inputs are specified in dependency.yml, the output is saved into _data/ubuntu-baseline.yml. This PR already adds such a file, which could in principle then be rendered on the website.
See some suggestions, which should all be easy to implement.
| import subprocess | ||
| import yaml | ||
| import argparse | ||
| from pathlib import Path | ||
| from datetime import datetime, UTC |
There was a problem hiding this comment.
This Python script would still need a requirements.txt defining PyYAML as a dependency (probably PyYAML==6). And then change the CI to replace pip install PyYAML with pip install -r requirements.txt.
| def get_version_mock(package): | ||
| return "0.0.0-mock" |
There was a problem hiding this comment.
What is the use case for this one? It just assigns 0.0.0-mock to every dependency.
| f"ubuntu:{ubuntu_version}", | ||
| "bash", | ||
| "-c", | ||
| f"apt-get update -qq && apt-cache policy {package} | grep Candidate | awk '{{print $2}}'", |
There was a problem hiding this comment.
While this will give the package name, which includes the respective upstream version, it also includes other elements, such as the Debian package revision. For example, 1.83.0.1ubuntu2 or 2.9.14+dfsg.
I am not sure if these would be useful for the user on the website, or rather confusing. In principle, the first three digits should work (all these packages use semantic versioning).
| git config user.name github-actions | ||
| git config user.email github-actions@github.com |
There was a problem hiding this comment.
In other workflows (update-submodules.yml and update-discourse-data.yml), we use:
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git config --local user.name "precice-bot" | |
| git config --local user.email "info@precice.org" |
| python3 scripts/generate_ubuntu_baseline.py \ | ||
| --lts 22.04 24.04 |
There was a problem hiding this comment.
Since precice/precice#2564, the baseline has shifted to 24.04, and we have added 26.04. For the current version (3.4.x), we still need to keep 22.04 listed.
Let's make this:
| python3 scripts/generate_ubuntu_baseline.py \ | |
| --lts 22.04 24.04 | |
| python3 scripts/generate_ubuntu_baseline.py \ | |
| --lts 22.04 24.04 26.04 |
|
|
||
| jobs: | ||
| generate: | ||
| if: github.actor != 'github-actions[bot]' |
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 |
There was a problem hiding this comment.
There is already a v6:
| - uses: actions/checkout@v4 | |
| - uses: actions/checkout@v6 |
There was a problem hiding this comment.
Ideally, I would put this script (everything you currently have into scripts/) into a directory specific to this script (scripts/baseline/).
| parser.add_argument( | ||
| "--lts", | ||
| nargs="+", | ||
| required=True, | ||
| help="Ubuntu LTS versions to query (e.g. 22.04 24.04)", | ||
| ) |
There was a problem hiding this comment.
Why restrict that to LTS releases? I would rather name the option --release. For example, --lts 25.10 also works, even though that is not an LTS release.
| "-c", | ||
| f"apt-get update -qq && apt-cache policy {package} | grep Candidate | awk '{{print $2}}'", | ||
| ] | ||
| raw = run_command(cmd) |
There was a problem hiding this comment.
Before running this command, I would expect some output with the command to run, especially since this might take a while. This would also be useful for debugging and for understanding what this script does.
fsimonis
left a comment
There was a problem hiding this comment.
As described in the issue, we have an API key for pkgs.org.
There is no reason to probe a Docker container to get the package versions.
Also, the distinction between optional and required packages is unnecessary. It is handled where we display the information.
Furthermore, we are interested in the version of the packaged software, not the package. Meaning that we want 1.83.0, not 1.83.0.1ubuntu2.
Automate Ubuntu dependency baseline generation
addresses #617
Approach
Repology's API is rate-limited and the dumps are too large (noted in the issue), so this uses Docker +
apt-cache policyto query package versions directly from Ubuntu's apt repositories instead.What's included
scripts/dependencies.yml— package list (required/optional), derived from the Ubuntu system guidescripts/generate_ubuntu_baseline.py— queries each package version via Docker and writes_data/ubuntu-baseline.yml. Run manually at release time withpython3 scripts/generate_ubuntu_baseline.py --lts 22.04 24.04. A--mockflag is available to test without Docker._data/ubuntu-baseline.yml— generated output, committed so Jekyll can reference it at build time.github/workflows/generate-baseline.yml—workflow_dispatch-only workflow for auto regenerating and adding ubuntu-baseline.yml list locallyHow I tested
debug.yml(a temporary workflow, not included in this PR) on theissue617branch to verify all packages independencies.ymlare actually available and resolvable on both Ubuntu 22.04 and 24.04 via apt.ubuntu-baseline.ymland confirmed the versions match whatapt-cache policyreports inside the containers.Notes
dependencies.ymlcan be updated independently of the script — easy to add or remove packages without touching any logic.content/docs/installation/building-from-source/installation-source-dependenciesis intentionally left untouched for now. Happy to wire the data file into the dependencies page however you'd prefer.Screenshots:

Core:
Autogenerated:
