Guard the compact DuneMenus-only rollout
This commit is contained in:
parent
8544fb4f2e
commit
670ad0de5f
5 changed files with 99 additions and 4 deletions
44
.forgejo/workflows/compact-menus.yml
Normal file
44
.forgejo/workflows/compact-menus.yml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
name: Compact DuneMenus Build
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: ['feat/dunemenus-compact-*']
|
||||
|
||||
jobs:
|
||||
compact-menus:
|
||||
runs-on: dune-ci
|
||||
steps:
|
||||
- name: Check out exact revision
|
||||
shell: bash
|
||||
env:
|
||||
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git init .
|
||||
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA"
|
||||
git checkout --detach FETCH_HEAD
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: '21'
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: '9.2.1'
|
||||
- name: Verify the DuneMenus-only transition
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
gradle --no-daemon -p DuneMenus test jar
|
||||
python3 tools/test_plugin_fleet_install.py -v
|
||||
python3 tools/plugin_compact_menus.py DuneMenus/build/libs/DuneMenus.jar
|
||||
mkdir compact-menus-artifacts
|
||||
cp DuneMenus/build/libs/DuneMenus.jar compact-menus-artifacts/
|
||||
printf '%s\n' "$(git rev-parse HEAD)" > compact-menus-artifacts/SOURCE_COMMIT
|
||||
python3 tools/write-plugin-manifest.py compact-menus-artifacts "$GITHUB_SHA"
|
||||
cp tools/{install-plugin-fleet,plugin_compact_menus,plugin_menu_pack,plugin_backend_abi,plugin_fleet_rollback,plugin_pack_properties,plugin_pillager_abi}.py compact-menus-artifacts/
|
||||
(cd compact-menus-artifacts && sha256sum -- *.jar *.json *.py SOURCE_COMMIT > SHA256SUMS)
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: DuneRealms-Compact-Menus
|
||||
path: compact-menus-artifacts/
|
||||
if-no-files-found: error
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import java.security.MessageDigest
|
||||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "2.0.8-navigator1"
|
||||
version = "2.0.9-compact1"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
|
|
|
|||
|
|
@ -75,8 +75,9 @@ def verify_dunechest_fleet_target(sid, root, unit, incoming, installed):
|
|||
|
||||
def plan(artifacts, inventory, expected_source):
|
||||
mode=inventory.get('mode')
|
||||
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest','fleet-dunechest','arrakis-raw-spice','arrakis-jerboa'}:
|
||||
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest','fleet-dunechest','arrakis-raw-spice','arrakis-jerboa','compact-menus'}:
|
||||
raise ValueError('An explicit supported rollout mode is required')
|
||||
compact_menus=mode=='compact-menus'
|
||||
jerboa=mode=='arrakis-jerboa'
|
||||
raw_spice=mode=='arrakis-raw-spice'
|
||||
pillager=mode=='pillager-preserve-economy'
|
||||
|
|
@ -91,6 +92,10 @@ def plan(artifacts, inventory, expected_source):
|
|||
allowed_names = {'DuneEss', 'DuneRealms', 'DuneCore', 'DuneLobby', 'DuneNPC', 'DunerealmsGUI', 'DuneTerrain', 'JarvisTranslator', 'DuneMenus'}
|
||||
if dunechest:
|
||||
allowed_names={'DuneChest'}
|
||||
if compact_menus:
|
||||
allowed_names={'DuneMenus'}
|
||||
if inventory.get('menuPack') is not None:
|
||||
raise ValueError('Compact menus require retaining the current resource pack')
|
||||
if jerboa:
|
||||
allowed_names={'DuneTerrain'}
|
||||
if raw_spice:
|
||||
|
|
@ -160,11 +165,16 @@ def plan(artifacts, inventory, expected_source):
|
|||
raise ValueError('Server private prerequisites must be explicitly provided and reviewed')
|
||||
chosen = [files[name] for name in selected] + [prerequisites[key] for key in selected_prerequisites]
|
||||
wanted = {entry['name'].casefold() for entry in chosen}
|
||||
uses_menu='dunemenus' in wanted or bool(menu and menu.get('unified') and not (crysknife or dunechest or jerboa))
|
||||
uses_menu=not compact_menus and ('dunemenus' in wanted or bool(menu and menu.get('unified') and not (crysknife or dunechest or jerboa)))
|
||||
if menu and menu.get('unified') and not (crysknife or dunechest or jerboa) and 'dunerealmsgui' not in wanted:
|
||||
raise ValueError('Unified pack rollout must select its matching DunerealmsGUI adapter')
|
||||
if not (pillager or crysknife or navigator or dunechest or raw_spice or jerboa) and wanted - {'dunemenus','dunerealmsgui','dunenpc','dunelobby','mcgui'}:
|
||||
raise ValueError('GUI rollout must retain working Ess/JARVIS/Core/Terrain binaries')
|
||||
if compact_menus:
|
||||
expected_root = Path('/opt/dunerealms/lobby') if sid == 'lobby' else Path('/opt/dunerealms/servers') / sid
|
||||
if (sid not in DUNECHEST_PLANETS | {'lobby'} or root != expected_root or unit != f'dune-{sid}.service'
|
||||
or wanted != {'dunemenus'} or selected_prerequisites):
|
||||
raise ValueError('Compact menus may only replace DuneMenus on a reviewed server')
|
||||
if jerboa and (sid != 'arrakis' or root != ARRAKIS_ROOT or unit != 'dune-arrakis.service'
|
||||
or wanted != {'duneterrain'} or selected_prerequisites):
|
||||
raise ValueError('Jerboa rollout may only replace Terrain on Arrakis')
|
||||
|
|
@ -325,6 +335,17 @@ def plan(artifacts, inventory, expected_source):
|
|||
replaced={entry['filename'] for entry in previous}
|
||||
retained=[{'filename':path.name,'sha256':digest(path),'metadata':metadata(path)}
|
||||
for path in sorted(plugins.glob('*.jar')) if path.name not in replaced]
|
||||
if compact_menus:
|
||||
from plugin_compact_menus import BASELINE_SHA256, verify_jar
|
||||
installed = existing_paths.get('dunemenus')
|
||||
if installed is None or digest(installed) not in {BASELINE_SHA256, chosen[0]['sha256']}:
|
||||
raise ValueError('Compact menus require the reviewed installed DuneMenus')
|
||||
if not {'dunerealmsgui', 'jarvistranslator', 'mcgui'}.issubset(existing_paths):
|
||||
raise ValueError('Compact menus require the retained GUI, JARVIS and MCGUI runtimes')
|
||||
verify_jar(chosen[0]['source'])
|
||||
replaced = {entry['filename'] for entry in previous}
|
||||
retained = [{'filename': path.name, 'sha256': digest(path), 'metadata': metadata(path)}
|
||||
for path in sorted(plugins.glob('*.jar')) if path.name not in replaced]
|
||||
if jerboa:
|
||||
from plugin_arrakis_jerboa import BASELINE_SHA256, verify_terrain
|
||||
installed = existing_paths.get('duneterrain')
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
},
|
||||
"modules": {
|
||||
"DuneMenus": {
|
||||
"version": "2.0.8-navigator1",
|
||||
"version": "2.0.9-compact1",
|
||||
"changedClasses": [
|
||||
"com/dunerealms/menus/CanvasProvider.class",
|
||||
"com/dunerealms/menus/Card.class",
|
||||
|
|
|
|||
30
tools/plugin_compact_menus.py
Normal file
30
tools/plugin_compact_menus.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from pathlib import Path
|
||||
import hashlib
|
||||
import zipfile
|
||||
|
||||
BASELINE_SHA256 = '1b8bbfe5ff34341e54267bca2fb87aabc780e483b5ea015870dd517b99af8871'
|
||||
OVERLAY = 'com/dunerealms/menus/SuppliedDocument.class'
|
||||
RETAINED_TREE = 'b8ed957242f45c034250cb482a23f91af7affe11167e5a7e9d070360d57f85df'
|
||||
DESCRIPTOR_SHA256 = '209c7f8da76a2788ce40de9e83fbca9e4370c665cf5d9803b5ea31d812f1894b'
|
||||
|
||||
|
||||
def verify_jar(path):
|
||||
if any(len(pin) != 64 for pin in (BASELINE_SHA256, RETAINED_TREE, DESCRIPTOR_SHA256)):
|
||||
raise ValueError('Expected complete SHA-256 pins')
|
||||
with zipfile.ZipFile(path) as jar:
|
||||
names = [name for name in jar.namelist() if not name.endswith('/')]
|
||||
if len(set(names)) != len(names):
|
||||
raise ValueError('Duplicate DuneMenus archive entry')
|
||||
if b'THE SPICE MUST FLOW' not in jar.read(OVERLAY):
|
||||
raise ValueError('Compact menu markup is missing')
|
||||
if hashlib.sha256(jar.read('plugin.yml')).hexdigest() != DESCRIPTOR_SHA256:
|
||||
raise ValueError('DuneMenus descriptor differs outside the reviewed version')
|
||||
rows = [name + '\0' + hashlib.sha256(jar.read(name)).hexdigest()
|
||||
for name in sorted(names) if name not in {OVERLAY, 'plugin.yml'}]
|
||||
if hashlib.sha256('\n'.join(rows).encode()).hexdigest() != RETAINED_TREE:
|
||||
raise ValueError('DuneMenus changed outside the reviewed compact UI and version')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
verify_jar(Path(sys.argv[1]))
|
||||
Loading…
Reference in a new issue

Staff