mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
jw-pkg compile-templates: Beautify logging
Don't renew files with nothing to change, and be verbose about it. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
19bc4037c0
commit
c2ad910e91
1 changed files with 27 additions and 3 deletions
|
|
@ -2,7 +2,25 @@
|
||||||
|
|
||||||
log()
|
log()
|
||||||
{
|
{
|
||||||
echo "$myname: $@"
|
if [ "$1" = -n ]; then
|
||||||
|
shift
|
||||||
|
echo -n "$myname: $*"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = -c ]; then
|
||||||
|
shift
|
||||||
|
echo "$*"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = -C ]; then
|
||||||
|
shift
|
||||||
|
echo -n "$*"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$myname: $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_present()
|
channel_present()
|
||||||
|
|
@ -309,18 +327,24 @@ cmd_compile_templates()
|
||||||
}
|
}
|
||||||
# TODO: use mktemp -d and keep temporary files in read-only dir
|
# TODO: use mktemp -d and keep temporary files in read-only dir
|
||||||
local tmp=$to.tmp
|
local tmp=$to.tmp
|
||||||
log "Applying macros in $table to $f."
|
log -n "Applying macros in $table to $f"
|
||||||
eval `sed "/$conf_patt/ !d; s/$conf_patt//" $table`
|
eval `sed "/$conf_patt/ !d; s/$conf_patt//" $table`
|
||||||
sed 's|^[ ]*#.*||; s|/|\\/|g; s|\([^ =]\+\)[ =]\+\(.*\)|s/\1/\2/g|' $table | sed -f - $f > $tmp
|
sed 's|^[ ]*#.*||; s|/|\\/|g; s|\([^ =]\+\)[ =]\+\(.*\)|s/\1/\2/g|' $table | sed -f - $f > $tmp
|
||||||
chmod $mode $tmp
|
chmod $mode $tmp
|
||||||
chown $owner $tmp
|
chown $owner $tmp
|
||||||
chgrp $group $tmp
|
chgrp $group $tmp
|
||||||
|
if diff -q $tmp $to >/dev/null 2>&1 && [ "$(stat --format '%u:%g:%A' $to)" = "$(stat --format '%u:%g:%A' $tmp)" ]; then
|
||||||
|
log -c ", no changes."
|
||||||
|
rm $tmp
|
||||||
|
continue
|
||||||
|
fi
|
||||||
local bak=$to$template_bak_ext
|
local bak=$to$template_bak_ext
|
||||||
if [ "$backup" = 1 -a -f $to ] && ! diff -q $to $bak >/dev/null 2>&1; then
|
if [ "$backup" = 1 -a -f $to ] && ! diff -q $to $bak >/dev/null 2>&1; then
|
||||||
log "Saving backup to $to to $bak"
|
log -C ", saving backup to $to to $bak,"
|
||||||
cp -p $to $bak
|
cp -p $to $bak
|
||||||
fi
|
fi
|
||||||
mv $tmp $to
|
mv $tmp $to
|
||||||
|
log -c ", done."
|
||||||
done <<< $(cmd_list_templates "$@")
|
done <<< $(cmd_list_templates "$@")
|
||||||
|
|
||||||
if [ "$missing_table" != 0 ]; then
|
if [ "$missing_table" != 0 ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue