Skip to content

Commit

Permalink
Publish from #896
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jul 14, 2023
0 parents commit 2839723
Show file tree
Hide file tree
Showing 8 changed files with 819 additions and 0 deletions.
514 changes: 514 additions & 0 deletions .github/workflows/stable-cargo.yml

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[target.x86_64-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:x86_64-unknown-linux-gnu"

[target.x86_64-unknown-linux-musl]
image = "ghcr.io/cargo-prebuilt/cross-auditable:x86_64-unknown-linux-musl"

[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:aarch64-unknown-linux-gnu"

[target.aarch64-unknown-linux-musl]
image = "ghcr.io/cargo-prebuilt/cross-auditable:aarch64-unknown-linux-musl"

[target.x86_64-unknown-freebsd]
image = "ghcr.io/cargo-prebuilt/cross-auditable:x86_64-unknown-freebsd"

[target.x86_64-unknown-netbsd]
image = "ghcr.io/cargo-prebuilt/cross-auditable:x86_64-unknown-netbsd"

[target.x86_64-unknown-illumos]
image = "ghcr.io/cargo-prebuilt/cross-auditable:x86_64-unknown-illumos"

[target.x86_64-sun-solaris]
image = "ghcr.io/cargo-prebuilt/cross-auditable:x86_64-sun-solaris"

[target.riscv64gc-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:riscv64gc-unknown-linux-gnu"

[target.powerpc64-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:powerpc64-unknown-linux-gnu"

[target.powerpc64le-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:powerpc64le-unknown-linux-gnu"

[target.s390x-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:s390x-unknown-linux-gnu"

[target.mips64-unknown-linux-gnuabi64]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mips64-unknown-linux-gnuabi64"

[target.mips64-unknown-linux-muslabi64]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mips64-unknown-linux-muslabi64"

[target.mips64el-unknown-linux-gnuabi64]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mips64el-unknown-linux-gnuabi64"

[target.mips64el-unknown-linux-muslabi64]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mips64el-unknown-linux-muslabi64"

[target.i686-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:i686-unknown-linux-gnu"

[target.i686-unknown-linux-musl]
image = "ghcr.io/cargo-prebuilt/cross-auditable:i686-unknown-linux-musl"

[target.i686-unknown-freebsd]
image = "ghcr.io/cargo-prebuilt/cross-auditable:i686-unknown-freebsd"

[target.armv7-unknown-linux-gnueabihf]
image = "ghcr.io/cargo-prebuilt/cross-auditable:armv7-unknown-linux-gnueabihf"

[target.armv7-unknown-linux-musleabihf]
image = "ghcr.io/cargo-prebuilt/cross-auditable:armv7-unknown-linux-musleabihf"

[target.powerpc-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:powerpc-unknown-linux-gnu"

[target.mips-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mips-unknown-linux-gnu"

[target.mips-unknown-linux-musl]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mips-unknown-linux-musl"

[target.mipsel-unknown-linux-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mipsel-unknown-linux-gnu"

[target.mipsel-unknown-linux-musl]
image = "ghcr.io/cargo-prebuilt/cross-auditable:mipsel-unknown-linux-musl"

[target.x86_64-pc-windows-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:x86_64-pc-windows-gnu"

[target.i686-pc-windows-gnu]
image = "ghcr.io/cargo-prebuilt/cross-auditable:i686-pc-windows-gnu"
8 changes: 8 additions & 0 deletions crates/cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[info]
id = "cargo"
git = "https://github.com/rust-lang/cargo"
unsupported = ["aarch64-pc-windows-msvc", "x86_64-sun-solaris"]
bins = ["cargo"]

[target.all]
features = "vendored-openssl"
2 changes: 2 additions & 0 deletions keys/cargo-prebuilt-index.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
untrusted comment: minisign public key 51FF575479E09402
RWQClOB5VFf/UXuhG+697EOSWlSyIPWjyehJpepjgQ7qsLnZxGQzDnqA
1 change: 1 addition & 0 deletions keys/cargo-prebuilt-index.pub.base64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXkgNTFGRjU3NTQ3OUUwOTQwMgpSV1FDbE9CNVZGZi9VWHVoRys2OTdFT1NXbFN5SVBXanllaEpwZXBqZ1E3cXNMblp4R1F6RG5xQQo=
69 changes: 69 additions & 0 deletions scripts/collect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import hashlib
import json
import os
import stat
import sys
import tarfile


def main(target, build_path, bins):
bins = bins.split(",")

hash_obj = {
"bins": [],
"archive": [],
}

ending = ""
if "windows" in target:
ending = ".exe"

with tarfile.open(target + ".tar.gz", "w:gz") as archive:
for b in bins:
basename = b + ending
path = build_path + "/" + basename

# Permission Fix
if "windows" not in target:
st = os.stat(path)
os.chmod(path, st.st_mode | stat.S_IEXEC)

# Hashes
with open(path, "rb") as file:
file = file.read()
h = hashlib.sha256(file).hexdigest()
hash_obj["bins"].append({"bin": basename, "hash": h, "type": "sha256"})
h = hashlib.sha512(file).hexdigest()
hash_obj["bins"].append({"bin": basename, "hash": h, "type": "sha512"})
h = hashlib.sha3_256(file).hexdigest()
hash_obj["bins"].append({"bin": basename, "hash": h, "type": "sha3_256"})
h = hashlib.sha3_512(file).hexdigest()
hash_obj["bins"].append({"bin": basename, "hash": h, "type": "sha3_512"})

# Add to archive
archive.add(path, basename)

with open(target + ".tar.gz", "rb") as file:
file = file.read()
h = hashlib.sha256(file).hexdigest()
hash_obj["archive"].append({"hash": h, "type": "sha256"})

# TODO: Remove with 0.6.0 of cargo-prebuilt
with open(target + ".sha256", "w") as tmp_file:
tmp_file.write(h)
#

h = hashlib.sha512(file).hexdigest()
hash_obj["archive"].append({"hash": h, "type": "sha512"})
h = hashlib.sha3_256(file).hexdigest()
hash_obj["archive"].append({"hash": h, "type": "sha3_256"})
h = hashlib.sha3_512(file).hexdigest()
hash_obj["archive"].append({"hash": h, "type": "sha3_512"})

with open(target + ".hashes.json", "w") as file:
file.write(json.dumps(hash_obj))


if __name__ == "__main__":
argv = sys.argv
main(argv[1], argv[2], argv[3])
87 changes: 87 additions & 0 deletions scripts/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import datetime
import glob
import json
import sys
import tomllib
from datetime import datetime
import misc


def main(filename, version, license_spdx, description, rustc_version_guess):
with open(filename, "rb") as file:
crate_toml = tomllib.load(file)

description = json.loads(description)["description"]
features = misc.gen_flags(crate_toml)

targets = []
for t in glob.glob("target-*"):
targets.append(t[7:])

info = { # info.json
"info_version": "1",
"id": crate_toml["info"]["id"],
"version": version,
"license": license_spdx,
"git": crate_toml["info"]["git"],
"description": description,
"bins": crate_toml["info"]["bins"],
"info": {
"rustc_version_guess": rustc_version_guess[6:],
"index_publish_date": datetime.utcnow().strftime("%Y-%m-%d"),
"features_apple": str(features["apple"][0]),
"features_linux": str(features["linux"][0]),
"features_windows": str(features["windows"][0]),
"no_default_features_apple": str(features["apple"][1]),
"no_default_features_linux": str(features["linux"][1]),
"no_default_features_windows": str(features["windows"][1]),
},
"archive": {
"compression": "gz",
"ext": "tar.gz"
},
"files": {
"hash": "hashes.json",
"license": "license.report",
"deps": "deps.report",
"audit": "audit.report",
"sig_info": "info.json.minisig",
"sig_hash": "hashes.json.minisig",
},
"targets": targets,
}

with open("./info.json", "w") as file:
file.write(json.dumps(info))

hashes = { # hashes.json
"hashes_version": "1",
"hashes": {}
}

# Fill hashes
for t in targets:
with open(f"./target-{t}/{t}.hashes.json", "r") as file:
blob = {
"archive": {},
"bins": {}
}
hash_file = json.loads(file.read())

for h in hash_file["archive"]:
blob["archive"][h["type"]] = h["hash"]

for b in hash_file["bins"]:
if b["bin"] not in blob["bins"]:
blob["bins"][b["bin"]] = {}
blob["bins"][b["bin"]][b["type"]] = b["hash"]

hashes["hashes"][t] = blob

with open("./hashes.json", "w") as file:
file.write(json.dumps(hashes))


if __name__ == "__main__":
argv = sys.argv
main(argv[1], argv[2], argv[3], argv[4], argv[5])
55 changes: 55 additions & 0 deletions scripts/misc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Misc code to reduce duplicate blocks

def gen_flags(crate_toml):
apple_flags = [None, False, ""] # FEATURES(0), NO_DEFAULT_FEATURES(1), EXTRA_FLAGS(2)
linux_flags = [None, False, ""]
windows_flags = [None, False, ""]

if "target" in crate_toml:
targets = crate_toml["target"]
if "all" in targets:
if "features" in targets["all"]:
f = targets["all"]["features"]
apple_flags[0] = f
linux_flags[0] = f
windows_flags[0] = f
if "no-default-features" in targets["all"]:
f = targets["all"]["no-default-features"]
apple_flags[1] = f
linux_flags[1] = f
windows_flags[1] = f
if "flags" in targets["all"]:
f = targets["all"]["flags"]
apple_flags[2] = f
linux_flags[2] = f
windows_flags[2] = f

if "apple" in targets:
if "features" in targets["apple"]:
apple_flags[0] = targets["apple"]["features"]
if "no-default-features" in targets["apple"]:
apple_flags[1] = targets["apple"]["no-default-features"]
if "flags" in targets["apple"]:
apple_flags[2] = targets["apple"]["flags"]

if "linux" in targets:
if "features" in targets["linux"]:
linux_flags[0] = targets["linux"]["features"]
if "no-default-features" in targets["linux"]:
linux_flags[1] = targets["linux"]["no-default-features"]
if "flags" in targets["linux"]:
linux_flags[2] = targets["linux"]["flags"]

if "windows" in targets:
if "features" in targets["windows"]:
windows_flags[0] = targets["windows"]["features"]
if "no-default-features" in targets["windows"]:
windows_flags[1] = targets["windows"]["no-default-features"]
if "flags" in targets["windows"]:
windows_flags[2] = targets["windows"]["flags"]

return {
"apple": apple_flags,
"linux": linux_flags,
"windows": windows_flags,
}

0 comments on commit 2839723

Please sign in to comment.