[Xenial,SRU,1/1] UBUNTU: [Debian] autoreconstruct - add resoration of execute permissions
diff mbox series

Message ID 20200205122459.4398-2-po-hsu.lin@canonical.com
State New
Headers show
Series
  • [Xenial,SRU,1/1] UBUNTU: [Debian] autoreconstruct - add resoration of execute permissions
Related show

Commit Message

Po-Hsu Lin Feb. 5, 2020, 12:24 p.m. UTC
From: Seth Forshee <seth.forshee@canonical.com>

BugLink: https://bugs.launchpad.net/bugs/1861973

Debian source package diffs cannot represent that a file should
be executable. This is a problem for us if a patch adds a script
which is invoked directly during the build, as happened with a
recent stable update for 4.14. Update gen-auto-reconstruct to
detect this situation and restore the execute permissions in the
reconstruct script. Exclude the debian packaging directories as
the scripts here already account for the loss of execute
permissions.

Signed-off-by: Seth Forshee <seth.foddrshee@canonical.com>
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 debian/scripts/misc/gen-auto-reconstruct | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Patch
diff mbox series

diff --git a/debian/scripts/misc/gen-auto-reconstruct b/debian/scripts/misc/gen-auto-reconstruct
index acc90fe..b20551e 100755
--- a/debian/scripts/misc/gen-auto-reconstruct
+++ b/debian/scripts/misc/gen-auto-reconstruct
@@ -42,6 +42,23 @@  fi
 		echo "rm -f '$name'"
 	done
 
+	# Identify files with execute permissions added since the proffered tag.
+	git diff "$tag.." --raw --no-renames | awk -F '[: \t]' '{print $2, $3, $NF }' | \
+	while IFS=" " read old new name
+	do
+		# Exclude files in debian* directories
+		if [[ "$name" =~ ^debian ]]; then
+			continue
+		fi
+
+		old=$( printf "0%s" $old )
+		new=$( printf "0%s" $new )
+		changed=$(( (old ^ new) & 0111 ))
+		if [ "$changed" -ne 0 ]; then
+			echo "chmod +x '$name'"
+		fi
+	done
+
 	# All done, make sure this does not complete in error.
 	echo "exit 0"
 ) >"$reconstruct"