chore: Adjust modules to use the future /tmp/files/ directory (#278)

* chore: Adjust modules to use the future `/tmp/files/` directory

* docs: Replace old `config/` with `files/` directory

* Revert "docs: Replace old `config/` with `files/` directory"

This reverts commit 68870a3d02136860b4f3bca2d34618d71dcae160.

* chore(files): Support new recipe format proposed by @xynydev

* chore(files): Support legacy recipe format along with new one

Mixed usage of it in recipe is supported too.

---------

Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
Co-authored-by: xyny <60004820+xynydev@users.noreply.github.com>
This commit is contained in:
fiftydinar 2024-07-21 12:10:32 +02:00 committed by GitHub
parent 6d4597e56c
commit 55858a8d83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 4 deletions

View file

@ -5,14 +5,32 @@ set -euo pipefail
get_yaml_array FILES '.files[]' "$1"
cd "$CONFIG_DIRECTORY/files"
shopt -s dotglob
# Support for legacy "/tmp/config/" to satisfy transition period to "/tmp/files/"
if [[ "${CONFIG_DIRECTORY}" == "/tmp/config" ]]; then
FILES_DIR="${CONFIG_DIRECTORY}/files"
elif [[ "${CONFIG_DIRECTORY}" == "/tmp/files" ]]; then
FILES_DIR="${CONFIG_DIRECTORY}"
fi
cd "${FILES_DIR}"
shopt -s dotglob
if [[ ${#FILES[@]} -gt 0 ]]; then
echo "Adding files to image"
for pair in "${FILES[@]}"; do
# Support for legacy recipe format to satisfy transition period to new source/destination recipe format
if [[ $(echo $pair | yq '.source') == "null" || -z $(echo $pair | yq '.source') ]] && [[ $(echo $pair | yq '.destination') == "null" || -z $(echo $pair | yq '.destination') ]]; then
echo "ATTENTION: You are using the legacy module recipe format"
echo " It is advised to switch to new module recipe format,"
echo " which contains 'source' & 'destination' YAML keys"
echo " For more details, please visit 'files' module documentation:"
echo " https://blue-build.org/reference/modules/files/"
FILE="$PWD/$(echo $pair | yq 'to_entries | .[0].key')"
DEST=$(echo $pair | yq 'to_entries | .[0].value')
else
FILE="$PWD/$(echo $pair | yq '.source')"
DEST=$(echo $pair | yq '.destination')
fi
if [ -d "$FILE" ]; then
if [ ! -d "$DEST" ]; then
mkdir -p "$DEST"
@ -29,7 +47,7 @@ if [[ ${#FILES[@]} -gt 0 ]]; then
cp -f $FILE $DEST
rm -f "$DEST"/.gitkeep
else
echo "File or Directory $FILE Does Not Exist in $CONFIG_DIRECTORY/files"
echo "File or Directory $FILE Does Not Exist in ${FILES_DIR}"
exit 1
fi
done

View file

@ -4,7 +4,7 @@ set -euo pipefail
get_yaml_array INCLUDE '.include[]' "$1"
schema_include_location="/tmp/config/gschema-overrides"
schema_include_location="${CONFIG_DIRECTORY}/gschema-overrides"
schema_test_location="/tmp/bluebuild-schema-test"
schema_location="/usr/share/glib-2.0/schemas"
gschema_extension=false