Skip to contentSkip to conversation

scripts/oe-replicate-build: add a script that packages and replicates a yocto build elsewhere

RFC PATCH In review Alexander Kanavin 2 participants 2 messages Nov 7, 2023

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 scripts/oe-replicate-build: add a script that packages and replicates a yocto build elsewhere

This scripts takes an existing, active yocto build, and puts pieces of it into a bundle directory, which is then placed in a tarball, and a self-extracting shell archive. This allows moving the bundle to another machine, or placing it on a network server for downloads.

The bundle includes:
- a json/script to restore the layers at the correct revisions from the network
- build configuration as a template in a special layer private to the bundle
- (this is the best bit) all the sstate needed for the specified target, but *only* that sstate and not a complete copy of the local cache.

When someone runs the self-extracting shell archive, everything should 'just work': the layers are restored, and the build
set up to use them, the bundle sstate cache, and the template configuration.

Alternatively, it's possible to not include the cache, and presumably it will come from a configured sstate mirror.

This enables at least two*scratch*three interesting use cases:

- moving builds around in single-step fashion: run the script, and give the artifact to someone else via file sharing or usb sticks.

- publishing builds on the network, perhaps right next to the sstate cache that can fulfil them. This allows an alternative, much smoother entry point into 'doing yocto', as this guarantees availability of needed cache items, and so builds will be a lot faster than the typical 'compile everything from scratch' yocto experience. Sstate is guaranteed to be available, as there's a record of needed items in each bundle, and that record can be used to prevent pruning of still-needed cache items.

- this, in turn, enables 'binary Yocto distro' implemented with sstate, if there's a higher level tool that creates bundles in a systematic, structured fashion, and another tool that iterates over available bundles, and lets users pick them for building locally.

---
 meta/files/replica-shar-extract.sh | 56 ++++++++++++++++++++++++++++++
 scripts/oe-replicate-build         | 56 ++++++++++++++++++++++++++++++
 2 files changed, 112 insertions(+)
 create mode 100644 meta/files/replica-shar-extract.sh
 create mode 100755 scripts/oe-replicate-build
meta/files/replica-shar-extract.sh new file +56 -0
new file mode 100644
index 00000000000..78bb6a524ff
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+verbose=0
+listcontents=0
+prepare_buildsystem="yes"
+while getopts "Dl" OPT; do
+        case $OPT in
+        D)
+                verbose=1
+                ;;
+        l)
+                listcontents=1
+                ;;
+        n)
+                prepare_buildsystem="no"
+                ;;
+        *)
+                echo "Usage: $(basename "$0") [-D] [-l] [-n]"
+                echo "  -D         Use set -x to see what is going on"
+                echo "  -l         list files that will be extracted"
+                echo "  -n         Extract files but do not prepare the build system"
+                exit 1
+                ;;
+        esac
+done
+
+if [ $verbose = 1 ] ; then
+        set -x
+fi
+
+payload_offset=$(($(grep -na -m1 "^MARKER:$" "$0"|cut -d':' -f1) + 1))
+
+if [ "$listcontents" = "1" ] ; then
+    tail -n +$payload_offset "$0"| tar tv || exit 1
+    exit
+fi
+
+
+tail -n +$payload_offset "$0"| tar mx --checkpoint=.2500 || exit 1
+
+if [ $prepare_buildsystem = "no" ] ; then
+        exit
+fi
+
+target_dir=$(basename "$0" .sh)
+pushd $target_dir
+./setup-layers --destdir layers
+TEMPLATECONF=$(pwd)/meta-build-config/conf/templates/replica . layers/poky/oe-init-build-env
+popd
+
+echo "Each time you wish to use build in a new shell session, you need to source the environment setup script e.g."
+echo " \$ . $target_dir/layers/poky/oe-init-build-env $target_dir/build"
+
+exit 0
+
+MARKER:
scripts/oe-replicate-build new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
2.39.2
#1 lore raw

Patchtest results for [RFC PATCH] scripts/oe-replicate-build: add a script that packages and replicates a yocto build elsewhere

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/RFC-scripts-oe-replicate-build-add-a-script-that-packages-and-replicates-a-yocto-build-elsewhere.patch

FAIL: test shortlog length: Edit shortlog so that it is 90 characters or less (currently 93 characters) (test_mbox.TestMbox.test_shortlog_length)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)

SKIP: pretest lic files chksum modified not mentioned: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_lic_files_chksum_modified_not_mentioned)
SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)
SKIP: test target mailing list: Series merged, no reason to check other mailing lists (test_mbox.TestMbox.test_target_mailing_list)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!