Skip to contentSkip to conversation

utils/genrandconfig: make default toolchain_csv path absolute

PATCH In review James Hilliard 2 participants 5 messages Feb 15, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 utils/genrandconfig: make default toolchain_csv path absolute

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 make the default toolchain_csv path absolute.

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

---
Changes v1 -> v2:
- set default path as absolute

---
 utils/genrandconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
utils/genrandconfig +3 -1
index b3576f8a51..3552b83694 100755
@@ -801,7 +801,9 @@ if __name__ == '__main__':
                                 dest="toolchains_csv",
                                 help="Generate random toolchain configuration",
                                 action='store_false')
-    parser.set_defaults(toolchains_csv="support/config-fragments/autobuild/toolchain-configs.csv")
+    buildroot_abs = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    parser.set_defaults(toolchains_csv=os.path.join(buildroot_abs,
+                        "support/config-fragments/autobuild/toolchain-configs.csv"))
 
     args = parser.parse_args()
 
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 24 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 make the default toolchain_csv path absolute.

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

---
Changes v1 -> v2:
- set default path as absolute

---
  utils/genrandconfig | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
utils/genrandconfig +0 -0
index b3576f8a51..3552b83694 100755

utils/genrandconfig if __name__ == '__main__': · line 806

Quoted 7 lines
utils/genrandconfig +3 -1
@@ -801,7 +801,9 @@ if __name__ == '__main__':
                                  dest="toolchains_csv",
                                  help="Generate random toolchain configuration",
                                  action='store_false')
-    parser.set_defaults(toolchains_csv="support/config-fragments/autobuild/toolchain-configs.csv")
+    buildroot_abs = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    parser.set_defaults(toolchains_csv=os.path.join(buildroot_abs,
+                        "support/config-fragments/autobuild/toolchain-configs.csv"))

Sorry, that's not going to work either (if it was that easy I'd done it myself :-)

buildrootdir can be set to something else with the -b argument, and we want it
relative to *that* one of course.

Regards,
Arnout

utils/genrandconfig if __name__ == '__main__': · line 809

Quoted 3 lines
utils/genrandconfig +0 -0
      args = parser.parse_args()
 

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

#2 lore raw
Quoted 23 lines · Arnout Vandecappelle
Quoted 19 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 make the default toolchain_csv path absolute.

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

---
Changes v1 -> v2:
- set default path as absolute

---
  utils/genrandconfig | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 14 lines

utils/genrandconfig if __name__ == '__main__': · line 806

Quoted 12 lines
utils/genrandconfig +3 -1
index b3576f8a51..3552b83694 100755
@@ -801,7 +801,9 @@ if __name__ == '__main__':
                                  dest="toolchains_csv",
                                  help="Generate random toolchain configuration",
                                  action='store_false')
-    parser.set_defaults(toolchains_csv="support/config-fragments/autobuild/toolchain-configs.csv")
+    buildroot_abs = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    parser.set_defaults(toolchains_csv=os.path.join(buildroot_abs,
+                        "support/config-fragments/autobuild/toolchain-configs.csv"))

Sorry, that's not going to work either (if it was that easy I'd done it myself :-)

Under what scenario would this break?

Quoted 3 lines

buildrootdir can be set to something else with the -b argument, and we want it
relative to *that* one of course.

Using buildrootdir is cwd dependent, the approach I used is not as it uses the absolute path of the genrandconfig file to compute the default toolchain_csv abs path.

Quoted 7 lines

Regards,
Arnout

Quoted 3 lines
utils/genrandconfig +0 -0
      args = parser.parse_args()
 

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

#3 lore raw
Quoted 39 lines · James Hilliard
Quoted 23 lines · Arnout Vandecappelle
Quoted 19 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 make the default toolchain_csv path absolute.

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

---
Changes v1 -> v2:
- set default path as absolute

---
   utils/genrandconfig | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 14 lines

utils/genrandconfig if __name__ == '__main__': · line 806

Quoted 12 lines
utils/genrandconfig +3 -1
index b3576f8a51..3552b83694 100755
@@ -801,7 +801,9 @@ if __name__ == '__main__':
                                   dest="toolchains_csv",
                                   help="Generate random toolchain configuration",
                                   action='store_false')
-    parser.set_defaults(toolchains_csv="support/config-fragments/autobuild/toolchain-configs.csv")
+    buildroot_abs = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    parser.set_defaults(toolchains_csv=os.path.join(buildroot_abs,
+                        "support/config-fragments/autobuild/toolchain-configs.csv"))

Sorry, that's not going to work either (if it was that easy I'd done it myself :-)

Quoted 1 line

Under what scenario would this break?

I have ~/src/buildroot/utils in my PATH, so I just run 'genrandconfig' from
path. If I want to run it in a different worktree (e.g. ~/src/buildroot-next which tracks the next branch), I would go to that directory and run "genrandconfig", so it would use the one in ~/src/buildroot, not the one in ~/sr/buildroot-next. In that case, of course, I want to use the toolchain-configs.csv from the next branch, not the one from ~/src/buildroot.

Quoted 4 lines
Quoted 2 lines

buildrootdir can be set to something else with the -b argument, and we want it
relative to *that* one of course.

Using buildrootdir is cwd dependent,

The default value is cwd dependent; the value you give with the -b option can
be absolute or relative.

Quoted 3 lines

the approach I used is not as it uses the
absolute path of the genrandconfig file to compute the default toolchain_csv abs path.

And my point is that it should be relative to the buildrootdir given with the
commandline option, not relative to the place where genrandconfig happens to reside.

TBH, I think genrandonfig has too many options :-)

Regards,
Arnout

Quoted 8 lines
Quoted 8 lines

Regards,
Arnout

Quoted 3 lines
utils/genrandconfig +0 -0
       args = parser.parse_args()
 

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

#4 lore raw
Quoted 43 lines · Arnout Vandecappelle
Quoted 39 lines · James Hilliard
Quoted 37 lines · Arnout Vandecappelle
Quoted 24 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 make the default toolchain_csv path absolute.

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

---
Changes v1 -> v2:
- set default path as absolute

---
   utils/genrandconfig | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
utils/genrandconfig +0 -0
index b3576f8a51..3552b83694 100755

utils/genrandconfig if __name__ == '__main__': · line 806

Quoted 7 lines
utils/genrandconfig +3 -1
@@ -801,7 +801,9 @@ if __name__ == '__main__':
                                   dest="toolchains_csv",
                                   help="Generate random toolchain configuration",
                                   action='store_false')
-    parser.set_defaults(toolchains_csv="support/config-fragments/autobuild/toolchain-configs.csv")
+    buildroot_abs = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    parser.set_defaults(toolchains_csv=os.path.join(buildroot_abs,
+                        "support/config-fragments/autobuild/toolchain-configs.csv"))

Sorry, that's not going to work either (if it was that easy I'd done it myself :-)

Quoted 8 lines
Quoted 1 line

Under what scenario would this break?

I have ~/src/buildroot/utils in my PATH, so I just run 'genrandconfig' from
path. If I want to run it in a different worktree (e.g. ~/src/buildroot-next which tracks the next branch), I would go to that directory and run "genrandconfig", so it would use the one in ~/src/buildroot, not the one in ~/sr/buildroot-next. In that case, of course, I want to use the toolchain-configs.csv from the next branch, not the one from ~/src/buildroot.

Well you can still do that by passing the relative path via --toolchains-csv to override the default abs path.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

buildrootdir can be set to something else with the -b argument, and we want it
relative to *that* one of course.

Using buildrootdir is cwd dependent,

The default value is cwd dependent; the value you give with the -b option can
be absolute or relative.

Yeah, but I think making it an abs path relative to the genrandconfig file as the
default is less likely to cause unexpected issues. Having it relative to cwd when
not passing an option is a bit unexpected IMO.

Quoted 7 lines
Quoted 4 lines

the approach I used is not as it uses the
absolute path of the genrandconfig file to compute the default toolchain_csv abs path.

And my point is that it should be relative to the buildrootdir given with the
commandline option, not relative to the place where genrandconfig happens to reside.

It's still relative to cwd when passing a relative path via --toolchains-csv, just the
default is changed to be an abs path.

Quoted 14 lines

TBH, I think genrandonfig has too many options :-)

Regards,
Arnout

Quoted 8 lines
Quoted 8 lines

Regards,
Arnout

Quoted 3 lines
utils/genrandconfig +0 -0
       args = parser.parse_args()
 

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