diff mbox series

[07/15,v4] fs: use a per-rootfs fakeroot script

Message ID c296e87bd778b9c2ef610a772adbd3d41bcb54a3.1522487149.git.yann.morin.1998@free.fr
State Accepted
Commit 48152408306a0dd06153f1816568036738c628d5
Headers show
Series [01/15,v4] fs: run filesystem hooks under fakeroot | expand

Commit Message

Yann E. MORIN March 31, 2018, 9:05 a.m. UTC
... and locate that script in a per-rootfs directory.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
---
 fs/common.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Peter Korsgaard March 31, 2018, 5:50 p.m. UTC | #1
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > ... and locate that script in a per-rootfs directory.
 > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 > Cc: Arnout Vandecappelle <arnout@mind.be>
 > ---
 >  fs/common.mk | 6 +++---
 >  1 file changed, 3 insertions(+), 3 deletions(-)

 > diff --git a/fs/common.mk b/fs/common.mk
 > index eebe83d6e5..db4f8c23ad 100644
 > --- a/fs/common.mk
 > +++ b/fs/common.mk
 > @@ -28,7 +28,6 @@
 >  # macro will automatically generate a compressed filesystem image.
 
 >  FS_DIR = $(BUILD_DIR)/buildroot-fs
 > -FAKEROOT_SCRIPT = $(FS_DIR)/fakeroot.fs
 >  FULL_DEVICE_TABLE = $(FS_DIR)/device_table.txt
 >  ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
 >  	$(BR2_ROOTFS_STATIC_DEVICE_TABLE))
 > @@ -76,10 +75,11 @@ ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c
 >  endif
 
 >  $$(BINARIES_DIR)/rootfs.$(1): ROOTFS=$(2)
 > +$$(BINARIES_DIR)/rootfs.$(1): FAKEROOT_SCRIPT=$$(ROOTFS_$(2)_DIR)/fakeroot

It wasn't quite clear to me why we had to go through the hoops to ensure
ROOTFS didn't leak but we don't do it for FAKEROOT_SCRIPT, so I've
extended the commit message a bit.
Arnout Vandecappelle March 31, 2018, 6:26 p.m. UTC | #2
On 31-03-18 11:05, Yann E. MORIN wrote:
> ... and locate that script in a per-rootfs directory.
> 
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Arnout Vandecappelle <arnout@mind.be>
> ---
>  fs/common.mk | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/common.mk b/fs/common.mk
> index eebe83d6e5..db4f8c23ad 100644
> --- a/fs/common.mk
> +++ b/fs/common.mk
> @@ -28,7 +28,6 @@
>  # macro will automatically generate a compressed filesystem image.
>  
>  FS_DIR = $(BUILD_DIR)/buildroot-fs
> -FAKEROOT_SCRIPT = $(FS_DIR)/fakeroot.fs
>  FULL_DEVICE_TABLE = $(FS_DIR)/device_table.txt
>  ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
>  	$(BR2_ROOTFS_STATIC_DEVICE_TABLE))
> @@ -76,10 +75,11 @@ ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c
>  endif
>  
>  $$(BINARIES_DIR)/rootfs.$(1): ROOTFS=$(2)
> +$$(BINARIES_DIR)/rootfs.$(1): FAKEROOT_SCRIPT=$$(ROOTFS_$(2)_DIR)/fakeroot

 I don't agree with this bit. We want to avoid this kind of per-target override
whenever possible.

 So IMO we should define the global FAKEROOT_SCRIPT as

-FAKEROOT_SCRIPT = $(FS_DIR)/fakeroot.fs
+FAKEROOT_SCRIPT = $(ROOTFS_$(ROOTFS)_DIR)/fakeroot.fs

 Regards,
 Arnout

>  $$(BINARIES_DIR)/rootfs.$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES)
>  	@$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
> -	rm -rf $(FS_DIR)
> -	mkdir -p $(FS_DIR)
> +	rm -rf $(FS_DIR) $$(ROOTFS_$(2)_DIR)
> +	mkdir -p $(FS_DIR) $$(ROOTFS_$(2)_DIR)
>  	echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
>  	echo "set -e" >> $$(FAKEROOT_SCRIPT)
>  	$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\
>
Arnout Vandecappelle March 31, 2018, 6:43 p.m. UTC | #3
On 31-03-18 20:26, Arnout Vandecappelle wrote:
> 
> 
> On 31-03-18 11:05, Yann E. MORIN wrote:
>> ... and locate that script in a per-rootfs directory.
>>
>> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
>> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
>> Cc: Arnout Vandecappelle <arnout@mind.be>
>> ---
>>  fs/common.mk | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/common.mk b/fs/common.mk
>> index eebe83d6e5..db4f8c23ad 100644
>> --- a/fs/common.mk
>> +++ b/fs/common.mk
>> @@ -28,7 +28,6 @@
>>  # macro will automatically generate a compressed filesystem image.
>>  
>>  FS_DIR = $(BUILD_DIR)/buildroot-fs
>> -FAKEROOT_SCRIPT = $(FS_DIR)/fakeroot.fs
>>  FULL_DEVICE_TABLE = $(FS_DIR)/device_table.txt
>>  ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
>>  	$(BR2_ROOTFS_STATIC_DEVICE_TABLE))
>> @@ -76,10 +75,11 @@ ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c
>>  endif
>>  
>>  $$(BINARIES_DIR)/rootfs.$(1): ROOTFS=$(2)
>> +$$(BINARIES_DIR)/rootfs.$(1): FAKEROOT_SCRIPT=$$(ROOTFS_$(2)_DIR)/fakeroot
> 
>  I don't agree with this bit. We want to avoid this kind of per-target override
> whenever possible.
> 
>  So IMO we should define the global FAKEROOT_SCRIPT as
> 
> -FAKEROOT_SCRIPT = $(FS_DIR)/fakeroot.fs
> +FAKEROOT_SCRIPT = $(ROOTFS_$(ROOTFS)_DIR)/fakeroot.fs

 As Yann pointed out to me, if we do this, then patch 12/15 should also add a
definition of ROOTFS_COMMON_DIR = $(FS_DIR). And then probably FS_DIR should be
renamed to ROOTFS_COMMON_DIR (which it is, in the end...).


 Given that this is getting a little complicated, I'm OK to do this in a
follow-up patch instead.

 Regards,
 Arnout

> 
>  Regards,
>  Arnout
> 
>>  $$(BINARIES_DIR)/rootfs.$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES)
>>  	@$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
>> -	rm -rf $(FS_DIR)
>> -	mkdir -p $(FS_DIR)
>> +	rm -rf $(FS_DIR) $$(ROOTFS_$(2)_DIR)
>> +	mkdir -p $(FS_DIR) $$(ROOTFS_$(2)_DIR)
>>  	echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
>>  	echo "set -e" >> $$(FAKEROOT_SCRIPT)
>>  	$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\
>>
>
diff mbox series

Patch

diff --git a/fs/common.mk b/fs/common.mk
index eebe83d6e5..db4f8c23ad 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -28,7 +28,6 @@ 
 # macro will automatically generate a compressed filesystem image.
 
 FS_DIR = $(BUILD_DIR)/buildroot-fs
-FAKEROOT_SCRIPT = $(FS_DIR)/fakeroot.fs
 FULL_DEVICE_TABLE = $(FS_DIR)/device_table.txt
 ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
 	$(BR2_ROOTFS_STATIC_DEVICE_TABLE))
@@ -76,10 +75,11 @@  ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c
 endif
 
 $$(BINARIES_DIR)/rootfs.$(1): ROOTFS=$(2)
+$$(BINARIES_DIR)/rootfs.$(1): FAKEROOT_SCRIPT=$$(ROOTFS_$(2)_DIR)/fakeroot
 $$(BINARIES_DIR)/rootfs.$(1): target-finalize $$(ROOTFS_$(2)_DEPENDENCIES)
 	@$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
-	rm -rf $(FS_DIR)
-	mkdir -p $(FS_DIR)
+	rm -rf $(FS_DIR) $$(ROOTFS_$(2)_DIR)
+	mkdir -p $(FS_DIR) $$(ROOTFS_$(2)_DIR)
 	echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
 	echo "set -e" >> $$(FAKEROOT_SCRIPT)
 	$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\