diff options
| author | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-01-05 03:28:17 +0000 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2026-02-09 03:32:52 +0000 |
| commit | c03fa452f381d54af66c6bc0d0394622c3d3d61f (patch) | |
| tree | f341cba988b577493ec9228ac1c8cb063a10e33f /recipes-containers/vcontainer/files | |
| parent | f9f8e294e5d870f28dd65f13ddb43c224be958fc (diff) | |
| download | meta-virtualization-c03fa452f381d54af66c6bc0d0394622c3d3d61f.tar.gz | |
vcontainer: add SDK-based standalone tarball
Add vcontainer-tarball.bb recipe that creates a relocatable standalone
distribution of vdkr and vpdmn container tools using Yocto SDK infrastructure.
Features:
- Auto-detects available architectures from built blobs
- Custom SDK installer with vcontainer-specific messages
- nativesdk-qemu-vcontainer.bb: minimal QEMU without OpenGL deps
Recipe changes:
- DELETE vdkr-native_1.0.bb (functionality moved to SDK)
- DELETE vpdmn-native_1.0.bb (functionality moved to SDK)
- ADD vcontainer-tarball.bb (SDK tarball recipe)
- ADD toolchain-shar-extract.sh (SDK installer template)
- ADD nativesdk-qemu-vcontainer.bb (minimal QEMU for SDK)
Usage:
MACHINE=qemux86-64 bitbake vcontainer-tarball
./tmp/deploy/sdk/vcontainer-standalone.sh -d /opt/vcontainer -y
source /opt/vcontainer/init-env.sh
vdkr images
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers/vcontainer/files')
| -rw-r--r-- | recipes-containers/vcontainer/files/toolchain-shar-extract.sh | 326 | ||||
| -rwxr-xr-x | recipes-containers/vcontainer/files/vrunner.sh | 10 |
2 files changed, 336 insertions, 0 deletions
diff --git a/recipes-containers/vcontainer/files/toolchain-shar-extract.sh b/recipes-containers/vcontainer/files/toolchain-shar-extract.sh new file mode 100644 index 00000000..5e72f14d --- /dev/null +++ b/recipes-containers/vcontainer/files/toolchain-shar-extract.sh | |||
| @@ -0,0 +1,326 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # SPDX-FileCopyrightText: Copyright (C) 2025 Bruce Ashfield | ||
| 3 | # | ||
| 4 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 5 | |||
| 6 | export LC_ALL=en_US.UTF-8 | ||
| 7 | |||
| 8 | # The pipefail option is now part of POSIX (POSIX.1-2024) and available in more | ||
| 9 | # and more shells. Enable it if available to make the SDK installer more robust. | ||
| 10 | (set -o pipefail 2> /dev/null) && set -o pipefail | ||
| 11 | |||
| 12 | #Make sure at least one python is installed | ||
| 13 | INIT_PYTHON=$(command -v python3 2>/dev/null ) | ||
| 14 | [ -z "$INIT_PYTHON" ] && INIT_PYTHON=$(command -v python2 2>/dev/null) | ||
| 15 | [ -z "$INIT_PYTHON" ] && echo "Error: The SDK needs a python installed" && exit 1 | ||
| 16 | |||
| 17 | # Remove invalid PATH elements first (maybe from a previously setup toolchain now deleted | ||
| 18 | PATH=`$INIT_PYTHON -c 'import os; print(":".join(e for e in os.environ["PATH"].split(":") if os.path.exists(e)))'` | ||
| 19 | |||
| 20 | tweakpath () { | ||
| 21 | case ":${PATH}:" in | ||
| 22 | *:"$1":*) | ||
| 23 | ;; | ||
| 24 | *) | ||
| 25 | PATH=$PATH:$1 | ||
| 26 | esac | ||
| 27 | } | ||
| 28 | |||
| 29 | # Some systems don't have /usr/sbin or /sbin in the cleaned environment PATH but we make need it | ||
| 30 | # for the system's host tooling checks | ||
| 31 | tweakpath /usr/sbin | ||
| 32 | tweakpath /sbin | ||
| 33 | |||
| 34 | INST_ARCH=$(uname -m | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") | ||
| 35 | SDK_ARCH=$(echo @SDK_ARCH@ | sed -e "s/i[3-6]86/ix86/" -e "s/x86[-_]64/x86_64/") | ||
| 36 | |||
| 37 | verlte () { | ||
| 38 | [ "$1" = "`printf "$1\n$2" | sort -V | head -n1`" ] | ||
| 39 | } | ||
| 40 | |||
| 41 | verlt() { | ||
| 42 | [ "$1" = "$2" ] && return 1 || verlte $1 $2 | ||
| 43 | } | ||
| 44 | |||
| 45 | verlt `uname -r` @OLDEST_KERNEL@ | ||
| 46 | if [ $? = 0 ]; then | ||
| 47 | echo "Error: The SDK needs a kernel > @OLDEST_KERNEL@" | ||
| 48 | exit 1 | ||
| 49 | fi | ||
| 50 | |||
| 51 | if [ "$INST_ARCH" != "$SDK_ARCH" ]; then | ||
| 52 | # Allow for installation of ix86 SDK on x86_64 host | ||
| 53 | if [ "$INST_ARCH" != x86_64 -o "$SDK_ARCH" != ix86 ]; then | ||
| 54 | echo "Error: Incompatible SDK installer! Your host is $INST_ARCH and this SDK was built for $SDK_ARCH hosts." | ||
| 55 | exit 1 | ||
| 56 | fi | ||
| 57 | fi | ||
| 58 | |||
| 59 | if ! xz -V > /dev/null 2>&1; then | ||
| 60 | echo "Error: xz is required for installation of this SDK, please install it first" | ||
| 61 | exit 1 | ||
| 62 | fi | ||
| 63 | |||
| 64 | SDK_BUILD_PATH="@SDKPATH@" | ||
| 65 | DEFAULT_INSTALL_DIR="@SDKPATHINSTALL@" | ||
| 66 | SUDO_EXEC="" | ||
| 67 | EXTRA_TAR_OPTIONS="" | ||
| 68 | target_sdk_dir="" | ||
| 69 | answer="" | ||
| 70 | relocate=1 | ||
| 71 | savescripts=0 | ||
| 72 | verbose=0 | ||
| 73 | publish=0 | ||
| 74 | listcontents=0 | ||
| 75 | while getopts ":yd:npDRSl" OPT; do | ||
| 76 | case $OPT in | ||
| 77 | y) | ||
| 78 | answer="Y" | ||
| 79 | ;; | ||
| 80 | d) | ||
| 81 | target_sdk_dir=$OPTARG | ||
| 82 | ;; | ||
| 83 | n) | ||
| 84 | prepare_buildsystem="no" | ||
| 85 | ;; | ||
| 86 | p) | ||
| 87 | prepare_buildsystem="no" | ||
| 88 | publish=1 | ||
| 89 | ;; | ||
| 90 | D) | ||
| 91 | verbose=1 | ||
| 92 | ;; | ||
| 93 | R) | ||
| 94 | relocate=0 | ||
| 95 | savescripts=1 | ||
| 96 | ;; | ||
| 97 | S) | ||
| 98 | savescripts=1 | ||
| 99 | ;; | ||
| 100 | l) | ||
| 101 | listcontents=1 | ||
| 102 | ;; | ||
| 103 | *) | ||
| 104 | echo "Usage: $(basename "$0") [-y] [-d <dir>]" | ||
| 105 | echo " -y Automatic yes to all prompts" | ||
| 106 | echo " -d <dir> Install the SDK to <dir>" | ||
| 107 | echo "======== Extensible SDK only options ============" | ||
| 108 | echo " -n Do not prepare the build system" | ||
| 109 | echo " -p Publish mode (implies -n)" | ||
| 110 | echo "======== Advanced DEBUGGING ONLY OPTIONS ========" | ||
| 111 | echo " -S Save relocation scripts" | ||
| 112 | echo " -R Do not relocate executables" | ||
| 113 | echo " -D use set -x to see what is going on" | ||
| 114 | echo " -l list files that will be extracted" | ||
| 115 | exit 1 | ||
| 116 | ;; | ||
| 117 | esac | ||
| 118 | done | ||
| 119 | |||
| 120 | payload_offset=$(($(grep -na -m1 "^MARKER:$" "$0"|cut -d':' -f1) + 1)) | ||
| 121 | if [ "$listcontents" = "1" ] ; then | ||
| 122 | if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then | ||
| 123 | tail -n +$payload_offset "$0" > sdk.zip | ||
| 124 | if unzip -l sdk.zip;then | ||
| 125 | rm sdk.zip | ||
| 126 | else | ||
| 127 | rm sdk.zip && exit 1 | ||
| 128 | fi | ||
| 129 | else | ||
| 130 | tail -n +$payload_offset "$0"| tar tvJ || exit 1 | ||
| 131 | fi | ||
| 132 | exit | ||
| 133 | fi | ||
| 134 | |||
| 135 | titlestr="@SDK_TITLE@ installer version @SDK_VERSION@" | ||
| 136 | printf "%s\n" "$titlestr" | ||
| 137 | printf "%${#titlestr}s\n" | tr " " "=" | ||
| 138 | |||
| 139 | if [ $verbose = 1 ] ; then | ||
| 140 | set -x | ||
| 141 | fi | ||
| 142 | |||
| 143 | @SDK_PRE_INSTALL_COMMAND@ | ||
| 144 | |||
| 145 | # SDK_EXTENSIBLE is exposed from the SDK_PRE_INSTALL_COMMAND above | ||
| 146 | if [ "$SDK_EXTENSIBLE" = "1" ]; then | ||
| 147 | DEFAULT_INSTALL_DIR="@SDKEXTPATH@" | ||
| 148 | fi | ||
| 149 | |||
| 150 | if [ "$target_sdk_dir" = "" ]; then | ||
| 151 | if [ "$answer" = "Y" ]; then | ||
| 152 | target_sdk_dir="$DEFAULT_INSTALL_DIR" | ||
| 153 | else | ||
| 154 | read -p "Enter target directory for SDK (default: $DEFAULT_INSTALL_DIR): " target_sdk_dir | ||
| 155 | [ "$target_sdk_dir" = "" ] && target_sdk_dir=$DEFAULT_INSTALL_DIR | ||
| 156 | fi | ||
| 157 | fi | ||
| 158 | |||
| 159 | eval target_sdk_dir=$(echo "$target_sdk_dir"|sed 's/ /\\ /g') | ||
| 160 | if [ -d "$target_sdk_dir" ]; then | ||
| 161 | target_sdk_dir=$(cd "$target_sdk_dir"; pwd) | ||
| 162 | else | ||
| 163 | target_sdk_dir=$(readlink -m "$target_sdk_dir") | ||
| 164 | fi | ||
| 165 | |||
| 166 | # limit the length for target_sdk_dir, ensure the relocation behaviour in relocate_sdk.py has right result. | ||
| 167 | # This is due to ELF interpreter being set to 'a'*1024 in | ||
| 168 | # meta/recipes-core/meta/uninative-tarball.bb | ||
| 169 | if [ ${#target_sdk_dir} -gt 1024 ]; then | ||
| 170 | echo "Error: The target directory path is too long!!!" | ||
| 171 | exit 1 | ||
| 172 | fi | ||
| 173 | |||
| 174 | if [ "$SDK_EXTENSIBLE" = "1" ]; then | ||
| 175 | # We're going to be running the build system, additional restrictions apply | ||
| 176 | if echo "$target_sdk_dir" | grep -q '[+\ @$]'; then | ||
| 177 | echo "The target directory path ($target_sdk_dir) contains illegal" \ | ||
| 178 | "characters such as spaces, @, \$ or +. Abort!" | ||
| 179 | exit 1 | ||
| 180 | fi | ||
| 181 | # The build system doesn't work well with /tmp on NFS | ||
| 182 | fs_dev_path="$target_sdk_dir" | ||
| 183 | while [ ! -d "$fs_dev_path" ] ; do | ||
| 184 | fs_dev_path=`dirname $fs_dev_path` | ||
| 185 | done | ||
| 186 | fs_dev_type=`stat -f -c '%t' "$fs_dev_path"` | ||
| 187 | if [ "$fsdevtype" = "6969" ] ; then | ||
| 188 | echo "The target directory path $target_sdk_dir is on NFS, this is not possible. Abort!" | ||
| 189 | exit 1 | ||
| 190 | fi | ||
| 191 | else | ||
| 192 | if [ -n "$(echo $target_sdk_dir|grep ' ')" ]; then | ||
| 193 | echo "The target directory path ($target_sdk_dir) contains spaces. Abort!" | ||
| 194 | exit 1 | ||
| 195 | fi | ||
| 196 | fi | ||
| 197 | |||
| 198 | if [ -e "$target_sdk_dir/environment-setup-@REAL_MULTIMACH_TARGET_SYS@" ]; then | ||
| 199 | echo "The directory \"$target_sdk_dir\" already contains vcontainer tools." | ||
| 200 | printf "If you continue, existing files will be overwritten! Proceed [y/N]? " | ||
| 201 | |||
| 202 | default_answer="n" | ||
| 203 | else | ||
| 204 | printf "You are about to install vcontainer tools (vdkr/vpdmn) to \"$target_sdk_dir\". Proceed [Y/n]? " | ||
| 205 | |||
| 206 | default_answer="y" | ||
| 207 | fi | ||
| 208 | |||
| 209 | if [ "$answer" = "" ]; then | ||
| 210 | read answer | ||
| 211 | [ "$answer" = "" ] && answer="$default_answer" | ||
| 212 | else | ||
| 213 | echo $answer | ||
| 214 | fi | ||
| 215 | |||
| 216 | if [ "$answer" != "Y" -a "$answer" != "y" ]; then | ||
| 217 | echo "Installation aborted!" | ||
| 218 | exit 1 | ||
| 219 | fi | ||
| 220 | |||
| 221 | # Try to create the directory (this will not succeed if user doesn't have rights) | ||
| 222 | mkdir -p $target_sdk_dir >/dev/null 2>&1 | ||
| 223 | |||
| 224 | # if don't have the right to access dir, gain by sudo | ||
| 225 | if [ ! -x $target_sdk_dir -o ! -w $target_sdk_dir -o ! -r $target_sdk_dir ]; then | ||
| 226 | if [ "$SDK_EXTENSIBLE" = "1" ]; then | ||
| 227 | echo "Unable to access \"$target_sdk_dir\", will not attempt to use" \ | ||
| 228 | "sudo as as extensible SDK cannot be used as root." | ||
| 229 | exit 1 | ||
| 230 | fi | ||
| 231 | |||
| 232 | SUDO_EXEC=$(command -v "sudo") | ||
| 233 | if [ -z $SUDO_EXEC ]; then | ||
| 234 | echo "No command 'sudo' found, please install sudo first. Abort!" | ||
| 235 | exit 1 | ||
| 236 | fi | ||
| 237 | |||
| 238 | # test sudo could gain root right | ||
| 239 | $SUDO_EXEC pwd >/dev/null 2>&1 | ||
| 240 | [ $? -ne 0 ] && echo "Sorry, you are not allowed to execute as root." && exit 1 | ||
| 241 | |||
| 242 | # now that we have sudo rights, create the directory | ||
| 243 | $SUDO_EXEC mkdir -p $target_sdk_dir >/dev/null 2>&1 | ||
| 244 | fi | ||
| 245 | |||
| 246 | printf "Extracting vcontainer tools..." | ||
| 247 | if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then | ||
| 248 | if [ -z "$(command -v unzip)" ]; then | ||
| 249 | echo "Aborted, unzip is required to extract the SDK archive, please make sure it's installed on your system!" | ||
| 250 | exit 1 | ||
| 251 | fi | ||
| 252 | tail -n +$payload_offset "$0" > sdk.zip | ||
| 253 | if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then | ||
| 254 | rm sdk.zip | ||
| 255 | else | ||
| 256 | rm sdk.zip && exit 1 | ||
| 257 | fi | ||
| 258 | elif [ @SDK_ARCHIVE_TYPE@ = "tar.zst" ]; then | ||
| 259 | if [ -z "$(command -v zstd)" ]; then | ||
| 260 | echo "Aborted, zstd is required to extract the SDK archive, please make sure it's installed on your system!" | ||
| 261 | exit 1 | ||
| 262 | fi | ||
| 263 | tail -n +$payload_offset "$0"| zstd -T0 -dc | $SUDO_EXEC tar mx -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 | ||
| 264 | else | ||
| 265 | if [ -z "$(command -v xz)" ]; then | ||
| 266 | echo "Aborted, xz is required to extract the SDK archive, please make sure it's installed on your system!" | ||
| 267 | exit 1 | ||
| 268 | fi | ||
| 269 | tail -n +$payload_offset "$0"| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 | ||
| 270 | fi | ||
| 271 | echo "done" | ||
| 272 | |||
| 273 | printf "Configuring paths..." | ||
| 274 | # fix environment paths | ||
| 275 | real_env_setup_script="" | ||
| 276 | for env_setup_script in `ls $target_sdk_dir/environment-setup-*`; do | ||
| 277 | if grep -q 'OECORE_NATIVE_SYSROOT=' $env_setup_script; then | ||
| 278 | # Handle custom env setup scripts that are only named | ||
| 279 | # environment-setup-* so that they have relocation | ||
| 280 | # applied - what we want beyond here is the main one | ||
| 281 | # rather than the one that simply sorts last | ||
| 282 | real_env_setup_script="$env_setup_script" | ||
| 283 | fi | ||
| 284 | $SUDO_EXEC sed -e "s:@SDKPATH@:$target_sdk_dir:g" -i $env_setup_script | ||
| 285 | done | ||
| 286 | if [ -n "$real_env_setup_script" ] ; then | ||
| 287 | env_setup_script="$real_env_setup_script" | ||
| 288 | fi | ||
| 289 | echo "done" | ||
| 290 | |||
| 291 | @SDK_POST_INSTALL_COMMAND@ | ||
| 292 | |||
| 293 | # delete the relocating script, so that user is forced to re-run the installer | ||
| 294 | # if he/she wants another location for the sdk | ||
| 295 | if [ $savescripts = 0 ] ; then | ||
| 296 | $SUDO_EXEC rm -f ${env_setup_script%/*}/relocate_sdk.py ${env_setup_script%/*}/relocate_sdk.sh | ||
| 297 | fi | ||
| 298 | |||
| 299 | # Execute post-relocation script | ||
| 300 | post_relocate="$target_sdk_dir/post-relocate-setup.sh" | ||
| 301 | if [ -e "$post_relocate" ]; then | ||
| 302 | $SUDO_EXEC sed -e "s:@SDKPATH@:$target_sdk_dir:g" -i $post_relocate | ||
| 303 | $SUDO_EXEC /bin/sh $post_relocate "$target_sdk_dir" "@SDKPATH@" | ||
| 304 | if [ $? -ne 0 ]; then | ||
| 305 | echo "Executing $post_relocate failed" | ||
| 306 | exit 1 | ||
| 307 | fi | ||
| 308 | $SUDO_EXEC rm -f $post_relocate | ||
| 309 | fi | ||
| 310 | |||
| 311 | echo "" | ||
| 312 | echo "vcontainer tools installed successfully!" | ||
| 313 | echo "" | ||
| 314 | echo "To use, source the environment script:" | ||
| 315 | echo " \$ . $target_sdk_dir/init-env.sh" | ||
| 316 | echo "" | ||
| 317 | echo "Architectures included: @VCONTAINER_ARCHITECTURES@" | ||
| 318 | echo "" | ||
| 319 | echo "Then run:" | ||
| 320 | echo " \$ vdkr-<arch> images # Docker" | ||
| 321 | echo " \$ vpdmn-<arch> images # Podman" | ||
| 322 | echo "" | ||
| 323 | |||
| 324 | exit 0 | ||
| 325 | |||
| 326 | MARKER: | ||
diff --git a/recipes-containers/vcontainer/files/vrunner.sh b/recipes-containers/vcontainer/files/vrunner.sh index 588261ff..2be33765 100755 --- a/recipes-containers/vcontainer/files/vrunner.sh +++ b/recipes-containers/vcontainer/files/vrunner.sh | |||
| @@ -872,6 +872,16 @@ if [ -n "$STATE_DIR" ]; then | |||
| 872 | mkdir -p "$STATE_DIR" | 872 | mkdir -p "$STATE_DIR" |
| 873 | STATE_IMG="$STATE_DIR/$STATE_FILE" | 873 | STATE_IMG="$STATE_DIR/$STATE_FILE" |
| 874 | 874 | ||
| 875 | # Migration: vpdmn used to use docker-state.img, now uses podman-state.img | ||
| 876 | # If old file exists but new file doesn't, rename it automatically | ||
| 877 | if [ "$STATE_FILE" = "podman-state.img" ]; then | ||
| 878 | OLD_STATE_IMG="$STATE_DIR/docker-state.img" | ||
| 879 | if [ -f "$OLD_STATE_IMG" ] && [ ! -f "$STATE_IMG" ]; then | ||
| 880 | log "INFO" "Migrating old vpdmn state file: docker-state.img -> podman-state.img" | ||
| 881 | mv "$OLD_STATE_IMG" "$STATE_IMG" | ||
| 882 | fi | ||
| 883 | fi | ||
| 884 | |||
| 875 | if [ ! -f "$STATE_IMG" ]; then | 885 | if [ ! -f "$STATE_IMG" ]; then |
| 876 | log "INFO" "Creating new state disk at $STATE_IMG..." | 886 | log "INFO" "Creating new state disk at $STATE_IMG..." |
| 877 | # Create 2GB state disk for Docker storage | 887 | # Create 2GB state disk for Docker storage |
