-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmodify-recipe.py
More file actions
51 lines (40 loc) · 1.54 KB
/
modify-recipe.py
File metadata and controls
51 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Modify the git2cpp emscripten-forge recipe to build from the local repo.
# This can be called repeatedly and will produce the same output.
import argparse
from pathlib import Path
import shutil
import yaml
parser = argparse.ArgumentParser()
parser.add_argument("input_directory", type=Path)
parser.add_argument("--no-patches", action="store_true")
args = parser.parse_args()
input_dir = args.input_directory
if not input_dir.is_dir():
quit(f"{input_dir} should exist and be a directory")
input_filename = input_dir / "recipe.yaml"
if not input_filename.is_file():
quit(f"{input_filename} should exist and be a file")
# If backup does not exist create it.
input_backup = input_dir / "recipe_original.yaml"
backup_exists = input_backup.exists()
if not backup_exists:
shutil.copy(input_filename, input_backup)
# Read and parse input backup file which is the original recipe file.
with open(input_backup) as f:
recipe = yaml.safe_load(f)
build_number = recipe["build"]["number"]
print(f" Changing build number from {build_number} to {build_number + 1}")
recipe["build"]["number"] = build_number + 1
source = recipe["source"]
if not ("sha256" in source and "url" in source):
raise RuntimeError("Expected recipe to have both a source sha256 and url")
del source["sha256"]
del source["url"]
print(" Changing source to point to local git2cpp repo")
source["path"] = "../../../../../../"
if args.no_patches:
print(" Deleting patches")
del source["patches"]
# Overwrite recipe file.
with open(input_filename, "w") as f:
yaml.dump(recipe, f)