forked from droidian-images/droidian
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerate_recipe.py
executable file
·78 lines (66 loc) · 2.42 KB
/
generate_recipe.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import json
from datetime import datetime
import argparse
# List of architectures and UIs
architectures = ["arm64", "armhf", "amd64"]
uis = ["plasma"]
# Common suffix for all files
suffix = datetime.today().strftime('%Y%m%d')
# Function to generate the content
def generate_content(architecture, ui):
return f"""{{{{- $product := or .product "rootfs" -}}}}
{{{{- $architecture := or .architecture "{architecture}" -}}}}
{{{{- $suffix := or .suffix "{suffix}" -}}}}
{{{{- $edition := or .edition "{ui}" -}}}}
{{{{- $version := or .version "nightly" -}}}}
{{{{- $mtype := or .mtype "OFFICIAL" -}}}}
{{{{- $image := or .image (printf "droidian-%s-%s-%s-%s-%s_%s.zip" $mtype $edition $architecture $version $suffix) -}}}}
{{{{- $output_type := or .output_type "rootfs" -}}}}
{{{{- $use_internal_repository := or .use_internal_repository "no" -}}}}
architecture: {{{{ $architecture }}}}
actions:
- action: run
description: Do nothing
chroot: false
command: echo "Doing nothing!"
- action: recipe
description: Build Droidian
recipe: ../rootfs-templates/lindroid_{ui}.yaml
variables:
architecture: {{{{ $architecture }}}}
suffix: {{{{ $suffix }}}}
edition: {{{{ $edition }}}}
version: {{{{ $version }}}}
image: {{{{ $image }}}}
output_type: {{{{ $output_type }}}}
use_internal_repository: {{{{ $use_internal_repository }}}}
"""
# Directory to save generated files
output_dir = "generated"
os.makedirs(output_dir, exist_ok=True)
# Generate files and matrix
matrix = []
for architecture in architectures:
for ui in uis:
filename = f"lindroid-{ui}-{architecture}.yaml"
filepath = os.path.join(output_dir, filename)
content = generate_content(architecture, ui)
with open(filepath, 'w') as file:
file.write(content)
job_name = f"rootfs ({ui} edition) - {architecture}"
matrix.append({
"job_name": job_name,
"product": "rootfs",
"arch": architecture,
"edition": ui
})
# Parse arguments for matrix generation
parser = argparse.ArgumentParser(description='Generate device recipe files and matrix.')
parser.add_argument('--matrix', action='store_true', help='Generate and display the matrix.')
args = parser.parse_args()
# Display the matrix if the --matrix flag is set
if args.matrix:
print(json.dumps(matrix, indent=4))