Assemble the spice overlay against the exact retained Arrakis JAR
This commit is contained in:
parent
4f0155dda9
commit
90cd25de67
2 changed files with 28 additions and 3 deletions
|
|
@ -30,9 +30,9 @@ jobs:
|
|||
set -euo pipefail
|
||||
gradle --no-daemon -p JarvisConnector test jar
|
||||
python3 tools/test_plugin_fleet_install.py -v
|
||||
python3 tools/plugin_arrakis_raw_spice.py JarvisConnector/build/libs/jarvistranslator.jar
|
||||
mkdir raw-spice-artifacts
|
||||
cp JarvisConnector/build/libs/jarvistranslator.jar raw-spice-artifacts/
|
||||
curl --fail --location --retry 2 https://www.dunerealms.com/git/api/v1/repos/unimatrix/plugins/actions/artifacts/8602/zip -o retained-navigator.zip
|
||||
python3 tools/plugin_arrakis_raw_spice.py retained-navigator.zip JarvisConnector/build/libs/jarvistranslator.jar raw-spice-artifacts/jarvistranslator.jar
|
||||
printf '%s\n' "$(git rev-parse HEAD)" > raw-spice-artifacts/SOURCE_COMMIT
|
||||
python3 tools/write-plugin-manifest.py raw-spice-artifacts "$GITHUB_SHA"
|
||||
cp tools/{install-plugin-fleet,plugin_arrakis_raw_spice,plugin_menu_pack,plugin_backend_abi,plugin_fleet_rollback,plugin_pack_properties,plugin_pillager_abi,reset-arrakis-terrain}.py raw-spice-artifacts/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from pathlib import Path
|
||||
import hashlib
|
||||
import io
|
||||
import zipfile
|
||||
|
||||
BASELINE_SHA256 = 'ebe8d2edc9f3300a039de1f76b81a2435895569704b2087e0625db699effe5d7'
|
||||
|
|
@ -23,6 +24,30 @@ def verify_jar(path):
|
|||
raise ValueError('JARVIS changed outside the reviewed raw spice overlay and version')
|
||||
|
||||
|
||||
def assemble(baseline_artifact, compiled, output):
|
||||
with zipfile.ZipFile(baseline_artifact) as wrapper:
|
||||
names = wrapper.namelist()
|
||||
if len(names) == 1 and names[0].endswith('.zip'):
|
||||
with zipfile.ZipFile(io.BytesIO(wrapper.read(names[0]))) as release:
|
||||
baseline = release.read('jarvistranslator.jar')
|
||||
else:
|
||||
baseline = wrapper.read('jarvistranslator.jar')
|
||||
if hashlib.sha256(baseline).hexdigest() != BASELINE_SHA256:
|
||||
raise ValueError('Retained Jarvis baseline differs from deployed Arrakis runtime')
|
||||
with zipfile.ZipFile(io.BytesIO(baseline)) as original, zipfile.ZipFile(compiled) as build:
|
||||
replacements = {entry: build.read(entry) for entry in (OVERLAY, 'plugin.yml')}
|
||||
with zipfile.ZipFile(output, 'x') as result:
|
||||
for info in original.infolist():
|
||||
data = replacements[info.filename] if info.filename in replacements else original.read(info)
|
||||
result.writestr(info, data)
|
||||
verify_jar(output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
verify_jar(Path(sys.argv[1]))
|
||||
if len(sys.argv) == 4:
|
||||
assemble(*map(Path, sys.argv[1:]))
|
||||
elif len(sys.argv) == 2:
|
||||
verify_jar(Path(sys.argv[1]))
|
||||
else:
|
||||
raise SystemExit('Specify a JAR to verify, or baseline artifact, built JAR and output JAR')
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff