Fix cleanup when kpatch is installed in read-only location

On NixOS files are installed with mode 444 (read-only). This causes
directories in $TEMPDIR to be read-only as well, because they are
created by:

cp -LR "$DATADIR/patch" "$TEMPDIR" || die

which preserves the mode of the directory. We could do
--no-preserve=mode, but this will make people with non-coreutils cp
unhappy. Instead just chmod the files after copying.

If this patch is not applied, cleanup complains like this:

rm: cannot remove '/home/julian/.kpatch/tmp/patch/kpatch.h': Permission denied
rm: cannot remove '/home/julian/.kpatch/tmp/patch/Makefile': Permission denied
rm: cannot remove '/home/julian/.kpatch/tmp/patch/kpatch-macros.h': Permission denied
...

Signed-off-by: Julian Stecklina <julian.stecklina@cyberus-technology.de>
This commit is contained in:
Julian Stecklina 2024-07-12 09:35:02 +02:00
parent 6115a1a4e7
commit 828b557b50
1 changed files with 3 additions and 0 deletions

View File

@ -1236,7 +1236,10 @@ verify_patch_files
apply_patches apply_patches
remove_patches remove_patches
# cp preserves mode and the files might have been read-only. This would
# interfere with cleanup later, so ensure the $TEMPDIR is read/write.
cp -LR "$DATADIR/patch" "$TEMPDIR" || die cp -LR "$DATADIR/patch" "$TEMPDIR" || die
chmod -R u+rw "$TEMPDIR" || die
if [[ "$ARCH" = "ppc64le" ]]; then if [[ "$ARCH" = "ppc64le" ]]; then
ARCH_KCFLAGS="-mcmodel=large -fplugin=$PLUGINDIR/ppc64le-plugin.so" ARCH_KCFLAGS="-mcmodel=large -fplugin=$PLUGINDIR/ppc64le-plugin.so"