Skip to content

Commit 19514fc

Browse files
rric-netmichal42
authored andcommitted
arm, kbuild: make "make install" not depend on vmlinux
Install targets (install, zinstall, uinstall) on arm have a dependency to vmlinux. This may cause parts of the kernel to be rebuilt during installation. We must avoid this since this may run as root. Install targets "ABSOLUTELY MUST NOT MODIFY THE SOURCE TREE." as Linus emphasized this in: http://lkml.org/lkml/2013/7/10/600 So on arm and maybe other archs we need the same as for x86: 1648e4f x86, kbuild: make "make install" not depend on vmlinux This patch fixes this for arm. Dependencies are removed and instead a check to install.sh is added for the files that are needed. This issue was uncovered by this build error where the -j option is used in conjunction with install targets: $ make <makeflags> $ make <makeflags> zinstall ... DEPMOD Usage: .../scripts/depmod.sh /sbin/depmod <kernelrelease> (INSTALL_MOD_PATH and INSTALL_PATH variables set, so no root perms required in this case.) The problem is that zinstall on arm due to its dependency to vmlinux does a prepare/prepare3 and finally does a forced rewrite of kernel.release even if it exists already. Rebuilding kernel.release removes it first and then recreates it. This might race with another parallel make job running depmod. So this patch should fix this one too. Also quoting $(KERNELRELEASE) arg for install.sh as this messes argument order in case it is empty (which is the case if the kernel was not built yet). Signed-off-by: Robert Richter <[email protected]> Signed-off-by: Robert Richter <[email protected]> Acked-by: Michal Marek <[email protected]>. Acked-by: Linus Torvalds <[email protected]> Signed-off-by: "Yann E. MORIN" <[email protected]> Signed-off-by: Michal Marek <[email protected]>
1 parent 272b98c commit 19514fc

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

arch/arm/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,15 @@ archprepare:
296296
# Convert bzImage to zImage
297297
bzImage: zImage
298298

299-
zImage Image xipImage bootpImage uImage: vmlinux
299+
BOOT_TARGETS = zImage Image xipImage bootpImage uImage
300+
INSTALL_TARGETS = zinstall uinstall install
301+
302+
PHONY += bzImage $(BOOT_TARGETS) $(INSTALL_TARGETS)
303+
304+
$(BOOT_TARGETS): vmlinux
300305
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
301306

302-
zinstall uinstall install: vmlinux
307+
$(INSTALL_TARGETS):
303308
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
304309

305310
%.dtb: | scripts

arch/arm/boot/Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,24 @@ initrd:
9595
@test "$(INITRD)" != "" || \
9696
(echo You must specify INITRD; exit -1)
9797

98-
install: $(obj)/Image
99-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
98+
install:
99+
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
100100
$(obj)/Image System.map "$(INSTALL_PATH)"
101101

102-
zinstall: $(obj)/zImage
103-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
102+
zinstall:
103+
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
104104
$(obj)/zImage System.map "$(INSTALL_PATH)"
105105

106-
uinstall: $(obj)/uImage
107-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
106+
uinstall:
107+
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
108108
$(obj)/uImage System.map "$(INSTALL_PATH)"
109109

110110
zi:
111-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
111+
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
112112
$(obj)/zImage System.map "$(INSTALL_PATH)"
113113

114114
i:
115-
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
115+
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
116116
$(obj)/Image System.map "$(INSTALL_PATH)"
117117

118118
subdir- := bootp compressed dts

arch/arm/boot/install.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
# $4 - default install path (blank if root directory)
2121
#
2222

23+
verify () {
24+
if [ ! -f "$1" ]; then
25+
echo "" 1>&2
26+
echo " *** Missing file: $1" 1>&2
27+
echo ' *** You need to run "make" before "make install".' 1>&2
28+
echo "" 1>&2
29+
exit 1
30+
fi
31+
}
32+
33+
# Make sure the files actually exist
34+
verify "$2"
35+
verify "$3"
36+
2337
# User may have a custom install script
2438
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
2539
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi

0 commit comments

Comments
 (0)