[PATCH] util/cutil: Allow relocatable install with prefix /

Bin Meng posted 1 patch 10 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240123100640.1865139-1-bin.meng@windriver.com
util/cutils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] util/cutil: Allow relocatable install with prefix /
Posted by Bin Meng 10 months, 1 week ago
When configuring QEMU with --prefix=/, the generated QEMU executables
can't be relocated to other directories. Add an additional test logic
in starts_with_prefix() to handle this.

Signed-off-by: Bin Meng <bin.meng@windriver.com>

---

 util/cutils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/cutils.c b/util/cutils.c
index 42364039a5..676bd757ba 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1021,7 +1021,8 @@ static inline bool starts_with_prefix(const char *dir)
 #pragma GCC diagnostic ignored "-Warray-bounds="
 #endif
     return !memcmp(dir, CONFIG_PREFIX, prefix_len) &&
-        (!dir[prefix_len] || G_IS_DIR_SEPARATOR(dir[prefix_len]));
+        (!dir[prefix_len] || G_IS_DIR_SEPARATOR(dir[prefix_len]) ||
+         !strcmp(CONFIG_PREFIX, "/"));
 #pragma GCC diagnostic pop
 }
 
-- 
2.34.1
Re: [PATCH] util/cutil: Allow relocatable install with prefix /
Posted by Akihiko Odaki 10 months, 1 week ago
On 2024/01/23 19:06, Bin Meng wrote:
> When configuring QEMU with --prefix=/, the generated QEMU executables
> can't be relocated to other directories. Add an additional test logic
> in starts_with_prefix() to handle this.

What about setting "" as CONFIG_PREFIX in Meson when --prefix=/ ?

CONFIG_PREFIX is expected not to have the ending slash. --prefix needs 
the ending slash for the root, but it is just a quirk of Meson, which is 
probably better to be handled in Meson, too.

Regards,
Akihiko Odaki