diff mbox series

util/cutil: Allow relocatable install with prefix /

Message ID 20240123100640.1865139-1-bin.meng@windriver.com (mailing list archive)
State New, archived
Headers show
Series util/cutil: Allow relocatable install with prefix / | expand

Commit Message

Bin Meng Jan. 23, 2024, 10:06 a.m. UTC
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(-)

Comments

Akihiko Odaki Jan. 24, 2024, 3:25 a.m. UTC | #1
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
diff mbox series

Patch

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
 }