-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmakecrosscompile.py
183 lines (159 loc) · 6.62 KB
/
makecrosscompile.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# -*- python -*-
# ex: set syntax=python:
import os
from buildbot.plugins import changes, schedulers, steps, util
from nextgis_utils import create_tags
# fmt: off
repositories = [
{'repo':'lib_z', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_curl', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_expat', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_geos', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_geotiff', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_jpeg', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_jbig', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_iconv', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_lzma', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_png', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_tiff', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_sqlite', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_proj', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_jsonc', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_xml2', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_gdal', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'lib_openssl', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis-borsch'},
{'repo':'nextgis_datastore', 'os':['jammy-crosscompile'], 'repo_root':'https://github.com', 'org':'nextgis'},
]
# fmt: on
c = {
"change_source": [],
"schedulers": [],
"builders": [],
}
platforms = [
{"name": "jammy-crosscompile", "worker": "deb-build-jammy-crosscompile"},
]
build_lock = util.MasterLock("crosscompile_worker_builds")
tools_base_url = "https://github.com/nextgis-borsch/borsch/raw/master/opt/"
crosscompile_script_name = "crosscompile.py"
crosscompile_script_src = tools_base_url + crosscompile_script_name
repka_release_script_name = "repka_release.py"
repka_release_script_src = tools_base_url + repka_release_script_name
logname = "stdio"
username = "buildbot"
userkey = os.environ.get("BUILDBOT_PASSWORD")
def get_env(os):
env = {
"BUILDBOT_USERPWD": "{}:{}".format(username, userkey),
}
return env
# Create builders
for repository in repositories:
project_name = repository["repo"]
org = repository["org"]
repourl = "{}/{}/{}.git".format(repository["repo_root"], org, project_name)
branch = "master"
if "branch" in repository:
branch = repository["branch"]
git_project_name = "{}/{}".format(org, project_name)
git_poller = changes.GitPoller(
project=git_project_name,
repourl=repourl,
# workdir = project_name + '-workdir',
branches=[branch],
pollinterval=5400,
)
c["change_source"].append(git_poller)
builderNames = []
for platform in platforms:
if platform["name"] in repository["os"]:
builderNames.append(project_name + "_" + platform["name"])
scheduler_name = project_name + "_crosscompile"
scheduler = schedulers.SingleBranchScheduler(
name=scheduler_name,
change_filter=util.ChangeFilter(project=git_project_name, branch=branch),
treeStableTimer=1 * 60,
builderNames=builderNames,
)
c["schedulers"].append(scheduler)
forceScheduler = schedulers.ForceScheduler(
name=scheduler_name + "_force",
label="Force build",
buttonName="Force build",
builderNames=builderNames,
)
c["schedulers"].append(forceScheduler)
root_dir = "build/"
repo_name = repository["repo"]
code_dir = root_dir + repo_name + "_code"
for platform in platforms:
if platform["name"] not in repository["os"]:
continue
factory = util.BuildFactory()
# 1. checkout the source
factory.addStep(
steps.Git(
repourl=repourl,
mode="full",
shallow=True,
submodules=True,
workdir=code_dir,
)
)
factory.addStep(
steps.ShellSequence(
commands=[
util.ShellArg(
command=[
"curl",
crosscompile_script_src,
"-o",
crosscompile_script_name,
"-s",
"-L",
],
logname=logname,
),
util.ShellArg(
command=[
"curl",
repka_release_script_src,
"-o",
repka_release_script_name,
"-s",
"-L",
],
logname=logname,
),
],
name="Download scripts",
haltOnFailure=True,
workdir=root_dir,
)
)
factory.addStep(
steps.ShellCommand(
command=[
"python",
crosscompile_script_name,
"--packages",
repo_name,
"--login",
username,
"--password",
userkey,
],
name="Crosscompile and send to repka",
haltOnFailure=True,
workdir=root_dir,
)
)
builder = util.BuilderConfig(
name=project_name + "_" + platform["name"],
workernames=[platform["worker"]],
factory=factory,
locks=[build_lock.access("exclusive")], # counting
description="Make {} on {}".format(project_name, platform["name"]),
tags=create_tags([project_name]),
)
c["builders"].append(builder)