From fafa7da28c9cbe13a2c21f69e3c97f3ec6b6e871 Mon Sep 17 00:00:00 2001 From: Roxana Nicolescu Date: Thu, 6 Apr 2023 19:49:05 +0200 Subject: [PATCH] UBUNTU: [Debian] autoreconstruct - fix restoration of execute permissions BugLink: http://bugs.launchpad.net/bugs/2015498 Debian source package diffs cannot represent that a file should be executable. gen-auto-reconstruct detects the situations where a file has changed its permissions and restores the execute permissions in the reconstruct script, assuming the file has always had execute permission. This does not work in case a file removed the execute permission because the script will change it back. The script now adds either `chmod +x` or `chmod -x` based on the actual permission change. Signed-off-by: Andy Whitcroft Signed-off-by: Roxana Nicolescu Acked-by: Andrei Gherzan Acked-by: Tim Gardner Acked-by: Cory Todd Signed-off-by: Paolo Pisati --- debian/scripts/misc/gen-auto-reconstruct | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/scripts/misc/gen-auto-reconstruct b/debian/scripts/misc/gen-auto-reconstruct index 43ec90345055..a50ceb619f17 100755 --- a/debian/scripts/misc/gen-auto-reconstruct +++ b/debian/scripts/misc/gen-auto-reconstruct @@ -50,7 +50,12 @@ fi new=$( printf "0%s" $new ) changed=$(( (old ^ new) & 0111 )) if [ "$changed" -ne 0 ]; then - echo "chmod +x '$name'" + added=$(( new & 0111 )) + if [ "$added" -ne 0 ]; then + echo "chmod +x '$name'" + else + echo "chmod -x '$name'" + fi fi done