1
0
Fork 0
mirror of https://github.com/pygos/build.git synced 2024-11-16 16:37:10 +01:00
build/util/override.sh

59 lines
875 B
Bash
Raw Normal View History

file_path_override() {
local layer
if [ -z "$LAYERCONF" ]; then
return
fi
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
if [ -z "$LAYERCONF" ]; then
return
fi
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
if [ -z "$LAYERCONF" ]; then
return
fi
while read layer; do
if [ -e "$SCRIPTDIR/layer/$layer/$1" ]; then
source "$SCRIPTDIR/layer/$layer/$1"
fi
done < "$LAYERCONF"
}