diff options
Diffstat (limited to 'recipes-containers/vcontainer/vdkr-native_1.0.bb')
| -rw-r--r-- | recipes-containers/vcontainer/vdkr-native_1.0.bb | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/recipes-containers/vcontainer/vdkr-native_1.0.bb b/recipes-containers/vcontainer/vdkr-native_1.0.bb deleted file mode 100644 index a6a56ecb..00000000 --- a/recipes-containers/vcontainer/vdkr-native_1.0.bb +++ /dev/null | |||
| @@ -1,191 +0,0 @@ | |||
| 1 | # SPDX-FileCopyrightText: Copyright (C) 2025 Bruce Ashfield | ||
| 2 | # | ||
| 3 | # SPDX-License-Identifier: MIT | ||
| 4 | # | ||
| 5 | # vdkr-native_1.0.bb | ||
| 6 | # =========================================================================== | ||
| 7 | # Emulated Docker for cross-architecture container operations | ||
| 8 | # =========================================================================== | ||
| 9 | # | ||
| 10 | # vdkr provides a Docker-like CLI that executes arbitrary docker commands | ||
| 11 | # inside a QEMU-emulated environment with the target architecture's Docker | ||
| 12 | # daemon. Commands like "docker load", "docker export", "docker images" etc | ||
| 13 | # are passed through to Docker running inside QEMU and results streamed back. | ||
| 14 | # | ||
| 15 | # vdkr uses its own initramfs (built by vdkr-initramfs-create) which | ||
| 16 | # has vdkr-init.sh baked in. This is separate from container-cross-install. | ||
| 17 | # | ||
| 18 | # USAGE: | ||
| 19 | # vdkr images # Uses detected default arch | ||
| 20 | # vdkr -a aarch64 images # Explicit arch | ||
| 21 | # vdkr-aarch64 images # Symlink (backwards compatible) | ||
| 22 | # vdkr-x86_64 load -i myimage.tar | ||
| 23 | # | ||
| 24 | # Architecture detection (in priority order): | ||
| 25 | # 1. --arch / -a flag | ||
| 26 | # 2. Executable name (vdkr-aarch64, vdkr-x86_64) | ||
| 27 | # 3. VDKR_ARCH environment variable | ||
| 28 | # 4. Config file: ~/.config/vdkr/arch | ||
| 29 | # 5. Host architecture (uname -m) | ||
| 30 | # | ||
| 31 | # DEPENDENCIES: | ||
| 32 | # - Kernel/initramfs blobs from vdkr-initramfs-create | ||
| 33 | # - QEMU system emulator (qemu-system-native) | ||
| 34 | # | ||
| 35 | # =========================================================================== | ||
| 36 | |||
| 37 | SUMMARY = "Emulated Docker for cross-architecture container operations" | ||
| 38 | DESCRIPTION = "Provides vdkr CLI that executes docker commands inside \ | ||
| 39 | QEMU-emulated environment. Useful for building/manipulating \ | ||
| 40 | containers for target architectures on a different host." | ||
| 41 | HOMEPAGE = "https://github.com/anthropics/meta-virtualization" | ||
| 42 | LICENSE = "MIT" | ||
| 43 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
| 44 | |||
| 45 | inherit native | ||
| 46 | |||
| 47 | # Dependencies | ||
| 48 | DEPENDS = "qemu-system-native coreutils-native socat-native" | ||
| 49 | |||
| 50 | # vdkr-init.sh is now baked into the initramfs, not installed separately | ||
| 51 | SRC_URI = "\ | ||
| 52 | file://vdkr.sh \ | ||
| 53 | file://vrunner.sh \ | ||
| 54 | " | ||
| 55 | |||
| 56 | # Pre-built blobs are optional - they're checked into the layer after being | ||
| 57 | # built by vdkr-initramfs-build. If not present, vdkr will still build | ||
| 58 | # but will require --blob-dir at runtime. | ||
| 59 | # | ||
| 60 | # To build blobs: | ||
| 61 | # MACHINE=qemuarm64 bitbake vdkr-initramfs-build | ||
| 62 | # MACHINE=qemux86-64 bitbake vdkr-initramfs-build | ||
| 63 | # Then copy from tmp/deploy/images/<machine>/vdkr-initramfs/ to files/blobs/vdkr/<arch>/ | ||
| 64 | # | ||
| 65 | # For development, set VDKR_USE_DEPLOY = "1" in local.conf to use blobs | ||
| 66 | # directly from DEPLOY_DIR instead of copying to layer. | ||
| 67 | |||
| 68 | FILESEXTRAPATHS:prepend := "${THISDIR}/files:" | ||
| 69 | |||
| 70 | # Layer directory containing optional blobs | ||
| 71 | VDKR_LAYER_BLOBS = "${THISDIR}/files/blobs/vdkr" | ||
| 72 | |||
| 73 | # Deploy directories (used when VDKR_USE_DEPLOY = "1") | ||
| 74 | VDKR_DEPLOY_AARCH64 = "${DEPLOY_DIR}/images/qemuarm64/vdkr-initramfs" | ||
| 75 | VDKR_DEPLOY_X86_64 = "${DEPLOY_DIR}/images/qemux86-64/vdkr-initramfs" | ||
| 76 | |||
| 77 | # Set to "1" in local.conf to prefer DEPLOY_DIR blobs over layer | ||
| 78 | VDKR_USE_DEPLOY ?= "0" | ||
| 79 | |||
| 80 | S = "${UNPACKDIR}" | ||
| 81 | |||
| 82 | do_install() { | ||
| 83 | # Install vdkr main script and architecture symlinks | ||
| 84 | install -d ${D}${bindir} | ||
| 85 | install -d ${D}${bindir}/vdkr-blobs/aarch64 | ||
| 86 | install -d ${D}${bindir}/vdkr-blobs/x86_64 | ||
| 87 | |||
| 88 | # Install main vdkr script (arch detected at runtime) | ||
| 89 | install -m 0755 ${S}/vdkr.sh ${D}${bindir}/vdkr | ||
| 90 | |||
| 91 | # Create backwards-compatible symlinks | ||
| 92 | ln -sf vdkr ${D}${bindir}/vdkr-aarch64 | ||
| 93 | ln -sf vdkr ${D}${bindir}/vdkr-x86_64 | ||
| 94 | |||
| 95 | # Install runner script | ||
| 96 | install -m 0755 ${S}/vrunner.sh ${D}${bindir}/ | ||
| 97 | |||
| 98 | # Determine blob source directories based on VDKR_USE_DEPLOY | ||
| 99 | if [ "${VDKR_USE_DEPLOY}" = "1" ]; then | ||
| 100 | AARCH64_SRC="${VDKR_DEPLOY_AARCH64}" | ||
| 101 | X86_64_SRC="${VDKR_DEPLOY_X86_64}" | ||
| 102 | bbwarn "============================================================" | ||
| 103 | bbwarn "VDKR_USE_DEPLOY=1: Using blobs from DEPLOY_DIR" | ||
| 104 | bbwarn "This is for development only. For permanent use, copy blobs:" | ||
| 105 | bbwarn "" | ||
| 106 | bbwarn " # For aarch64:" | ||
| 107 | bbwarn " cp ${VDKR_DEPLOY_AARCH64}/Image \\" | ||
| 108 | bbwarn " ${VDKR_LAYER_BLOBS}/aarch64/" | ||
| 109 | bbwarn " cp ${VDKR_DEPLOY_AARCH64}/initramfs.cpio.gz \\" | ||
| 110 | bbwarn " ${VDKR_LAYER_BLOBS}/aarch64/" | ||
| 111 | bbwarn "" | ||
| 112 | bbwarn " # For x86_64:" | ||
| 113 | bbwarn " cp ${VDKR_DEPLOY_X86_64}/bzImage \\" | ||
| 114 | bbwarn " ${VDKR_LAYER_BLOBS}/x86_64/" | ||
| 115 | bbwarn " cp ${VDKR_DEPLOY_X86_64}/initramfs.cpio.gz \\" | ||
| 116 | bbwarn " ${VDKR_LAYER_BLOBS}/x86_64/" | ||
| 117 | bbwarn "" | ||
| 118 | bbwarn "Then remove VDKR_USE_DEPLOY from local.conf" | ||
| 119 | bbwarn "============================================================" | ||
| 120 | else | ||
| 121 | AARCH64_SRC="${VDKR_LAYER_BLOBS}/aarch64" | ||
| 122 | X86_64_SRC="${VDKR_LAYER_BLOBS}/x86_64" | ||
| 123 | fi | ||
| 124 | |||
| 125 | # Install aarch64 blobs (if available) | ||
| 126 | # Requires: Image, initramfs.cpio.gz, rootfs.img | ||
| 127 | if [ -f "$AARCH64_SRC/Image" ] && [ -f "$AARCH64_SRC/rootfs.img" ]; then | ||
| 128 | install -m 0644 "$AARCH64_SRC/Image" ${D}${bindir}/vdkr-blobs/aarch64/ | ||
| 129 | install -m 0644 "$AARCH64_SRC/initramfs.cpio.gz" ${D}${bindir}/vdkr-blobs/aarch64/ | ||
| 130 | install -m 0644 "$AARCH64_SRC/rootfs.img" ${D}${bindir}/vdkr-blobs/aarch64/ | ||
| 131 | bbnote "Installed aarch64 blobs from $AARCH64_SRC" | ||
| 132 | else | ||
| 133 | bbnote "No aarch64 blobs found at $AARCH64_SRC" | ||
| 134 | bbnote "Required: Image, initramfs.cpio.gz, rootfs.img" | ||
| 135 | fi | ||
| 136 | |||
| 137 | # Install x86_64 blobs (if available) | ||
| 138 | # Requires: bzImage, initramfs.cpio.gz, rootfs.img | ||
| 139 | if [ -f "$X86_64_SRC/bzImage" ] && [ -f "$X86_64_SRC/rootfs.img" ]; then | ||
| 140 | install -m 0644 "$X86_64_SRC/bzImage" ${D}${bindir}/vdkr-blobs/x86_64/ | ||
| 141 | install -m 0644 "$X86_64_SRC/initramfs.cpio.gz" ${D}${bindir}/vdkr-blobs/x86_64/ | ||
| 142 | install -m 0644 "$X86_64_SRC/rootfs.img" ${D}${bindir}/vdkr-blobs/x86_64/ | ||
| 143 | bbnote "Installed x86_64 blobs from $X86_64_SRC" | ||
| 144 | else | ||
| 145 | bbnote "No x86_64 blobs found at $X86_64_SRC" | ||
| 146 | bbnote "Required: bzImage, initramfs.cpio.gz, rootfs.img" | ||
| 147 | fi | ||
| 148 | } | ||
| 149 | |||
| 150 | # Make available in native sysroot | ||
| 151 | SYSROOT_DIRS += "${bindir}" | ||
| 152 | |||
| 153 | # Task to print usage instructions for using vdkr from current location | ||
| 154 | # Run with: bitbake vdkr-native -c print_usage | ||
| 155 | python do_print_usage() { | ||
| 156 | import os | ||
| 157 | bindir = d.getVar('D') + d.getVar('bindir') | ||
| 158 | |||
| 159 | # Find the actual install location | ||
| 160 | image_dir = d.getVar('D') | ||
| 161 | native_sysroot = d.getVar('STAGING_DIR_NATIVE') | ||
| 162 | |||
| 163 | bb.plain("") | ||
| 164 | bb.plain("=" * 70) | ||
| 165 | bb.plain("vdkr Usage Instructions") | ||
| 166 | bb.plain("=" * 70) | ||
| 167 | bb.plain("") | ||
| 168 | bb.plain("Option 1: Add to PATH (recommended)") | ||
| 169 | bb.plain("-" * 40) | ||
| 170 | bb.plain("export PATH=\"%s:$PATH\"" % (native_sysroot + d.getVar('bindir'))) | ||
| 171 | bb.plain("") | ||
| 172 | bb.plain("Then use:") | ||
| 173 | bb.plain(" vdkr images # Uses default arch (host or config)") | ||
| 174 | bb.plain(" vdkr -a aarch64 images # Explicit arch") | ||
| 175 | bb.plain(" vdkr-x86_64 images # Symlink (backwards compatible)") | ||
| 176 | bb.plain("") | ||
| 177 | bb.plain("Option 2: Direct invocation") | ||
| 178 | bb.plain("-" * 40) | ||
| 179 | bb.plain("%s/vdkr images" % (native_sysroot + d.getVar('bindir'))) | ||
| 180 | bb.plain("") | ||
| 181 | bb.plain("Option 3: Set default architecture") | ||
| 182 | bb.plain("-" * 40) | ||
| 183 | bb.plain("mkdir -p ~/.config/vdkr && echo 'aarch64' > ~/.config/vdkr/arch") | ||
| 184 | bb.plain("") | ||
| 185 | bb.plain("Note: QEMU must be in PATH. If not found, also add:") | ||
| 186 | bb.plain("export PATH=\"%s:$PATH\"" % (d.getVar('STAGING_BINDIR_NATIVE'))) | ||
| 187 | bb.plain("") | ||
| 188 | bb.plain("=" * 70) | ||
| 189 | } | ||
| 190 | addtask print_usage | ||
| 191 | do_print_usage[nostamp] = "1" | ||
