From 97cc7fbecd9c9da37ec4d63bbdd6e82a41e1b54b Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 27 Oct 2026 06:40:24 +0100 Subject: [PATCH] pkg.sh: Fix chown and chmod lines in generated postinst The postinst generator looks up the install log line of each file with a regex grep on the file path, and the dots of the path match any character. When the grep returns several lines, milk_install_log_spec_attr() passes the extra lines through, so the emitted chown and chmod commands split across lines, dpkg -i reports errors for the fragments, and the owner and mode of the file are not applied. Match the end of the log line against the file path literally and take the first match. The install log line ends in the file path, but may carry a build prefix before it, so the literal comparison of the tail of the line selects exactly the line of the file, for plain and %config entries alike. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.4.0 Signed-off-by: Jan Lindemann --- scripts/pkg.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/pkg.sh b/scripts/pkg.sh index 77536a9d..88c042f1 100644 --- a/scripts/pkg.sh +++ b/scripts/pkg.sh @@ -1088,7 +1088,11 @@ cmd_milk_install_log() file=`echo /$file | sed 's/inst-root\///; s%^//*%/%'` #echo file is now \"$file\" >&2 #echo grep \"$prefix/*$file$\" $in >&2 - line=`grep $file$ $in` + # match the end of the log line against + # the file path literally; the line may + # carry a prefix before the path, and a + # regex grep lets dots match other lines + line=`awk -v f="$file" '{ if (substr($0, length($0) - length(f) + 1) == f) print }' $in | head -n 1` perm=`milk_install_log_spec_attr 1 "$line"` owner=`milk_install_log_spec_attr 2 "$line"` group=`milk_install_log_spec_attr 3 "$line"`