[build] Fix against stray tmp.XXXXXX files in ./dpkg dir #20773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why I did it
I don't like a bunch of useless tempdirs laying around.
Resolves: #20772
How I did it
The make function SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR is not always run, but if it's parsed, the $(shell) calls would be executed. They caused tempdirs to be created. But only if the function was run, were those dirs cleaned up.
This change moves the tempdir creation to the function run.
Additionally it moves the trap EXIT two lines earlier, so that a failing mount would not leave useless dirs either.
How to verify it
Run
make
and observe how at the end there aren't lots of stale temp dirs./dpkg
.Which release branch to backport (provide reason below if selected)
I think this change could be backported to at least the active 202405 branch, but it's not strictly necessary.
Tested branch (Please provide the tested image version)
master