1 parent
639362fbf5
commit
bdd69f0aad
101 files changed
+22691
-531
No files matched your search
@@ -12,8 +12,9 @@ trap 'rm -rf -- "$temporary"' EXIT
|
||||
stage="$temporary/stage"
|
||||
mkdir -p "$stage/bin" "$stage/lib"
|
||||
install -m 0755 /bin/true "$stage/bin/echoiond"
|
||||
install -m 0755 /bin/true "$stage/bin/echoion-updater"
|
||||
install -m 0644 /bin/true "$stage/lib/Echoion.ts"
|
||||
printf '%s\n' '{}' >"$stage/manifest.json"
|
||||
printf '%s\n' '{"schemaVersion":2,"version":"1.2.3"}' >"$stage/manifest.json"
|
||||
cat >"$stage/install.sh" <<'INSTALL'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
@@ -39,6 +40,121 @@ bash "$source_root/scripts/package-release-payload.sh" \
|
||||
"$stage" "$base" 1700000000 "$archive_two" "$installer_two" "$temporary"
|
||||
cmp "$archive_one" "$archive_two"
|
||||
cmp "$installer_one" "$installer_two"
|
||||
[[ $(stat -c '%a' -- "$archive_one") == 644 ]]
|
||||
[[ $(stat -c '%a' -- "$archive_two") == 644 ]]
|
||||
[[ $(stat -c '%a' -- "$installer_one") == 755 ]]
|
||||
[[ $(stat -c '%a' -- "$installer_two") == 755 ]]
|
||||
|
||||
feed_payload="$temporary/update-payload.json"
|
||||
core_feed_payload="$temporary/core-update-payload.json"
|
||||
plugin_feed_payload="$temporary/plugin-update-payload.json"
|
||||
feed_envelope="$temporary/update-envelope.json"
|
||||
private_key="$temporary/update-private.pem"
|
||||
public_key="$temporary/update-public.pem"
|
||||
signature="$temporary/update-signature.bin"
|
||||
SOURCE_DATE_EPOCH=1700000000 python3 \
|
||||
"$source_root/scripts/generate-update-feed.py" \
|
||||
--artifact "$archive_one" \
|
||||
--manifest "$stage/manifest.json" \
|
||||
--version 1.2.3 \
|
||||
--url https://updates.example.invalid/echoion-1.2.3-linux-x86_64.tar.zst \
|
||||
--channel beta \
|
||||
--feed-id echoion-test \
|
||||
--sequence 42 \
|
||||
--output-payload "$feed_payload"
|
||||
python3 - "$feed_payload" "$archive_one" "$stage/manifest.json" <<'PY'
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
payload = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
|
||||
artifact = Path(sys.argv[2])
|
||||
manifest = Path(sys.argv[3])
|
||||
release = payload["releases"][0]
|
||||
assert payload["schemaVersion"] == 1
|
||||
assert payload["feedId"] == "echoion-test"
|
||||
assert payload["sequence"] == 42
|
||||
assert release["component"] == "runtime"
|
||||
assert release["artifactId"] == ""
|
||||
assert release["channel"] == "beta"
|
||||
assert release["packageType"] == "tar.zst"
|
||||
assert release["size"] == artifact.stat().st_size
|
||||
assert release["sha256"] == hashlib.sha256(artifact.read_bytes()).hexdigest()
|
||||
assert release["releaseManifestSha256"] == hashlib.sha256(
|
||||
manifest.read_bytes()
|
||||
).hexdigest()
|
||||
PY
|
||||
|
||||
SOURCE_DATE_EPOCH=1700000000 python3 \
|
||||
"$source_root/scripts/generate-update-feed.py" \
|
||||
--artifact "$stage/lib/Echoion.ts" \
|
||||
--component core \
|
||||
--version 1.2.3 \
|
||||
--url https://updates.example.invalid/Echoion-1.2.3.so \
|
||||
--feed-id echoion-core-test \
|
||||
--sequence 43 \
|
||||
--output-payload "$core_feed_payload"
|
||||
SOURCE_DATE_EPOCH=1700000000 python3 \
|
||||
"$source_root/scripts/generate-update-feed.py" \
|
||||
--artifact "$stage/lib/Echoion.ts" \
|
||||
--component plugin \
|
||||
--artifact-id lyrics \
|
||||
--version 2.3.4 \
|
||||
--url https://updates.example.invalid/lyrics-2.3.4.so \
|
||||
--feed-id echoion-plugin-test \
|
||||
--sequence 44 \
|
||||
--output-payload "$plugin_feed_payload"
|
||||
python3 - "$core_feed_payload" "$plugin_feed_payload" <<'PY'
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
core = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))["releases"][0]
|
||||
plugin = json.loads(Path(sys.argv[2]).read_text(encoding="utf-8"))["releases"][0]
|
||||
|
||||
assert core["component"] == "core"
|
||||
assert core["artifactId"] == ""
|
||||
assert core["packageType"] == "shared-library"
|
||||
assert "releaseManifestSha256" not in core
|
||||
assert plugin["component"] == "plugin"
|
||||
assert plugin["artifactId"] == "lyrics"
|
||||
assert plugin["packageType"] == "shared-library"
|
||||
assert "releaseManifestSha256" not in plugin
|
||||
PY
|
||||
|
||||
openssl genpkey -algorithm ED25519 -out "$private_key" >/dev/null 2>&1
|
||||
SOURCE_DATE_EPOCH=1700000000 python3 \
|
||||
"$source_root/scripts/generate-update-feed.py" \
|
||||
--artifact "$archive_one" \
|
||||
--manifest "$stage/manifest.json" \
|
||||
--version 1.2.3 \
|
||||
--url https://updates.example.invalid/echoion-1.2.3-linux-x86_64.tar.zst \
|
||||
--sequence 42 \
|
||||
--output-payload "$feed_payload" \
|
||||
--output-envelope "$feed_envelope" \
|
||||
--key-id test-key \
|
||||
--private-key "$private_key"
|
||||
python3 - "$feed_payload" "$feed_envelope" "$signature" <<'PY'
|
||||
import base64
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
payload = Path(sys.argv[1]).read_bytes()
|
||||
envelope = json.loads(Path(sys.argv[2]).read_text(encoding="utf-8"))
|
||||
|
||||
def decode(value: str) -> bytes:
|
||||
return base64.urlsafe_b64decode(value + "=" * (-len(value) % 4))
|
||||
|
||||
assert envelope["schemaVersion"] == 1
|
||||
assert envelope["keyId"] == "test-key"
|
||||
assert decode(envelope["payload"]) == payload
|
||||
Path(sys.argv[3]).write_bytes(decode(envelope["signature"]))
|
||||
PY
|
||||
openssl pkey -in "$private_key" -pubout -out "$public_key" >/dev/null 2>&1
|
||||
openssl pkeyutl -verify -rawin -pubin -inkey "$public_key" \
|
||||
-in "$feed_payload" -sigfile "$signature" >/dev/null
|
||||
|
||||
mapfile -t members < <(tar --zstd -tf "$archive_one")
|
||||
((${#members[@]} > 0))
|
||||
@@ -58,4 +174,15 @@ record="$temporary/installer-arguments"
|
||||
printf '%s\n' alpha 'two words' >"$temporary/expected-arguments"
|
||||
cmp "$temporary/expected-arguments" "$record"
|
||||
|
||||
path_installer_directory="$temporary/path-installer"
|
||||
mkdir "$path_installer_directory"
|
||||
install -m 0755 "$installer_one" "$path_installer_directory/echoion-installer"
|
||||
path_record="$temporary/path-installer-arguments"
|
||||
(
|
||||
cd /
|
||||
PATH="$path_installer_directory:$PATH" \
|
||||
echoion-installer --record "$path_record" alpha 'two words'
|
||||
)
|
||||
cmp "$temporary/expected-arguments" "$path_record"
|
||||
|
||||
echo "release archive layout and .run regressions passed"
|
||||
Reference in new issue
Block a user