MCPcopy Create free account
hub / github.com/ClangBuiltLinux/boot-utils / download_initrd

Function download_initrd

utils.py:47–73  ·  view source on GitHub ↗

Download an initial ramdisk from a GitHub release Parameters: gh_json (dict): A serialized JSON object from a repo's release endpoint local_dest (Path): A Path object pointing to the local file destination

(gh_json, local_dest)

Source from the content-addressed store, hash-verified

45 sys.exit(1)
46
47
48def download_initrd(gh_json, local_dest):
49 """
50 Download an initial ramdisk from a GitHub release
51
52 Parameters:
53 gh_json (dict): A serialized JSON object from a repo's release endpoint
54 local_dest (Path): A Path object pointing to the local file destination
55 """
56 assets = gh_json['assets']
57 tag = gh_json['tag_name']
58 url = gh_json['url']
59
60 # Turns '<arch>/rootfs.<format>.zst' into '<arch>-rootfs.<format>.zst'
61 remote_file = '-'.join(local_dest.parts[-2:])
62
63 for asset in assets:
64 if asset['name'] == remote_file:
65 curl_cmd = ['curl', '-LSs', '-o', local_dest, asset['browser_download_url']]
66 subprocess.run(curl_cmd, check=True)
67
68 # Update the '.release' file in the same folder as the download
69 local_dest.with_name('.release').write_text(tag, encoding='utf-8')
70
71 return
72
73 msg = f"Failed to find {remote_file} in downloads of {url}?"
74 raise RuntimeError(msg)
75
76

Callers 1

prepare_initrdFunction · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected