1
0
Fork 0
mirror of https://github.com/pygos/build.git synced 2024-05-09 07:16:13 +02:00
build/util/override.sh
David Oberhollenzer c7231478d5 Restructure build system configuration
Add a generic, stackable layer based structure instead of special purpose
subdirectories with specific behaviour.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-09-23 16:19:52 +02:00

47 lines
743 B
Bash

file_path_override() {
local layer
tac "$LAYERCONF" | while read layer; do
if [ -e "$SCRIPTDIR/layer/$layer/$1" ]; then
echo "$SCRIPTDIR/layer/$layer/$1"
return
fi
done
}
cat_file_override() {
local path=$(file_path_override "$1")
if [ ! -z "$path" ]; then
cat "$path"
fi
}
cat_file_merge() {
local layer
while read layer; do
if [ -e "$SCRIPTDIR/layer/$layer/$1" ]; then
cat "$SCRIPTDIR/layer/$layer/$1"
fi
done < "$LAYERCONF"
}
include_override() {
local path=$(file_path_override "$1")
if [ ! -z "$path" ]; then
source "$path"
fi
}
include_merge() {
local layer
while read layer; do
if [ -e "$SCRIPTDIR/layer/$layer/$1" ]; then
source "$SCRIPTDIR/layer/$layer/$1"
fi
done < "$LAYERCONF"
}