This should produce the same images (except for no more dnf metadata),
but avoids depsolving (and network access) from stages.
The following helper script around osbuild-composer's dnf-json was
used for the translation:
```
import json
import os
import subprocess
import sys
def fetch_repos(sources, repo):
if isinstance(repo, str):
repo = sources["org.osbuild.dnf"]["repos"][repo]
return repo, repo["gpgkey"]
def convert_stage(sources, stage, cachedir):
gpgkeys = []
repos = []
for repoid, repo in enumerate(stage["options"]["repos"]):
repo, gpgkey = fetch_repos(sources, repo)
repo["id"] = repoid
repo["name"] = f"repo-{repoid}"
repos.append(repo)
gpgkeys.append(gpgkey)
arguments = {}
arguments["cachedir"] = cachedir
arguments["module_platform_id"] = stage["options"]["module_platform_id"]
arguments["package-specs"] = stage["options"]["packages"]
arguments["exclude-specs"] = stage["options"].get("exclude_packages", [])
arguments["repos"] = repos
call = {}
call["command"] = "depsolve"
call["arguments"] = arguments
r = subprocess.run(["./dnf-json"],
input=json.dumps(call),
stdout=subprocess.PIPE,
encoding="utf-8",
check=True)
pkgs = json.loads(r.stdout)["dependencies"]
packages = []
urls = {}
for p in pkgs:
packages.append(p["checksum"])
urls[p["checksum"]] = p["remote_location"]
options = {}
options["gpgkeys"] = gpgkeys
options["packages"] = packages
stage["name"] = "org.osbuild.rpm"
stage["options"] = options
return urls
def convert_pipeline(sources, pipeline, cachedir):
urls = {}
if "build" in pipeline:
u = convert_pipeline(sources, pipeline["build"]["pipeline"], cachedir)
urls = {**urls, **u}
for stage in pipeline["stages"]:
if stage["name"] == "org.osbuild.dnf":
u = convert_stage(sources, stage, cachedir)
urls = {**urls, **u}
return urls
manifest = json.load(sys.stdin)
urls = convert_pipeline(manifest["sources"], manifest["pipeline"], f"{os.getcwd()}/dnf-cache")
sources = { "org.osbuild.files": { "urls": urls }}
json.dump({"sources": sources, "pipeline": manifest["pipeline"]}, sys.stdout)
75,9 Bot
```
Signed-off-by: Tom Gundersen <teg@jklm.no>
|
||
|---|---|---|
| .. | ||
| os-release | ||
| pipelines | ||
| sources_tests/org.osbuild.files | ||
| stages_tests | ||
| testing-rpms | ||
| .gitignore | ||
| __init__.py | ||
| osbuildtest.py | ||
| README.md | ||
| test_assemblers.py | ||
| test_boot.py | ||
| test_objectstore.py | ||
| test_osbuild.py | ||
| test_osrelease.py | ||
| test_sources.py | ||
| test_stageinfo.py | ||
| test_stages.py | ||
Setup
To run the tests in vagrant virtual machine, please follow this tutorial: https://developer.fedoraproject.org/tools/vagrant/vagrant-libvirt.html
(run also sudo systemctl start libvirtd)
Using Vagrant
To start a Vagrant box by hand, run vagrant up in this directory. To stop and remove all volumes run vagrant destroy again in this directory.
Troubleshooting
In case you accidentally deleted .vagrant directory, you can use some of these commands in order to get rid of running instance:
$ virsh list # this should display test_default
$ virsh managedsave-remove test_default
$ virsh undefine test_default
# or using vagrant cli tool
$ vagrant global-status
$ vagrant destroy <id>
$ vagrant global-status --prune