Skip to content

snagflash: Fastboot cmd file now supports "paths-relative-to" env variable#92

Merged
rgantois merged 1 commit into
bootlin:mainfrom
bastien-sagetat:bsa/fastboot-relative-path
Jun 19, 2026
Merged

snagflash: Fastboot cmd file now supports "paths-relative-to" env variable#92
rgantois merged 1 commit into
bootlin:mainfrom
bastien-sagetat:bsa/fastboot-relative-path

Conversation

@bastien-sagetat

@bastien-sagetat bastien-sagetat commented Jun 15, 2026

Copy link
Copy Markdown

Path resolution can be controlled through the "paths-relative-to" environement variable, which can be configured using the existing "set" command.

Supported values:

  • CWD (default): resolve paths relative to the current working directory.
  • THIS_FILE: resolve paths relative to the command file's directory.
    Any other value raises an error.

The "paths-relative-to" environment variable is documented in the help text, as well as in docs/snagflash.md

Add unittests for testing this feature (tests/fastboot_uboot.py), most notably for testing the SnagflashFastbootUboot.resolve_path() method.

Note:
The snagrecover config file already implements this feature, with the same variable name.

Changes

  • Add the private resolve_path() method to the SnagflashFastbootUboot class.
  • Calls the resolve_path() method in SnagflashFastbootUboot.cmd_flash()
  • Add the optional "cmdfile" argument to the SnagflashFastbootUboot.run() method.

@bastien-sagetat bastien-sagetat changed the title snagflash: Path in fastboot flash cmd can be relative snagflash: support relative paths in fastboot command files Jun 15, 2026
@bastien-sagetat bastien-sagetat marked this pull request as draft June 15, 2026 16:38
@rgantois

Copy link
Copy Markdown
Collaborator

Hi Bastien, thanks for the contrib :). I don't think this is the right way to solve this, since it breaks backwards compatibility. I'll see if I can add a parameter to enable config-file-relative paths, like what was done for snagrecover config files.

@bastien-sagetat bastien-sagetat force-pushed the bsa/fastboot-relative-path branch 2 times, most recently from 30f1ff8 to 75576b4 Compare June 17, 2026 09:03
@bastien-sagetat bastien-sagetat changed the title snagflash: support relative paths in fastboot command files snagflash: Fastboot cmd file now support "base-dir" env variable Jun 17, 2026
@bastien-sagetat bastien-sagetat changed the title snagflash: Fastboot cmd file now support "base-dir" env variable snagflash: Fastboot cmd file now supports "base-dir" env variable Jun 17, 2026

@rgantois rgantois left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the two changes requested below, looks great!

Comment thread src/snagflash/fastboot_uboot.py Outdated

self.checked = True

def _resolve_path(self, path: str) -> str:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove "_" prefix to follow naming conventions in this file

@bastien-sagetat bastien-sagetat Jun 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok fixed

Comment thread src/snagflash/fastboot_uboot.py Outdated
self.checked = True

def _resolve_path(self, path: str) -> str:
if not os.path.isabs(path):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to if os.path.isabs(path): return to save an indent

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, done

@bastien-sagetat bastien-sagetat force-pushed the bsa/fastboot-relative-path branch 7 times, most recently from 76e7964 to 12e0765 Compare June 18, 2026 13:59
@bastien-sagetat bastien-sagetat changed the title snagflash: Fastboot cmd file now supports "base-dir" env variable snagflash: Fastboot cmd file now supports "paths-relative-to" env variable Jun 18, 2026
@bastien-sagetat bastien-sagetat marked this pull request as ready for review June 19, 2026 12:14
@rgantois

Copy link
Copy Markdown
Collaborator

Looks like the linter is complaining, please run ruff format src and ruff format tests to see if some reformatting is required. You can also run ruff check src, ruff check tests, and python tests.py to be sure.

Path resolution can be controlled through the "paths-relative-to" environement variable,
which can be configured using the existing "set" command.

Supported values:
- CWD (default): resolve paths relative to the current working directory.
- THIS_FILE: resolve paths relative to the command file's directory.
Any other value raises an error.

The "paths-relative-to" environment variable is documented in the help text,
as well as in docs/snagflash.md

Add unittests for testing this feature (tests/fastboot_uboot.py),
most notably for testing the SnagflashFastbootUboot.resolve_path() method.

Note:
The snagrecover config file already implements this feature,
with the same variable name.

Signed-off-by: Christophe Guerreiro <christophe.guerreiro@non.se.com>
Signed-off-by: Bastien Sagetat <sagetat.bastien@non.se.com>
@bastien-sagetat bastien-sagetat force-pushed the bsa/fastboot-relative-path branch from 12e0765 to 1d768b6 Compare June 19, 2026 12:37
@rgantois

Copy link
Copy Markdown
Collaborator

Nice, thanks!

@rgantois rgantois merged commit 1b76eec into bootlin:main Jun 19, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants