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

Callers 1

prepare_initrdFunction · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected