Skip to contentSkip to conversation

initramfs: Prefix simple paths with $(srctree)

RFC PATCH In review Geert Uytterhoeven 2 participants 2 messages Nov 14, 2013 – Nov 15, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 initramfs: Prefix simple paths with $(srctree)

If CONFIG_INITRAMFS_SOURCE contains relative paths inside the source tree (e.g. in a defconfig pointing to arch-specific files), the corresponding file system entries are not found when building outside the source tree.

Prefix all simple paths (paths not starting with "/", "../", or "./") with $(srctree) to fix this.

---
This issue happens when building an OpenRISC defconfig from
git://openrisc.net/jonas/linux. Mainline doesn't have the OpenRISC initramfs.

Questions:
1. Is this an acceptable solution for mainline?
2. My make-foo is limited. is there a better way to accomplish this, than by prefixing all paths and removing the prefixes again where they're not wanted?

 usr/Makefile |    6 ++++++
 1 file changed, 6 insertions(+)
usr/Makefile +6 -0
index e767f019accf..2170c38936ce 100644
@@ -41,6 +41,12 @@ hostprogs-y := gen_init_cpio
 initramfs   := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
 ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
 			$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
+ifneq ("$(ramfs-input)", "-d")
+ramfs-input := $(patsubst %, $(srctree)/%, $(ramfs-input))
+ramfs-input := $(patsubst $(srctree)//%, /%, $(ramfs-input))
+ramfs-input := $(patsubst $(srctree)/../%, ../%, $(ramfs-input))
+ramfs-input := $(patsubst $(srctree)/./%, ./%, $(ramfs-input))
+endif
 ramfs-args  := \
         $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
         $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 4 lines · Geert Uytterhoeven

If CONFIG_INITRAMFS_SOURCE contains relative paths inside the source tree (e.g. in a defconfig pointing to arch-specific files), the corresponding file system entries are not found when building outside the source tree.

Quoted 8 lines

Prefix all simple paths (paths not starting with "/", "../", or "./") with $(srctree) to fix this.

---
This issue happens when building an OpenRISC defconfig from
git://openrisc.net/jonas/linux. Mainline doesn't have the OpenRISC initramfs.

+1.
This applies to ARC defconfig too.

Quoted 28 lines

Questions:
1. Is this an acceptable solution for mainline?
2. My make-foo is limited. is there a better way to accomplish this, than by prefixing all paths and removing the prefixes again where they're not wanted?

 usr/Makefile |    6 ++++++
 1 file changed, 6 insertions(+)
usr/Makefile +6 -0
index e767f019accf..2170c38936ce 100644
@@ -41,6 +41,12 @@ hostprogs-y := gen_init_cpio
 initramfs   := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
 ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
 			$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
+ifneq ("$(ramfs-input)", "-d")
+ramfs-input := $(patsubst %, $(srctree)/%, $(ramfs-input))
+ramfs-input := $(patsubst $(srctree)//%, /%, $(ramfs-input))
+ramfs-input := $(patsubst $(srctree)/../%, ../%, $(ramfs-input))
+ramfs-input := $(patsubst $(srctree)/./%, ./%, $(ramfs-input))
+endif
 ramfs-args  := \
         $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
         $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))