41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
#!/usr/bin/python3
|
|
"""Build pinned script-free .deb artifacts; NEVER install or publish them."""
|
|
import importlib.util
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import stat
|
|
import sys
|
|
|
|
sys.dont_write_bytecode = True
|
|
SPEC = importlib.util.spec_from_file_location('apt_transaction',
|
|
Path(__file__).with_name('apt_transaction.py'))
|
|
apt = importlib.util.module_from_spec(SPEC)
|
|
sys.modules[SPEC.name] = apt
|
|
SPEC.loader.exec_module(apt)
|
|
|
|
|
|
def build(output):
|
|
output = Path(output).resolve(strict=True)
|
|
st = output.stat()
|
|
if not stat.S_ISDIR(st.st_mode) or st.st_uid != os.getuid() or st.st_mode & 0o077:
|
|
raise ValueError('output must be an owned private directory')
|
|
records = []
|
|
for version in ('1.0', '1.1'):
|
|
destination = output / ('rmm-mvp-test_' + version + '_all.deb')
|
|
data = apt.fixture_archive(version)
|
|
apt.require(apt.digest(data) == apt.FIXTURE_SHA256[version], 'FIXTURE_PINNED_BYTES')
|
|
with destination.open('xb') as stream:
|
|
stream.write(data)
|
|
records.append({'name': 'rmm-mvp-test', 'new_version': version,
|
|
'architecture': 'all', 'origin': 'rmm-test',
|
|
'sha256': apt.digest(data), 'size': len(data),
|
|
'local_build_path': str(destination)})
|
|
return records
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if len(sys.argv) != 2:
|
|
sys.exit('usage: build_fixture.py EXISTING_PRIVATE_OUTPUT_DIRECTORY')
|
|
print(json.dumps(build(sys.argv[1]), indent=2))
|