Skip to content

Commit f997cb5

Browse files
Merge pull request #492 from balena-os/alexgg/barys-samples
Allow to customize sample templates
2 parents e43e9f0 + 71b8b94 commit f997cb5

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

.github/workflows/yocto-build-deploy.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ on:
102102
required: false
103103
type: boolean
104104
default: false # Always false by default, override on specific device types which this is relevant in the device repo
105+
build-args:
106+
description: Extra barys build arguments
107+
required: false
108+
type: string
105109
# Supported fields for the test matrix:
106110
# - test_suite: (required) The test suite to run. The valid test suites are `os`, `hup`, and `cloud`
107111
# - environment: (required) The balenaCloud environment to use for testing, e.g. `bm.balena-dev.com` or `balena-cloud.com`
@@ -199,7 +203,7 @@ jobs:
199203
automation_dir: "${{ github.workspace }}/balena-yocto-scripts/automation"
200204
BALENARC_BALENA_URL: ${{ vars.BALENA_HOST || inputs.deploy-environment || 'balena-cloud.com' }}
201205
API_ENV: ${{ vars.BALENA_HOST || inputs.deploy-environment || 'balena-cloud.com' }}
202-
BARYS_ARGUMENTS_VAR: ""
206+
BARYS_ARGUMENTS_VAR: ${{ inputs.build-args || '' }}
203207
# https://docs.yoctoproject.org/3.1.21/overview-manual/overview-manual-concepts.html#user-configuration
204208
# Create an autobuilder configuration file that is loaded before local.conf
205209
AUTO_CONF_FILE: "${{ github.workspace }}/build/conf/auto.conf"

build/barys

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ function help {
116116
echo -e "\t\t able to run bitbake commands."
117117
echo -e "\t\t Default: no."
118118

119+
echo -e "\t-t | --templates-path"
120+
echo -e "\t\t Provide a custom absolute path to the layer containing custom sample templates."
121+
echo -e "\t\t For example, if local.conf.sample and bblayers.conf.sample"
122+
echo -e "\t\t are in a /path/to/layer/conf/samples directory, the template path would be /path/to/layer."
123+
echo -e "\t\t Default: Use the ones in the integration BSP layer."
124+
119125
echo -e "\t--rm-work"
120126
echo -e "\t\t Inherit rm_work in local.conf."
121127
echo -e "\t\t Default: no."
@@ -289,6 +295,15 @@ while [[ $# -ge 1 ]]; do
289295
SHARED_SSTATE=$2
290296
shift
291297
;;
298+
-t|--templates-path)
299+
# Argument needs to be non-empty
300+
if [ -z "$2" ]; then
301+
log ERROR "\"$1\" argument is invalid."
302+
fi
303+
LAYERSCONF_PATH=$2
304+
log WARN "LAYERSCONF_PATH: $LAYERSCONF_PATH"
305+
shift
306+
;;
292307
-l|--log)
293308
LOG=yes
294309
;;
@@ -371,6 +386,16 @@ while [[ $# -ge 1 ]]; do
371386
;;
372387
esac
373388

389+
read -p "Custom templates path? yes/[no] " yn
390+
case $yn in
391+
[Yy]* )
392+
read -p "Templated path? " LAYERSCONF_PATH
393+
if [ -z "$LAYERSCONF_PATH" ]; then
394+
log ERROR "Provided path is invalid."
395+
fi
396+
;;
397+
esac
398+
374399
read -p "Generate log? yes/[no] " yn
375400
case $yn in
376401
[Yy]* ) LOG=yes;;
@@ -418,6 +443,7 @@ if [ "z$LOG" == "zyes" ]; then
418443
echo "Compressed image? $COMPRESS" >> $LOGFILE
419444
echo "Shared downloads directory: $SHARED_DOWNLOADS" >> $LOGFILE
420445
echo "Shared sstate directory: $SHARED_SSTATE" >> $LOGFILE
446+
echo "Custom templates path: $LAYERSCONF_PATH" >> $LOGFILE
421447
echo "Development image? $DEVELOPMENT_IMAGE" >> $LOGFILE
422448
echo "Forced supervisor image release version: $SUPERVISOR_VERSION" >> $LOGFILE
423449
echo "Inherit rm_work? $RM_WORK" >> $LOGFILE
@@ -431,18 +457,27 @@ if [ "x$REMOVEBUILD" == "xyes" ]; then
431457
rm -rf $SCRIPTPATH/../../$BUILD_DIR
432458
fi
433459

434-
LAYERSCONF_PATH=$(find "${SCRIPTPATH}/../../layers/meta-balena"* -name bblayers.conf.sample)
435-
if [ "$(dirname LAYERSCONF_PATH)" = "samples" ]; then
436-
BALENA_MACHINE_LAYER=$(echo "${LAYERSCONF_PATH}" | awk -F'/' '{print $(NF-3)}')
460+
if [ -z "${LAYERSCONF_PATH}" ] ; then
461+
# Look on the BSP integration layer meta-balena-*
462+
LAYERSCONF_PATH="${SCRIPTPATH}/../../layers/meta-balena"*
437463
else
438-
BALENA_MACHINE_LAYER=$(echo "${LAYERSCONF_PATH}" | awk -F'/' '{print $(NF-4)}')
464+
if [ "${LAYERSCONF_PATH#/}" = "${LAYERSCONF_PATH}" ]; then
465+
if [ "${LAYERSCONF_PATH#layers/}" != "${LAYERSCONF_PATH}" ]; then
466+
LAYERSCONF_PATH="${SCRIPTPATH}/../../${LAYERSCONF_PATH}"
467+
else
468+
log ERROR "The custom templates layer path needs to be either absolute or relative to the build directoty, i.e layers/meta-custom. "
469+
fi
470+
fi
471+
fi
472+
TEMPLATECONF_PATH=$(dirname $(find ${LAYERSCONF_PATH} -name bblayers.conf.sample))
473+
if [ "$(echo "${TEMPLATECONF_PATH}" | wc -w)" -gt "1" ]; then
474+
log ERROR "Multiple bblayers.conf.sample files found in BSP integration layer. Please provide a custom path."
439475
fi
440476

441477
# Configure build
478+
$SCRIPTPATH/generate-conf-notes.sh "${TEMPLATECONF_PATH%/samples}" ${DEVICE_TYPES_JSONS}
442479

443-
$SCRIPTPATH/generate-conf-notes.sh $SCRIPTPATH/../../layers/${BALENA_MACHINE_LAYER}/conf/ ${DEVICE_TYPES_JSONS}
444-
445-
export TEMPLATECONF="$(dirname ${LAYERSCONF_PATH})"
480+
export TEMPLATECONF="${TEMPLATECONF_PATH}"
446481
# scarthgap expects templates to be contained in a subdirectory inside templates/
447482
if [ -d "${TEMPLATECONF}/default" ]; then
448483
TEMPLATECONF="${TEMPLATECONF}/default"

0 commit comments

Comments
 (0)