Ship Windows x64 through a separately signed official GNU release channel

This commit is contained in:
2026-11-18 10:53:16 +01:00
parent 7ddd579888
commit 663e846415
16 changed files with 110 additions and 45 deletions
+18 -4
View File
@@ -126,6 +126,13 @@ def https(value):
return url
def release_label(platform, official_windows):
if official_windows:
check(platform == WINDOWS_GNU, 'official Windows releases require a GNU x64 build receipt')
return 'windows-gnu-official'
return {LINUX: 'linux', WINDOWS: 'windows', WINDOWS_GNU: 'windows-gnu'}[platform]
def prepare(args):
provision_folder(args.state)
provision_folder(args.state/'private')
@@ -141,7 +148,7 @@ def prepare_locked(args):
check(minimum in (1,2), 'unknown minimum updater version')
check(0 < args.days <= 3650, 'invalid validity in days')
platform, blobs = binaries(args.artifacts, args.build_receipt)
label = {LINUX:'linux', WINDOWS:'windows', WINDOWS_GNU:'windows-gnu'}[platform]
label = release_label(platform, getattr(args, 'official_windows', False))
check(minimum == 1 or platform == WINDOWS_GNU, 'version 2 currently applies to the GNU Windows worker')
provision_folder(args.state)
config, private = args.state / 'config', args.state / 'private'
@@ -288,14 +295,19 @@ def publish(args):
check(bool(args.rotate_bootstrap_from) == bool(args.bootstrap_state), 'rotation needs previous SHA and local signing state')
check(not (args.rotate_bootstrap_from and args.bootstrap_worker), 'a rotation uses the new receipt-bound stable worker')
client = Publisher(args.origin, args.ca)
if args.dev_login_file:
if args.local_username:
login = {'username': args.local_username, 'password': getpass.getpass('WebUI password: '),
'totp_code': getpass.getpass('Authenticator code: ')}
elif args.dev_login_file:
path = args.dev_login_file
check(path.stat().st_mode & 0o077 == 0, 'dev login file requires private permissions')
credentials = json.loads(path.read_bytes())
login = {k: credentials[k] for k in ('username','password')}
else:
login = {'username': args.dev_username, 'password': getpass.getpass('Development WebUI password: ')}
client.request('POST', '/auth/dev/login', encoded(login), {'Content-Type': 'application/json'})
route = '/auth/local/login' if args.local_username else '/auth/dev/login'
client.request('POST', route, encoded(login), {'Content-Type': 'application/json'})
client.headers['X-RMM-Tenant'] = str(uuid.UUID(args.tenant))
session = client.request('GET', '/auth/session')
client.headers['X-CSRF-Token'] = session['csrf_token']
try:
@@ -319,7 +331,7 @@ def publish(args):
check(result['sha256'] == blob['sha256'] and result['size_bytes'] == blob['bytes'], 'artifact receipt differs')
if args.rotate_bootstrap_from:
stable = blobs[-1]
label = {LINUX:'linux', WINDOWS:'windows', WINDOWS_GNU:'windows-gnu'}[platform]
label = release_label(platform, getattr(args, 'official_windows', False))
rotate_pin(args.bootstrap_state,label,tenant,args.rotate_bootstrap_from,
{'sha256':stable['sha256'],'bytes':stable['bytes']})
if worker_only:
@@ -340,6 +352,7 @@ def main():
for name, fn in (('prepare', prepare), ('publish', publish)):
cmd = sub.add_parser(name)
cmd.set_defaults(run=fn)
cmd.add_argument('--official-windows', action='store_true', help='Use the dedicated Windows GNU production signing key and bootstrap state')
cmd.add_argument('--artifacts', type=Path, required=True)
cmd.add_argument('--build-receipt', type=Path, required=True)
if name == 'prepare':
@@ -360,6 +373,7 @@ def main():
cmd.add_argument('--envelope', type=Path, help='Prepared agent and helper release')
cmd.add_argument('--rotate-worker-only', action='store_true', help='Rotate the stable worker independently of a code-pair release')
auth = cmd.add_mutually_exclusive_group(required=True)
auth.add_argument('--local-username', help='Sign in with the public WebUI password and a fresh TOTP code')
auth.add_argument('--dev-username')
auth.add_argument('--dev-login-file', type=Path)
args = parser.parse_args()
+5 -2
View File
@@ -52,6 +52,8 @@ def on_server(options):
if hashlib.sha256(dest.read_bytes()).hexdigest() != digest:
raise ValueError('staged slot already contains different build: ' + name)
inputs = ['--artifacts', str(build), '--build-receipt', str(build / options['receipt'])]
if options['official']:
inputs.append('--official-windows')
if not options['worker_only']:
subprocess.run(['python3', '-I', str(tool), 'prepare', *inputs, '--state', str(state), '--gateway', options['gateway'],
'--service-uid','10001','--minimum-updater-version',str(options['minimum']),'--sequence',str(options['sequence']),'--version',options['version']],check=True)
@@ -128,6 +130,7 @@ def main():
parser.add_argument('--rotate-worker-only',action='store_true',help='Publish just the stable worker from its build receipt and rotate its tenant pin')
parser.add_argument('--gateway',default='https://discovery.ease-technologies.de')
parser.add_argument('--tenant',default='11111111-1111-4111-8111-111111111111')
parser.add_argument('--official-windows',action='store_true',help='Sign with the separate official Windows GNU key')
parser.add_argument('--prepare-only',action='store_true')
args=parser.parse_args()
if args.rotate_worker_only:
@@ -144,8 +147,8 @@ def main():
params={'files':{f.name:hashlib.sha256(f.read_bytes()).hexdigest() for f in files},'tool':hashlib.sha256(tool.read_bytes()).hexdigest(),
'receipt':args.build_receipt.name,'sequence':args.sequence,'version':args.version,'tenant':args.tenant,
'worker_only':args.rotate_worker_only,'worker_sha':descriptors[-1]['sha256'],
'minimum':args.minimum_updater_version,'rotate':args.rotate_bootstrap_from,'gateway':args.gateway,'prepare_only':args.prepare_only,'label':{agent_release.LINUX:'linux',
agent_release.WINDOWS:'windows',agent_release.WINDOWS_GNU:'windows-gnu'}[platform]}
'minimum':args.minimum_updater_version,'rotate':args.rotate_bootstrap_from,'gateway':args.gateway,'prepare_only':args.prepare_only,'official':args.official_windows,
'label':agent_release.release_label(platform,args.official_windows)}
subprocess.run([sys.executable,str(ROOT/'tools/dev_stage.py'),'server',*map(str,files),str(tool)],check=True)
command=inspect.getsource(on_server)+'\non_server('+repr(params)+')\n'
subprocess.run([*ssh_prefix('server'),shlex.join(['python3','-I','-'])],input=command,text=True,check=True)
+9 -3
View File
@@ -15,10 +15,14 @@ import uuid
from dev_stage import ssh_prefix
def publish(tenant, platform, release, *, root=Path('/opt/rust-discovery/devstate/mvp-releases'),
def publish(tenant, platform, release, official_windows=False, *, root=Path('/opt/rust-discovery/devstate/mvp-releases'),
database_container='rust-discovery-server-postgres-1', service_uid=10001):
labels = {'x86_64-pc-windows-gnu': 'windows-gnu', 'x86_64-unknown-linux-gnu': 'linux'}
label = labels[platform]
if official_windows:
if platform != 'x86_64-pc-windows-gnu':
raise ValueError('Official Windows starter requires GNU x64')
label = 'windows-gnu-official'
source = root / 'objects' / tenant
config = root / 'config'
dest = config / 'customer-starters'
@@ -71,7 +75,8 @@ def publish(tenant, platform, release, *, root=Path('/opt/rust-discovery/devstat
if not stat.S_ISREG(info.st_mode) or info.st_size!=size:
raise ValueError('Missing regular package file')
write(digest,iter(lambda:f.read(1024*1024),b''))
write(platform+'.json',[json.dumps(desc,separators=(',',':')).encode()])
descriptor = platform + ('-official.json' if official_windows else '.json')
write(descriptor,[json.dumps(desc,separators=(',',':')).encode()])
directory_fd = os.open(dest, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
try:
os.fsync(directory_fd)
@@ -84,10 +89,11 @@ def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--tenant',required=True,type=uuid.UUID)
parser.add_argument('--platform',required=True,choices=['x86_64-unknown-linux-gnu','x86_64-pc-windows-gnu'])
parser.add_argument('--official-windows',action='store_true')
parser.add_argument('--release',required=True,type=uuid.UUID)
args=parser.parse_args()
imports='import hashlib,json,os,re,stat,subprocess,tempfile\nfrom pathlib import Path\n'
script=imports+inspect.getsource(publish)+'\npublish'+repr((str(args.tenant),args.platform,str(args.release)))
script=imports+inspect.getsource(publish)+'\npublish'+repr((str(args.tenant),args.platform,str(args.release),args.official_windows))
subprocess.run([*ssh_prefix('server'),'python3 -I -'],input=script,text=True,check=True)