diff mbox series

[SRU,N,U,M,L,J,F] UBUNTU: [Debian] autoreconstruct - Do not generate chmod -x for deleted files

Message ID 20231204151525.125225-1-roxana.nicolescu@canonical.com
State New
Headers show
Series [SRU,N,U,M,L,J,F] UBUNTU: [Debian] autoreconstruct - Do not generate chmod -x for deleted files | expand

Commit Message

Roxana Nicolescu Dec. 4, 2023, 3:15 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/2045562

Debian source format 1.0 cannot remove files, create symlinks and change
permission in the .diff.gz tarball. Therefore any changes in these 3
categories cannot be represented without any tricks. To solve this,
the `reconstruct` script is used every time we build the source package.
The script is generated by `gen-auto-reconstruct` script during `cranky
close`. It checks if there has been any changes in the 3 categories
mentioned above between the upstream version (i.e v6.5) and the current one.
The problem with the script is that in case a file A was removed since the
upstream version was released, the `reconstruct` script will contains
these commands in this exact order:
        rm -f A
        chmod -x A
The second command will fail because file A does not exist anymore.
This is solved by generating the `chmod +/-x` commands before `rm`.
Which results in:
        chmod -x A
        rm -f A
But because the reconstruct script is used during `clean` rule which is
triggered pretty much during every cranky step which is run in the
source repo, the first command will always file because file A is not
present anymore in the tree. To solved this, any `chmod` change is added
only if the file has not been deleted. Therefore if file A has been
deleted, the `reconstruct` script will contain only this:
        rm -f A

Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
---
 debian/scripts/misc/gen-auto-reconstruct | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Dimitri John Ledkov Dec. 5, 2023, 12:18 a.m. UTC | #1
On Mon, 4 Dec 2023 at 15:16, Roxana Nicolescu
<roxana.nicolescu@canonical.com> wrote:
>
> BugLink: https://bugs.launchpad.net/bugs/2045562
>
> Debian source format 1.0 cannot remove files, create symlinks and change
> permission in the .diff.gz tarball. Therefore any changes in these 3
> categories cannot be represented without any tricks. To solve this,
> the `reconstruct` script is used every time we build the source package.
> The script is generated by `gen-auto-reconstruct` script during `cranky

by the

> close`. It checks if there has been any changes in the 3 categories
> mentioned above between the upstream version (i.e v6.5) and the current one.
> The problem with the script is that in case a file A was removed since the
> upstream version was released, the `reconstruct` script will contains
> these commands in this exact order:
>         rm -f A
>         chmod -x A
> The second command will fail because file A does not exist anymore.
> This is solved by generating the `chmod +/-x` commands before `rm`.
> Which results in:
>         chmod -x A
>         rm -f A
> But because the reconstruct script is used during `clean` rule which is
> triggered pretty much during every cranky step which is run in the
> source repo, the first command will always file because file A is not

fail because file

> present anymore in the tree. To solved this, any `chmod` change is added

solve this

> only if the file has not been deleted. Therefore if file A has been
> deleted, the `reconstruct` script will contain only this:
>         rm -f A
>
> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
> ---
>  debian/scripts/misc/gen-auto-reconstruct | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/debian/scripts/misc/gen-auto-reconstruct b/debian/scripts/misc/gen-auto-reconstruct
> index a50ceb619f17..87a6ff6ef0f0 100755
> --- a/debian/scripts/misc/gen-auto-reconstruct
> +++ b/debian/scripts/misc/gen-auto-reconstruct
> @@ -34,14 +34,6 @@ fi
>                 echo "[ ! -L '$name' ] && ln -sf '$link' '$name'"
>         done
>
> -       # Identify all removed files since the proffered tag.
> -       echo "# Remove any files deleted from the orig."
> -       git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> -       while read name
> -       do
> -               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
> @@ -53,12 +45,20 @@ fi
>                         added=$(( new & 0111 ))
>                         if [ "$added" -ne 0 ]; then
>                                 echo "chmod +x '$name'"
> -                       else
> +                       elif [ "$new" -ne 0 ]; then
>                                 echo "chmod -x '$name'"
>                         fi
>                 fi
>         done
>
> +       # Identify all removed files since the proffered tag.
> +       echo "# Remove any files deleted from the orig."
> +       git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> +       while read name
> +       do
> +               echo "rm -f '$name'"
> +       done
> +
>         # All done, make sure this does not complete in error.
>         echo "exit 0"
>  ) >"$reconstruct"
> --

Acked-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>

spelling typos in the commit message can be fixed up on application.
Manuel Diewald Dec. 5, 2023, 4:27 p.m. UTC | #2
On Mon, Dec 04, 2023 at 04:15:25PM +0100, Roxana Nicolescu wrote:
> BugLink: https://bugs.launchpad.net/bugs/2045562
> 
> Debian source format 1.0 cannot remove files, create symlinks and change
> permission in the .diff.gz tarball. Therefore any changes in these 3
> categories cannot be represented without any tricks. To solve this,
> the `reconstruct` script is used every time we build the source package.
> The script is generated by `gen-auto-reconstruct` script during `cranky
> close`. It checks if there has been any changes in the 3 categories
> mentioned above between the upstream version (i.e v6.5) and the current one.
> The problem with the script is that in case a file A was removed since the
> upstream version was released, the `reconstruct` script will contains
> these commands in this exact order:
>         rm -f A
>         chmod -x A
> The second command will fail because file A does not exist anymore.
> This is solved by generating the `chmod +/-x` commands before `rm`.
> Which results in:
>         chmod -x A
>         rm -f A
> But because the reconstruct script is used during `clean` rule which is
> triggered pretty much during every cranky step which is run in the
> source repo, the first command will always file because file A is not
> present anymore in the tree. To solved this, any `chmod` change is added
> only if the file has not been deleted. Therefore if file A has been
> deleted, the `reconstruct` script will contain only this:
>         rm -f A
> 
> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
> ---
>  debian/scripts/misc/gen-auto-reconstruct | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/debian/scripts/misc/gen-auto-reconstruct b/debian/scripts/misc/gen-auto-reconstruct
> index a50ceb619f17..87a6ff6ef0f0 100755
> --- a/debian/scripts/misc/gen-auto-reconstruct
> +++ b/debian/scripts/misc/gen-auto-reconstruct
> @@ -34,14 +34,6 @@ fi
>  		echo "[ ! -L '$name' ] && ln -sf '$link' '$name'"
>  	done
>  
> -	# Identify all removed files since the proffered tag.
> -	echo "# Remove any files deleted from the orig."
> -	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> -	while read name
> -	do
> -		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
> @@ -53,12 +45,20 @@ fi
>  			added=$(( new & 0111 ))
>  			if [ "$added" -ne 0 ]; then
>  				echo "chmod +x '$name'"
> -			else
> +                       elif [ "$new" -ne 0 ]; then
>  				echo "chmod -x '$name'"
>  			fi
>  		fi
>  	done
>  
> +       # Identify all removed files since the proffered tag.
> +	echo "# Remove any files deleted from the orig."
> +	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> +	while read name
> +	do
> +		echo "rm -f '$name'"
> +	done
> +
>  	# All done, make sure this does not complete in error.
>  	echo "exit 0"
>  ) >"$reconstruct"
> -- 
> 2.34.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Acked-by: Manuel Diewald <manuel.diewald@canonical.com>
Andrea Righi Jan. 2, 2024, 12:08 p.m. UTC | #3
On Mon, Dec 04, 2023 at 04:15:25PM +0100, Roxana Nicolescu wrote:
> BugLink: https://bugs.launchpad.net/bugs/2045562
> 
> Debian source format 1.0 cannot remove files, create symlinks and change
> permission in the .diff.gz tarball. Therefore any changes in these 3
> categories cannot be represented without any tricks. To solve this,
> the `reconstruct` script is used every time we build the source package.
> The script is generated by `gen-auto-reconstruct` script during `cranky
> close`. It checks if there has been any changes in the 3 categories
> mentioned above between the upstream version (i.e v6.5) and the current one.
> The problem with the script is that in case a file A was removed since the
> upstream version was released, the `reconstruct` script will contains
> these commands in this exact order:
>         rm -f A
>         chmod -x A
> The second command will fail because file A does not exist anymore.
> This is solved by generating the `chmod +/-x` commands before `rm`.
> Which results in:
>         chmod -x A
>         rm -f A
> But because the reconstruct script is used during `clean` rule which is
> triggered pretty much during every cranky step which is run in the
> source repo, the first command will always file because file A is not
> present anymore in the tree. To solved this, any `chmod` change is added
> only if the file has not been deleted. Therefore if file A has been
> deleted, the `reconstruct` script will contain only this:
>         rm -f A
> 
> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>

Applied to noble/linux-unstable (with the small typo fixes from Dimitri).

Thanks!
-Andrea

> ---
>  debian/scripts/misc/gen-auto-reconstruct | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/debian/scripts/misc/gen-auto-reconstruct b/debian/scripts/misc/gen-auto-reconstruct
> index a50ceb619f17..87a6ff6ef0f0 100755
> --- a/debian/scripts/misc/gen-auto-reconstruct
> +++ b/debian/scripts/misc/gen-auto-reconstruct
> @@ -34,14 +34,6 @@ fi
>  		echo "[ ! -L '$name' ] && ln -sf '$link' '$name'"
>  	done
>  
> -	# Identify all removed files since the proffered tag.
> -	echo "# Remove any files deleted from the orig."
> -	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> -	while read name
> -	do
> -		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
> @@ -53,12 +45,20 @@ fi
>  			added=$(( new & 0111 ))
>  			if [ "$added" -ne 0 ]; then
>  				echo "chmod +x '$name'"
> -			else
> +                       elif [ "$new" -ne 0 ]; then
>  				echo "chmod -x '$name'"
>  			fi
>  		fi
>  	done
>  
> +       # Identify all removed files since the proffered tag.
> +	echo "# Remove any files deleted from the orig."
> +	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> +	while read name
> +	do
> +		echo "rm -f '$name'"
> +	done
> +
>  	# All done, make sure this does not complete in error.
>  	echo "exit 0"
>  ) >"$reconstruct"
> -- 
> 2.34.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Roxana Nicolescu Jan. 4, 2024, 7:23 p.m. UTC | #4
On 04/12/2023 16:15, Roxana Nicolescu wrote:
> BugLink: https://bugs.launchpad.net/bugs/2045562
>
> Debian source format 1.0 cannot remove files, create symlinks and change
> permission in the .diff.gz tarball. Therefore any changes in these 3
> categories cannot be represented without any tricks. To solve this,
> the `reconstruct` script is used every time we build the source package.
> The script is generated by `gen-auto-reconstruct` script during `cranky
> close`. It checks if there has been any changes in the 3 categories
> mentioned above between the upstream version (i.e v6.5) and the current one.
> The problem with the script is that in case a file A was removed since the
> upstream version was released, the `reconstruct` script will contains
> these commands in this exact order:
>          rm -f A
>          chmod -x A
> The second command will fail because file A does not exist anymore.
> This is solved by generating the `chmod +/-x` commands before `rm`.
> Which results in:
>          chmod -x A
>          rm -f A
> But because the reconstruct script is used during `clean` rule which is
> triggered pretty much during every cranky step which is run in the
> source repo, the first command will always file because file A is not
> present anymore in the tree. To solved this, any `chmod` change is added
> only if the file has not been deleted. Therefore if file A has been
> deleted, the `reconstruct` script will contain only this:
>          rm -f A
>
> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
> ---
>   debian/scripts/misc/gen-auto-reconstruct | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/debian/scripts/misc/gen-auto-reconstruct b/debian/scripts/misc/gen-auto-reconstruct
> index a50ceb619f17..87a6ff6ef0f0 100755
> --- a/debian/scripts/misc/gen-auto-reconstruct
> +++ b/debian/scripts/misc/gen-auto-reconstruct
> @@ -34,14 +34,6 @@ fi
>   		echo "[ ! -L '$name' ] && ln -sf '$link' '$name'"
>   	done
>   
> -	# Identify all removed files since the proffered tag.
> -	echo "# Remove any files deleted from the orig."
> -	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> -	while read name
> -	do
> -		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
> @@ -53,12 +45,20 @@ fi
>   			added=$(( new & 0111 ))
>   			if [ "$added" -ne 0 ]; then
>   				echo "chmod +x '$name'"
> -			else
> +                       elif [ "$new" -ne 0 ]; then
>   				echo "chmod -x '$name'"
>   			fi
>   		fi
>   	done
>   
> +       # Identify all removed files since the proffered tag.
> +	echo "# Remove any files deleted from the orig."
> +	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
> +	while read name
> +	do
> +		echo "rm -f '$name'"
> +	done
> +
>   	# All done, make sure this does not complete in error.
>   	echo "exit 0"
>   ) >"$reconstruct"
Applied to mantic, lunar, jammy, focal master-next branch with the 
adjustements suggested by Dimitri. Thanks!
diff mbox series

Patch

diff --git a/debian/scripts/misc/gen-auto-reconstruct b/debian/scripts/misc/gen-auto-reconstruct
index a50ceb619f17..87a6ff6ef0f0 100755
--- a/debian/scripts/misc/gen-auto-reconstruct
+++ b/debian/scripts/misc/gen-auto-reconstruct
@@ -34,14 +34,6 @@  fi
 		echo "[ ! -L '$name' ] && ln -sf '$link' '$name'"
 	done
 
-	# Identify all removed files since the proffered tag.
-	echo "# Remove any files deleted from the orig."
-	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
-	while read name
-	do
-		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
@@ -53,12 +45,20 @@  fi
 			added=$(( new & 0111 ))
 			if [ "$added" -ne 0 ]; then
 				echo "chmod +x '$name'"
-			else
+                       elif [ "$new" -ne 0 ]; then
 				echo "chmod -x '$name'"
 			fi
 		fi
 	done
 
+       # Identify all removed files since the proffered tag.
+	echo "# Remove any files deleted from the orig."
+	git diff "$tag.." --raw --no-renames | awk '(/^:/ && $5 == "D") { print $NF }' | \
+	while read name
+	do
+		echo "rm -f '$name'"
+	done
+
 	# All done, make sure this does not complete in error.
 	echo "exit 0"
 ) >"$reconstruct"