#!/bin/bash # # Copyright (c) 2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # set -e source $(dirname "$0")/lib/job_utils.sh require_job_env BUILD_HOME require_job_env REMOTE_BUILD_HOME require_job_env REMOTE_SERVER load_build_env # Prepare the folder to receive the base ostree repository DEPLOY_DIR="${BUILD_HOME}/localdisk/deploy" # Name of the folder where we will copy the remote repository OSTREE_BASE="ostree_base" # Full path to the remote ostree repository REMOTE_BUILD_OSTREE=${REMOTE_BUILD_HOME}/localdisk/deploy/ostree_repo mkdir -p "${DEPLOY_DIR}" && cd "$_" # Init ostree repo ostree_cmd ${DRY_RUN_ARG} ${OSTREE_BASE} "init --mode=archive-z2" notice "Pulling content from remote ostree ${REMOTE_SERVER}/${REMOTE_BUILD_HOME}" # Add build as remote ostree_cmd ${DRY_RUN_ARG} ${OSTREE_BASE} "remote add --set=gpg-verify=false deb-build \ ${REMOTE_SERVER}/${REMOTE_BUILD_OSTREE} starlingx" # Pull only the latest commit ostree_cmd ${DRY_RUN_ARG} ${OSTREE_BASE} "pull --depth=0 --mirror deb-build starlingx" # Update ostree summary ostree_cmd ${DRY_RUN_ARG} ${OSTREE_BASE} "summary --update" notice "Pull done, ostree commit log" ostree_cmd ${DRY_RUN_ARG} ${OSTREE_BASE} "log starlingx" if ! $DRY_RUN ; then notice "Fixing ${OSTREE_BASE} permissions" OSTREE_USER=`stat -c %u ${REMOTE_BUILD_OSTREE}` OSTREE_GROUP=`stat -c %g ${REMOTE_BUILD_OSTREE}` notice "Changing ostree permission to match source, user: ${OSTREE_USER}, group: ${OSTREE_GROUP}" docker run --rm --volume "${BUILD_HOME}:${BUILD_HOME}" debian:bullseye chown -R "${OSTREE_USER}:${OSTREE_GROUP}" "${DEPLOY_DIR}/${OSTREE_BASE}" fi