eris/build-flatpak.py
Andrew Hamilton 88682bb82f flatpak: Make build-flatpak use the local eris repository.
- This lets the build be tested on a new commit that doesn't
  yet exist on github.
- A temporary patched version of the manifest is made with
  eris's url patched to the local repo. ($PWD)
- build-flatpak.py needs to be run in the eris root directory.
2019-06-30 12:20:41 +10:00

46 lines
1.4 KiB
Python
Executable file

#!/usr/bin/python3.7
# Copyright (C) 2019 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0.
import json
import os
import subprocess
import sys
import tempfile
USAGE = """Make a flatpak build of eris.
Usage: build-flatpak.sh <manifest_path> <build_dir> <state_dir>
e.g. # build-flatpak.sh com.github.ahamilton.eris.json eris-build flatpak-cache
The script should only be run from the root of the local eris repository.
"""
if len(sys.argv) != 4:
print(USAGE)
sys.exit(1)
def patch_manifest(manifest_path, patched_manifest_path):
with open(manifest_path) as manifest_file:
manifest = json.load(manifest_file)
eris_module = manifest["modules"][-1]
eris_module["sources"][0]["url"] = "file://" + os.getcwd()
with open(patched_manifest_path, "w") as patched_manifest_file:
json.dump(manifest, patched_manifest_file, indent=2)
manifest_path, build_dir, state_dir = sys.argv[1:4]
with tempfile.TemporaryDirectory() as temp_dir:
patched_manifest_path = os.path.join(temp_dir, "manifest.json")
patch_manifest(manifest_path, patched_manifest_path)
subprocess.run(["flatpak-builder", build_dir, patched_manifest_path,
"--force-clean", "--state-dir", state_dir], check=True)
subprocess.run(["flatpak", "build", build_dir, "test-all"], check=True)
subprocess.run(["flatpak", "build", build_dir, "eris", "--help"], check=True)
print("Build successful:", build_dir)