mkimage-profiles/bin/kflavours-expander
Anton Midyukov 5739103f6c Expand @KFLAVOUR in package lists
The line containing @KFLAVOUR is expanded into several lines,
it is successively replaced with values from the KFLAVOURS variable.
This will allow to specify kernel modules and kernel headers in lists.
2024-03-25 21:42:43 +07:00

22 lines
340 B
Bash
Executable File

#!/bin/sh -efu
kflavours="${1:-}"
[ -n "$kflavours" ] || exit 0
f="${2:-}"
[ -n "$f" ] || exit 0
grep -q @KFLAVOUR "$f" || exit 0
while IFS= read -r line; do
if [[ "$line" =~ @KFLAVOUR ]]; then
for i in $kflavours; do
echo "$line" | sed "s/@KFLAVOUR/$i/"
done
else
echo "$line"
fi
done < "$f" > "$f".temp
mv "$f".temp "$f"