Skip to contentSkip to conversation

utils/genrandconfig: fix relative toolchain_csv paths

PATCH In review James Hilliard 2 participants 3 messages Feb 8, 2023 – Feb 15, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils/genrandconfig: fix relative toolchain_csv paths

The default toolchain_csv path is a relative path to the buildroot directory.

If we run genrandconfig with a cwd that is not the buildroot directory the default toolchain_csv path will be wrong.

To fix this prepend the buildroot directory path to the toolchain_csv path whenever the toolchain_csv path is not absolute.

Fixes:
FileNotFoundError: [Errno 2] No such file or directory: 'support/config-fragments/autobuild/toolchain-configs.csv'

---
 utils/genrandconfig | 3 +++
 1 file changed, 3 insertions(+)
utils/genrandconfig +3 -0
index b3576f8a51..b96f2ee6de 100755
@@ -115,6 +115,9 @@ def get_toolchain_configs(toolchains_csv, buildrootdir):
     toolchain configuration is itself an array of lines of the defconfig.
     """
 
+    if not os.path.isabs(toolchains_csv):
+        toolchains_csv = os.path.join(buildrootdir, toolchains_csv)
+
     with open(toolchains_csv) as r:
         # filter empty lines and comments
         lines = [t for t in r.readlines() if len(t.strip()) > 0 and t[0] != '#']
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 8 lines · James Hilliard

The default toolchain_csv path is a relative path to the buildroot directory.

If we run genrandconfig with a cwd that is not the buildroot directory the default toolchain_csv path will be wrong.

To fix this prepend the buildroot directory path to the toolchain_csv path whenever the toolchain_csv path is not absolute.

Well, a typical use case for running genrandconfig with a cwd that is not the
buildroot directory could be from a br2-external, with a custom csv as argument. In that case, we actually *do* want the toolchains_csv to be interpreted relative to cwd rather than buildrootdir...

Since people may already be relying on that behaviour, I think it would be
better to fix it by just making the default one an absolute path, not anything passed explicitly through the commandline.

Regards,
Arnout

Quoted 14 lines

Fixes:
FileNotFoundError: [Errno 2] No such file or directory: 'support/config-fragments/autobuild/toolchain-configs.csv'

---
  utils/genrandconfig | 3 +++
  1 file changed, 3 insertions(+)
utils/genrandconfig +0 -0
index b3576f8a51..b96f2ee6de 100755

utils/genrandconfig def get_toolchain_configs(toolchains_csv, buildrootdir): · line 123

Quoted 9 lines
utils/genrandconfig +3 -0
@@ -115,6 +115,9 @@ def get_toolchain_configs(toolchains_csv, buildrootdir):
      toolchain configuration is itself an array of lines of the defconfig.
      """
 
+    if not os.path.isabs(toolchains_csv):
+        toolchains_csv = os.path.join(buildrootdir, toolchains_csv)
+
      with open(toolchains_csv) as r:
          # filter empty lines and comments
          lines = [t for t in r.readlines() if len(t.strip()) > 0 and t[0] != '#']

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

#2 lore raw
Quoted 13 lines · Arnout Vandecappelle
Quoted 8 lines · James Hilliard

The default toolchain_csv path is a relative path to the buildroot directory.

If we run genrandconfig with a cwd that is not the buildroot directory the default toolchain_csv path will be wrong.

To fix this prepend the buildroot directory path to the toolchain_csv path whenever the toolchain_csv path is not absolute.

Quoted 8 lines

Well, a typical use case for running genrandconfig with a cwd that is not the
buildroot directory could be from a br2-external, with a custom csv as argument. In that case, we actually *do* want the toolchains_csv to be interpreted relative to cwd rather than buildrootdir...

Since people may already be relying on that behaviour, I think it would be
better to fix it by just making the default one an absolute path, not anything passed explicitly through the commandline.

Changed the default to an absolute path in v2:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 21 lines

Regards,
Arnout

Quoted 17 lines

Fixes:
FileNotFoundError: [Errno 2] No such file or directory: 'support/config-fragments/autobuild/toolchain-configs.csv'

---
  utils/genrandconfig | 3 +++
  1 file changed, 3 insertions(+)
utils/genrandconfig +0 -0
index b3576f8a51..b96f2ee6de 100755
@@ -115,6 +115,9 @@ def get_toolchain_configs(toolchains_csv, buildrootdir):
      toolchain configuration is itself an array of lines of the defconfig.
      """
 
Quoted 6 lines

utils/genrandconfig def get_toolchain_configs(toolchains_csv, buildrootdir): · line 123

Quoted 6 lines
utils/genrandconfig +3 -0
+    if not os.path.isabs(toolchains_csv):
+        toolchains_csv = os.path.join(buildrootdir, toolchains_csv)
+
      with open(toolchains_csv) as r:
          # filter empty lines and comments
          lines = [t for t in r.readlines() if len(t.strip()) > 0 and t[0] != '#']

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