38 lines
1.9 KiB
Python
38 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Bundle upstream runtime sources, local changes and build recipes for binaries."""
|
|
import argparse
|
|
import io
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tarfile
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
def bundle(output):
|
|
cache = ROOT / 'build/runtime-sources'
|
|
olsr = ROOT / 'build/olsrd-source'
|
|
with tarfile.open(output, 'w:gz') as archive:
|
|
def blob(name, data):
|
|
info = tarfile.TarInfo(name)
|
|
info.size = len(data)
|
|
info.mode = 0o644
|
|
archive.addfile(info, io.BytesIO(data))
|
|
for source, name in [(cache / 'busybox.tar.bz2', 'busybox-1.37.0.tar.bz2'),
|
|
(cache / 'busybox-1.37.0/.config', 'busybox.config'),
|
|
(cache / 'bird-2.20.0.tar.gz', 'bird-2.20.0.tar.gz')]:
|
|
archive.add(source, arcname=name, recursive=False)
|
|
blob('olsrd.tar', subprocess.check_output(['git', 'archive', '--format=tar', 'HEAD'], cwd=olsr))
|
|
blob('olsrd.patch', subprocess.check_output(['git', 'diff', '--binary', 'HEAD'], cwd=olsr))
|
|
blob('project.tar', subprocess.check_output(['git', 'archive', '--format=tar', 'HEAD'], cwd=ROOT))
|
|
blob('README.txt', b'Runtime source bundle. Extract project.tar for build recipes and licenses.\n'
|
|
b'BusyBox: supplied archive and .config. BIRD: supplied archive.\n'
|
|
b'OLSR: extract olsrd.tar and apply olsrd.patch with git apply.\n'
|
|
b'Cross-toolchain URL and digest are pinned in tools/build-runtime.sh.\n'
|
|
b'Project source includes helper programs and all build scripts.\n'
|
|
b'RouterOS and Netinstall are upstream proprietary inputs, not in this archive.\n')
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--output', required=True)
|
|
bundle(parser.parse_args().output)
|