summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-02-10 19:10:52 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-02-10 21:04:20 +0000
commit5ca92e99dc0706c1dcda0edd29aec46a3ccdd851 (patch)
treea2bc87ff9c66139e0e08933db023c70300d20b3f
parenta4625a1fa2758c0d2496a898ed409b5225efdab1 (diff)
downloadmeta-virtualization-5ca92e99dc0706c1dcda0edd29aec46a3ccdd851.tar.gz
container tasks: move network access out of build chain
yocto-check-layer reports an error for any task between do_fetch and do_build that has network enabled. Two changes fix this: container-bundle.bbclass: Move do_fetch_containers from a standalone task into a do_fetch postfunc. When remote containers are configured, the anonymous function adds extend_recipe_sysroot as a do_fetch prefunc (so skopeo-native is available) and do_fetch_containers as a postfunc. Network access during do_fetch is permitted by the QA check. container-registry-index: Remove do_container_registry_index from the build dependency chain (drop "before do_build"). Registry push is a deployment action requiring explicit invocation: bitbake container-registry-index -c container_registry_index The default do_build task now prints usage instructions. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--classes/container-bundle.bbclass13
-rw-r--r--recipes-containers/container-registry/container-registry-index.bb13
2 files changed, 22 insertions, 4 deletions
diff --git a/classes/container-bundle.bbclass b/classes/container-bundle.bbclass
index 53b7b2f8..6f43149b 100644
--- a/classes/container-bundle.bbclass
+++ b/classes/container-bundle.bbclass
@@ -280,6 +280,12 @@ python __anonymous() {
280 d.setVar('_PROCESSED_BUNDLES', ' '.join(processed_bundles)) 280 d.setVar('_PROCESSED_BUNDLES', ' '.join(processed_bundles))
281 d.setVar('_BUNDLE_RUNTIME', runtime) 281 d.setVar('_BUNDLE_RUNTIME', runtime)
282 282
283 # Remote containers are fetched during do_fetch (network is allowed there).
284 # extend_recipe_sysroot populates the native sysroot so skopeo is available.
285 if remote_urls:
286 d.appendVarFlag('do_fetch', 'prefuncs', ' extend_recipe_sysroot')
287 d.appendVarFlag('do_fetch', 'postfuncs', ' do_fetch_containers')
288
283 # Build service file map for custom service files 289 # Build service file map for custom service files
284 # Format: container1=/path/to/file1;container2=/path/to/file2 290 # Format: container1=/path/to/file1;container2=/path/to/file2
285 service_mappings = [] 291 service_mappings = []
@@ -324,7 +330,7 @@ python do_fetch_containers() {
324 fetched_dir = os.path.join(workdir, 'fetched') 330 fetched_dir = os.path.join(workdir, 'fetched')
325 os.makedirs(fetched_dir, exist_ok=True) 331 os.makedirs(fetched_dir, exist_ok=True)
326 332
327 # Find skopeo in native sysroot (available after do_prepare_recipe_sysroot) 333 # Find skopeo in native sysroot (populated by extend_recipe_sysroot prefunc)
328 # skopeo-native installs to sbindir, not bindir 334 # skopeo-native installs to sbindir, not bindir
329 staging_sbindir = d.getVar('STAGING_SBINDIR_NATIVE') 335 staging_sbindir = d.getVar('STAGING_SBINDIR_NATIVE')
330 skopeo = os.path.join(staging_sbindir, 'skopeo') 336 skopeo = os.path.join(staging_sbindir, 'skopeo')
@@ -363,8 +369,9 @@ python do_fetch_containers() {
363 bb.fatal(f"Failed to fetch container '{url}': {e}") 369 bb.fatal(f"Failed to fetch container '{url}': {e}")
364} 370}
365 371
366do_fetch_containers[network] = "1" 372# do_fetch_containers runs as a postfunc of do_fetch (set in __anonymous
367addtask fetch_containers after do_prepare_recipe_sysroot before do_compile 373# when remote containers are configured). This keeps network access within
374# do_fetch where it is permitted by yocto-check-layer.
368 375
369do_compile() { 376do_compile() {
370 set -e 377 set -e
diff --git a/recipes-containers/container-registry/container-registry-index.bb b/recipes-containers/container-registry/container-registry-index.bb
index 590e89b3..7d53e28e 100644
--- a/recipes-containers/container-registry/container-registry-index.bb
+++ b/recipes-containers/container-registry/container-registry-index.bb
@@ -84,7 +84,18 @@ python do_container_registry_index() {
84 bb.plain(f"Pushed {len(pushed_refs)} image references to {registry}") 84 bb.plain(f"Pushed {len(pushed_refs)} image references to {registry}")
85} 85}
86 86
87addtask do_container_registry_index before do_build 87addtask do_container_registry_index
88
89python do_build() {
90 bb.plain("")
91 bb.plain("Container registry push requires explicit invocation (network access")
92 bb.plain("is not permitted during the normal build chain).")
93 bb.plain("")
94 bb.plain("To push OCI images to the registry, run:")
95 bb.plain("")
96 bb.plain(" bitbake container-registry-index -c container_registry_index")
97 bb.plain("")
98}
88 99
89# Generate a helper script with paths baked in 100# Generate a helper script with paths baked in
90# Script is placed alongside registry storage (outside tmp/) so it persists 101# Script is placed alongside registry storage (outside tmp/) so it persists