postmarketos-base: post-install script will not update configs when updating postmarketos-base
This function allows overwriting configs from Alpine, unless they were modified by the user. The problem is, that when updating postmarketos-base
, we might need to change the config yet again. But then apk audit
will report that the file was modified, and so it does not get replaced. Let's get creative
write_unless_modified() {
# Redirect the stdin to the file unless it has been modified
# $1: file path
if ! apk audit "$(dirname "$1")" | grep -q "${1:1}"; then
cat > "$1"
fi
}