flatcar-scripts/bootstrap_sdk_container
Thilo Fromm b567344234 sdk-container: add scripts for containerised SDK
This change introduces a containerised SDK as a replacement for cork SDK
operations. It also simplifies versioning by removing the need for
manifest repos as well as usage of the "repo" tool by use of git
submodules for coreos-overlay and portage-stable.

The following feature scripts are added:
- run_sdk_container: Run a command in an SDK container, using the
        current scripts repo + ebuild submodules.
        current scripts repo + ebuild submodules.
- bootstrap_sdk_container / build_sdk_container_image: Bootstrap a new
        SDK and create an SDK container from the resulting SDK tarball.

The following additions have been made to SDK scripts:
- setup_board: add --pkgdir parameter to use a custom binary packge
  directory.

Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
2021-11-26 17:54:43 +01:00

77 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2021 The Flatcar Maintainers.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -eu
cd $(dirname "$0")
source sdk_lib/sdk_container_common.sh
seed_version=""
target_version=""
vernum="$(strip_version_prefix "$target_version")"
if is_official "$vernum" ; then
official="true"
else
official="false"
fi
cleanup=""
# --
usage() {
echo " Usage:"
echo " $0 <seed-sdk-version> <new-sdk-version> [-x <cleanup-script>]"
echo
echo " This script will bootstrap a new SDK tarball using an SDK container."
echo " '$sdk_container_common_versionfile' will be updated to the target version."
echo
echo " <seed-sdk-vernum> - SDK version number (e.g. '3005.0.0') to use for bootstrapping."
echo " The SDK container will be pulled and the tarball"
echo " downloaded if necessary."
echo " <new-sdk-vernum> - SDK version number (e.g. '3027.0.0') of the new SDK."
echo " -x <cleanup-script> - For each resource generated during build (container etc.)"
echo " add a cleanup line to <script> which, when run, will free"
echo " the resource. Useful for CI."
echo " -h Print this help."
echo
}
# --
while [ 0 -lt $# ] ; do
case "$1" in
-h) usage; exit 0;;
-x) cleanup="-x $2"; shift; shift;;
*) if [ -z "$seed_version" ] ; then
seed_version="$1"
elif [ -z "$target_version" ] ; then
target_version="$1"
else
echo "ERROR: Spurious positional parameter '$1'"
usage; exit 1;
fi
shift;;
esac
done
if [ -z "$seed_version" -o -z "$target_version" ] ; then
echo "ERROR: Missing seed and /or target SDK version."
usage
exit 1
fi
# --
yell "\n######\n###### Bootstrapping SDK version $target_version from seed ($seed_version)"
if $official; then
export COREOS_OFFICIAL=1
fi
# bootstrap_sdk needs FLATCAR_SDK_VERSION set to the seed version
./run_sdk_container $cleanup -V "$seed_version" -v "$target_version" \
sudo -E ./bootstrap_sdk
# Update versionfile to the actual SDK version
create_versionfile "${target_version}"