-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
119 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "GnuPG" | ||
name: gnupg | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "Patchelf" | ||
name: patchelf | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
"""Produce the gnupg.json file associated with the mirror""" | ||
import json | ||
|
||
import glob | ||
import hashlib | ||
import json | ||
|
@@ -8,7 +8,6 @@ | |
import spack.spec | ||
import spack.traverse | ||
|
||
|
||
# Each entry in gnupg.json has the following keys: | ||
# | ||
# "spec": root spec to be matched | ||
|
@@ -19,82 +18,72 @@ | |
|
||
# Dictionary that maps (OS, TARGET) to info for the spec | ||
SPEC_INFO = { | ||
('centos7', 'x86_64'): { | ||
'spec': '[email protected]: %gcc platform=linux target=x86_64', | ||
}, | ||
('centos7', 'aarch64'): { | ||
'spec': '[email protected]: %gcc platform=linux target=aarch64', | ||
}, | ||
('centos7', 'ppc64le'): { | ||
'spec': '[email protected]: %gcc platform=linux target=ppc64le', | ||
}, | ||
('monterey', 'x86_64'): { | ||
'spec': '[email protected]: %apple-clang platform=darwin target=x86_64', | ||
}, | ||
('sonoma', 'aarch64'): { | ||
'spec': '[email protected]: %apple-clang platform=darwin target=aarch64', | ||
} | ||
("centos7", "x86_64"): {"spec": "[email protected]: %gcc platform=linux target=x86_64"}, | ||
("centos7", "aarch64"): {"spec": "[email protected]: %gcc platform=linux target=aarch64"}, | ||
("centos7", "ppc64le"): {"spec": "[email protected]: %gcc platform=linux target=ppc64le"}, | ||
("monterey", "x86_64"): {"spec": "[email protected]: %apple-clang platform=darwin target=x86_64"}, | ||
("sonoma", "aarch64"): {"spec": "[email protected]: %apple-clang platform=darwin target=aarch64"}, | ||
} | ||
|
||
|
||
def sha256(path): | ||
fn = hashlib.sha256() | ||
with open(path, "rb") as f: | ||
fn.update(f.read()) | ||
return fn.hexdigest() | ||
|
||
|
||
def tarball_hash(path): | ||
filename = os.path.basename(path) | ||
filename = filename.replace('.spack', '') | ||
return filename.split('-')[-1] | ||
filename = filename.replace(".spack", "") | ||
return filename.split("-")[-1] | ||
|
||
shaglob_expr = './build_cache/**/*.spack' | ||
|
||
shaglob_expr = "./build_cache/**/*.spack" | ||
tarballs = glob.glob(shaglob_expr, recursive=True) | ||
shas = {tarball_hash(tarball): sha256(tarball) for tarball in tarballs} | ||
|
||
glob_expr = './build_cache/*.json' | ||
glob_expr = "./build_cache/*.json" | ||
spec_json_files = glob.glob(glob_expr) | ||
|
||
mirror_info = [] | ||
spec_json_dict = {} | ||
for spec_json in spec_json_files: | ||
if 'gnupg' not in spec_json: | ||
if "gnupg" not in spec_json: | ||
continue | ||
|
||
s = spack.spec.Spec.from_specfile(spec_json) | ||
binaries = [] | ||
for edge in reversed(spack.traverse.traverse_edges_topo([s], direction="children", deptype=("link", "run"))): | ||
node = edge.spec | ||
binaries.append( | ||
(node.name, node.dag_hash(), shas[node.dag_hash()]) | ||
) | ||
for edge in reversed( | ||
spack.traverse.traverse_edges_topo([s], direction="children", deptype=("link", "run")) | ||
): | ||
node = edge.spec | ||
binaries.append((node.name, node.dag_hash(), shas[node.dag_hash()])) | ||
|
||
# Get the raw data from spec.json | ||
with open(spec_json) as f: | ||
spec_json_data = json.load(f)['spec']['nodes'] | ||
spec_json_data = json.load(f)["spec"]["nodes"] | ||
|
||
# Find the GnuPG entry and store it somewhere | ||
binary_data = {} | ||
for entry in spec_json_data: | ||
if 'gnupg' == entry['name']: | ||
binary_data['gnupg'] = entry | ||
assert 'gnupg' in binary_data | ||
if "gnupg" == entry["name"]: | ||
binary_data["gnupg"] = entry | ||
assert "gnupg" in binary_data | ||
|
||
assert 'gnupg' in binary_data, 'entry "gnupg" is required' | ||
current_os = binary_data['gnupg']['arch']['platform_os'] | ||
current_target = binary_data['gnupg']['arch']['target'] | ||
assert "gnupg" in binary_data, 'entry "gnupg" is required' | ||
|
||
current_os = binary_data["gnupg"]["arch"]["platform_os"] | ||
current_target = binary_data["gnupg"]["arch"]["target"] | ||
|
||
# If the target is not generic, like x86_64 etc. it's a fully fledged object | ||
if not isinstance(current_target, str): | ||
current_target = current_target["name"] | ||
|
||
current_hash = binary_data['gnupg']['hash'] | ||
mirror_entry = { | ||
"spec": SPEC_INFO[(current_os, current_target)]['spec'], | ||
"binaries": binaries, | ||
} | ||
|
||
current_hash = binary_data["gnupg"]["hash"] | ||
mirror_entry = {"spec": SPEC_INFO[(current_os, current_target)]["spec"], "binaries": binaries} | ||
mirror_info.append(mirror_entry) | ||
|
||
mirror_info = sorted(mirror_info, key=lambda x: x['spec']) | ||
with open('./gnupg.json', 'w') as f: | ||
json.dump({'verified': mirror_info}, f, sort_keys=True, indent=2) | ||
mirror_info = sorted(mirror_info, key=lambda x: x["spec"]) | ||
with open("./gnupg.json", "w") as f: | ||
json.dump({"verified": mirror_info}, f, sort_keys=True, indent=2) |
Oops, something went wrong.