mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-29 07:07:20 -05:00
fix: run verify and generate_pack from any dir
Started outside the repository root, both ended on a FileNotFoundError traceback: the database and the data registry name files from the root. They now move to the root after reading the paths the caller typed, which stay relative to where they were typed.
This commit is contained in:
1 parent
0457bd8f40
commit
738577b5a4
3 files changed
+62
No files matched your search
@@ -3160,6 +3160,12 @@ def _main(held: contextlib.ExitStack) -> None:
|
||||
help="Extract and verify pack integrity (path + hash)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
from verify import work_from_repo_root
|
||||
|
||||
work_from_repo_root(
|
||||
args, parser,
|
||||
["db", "platforms_dir", "bios_dir", "output_dir", "emulators_dir", "from_md5_file"],
|
||||
)
|
||||
packresolve.set_offline(bool(args.offline))
|
||||
if args.platform:
|
||||
require_platform(args.platform, args.platforms_dir)
|
||||
|
||||
@@ -109,6 +109,30 @@ DEFAULT_BIOS_DIR = "bios"
|
||||
# that pass no directory.
|
||||
_REPO_PLATFORMS = os.path.join(os.path.dirname(__file__), "..", "platforms")
|
||||
DEFAULT_EMULATORS_DIR = "emulators"
|
||||
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
def work_from_repo_root(
|
||||
args: argparse.Namespace, parser: argparse.ArgumentParser, path_flags: list[str]
|
||||
) -> None:
|
||||
"""Run from the repository root, whichever directory the command started in.
|
||||
|
||||
database.json records every file from the root and the data registry
|
||||
names its caches the same way, so a run from scripts/ ended on a
|
||||
FileNotFoundError traceback. A path the caller typed is read from where
|
||||
they typed it, a default from the root.
|
||||
"""
|
||||
if os.path.realpath(os.getcwd()) == os.path.realpath(REPO_ROOT):
|
||||
return
|
||||
for flag in path_flags:
|
||||
value = getattr(args, flag, None)
|
||||
if value and value != parser.get_default(flag):
|
||||
setattr(args, flag, os.path.abspath(value))
|
||||
os.chdir(REPO_ROOT)
|
||||
if getattr(args, "platform", None):
|
||||
# Read before the move, the registry was not there to map
|
||||
# "RetroArch" to its slug.
|
||||
args.platform = platform_arg(args.platform)
|
||||
|
||||
|
||||
# Status model: aligned with Batocera BiosStatus (batocera-systems:967-969)
|
||||
@@ -2367,6 +2391,7 @@ def _main(held: contextlib.ExitStack) -> None:
|
||||
"present with an unconfirmed hash is a warning, not a failure",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
work_from_repo_root(args, parser, ["db", "platforms_dir", "emulators_dir"])
|
||||
if args.platform:
|
||||
require_platform(args.platform, args.platforms_dir)
|
||||
|
||||
|
||||
Reference in new issue
Block a user