Skip to content

Commit

Permalink
dotnet: allow specifying the --runtime argument multiple times
Browse files Browse the repository at this point in the history
When doing so, `dotnet restore` gets executed once for each runtime,
creating a file that contains all the required sources.
  • Loading branch information
Parnassius authored and hfiguiere committed Nov 9, 2024
1 parent 9a48b5e commit 38910e2
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions dotnet/flatpak-dotnet-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('output', help='The output JSON sources file')
parser.add_argument('project', help='The project file')
parser.add_argument('--runtime', '-r', help='The target runtime to restore packages for')
parser.add_argument('--runtime', '-r', nargs='+', default=[None], help='The target runtime to restore packages for')
parser.add_argument('--freedesktop', '-f', help='The target version of the freedesktop sdk to use',
default=freedesktop_default)
parser.add_argument('--dotnet', '-d', help='The target version of dotnet to use',
Expand All @@ -34,18 +34,19 @@ def main():
sources = []

with tempfile.TemporaryDirectory(dir=Path()) as tmp:
runtime_args = []
if args.runtime:
runtime_args.extend(('-r', args.runtime))
for runtime in args.runtime:
runtime_args = []
if runtime is not None:
runtime_args.extend(('-r', runtime))

subprocess.run([
'flatpak', 'run',
'--env=DOTNET_CLI_TELEMETRY_OPTOUT=true',
'--env=DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true',
'--command=sh', f'--runtime=org.freedesktop.Sdk//{args.freedesktop}', '--share=network',
'--filesystem=host', f'org.freedesktop.Sdk.Extension.dotnet{args.dotnet}//{args.freedesktop}', '-c',
f'PATH="${{PATH}}:/usr/lib/sdk/dotnet{args.dotnet}/bin" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/sdk/dotnet{args.dotnet}/lib" exec dotnet restore "$@"',
'--', '--packages', tmp, args.project] + runtime_args)
subprocess.run([
'flatpak', 'run',
'--env=DOTNET_CLI_TELEMETRY_OPTOUT=true',
'--env=DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true',
'--command=sh', f'--runtime=org.freedesktop.Sdk//{args.freedesktop}', '--share=network',
'--filesystem=host', f'org.freedesktop.Sdk.Extension.dotnet{args.dotnet}//{args.freedesktop}', '-c',
f'PATH="${{PATH}}:/usr/lib/sdk/dotnet{args.dotnet}/bin" LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/sdk/dotnet{args.dotnet}/lib" exec dotnet restore "$@"',
'--', '--packages', tmp, args.project] + runtime_args)

for path in Path(tmp).glob('**/*.nupkg.sha512'):
name = path.parent.parent.name
Expand Down

0 comments on commit 38910e2

Please sign in to comment.