Skip to contentSkip to conversation

Makefile: remove /usr/lib/rpm directory on target

PATCH In review Norbert Lange 3 participants 11 messages Jun 5, 2020 – Jan 9, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Makefile: remove /usr/lib/rpm directory on target

this is only relevant for staging (if at all)

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index ce1c08a6f6..6a76e87b5e 100644
@@ -748,7 +748,7 @@ target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
 	rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
 		$(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
 		$(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \
-		$(TARGET_DIR)/usr/doc
+		$(TARGET_DIR)/usr/lib/rpm $(TARGET_DIR)/usr/doc
 	find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
 	find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
 		\( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/2 fs: clean the volatile /run and /tmp directories

Scripts in the fakeroot environment could call
tools preparing the early environment, leaving
traces in /run or /tmp.

mkusers might create home directories in /run for
example.

---
 fs/common.mk | 1 +
 1 file changed, 1 insertion(+)
fs/common.mk +1 -0
index 842ea924a5..a5c6b4ea96 100644
@@ -171,6 +171,7 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
 
 	$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\
 		$$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep))
+	echo "rm -rf $$(TARGET_DIR)/run/* $$(TARGET_DIR)/run/.[^.]* $$(TARGET_DIR)/tmp/* $$(TARGET_DIR)/tmp/.[^.]*" >> $$(FAKEROOT_SCRIPT)
 	$$(call PRINTF,$$(ROOTFS_REPRODUCIBLE)) >> $$(FAKEROOT_SCRIPT)
 	$$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT)
 	chmod a+x $$(FAKEROOT_SCRIPT)
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/2 fs: clean the volatile /run and /tmp directories

Hello,

Quoted 8 lines · On Sat, 6 Jun 2020 00:48:57 +0200 Norbert Lange <[email protected]> wrote:

Scripts in the fakeroot environment could call
tools preparing the early environment, leaving
traces in /run or /tmp.

mkusers might create home directories in /run for
example.

Looping Yann on this. I agree that we definitely want /tmp and /run to be empty, as we are anyway going to mount a tmpfs over them, so whatever they contains is not visible on the target system, but takes up some space on the filesystem.

However, I'm not sure if removing all what they contain is the right approach. Shouldn't we avoid creating things in /tmp and /run in the first place ?

Yann, any feedback on this ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH 2/2 fs: clean the volatile /run and /tmp directories

Am Sa., 6. Juni 2020 um 22:42 Uhr schrieb Thomas Petazzoni <[email protected]>:

Quoted 15 lines

Hello,

Quoted 8 lines · On Sat, 6 Jun 2020 00:48:57 +0200 Norbert Lange <[email protected]> wrote:

Scripts in the fakeroot environment could call
tools preparing the early environment, leaving
traces in /run or /tmp.

mkusers might create home directories in /run for
example.

Quoted 8 lines

Looping Yann on this. I agree that we definitely want /tmp and /run to be empty, as we are anyway going to mount a tmpfs over them, so whatever they contains is not visible on the target system, but takes up some space on the filesystem.

However, I'm not sure if removing all what they contain is the right approach. Shouldn't we avoid creating things in /tmp and /run in the first place ?

Yeah we should avoid creating stuff there, but it's sometimes hard to do. One example is defining a user with home dir in /run, mkusers will then create a dir there
(pretty late to clear it up otherwise)

More important would be tools that lazily create stuff on the first boot, and either buildroot or a custom fakeroot stage script would run this on the host instead (worstcase in some sort of container/chroot).

Quoted 8 lines

Yann, any feedback on this ?

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Norbert

#4 lore raw

PATCH 2/2 fs: clean the volatile /run and /tmp directories

Quoted 8 lines · On Sun, 7 Jun 2020 00:57:23 +0200 Norbert Lange <[email protected]> wrote:
Quoted 3 lines

However, I'm not sure if removing all what they contain is the right approach. Shouldn't we avoid creating things in /tmp and /run in the first place ?

Yeah we should avoid creating stuff there, but it's sometimes hard to do. One example is defining a user with home dir in /run, mkusers will then create a dir there
(pretty late to clear it up otherwise)

But our skeleton has a fstab that always mounts a tmpfs filesystem on /run, so how can it make sense for mkusers to create a home directory in /run ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

PATCH 2/2 fs: clean the volatile /run and /tmp directories

Am So., 7. Juni 2020 um 10:47 Uhr schrieb Thomas Petazzoni <[email protected]>:

Quoted 8 lines
Quoted 4 lines · On Sun, 7 Jun 2020 00:57:23 +0200 Norbert Lange <[email protected]> wrote:
Quoted 3 lines

However, I'm not sure if removing all what they contain is the right approach. Shouldn't we avoid creating things in /tmp and /run in the first place ?

Quoted 8 lines
Quoted 4 lines

Yeah we should avoid creating stuff there, but it's sometimes hard to do. One example is defining a user with home dir in /run, mkusers will then create a dir there
(pretty late to clear it up otherwise)

But our skeleton has a fstab that always mounts a tmpfs filesystem on /run, so how can it make sense for mkusers to create a home directory in /run ?

Think of system users, where the "home" is usually non-persistent or just some sort of jail.
For ex. my openssh patch sets the sshd user's home to /run/sshd - A directory that's automatically
created when the service starts and deleted when it stops.

Quoted 6 lines

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Norbert

#6 lore raw

PATCH 2/2 fs: clean the volatile /run and /tmp directories

Am So., 7. Juni 2020 um 20:41 Uhr schrieb Norbert Lange <[email protected]>:

Quoted 20 lines

Am So., 7. Juni 2020 um 10:47 Uhr schrieb Thomas Petazzoni <[email protected]>:

Quoted 8 lines
Quoted 4 lines · On Sun, 7 Jun 2020 00:57:23 +0200 Norbert Lange <[email protected]> wrote:
Quoted 3 lines

However, I'm not sure if removing all what they contain is the right approach. Shouldn't we avoid creating things in /tmp and /run in the first place ?

Quoted 8 lines
Quoted 4 lines

Yeah we should avoid creating stuff there, but it's sometimes hard to do. One example is defining a user with home dir in /run, mkusers will then create a dir there
(pretty late to clear it up otherwise)

But our skeleton has a fstab that always mounts a tmpfs filesystem on /run, so how can it make sense for mkusers to create a home directory in /run ?

Quoted 6 lines

Think of system users, where the "home" is usually non-persistent or just some sort of jail.
For ex. my openssh patch sets the sshd user's home to /run/sshd - A directory that's automatically
created when the service starts and deleted when it stops.

Some other example is dbus, creates a user with homedir=/var/run/dbus. So not only my hackjobs are affected ;)

Should I somehow ping you if some patches are ready BTW (not sure if you read through all discussions)?
On that note, can you upgrade fakeroot to 1.24 now?
https://patchwork.ozlabs.org/project/buildroot/list/?series=176013

Norbert

#7 lore raw

Re: [Buildroot] [PATCH 2/2] fs: clean the volatile /run and /tmp directories

In reply to Norbert Lange

Hi Norbert,

Quoted 8 lines · Norbert Lange

Scripts in the fakeroot environment could call
tools preparing the early environment, leaving
traces in /run or /tmp.

mkusers might create home directories in /run for
example.

I finally applied to master, thanks. I extended the commit message based on
the discussion on the patch.

Regards,
Arnout

Quoted 10 lines
---
  fs/common.mk | 1 +
  1 file changed, 1 insertion(+)
fs/common.mk +0 -0
index 842ea924a5..a5c6b4ea96 100644

fs/common.mk $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES) · line 177

Quoted 7 lines
fs/common.mk +1 -0
@@ -171,6 +171,7 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
 
  	$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\
  		$$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep))
+	echo "rm -rf $$(TARGET_DIR)/run/* $$(TARGET_DIR)/run/.[^.]* $$(TARGET_DIR)/tmp/* $$(TARGET_DIR)/tmp/.[^.]*" >> $$(FAKEROOT_SCRIPT)
  	$$(call PRINTF,$$(ROOTFS_REPRODUCIBLE)) >> $$(FAKEROOT_SCRIPT)
  	$$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT)
  	chmod a+x $$(FAKEROOT_SCRIPT)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#8 lore raw

PATCH 1/2 Makefile: remove /usr/lib/rpm directory on target

In reply to Norbert Lange
Quoted 12 lines · On Sat, 6 Jun 2020 00:48:56 +0200 Norbert Lange <[email protected]> wrote:

this is only relevant for staging (if at all)

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index ce1c08a6f6..6a76e87b5e 100644

Makefile target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize · line 751

Quoted 5 lines
Makefile +1 -1
@@ -748,7 +748,7 @@ target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
 	rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
 		$(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
 		$(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \
-		$(TARGET_DIR)/usr/doc
+		$(TARGET_DIR)/usr/lib/rpm $(TARGET_DIR)/usr/doc

What have you found installed in $(TARGET_DIR)/usr/lib/rpm ? Why does this needs to be done in target-finalize and not in the rpm package ? Is it because other packages install stuff in /usr/lib/rpm ? If so, what ?

Again, we need better commit logs, otherwise for each of your changes we'll have to ask for additional clarifications/details.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#9 lore raw

PATCH 1/2 Makefile: remove /usr/lib/rpm directory on target

Am Sa., 6. Juni 2020 um 22:39 Uhr schrieb Thomas Petazzoni <[email protected]>:

Quoted 11 lines
Quoted 7 lines · On Sat, 6 Jun 2020 00:48:56 +0200 Norbert Lange <[email protected]> wrote:

this is only relevant for staging (if at all)

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

Makefile target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize · line 751

Quoted 10 lines
Makefile +1 -1
index ce1c08a6f6..6a76e87b5e 100644
@@ -748,7 +748,7 @@ target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
      rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
              $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
              $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \
-             $(TARGET_DIR)/usr/doc
+             $(TARGET_DIR)/usr/lib/rpm $(TARGET_DIR)/usr/doc

What have you found installed in $(TARGET_DIR)/usr/lib/rpm ? Why does this needs to be done in target-finalize and not in the rpm package ? Is it because other packages install stuff in /usr/lib/rpm ? If so, what ?

I believe this to be a common occurrence, like /usr/share/aclocal. But I need to check that again

Quoted 11 lines

Again, we need better commit logs, otherwise for each of your changes we'll have to ask for additional clarifications/details.

Thanks!

Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#10 lore raw

PATCH 1/2 Makefile: remove /usr/lib/rpm directory on target

Am So., 7. Juni 2020 um 00:51 Uhr schrieb Norbert Lange <[email protected]>:

Quoted 30 lines

Am Sa., 6. Juni 2020 um 22:39 Uhr schrieb Thomas Petazzoni <[email protected]>:

Quoted 11 lines
Quoted 7 lines · On Sat, 6 Jun 2020 00:48:56 +0200 Norbert Lange <[email protected]> wrote:

this is only relevant for staging (if at all)

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines

Makefile target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize · line 751

Quoted 10 lines
Makefile +1 -1
index ce1c08a6f6..6a76e87b5e 100644
@@ -748,7 +748,7 @@ target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
      rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
              $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
              $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \
-             $(TARGET_DIR)/usr/doc
+             $(TARGET_DIR)/usr/lib/rpm $(TARGET_DIR)/usr/doc

What have you found installed in $(TARGET_DIR)/usr/lib/rpm ? Why does this needs to be done in target-finalize and not in the rpm package ? Is it because other packages install stuff in /usr/lib/rpm ? If so, what ?

Quoted 3 lines

I believe this to be a common occurrence, like /usr/share/aclocal. But I need to check that again

Turns out that systemd drops some "macros" there.

Norbert