Skip to contentSkip to conversation

build: Allow to install over dirty dir

PATCH In review Lucas De Marchi 2 participants 2 messages Mar 6, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: Allow to install over dirty dir

Before commit e98cef6f3f8c ("make: install/uninstall tools symlinks to kmod") it was possible to call make install DESTDIR=<dir> multiple times. Use ln -sf so the symlink is always re-created.

It would be preferred to remove install in an empty dir, but there's not a bad consequence of re-using the same, so let the user decide. Fixes the following errors while installing for the second time:

ln: failed to create symbolic link '/tmp/inst/usr/bin/insmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/lsmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/rmmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/depmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/modprobe': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/modinfo': File exists make[3]: *** [Makefile:2679: install-exec-hook] Error 1 make[2]: *** [Makefile:2553: install-exec-am] Error 2
make[1]: *** [Makefile:2439: install-am] Error 2
make: *** [Makefile:1848: install-recursive] Error 1

---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.am +1 -1
index d37b56d..2222c21 100644
@@ -113,7 +113,7 @@ install-exec-hook:
 	fi
 if BUILD_TOOLS
 	for tool in insmod lsmod rmmod depmod modprobe modinfo; do \
-		$(LN_S) kmod $(DESTDIR)$(bindir)/$$tool; \
+		$(LN_S) -f kmod $(DESTDIR)$(bindir)/$$tool; \
 	done
 endif
 
Signature · 1 line
2.43.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Lucas De Marchi

Before commit e98cef6f3f8c ("make: install/uninstall tools symlinks to kmod") it was possible to call make install DESTDIR=<dir> multiple times. Use ln -sf so the symlink is always re-created.

It would be preferred to remove install in an empty dir, but there's not a bad consequence of re-using the same, so let the user decide. Fixes the following errors while installing for the second time:

ln: failed to create symbolic link '/tmp/inst/usr/bin/insmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/lsmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/rmmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/depmod': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/modprobe': File exists
ln: failed to create symbolic link '/tmp/inst/usr/bin/modinfo': File exists make[3]: *** [Makefile:2679: install-exec-hook] Error 1 make[2]: *** [Makefile:2553: install-exec-am] Error 2
make[1]: *** [Makefile:2439: install-am] Error 2
make: *** [Makefile:1848: install-recursive] Error 1

Quoted 3 lines

This matches the default man 1 install behaviour, which overrides existing file(s).

-Emil