jolt 0.9.172__py3-none-any.whl → 0.9.435__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. jolt/__init__.py +80 -7
  2. jolt/__main__.py +9 -1
  3. jolt/bin/fstree-darwin-x86_64 +0 -0
  4. jolt/bin/fstree-linux-x86_64 +0 -0
  5. jolt/cache.py +596 -252
  6. jolt/chroot.py +36 -11
  7. jolt/cli.py +143 -130
  8. jolt/common_pb2.py +45 -45
  9. jolt/config.py +76 -40
  10. jolt/error.py +19 -4
  11. jolt/filesystem.py +2 -6
  12. jolt/graph.py +400 -82
  13. jolt/influence.py +110 -3
  14. jolt/loader.py +338 -174
  15. jolt/log.py +127 -31
  16. jolt/manifest.py +13 -46
  17. jolt/options.py +35 -11
  18. jolt/pkgs/abseil.py +42 -0
  19. jolt/pkgs/asio.py +25 -0
  20. jolt/pkgs/autoconf.py +41 -0
  21. jolt/pkgs/automake.py +41 -0
  22. jolt/pkgs/b2.py +31 -0
  23. jolt/pkgs/boost.py +111 -0
  24. jolt/pkgs/boringssl.py +32 -0
  25. jolt/pkgs/busybox.py +39 -0
  26. jolt/pkgs/bzip2.py +43 -0
  27. jolt/pkgs/cares.py +29 -0
  28. jolt/pkgs/catch2.py +36 -0
  29. jolt/pkgs/cbindgen.py +17 -0
  30. jolt/pkgs/cista.py +19 -0
  31. jolt/pkgs/clang.py +44 -0
  32. jolt/pkgs/cli11.py +24 -0
  33. jolt/pkgs/cmake.py +48 -0
  34. jolt/pkgs/cpython.py +196 -0
  35. jolt/pkgs/crun.py +29 -0
  36. jolt/pkgs/curl.py +38 -0
  37. jolt/pkgs/dbus.py +18 -0
  38. jolt/pkgs/double_conversion.py +24 -0
  39. jolt/pkgs/fastfloat.py +21 -0
  40. jolt/pkgs/ffmpeg.py +28 -0
  41. jolt/pkgs/flatbuffers.py +29 -0
  42. jolt/pkgs/fmt.py +27 -0
  43. jolt/pkgs/fstree.py +20 -0
  44. jolt/pkgs/gflags.py +18 -0
  45. jolt/pkgs/glib.py +18 -0
  46. jolt/pkgs/glog.py +25 -0
  47. jolt/pkgs/glslang.py +21 -0
  48. jolt/pkgs/golang.py +16 -11
  49. jolt/pkgs/googlebenchmark.py +18 -0
  50. jolt/pkgs/googletest.py +46 -0
  51. jolt/pkgs/gperf.py +15 -0
  52. jolt/pkgs/grpc.py +73 -0
  53. jolt/pkgs/hdf5.py +19 -0
  54. jolt/pkgs/help2man.py +14 -0
  55. jolt/pkgs/inja.py +28 -0
  56. jolt/pkgs/jsoncpp.py +31 -0
  57. jolt/pkgs/libarchive.py +43 -0
  58. jolt/pkgs/libcap.py +44 -0
  59. jolt/pkgs/libdrm.py +44 -0
  60. jolt/pkgs/libedit.py +42 -0
  61. jolt/pkgs/libevent.py +31 -0
  62. jolt/pkgs/libexpat.py +27 -0
  63. jolt/pkgs/libfastjson.py +21 -0
  64. jolt/pkgs/libffi.py +16 -0
  65. jolt/pkgs/libglvnd.py +30 -0
  66. jolt/pkgs/libogg.py +28 -0
  67. jolt/pkgs/libpciaccess.py +18 -0
  68. jolt/pkgs/libseccomp.py +21 -0
  69. jolt/pkgs/libtirpc.py +24 -0
  70. jolt/pkgs/libtool.py +42 -0
  71. jolt/pkgs/libunwind.py +35 -0
  72. jolt/pkgs/libva.py +18 -0
  73. jolt/pkgs/libvorbis.py +33 -0
  74. jolt/pkgs/libxml2.py +35 -0
  75. jolt/pkgs/libxslt.py +17 -0
  76. jolt/pkgs/libyajl.py +16 -0
  77. jolt/pkgs/llvm.py +81 -0
  78. jolt/pkgs/lua.py +54 -0
  79. jolt/pkgs/lz4.py +26 -0
  80. jolt/pkgs/m4.py +14 -0
  81. jolt/pkgs/make.py +17 -0
  82. jolt/pkgs/mesa.py +81 -0
  83. jolt/pkgs/meson.py +17 -0
  84. jolt/pkgs/mstch.py +28 -0
  85. jolt/pkgs/mysql.py +60 -0
  86. jolt/pkgs/nasm.py +49 -0
  87. jolt/pkgs/ncurses.py +30 -0
  88. jolt/pkgs/ng_log.py +25 -0
  89. jolt/pkgs/ninja.py +45 -0
  90. jolt/pkgs/nlohmann_json.py +25 -0
  91. jolt/pkgs/nodejs.py +19 -11
  92. jolt/pkgs/opencv.py +24 -0
  93. jolt/pkgs/openjdk.py +26 -0
  94. jolt/pkgs/openssl.py +103 -0
  95. jolt/pkgs/paho.py +76 -0
  96. jolt/pkgs/patchelf.py +16 -0
  97. jolt/pkgs/perl.py +42 -0
  98. jolt/pkgs/pkgconfig.py +64 -0
  99. jolt/pkgs/poco.py +39 -0
  100. jolt/pkgs/protobuf.py +77 -0
  101. jolt/pkgs/pugixml.py +27 -0
  102. jolt/pkgs/python.py +19 -0
  103. jolt/pkgs/qt.py +35 -0
  104. jolt/pkgs/rapidjson.py +26 -0
  105. jolt/pkgs/rapidyaml.py +28 -0
  106. jolt/pkgs/re2.py +30 -0
  107. jolt/pkgs/re2c.py +17 -0
  108. jolt/pkgs/readline.py +15 -0
  109. jolt/pkgs/rust.py +41 -0
  110. jolt/pkgs/sdl.py +28 -0
  111. jolt/pkgs/simdjson.py +27 -0
  112. jolt/pkgs/soci.py +46 -0
  113. jolt/pkgs/spdlog.py +29 -0
  114. jolt/pkgs/spirv_llvm.py +21 -0
  115. jolt/pkgs/spirv_tools.py +24 -0
  116. jolt/pkgs/sqlite.py +83 -0
  117. jolt/pkgs/ssl.py +12 -0
  118. jolt/pkgs/texinfo.py +15 -0
  119. jolt/pkgs/tomlplusplus.py +22 -0
  120. jolt/pkgs/wayland.py +26 -0
  121. jolt/pkgs/x11.py +58 -0
  122. jolt/pkgs/xerces_c.py +20 -0
  123. jolt/pkgs/xorg.py +360 -0
  124. jolt/pkgs/xz.py +29 -0
  125. jolt/pkgs/yamlcpp.py +30 -0
  126. jolt/pkgs/zeromq.py +47 -0
  127. jolt/pkgs/zlib.py +87 -0
  128. jolt/pkgs/zstd.py +33 -0
  129. jolt/plugins/alias.py +3 -0
  130. jolt/plugins/allure.py +2 -2
  131. jolt/plugins/autotools.py +66 -0
  132. jolt/plugins/cache.py +1 -1
  133. jolt/plugins/cmake.py +74 -6
  134. jolt/plugins/conan.py +238 -0
  135. jolt/plugins/cxxinfo.py +7 -0
  136. jolt/plugins/docker.py +76 -19
  137. jolt/plugins/email.xslt +141 -118
  138. jolt/plugins/environ.py +11 -0
  139. jolt/plugins/fetch.py +141 -0
  140. jolt/plugins/gdb.py +33 -14
  141. jolt/plugins/gerrit.py +0 -13
  142. jolt/plugins/git.py +248 -66
  143. jolt/plugins/googletest.py +1 -1
  144. jolt/plugins/http.py +1 -1
  145. jolt/plugins/libtool.py +63 -0
  146. jolt/plugins/linux.py +990 -0
  147. jolt/plugins/logstash.py +4 -4
  148. jolt/plugins/meson.py +61 -0
  149. jolt/plugins/ninja-compdb.py +96 -28
  150. jolt/plugins/ninja.py +424 -150
  151. jolt/plugins/paths.py +11 -1
  152. jolt/plugins/pkgconfig.py +219 -0
  153. jolt/plugins/podman.py +131 -87
  154. jolt/plugins/python.py +137 -0
  155. jolt/plugins/remote_execution/administration_pb2.py +27 -19
  156. jolt/plugins/remote_execution/log_pb2.py +12 -12
  157. jolt/plugins/remote_execution/scheduler_pb2.py +23 -23
  158. jolt/plugins/remote_execution/worker_pb2.py +19 -19
  159. jolt/plugins/report.py +7 -2
  160. jolt/plugins/rust.py +25 -0
  161. jolt/plugins/scheduler.py +135 -86
  162. jolt/plugins/selfdeploy/setup.py +6 -6
  163. jolt/plugins/selfdeploy.py +49 -31
  164. jolt/plugins/strings.py +35 -22
  165. jolt/plugins/symlinks.py +11 -4
  166. jolt/plugins/telemetry.py +1 -2
  167. jolt/plugins/timeline.py +13 -3
  168. jolt/scheduler.py +467 -165
  169. jolt/tasks.py +427 -111
  170. jolt/templates/timeline.html.template +44 -47
  171. jolt/timer.py +22 -0
  172. jolt/tools.py +527 -188
  173. jolt/utils.py +183 -3
  174. jolt/version.py +1 -1
  175. jolt/xmldom.py +12 -2
  176. {jolt-0.9.172.dist-info → jolt-0.9.435.dist-info}/METADATA +97 -41
  177. jolt-0.9.435.dist-info/RECORD +207 -0
  178. {jolt-0.9.172.dist-info → jolt-0.9.435.dist-info}/WHEEL +1 -1
  179. jolt/plugins/amqp.py +0 -855
  180. jolt/plugins/debian.py +0 -338
  181. jolt/plugins/repo.py +0 -253
  182. jolt/plugins/snap.py +0 -122
  183. jolt-0.9.172.dist-info/RECORD +0 -92
  184. {jolt-0.9.172.dist-info → jolt-0.9.435.dist-info}/entry_points.txt +0 -0
  185. {jolt-0.9.172.dist-info → jolt-0.9.435.dist-info}/top_level.txt +0 -0
jolt/plugins/debian.py DELETED
@@ -1,338 +0,0 @@
1
- from jolt import BooleanParameter, Parameter, Task
2
- from jolt import attributes, filesystem as fs, loader
3
- from jolt.tasks import TaskRegistry
4
-
5
- from jolt.cache import ArtifactListAttribute
6
- from jolt.cache import ArtifactAttributeSet
7
- from jolt.cache import ArtifactAttributeSetProvider
8
-
9
- import contextlib
10
- import os
11
- import platform
12
-
13
-
14
- class DebianListVariable(ArtifactListAttribute):
15
- pass
16
-
17
-
18
- class DebianAttributeSet(ArtifactAttributeSet):
19
- def __init__(self, artifact):
20
- super(DebianAttributeSet, self).__init__()
21
- super(ArtifactAttributeSet, self).__setattr__("_artifact", artifact)
22
-
23
- def create(self, name):
24
- if name == "chroot":
25
- return DebianListVariable(self._artifact, "chroot")
26
- assert False, "No such debian attribute: {0}".format(name)
27
-
28
-
29
- @ArtifactAttributeSetProvider.Register
30
- class DebianAttributeProvider(ArtifactAttributeSetProvider):
31
- def create(self, artifact):
32
- setattr(artifact, "debian", DebianAttributeSet(artifact))
33
-
34
- def parse(self, artifact, content):
35
- if "debian" not in content:
36
- return
37
- for key, value in content["debian"].items():
38
- getattr(artifact.debian, key).set_value(value, expand=False)
39
-
40
- def format(self, artifact, content):
41
- if "debian" not in content:
42
- content["debian"] = {}
43
- for key, attrib in artifact.debian.items():
44
- content["debian"][key] = attrib.get_value()
45
-
46
- def apply_deps(self, task, deps):
47
- lowerdirs = []
48
- for _, artifact in deps.items():
49
- lowerdirs += [
50
- fs.path.join(artifact.path, item)
51
- for item in artifact.debian.chroot.items()
52
- ]
53
- if lowerdirs:
54
- task.__chroot = task.tools.builddir("chroot")
55
- with task.tools.cwd(task.__chroot):
56
- task.tools.mkdir("work")
57
- task.tools.mkdir("uppr")
58
- task.tools.mkdir("root")
59
- task.tools.run("fuse-overlayfs -o lowerdir={},upperdir=uppr,workdir=work root",
60
- ":".join(lowerdirs))
61
- task.__unshare = contextlib.ExitStack()
62
- task.__unshare.enter_context(
63
- task.tools.chroot(chroot=fs.path.join(task.__chroot, "root")))
64
-
65
- def unapply_deps(self, task, deps):
66
- try:
67
- task.__unshare.close()
68
- with task.tools.cwd(task.__chroot):
69
- task.tools.run("fusermount -u root")
70
- except Exception:
71
- pass
72
-
73
-
74
- class Debian(Task):
75
- abstract = False
76
-
77
- packages = []
78
- """ List of packages to install, in addition to those included by variant. """
79
-
80
- mode = "unshare"
81
- """
82
- Mode of operation when creating Debian chroot.
83
-
84
- Valid modes are:
85
-
86
- - fakeroot
87
- - proot
88
- - unshare
89
-
90
- The default mode is fakeroot. See mmdebstrap documentation
91
- for details. Note that Jolt does not permit any mode that requires
92
- root privileges.
93
- """
94
-
95
- mirrors = []
96
- """ List of mirrors """
97
-
98
- suite = "bullseye"
99
- """
100
- Debian release codename.
101
-
102
- The suite may be a valid release code name (eg, sid, stretch, jessie)
103
- or a symbolic name (eg, unstable, testing, stable, oldstable).
104
- Any suite name that works with apt on the given mirror will work.
105
- """
106
-
107
- target = "rootfs.tar"
108
- """ Target """
109
-
110
- variant = "extract"
111
- """
112
- Choose which package set to install.
113
-
114
- Valid variant names are:
115
- - extract
116
- - custom
117
- - essential
118
- - apt
119
- - required
120
- - minbase
121
- - buildd
122
- - important
123
- - debootstrap
124
- - standard
125
-
126
- The default variant is extract where only packages listed in ``packages``
127
- are downloaded and extracted, but not installed.
128
-
129
- See mmdebstrab documentation for details.
130
- """
131
-
132
- def run(self, deps, tools):
133
- with tools.cwd(tools.builddir()):
134
- packages = "--include={}".format(",".join(self.packages)) if self.packages else ""
135
- tools.run(
136
- "mmdebstrap {} --mode={mode} --variant={variant} {suite} {target}",
137
- packages,
138
- )
139
-
140
- def publish(self, artifact, tools):
141
- with tools.cwd(tools.builddir()):
142
- artifact.collect("*", symlinks=True)
143
-
144
-
145
- class DebianPkgBase(Debian):
146
- abstract = True
147
-
148
- include = ["."]
149
- exclude = []
150
-
151
- def run(self, deps, tools):
152
- super().run(deps, tools)
153
- with tools.cwd(tools.builddir()):
154
- include = " ".join(self.include)
155
- exclude = " ".join(["--exclude=" + i for i in self.exclude])
156
- tools.run("tar --exclude=./dev {} -xf {target} {}", exclude, include)
157
- tools.unlink(self.target)
158
-
159
- def publish(self, artifact, tools):
160
- super().publish(artifact, tools)
161
-
162
- with tools.cwd(artifact.path):
163
- for bindir in ["bin", "sbin", "usr/bin", "usr/sbin"]:
164
- if os.path.exists(tools.expand_path(bindir)):
165
- artifact.environ.PATH.append(bindir)
166
-
167
- for incdir in ["usr/include"]:
168
- if os.path.exists(tools.expand_path(incdir)):
169
- pass # artifact.cxxinfo.incpaths.append(incdir)
170
-
171
- for libdir in ["lib", "usr/lib"]:
172
- if os.path.exists(tools.expand_path(libdir)):
173
- pass # artifact.cxxinfo.libpaths.append(libdir)
174
- artifact.environ.LD_LIBRARY_PATH.append(libdir)
175
-
176
- for pkgdir in ["usr/share/pkgconfig"]:
177
- if os.path.exists(tools.expand_path(pkgdir)):
178
- artifact.environ.PKG_CONFIG_PATH.append(pkgdir)
179
-
180
-
181
- @attributes.method("run", "run_{download[download,build]}")
182
- class MMDebstrap(DebianPkgBase):
183
- """
184
- Provides the tools required to build Debian tools and filesystems.
185
- """
186
-
187
- name = "debian/mmdebstrap"
188
- packages = [
189
- "bash",
190
- "bubblewrap",
191
- "coreutils",
192
- "dash",
193
- "fakechroot",
194
- "fakeroot",
195
- "fuse-overlayfs",
196
- "mmdebstrap",
197
- "proot",
198
- "qemu-user",
199
- "util-linux",
200
- ]
201
- mode = "unshare"
202
- suite = "bullseye"
203
- variant = "essential"
204
-
205
- download = BooleanParameter(True, help="Download files from Github, or build from scratch.")
206
- url = "https://github.com/srand/jolt/releases/download/v0.9.35/mmdebstrap.tgz"
207
-
208
- @property
209
- def joltdir(self):
210
- return loader.JoltLoader.get().joltdir
211
-
212
- def run_build(self, deps, tools):
213
- super().run(deps, tools)
214
-
215
- def run_download(self, deps, tools):
216
- with tools.cwd(tools.builddir()):
217
- assert tools.download(self.url, "debstrap.tgz"), "Failed to download mmdebstrap"
218
- tools.extract("debstrap.tgz", ".")
219
- tools.unlink("debstrap.tgz")
220
-
221
-
222
- TaskRegistry.get().add_task_class(MMDebstrap)
223
-
224
-
225
- class DebianPkg(DebianPkgBase):
226
- abstract = True
227
- requires = ["debian/mmdebstrap"]
228
-
229
- def publish(self, artifact, tools):
230
- super().publish(artifact, tools)
231
- artifact.debian.chroot.append(".")
232
-
233
-
234
- class DebianEssential(DebianPkg):
235
- name = "debian/essential"
236
- variant = "essential"
237
-
238
- @property
239
- def joltdir(self):
240
- return loader.JoltLoader.get().joltdir
241
-
242
-
243
- TaskRegistry.get().add_task_class(DebianEssential)
244
-
245
-
246
- def _host():
247
- m = platform.machine()
248
- if m == "x86_64":
249
- return "amd64"
250
- return m
251
-
252
-
253
- @attributes.attribute("packages", "packages_{host}_{arch}")
254
- @attributes.method("publish", "publish_{host}_{arch}")
255
- class GCC(DebianPkg):
256
- name = "debian/gcc"
257
-
258
- host = Parameter(_host(), values=["amd64"], const=True)
259
- arch = Parameter(_host(), values=["amd64", "armel", "armhf", "arm64"], help="Target architecture.")
260
-
261
- packages_amd64_amd64 = ["gcc", "g++"]
262
- packages_amd64_armhf = ["crossbuild-essential-armhf"]
263
- packages_amd64_armel = ["crossbuild-essential-armel"]
264
- packages_amd64_arm64 = ["crossbuild-essential-arm64"]
265
-
266
- @property
267
- def joltdir(self):
268
- return loader.JoltLoader.get().joltdir
269
-
270
- def publish_amd64_amd64(self, artifact, tools):
271
- super().publish(artifact, tools)
272
- artifact.environ.AR = "ar"
273
- artifact.environ.CC = "gcc"
274
- artifact.environ.CONFIGURE_FLAGS = ""
275
- artifact.environ.CPP = "cpp"
276
- artifact.environ.CROSS_COMPILE = ""
277
- artifact.environ.CXX = "g++"
278
- artifact.environ.LD = "ld"
279
- artifact.environ.OBJCOPY = "objcopy"
280
- artifact.environ.OBJDUMP = "objdump"
281
- artifact.environ.PKG_CONFIG = "pkg-config"
282
- artifact.environ.RANLIB = "ranlib"
283
- artifact.environ.STRIP = "strip"
284
- artifact.environ.TARGET_PREFIX = ""
285
-
286
- def publish_amd64_armel(self, artifact, tools):
287
- super().publish(artifact, tools)
288
- artifact.environ.AR = "arm-linux-gnueabi-ar"
289
- artifact.environ.CC = "arm-linux-gnueabi-gcc"
290
- artifact.environ.CONFIGURE_FLAGS = "--target arm-linux-gnueabi --host arm-linux-gnueabi --build x86_64-linux-gnu"
291
- artifact.environ.CPP = "arm-linux-gnueabi-cpp"
292
- artifact.environ.CROSS_COMPILE = "arm-linux-gnueabi-"
293
- artifact.environ.CXX = "arm-linux-gnueabi-g++"
294
- artifact.environ.LD = "arm-linux-gnueabi-ld"
295
- artifact.environ.NM = "arm-linux-gnueabi-nm"
296
- artifact.environ.OBJCOPY = "arm-linux-gnueabi-objcopy"
297
- artifact.environ.OBJDUMP = "arm-linux-gnueabi-objdump"
298
- artifact.environ.PKG_CONFIG = "arm-linux-gnueabi-pkg-config"
299
- artifact.environ.RANLIB = "arm-linux-gnueabi-ranlib"
300
- artifact.environ.STRIP = "arm-linux-gnueabi-strip"
301
- artifact.environ.TARGET_PREFIX = "arm-linux-gnueabi-"
302
-
303
- def publish_amd64_armhf(self, artifact, tools):
304
- super().publish(artifact, tools)
305
- artifact.environ.AR = "arm-linux-gnueabihf-ar"
306
- artifact.environ.CC = "arm-linux-gnueabihf-gcc"
307
- artifact.environ.CONFIGURE_FLAGS = "--target arm-linux-gnueabihf --host arm-linux-gnueabihf --build x86_64-linux-gnu"
308
- artifact.environ.CPP = "arm-linux-gnueabihf-cpp"
309
- artifact.environ.CROSS_COMPILE = "arm-linux-gnueabihf-"
310
- artifact.environ.CXX = "arm-linux-gnueabihf-g++"
311
- artifact.environ.LD = "arm-linux-gnueabihf-ld"
312
- artifact.environ.NM = "arm-linux-gnueabihf-nm"
313
- artifact.environ.OBJCOPY = "arm-linux-gnueabihf-objcopy"
314
- artifact.environ.OBJDUMP = "arm-linux-gnueabihf-objdump"
315
- artifact.environ.PKG_CONFIG = "arm-linux-gnueabihf-pkg-config"
316
- artifact.environ.RANLIB = "arm-linux-gnueabihf-ranlib"
317
- artifact.environ.STRIP = "arm-linux-gnueabihf-strip"
318
- artifact.environ.TARGET_PREFIX = "arm-linux-gnueabihf-"
319
-
320
- def publish_amd64_arm64(self, artifact, tools):
321
- super().publish(artifact, tools)
322
- artifact.environ.AR = "aarch64-linux-gnu-ar"
323
- artifact.environ.CC = "aarch64-linux-gnu-gcc"
324
- artifact.environ.CONFIGURE_FLAGS = "--target aarch64-linux-gnu --host aarch64-linux-gnu --build x86_64-linux-gnu"
325
- artifact.environ.CPP = "aarch64-linux-gnu-cpp"
326
- artifact.environ.CROSS_COMPILE = "aarch64-linux-gnu-"
327
- artifact.environ.CXX = "aarch64-linux-gnu-g++"
328
- artifact.environ.LD = "aarch64-linux-gnu-ld"
329
- artifact.environ.NM = "aarch64-linux-gnu-nm"
330
- artifact.environ.OBJCOPY = "aarch64-linux-gnu-objcopy"
331
- artifact.environ.OBJDUMP = "aarch64-linux-gnu-objdump"
332
- artifact.environ.PKG_CONFIG = "aarch64-linux-gnu-pkg-config"
333
- artifact.environ.RANLIB = "aarch64-linux-gnu-ranlib"
334
- artifact.environ.STRIP = "aarch64-linux-gnu-strip"
335
- artifact.environ.TARGET_PREFIX = "aarch64-linux-gnu-"
336
-
337
-
338
- TaskRegistry.get().add_task_class(GCC)
jolt/plugins/repo.py DELETED
@@ -1,253 +0,0 @@
1
- from copy import copy
2
- from threading import RLock
3
- from xml.dom import minidom
4
-
5
- from jolt.influence import HashInfluenceProvider, HashInfluenceRegistry
6
- from jolt.tools import Tools
7
- from jolt import filesystem as fs
8
- from jolt import log
9
- from jolt.plugins import git
10
- from jolt.scheduler import NetworkExecutorExtension, NetworkExecutorExtensionFactory
11
- from jolt.xmldom import Attribute, Composition, SubElement, Element, ElementTree, ET
12
-
13
-
14
- @Attribute('name')
15
- @Attribute('fetch')
16
- class RepoRemote(SubElement):
17
- def __init__(self, elem=None):
18
- super(RepoRemote, self).__init__('remote', elem=elem)
19
-
20
-
21
- @Attribute('revision')
22
- @Attribute('remote')
23
- @Attribute('sync-j')
24
- class RepoDefault(SubElement):
25
- def __init__(self, elem=None):
26
- super(RepoDefault, self).__init__('default', elem=elem)
27
-
28
-
29
- @Attribute('path')
30
- @Attribute('name')
31
- @Attribute('revision')
32
- @Attribute('upstream')
33
- @Attribute('remote')
34
- class RepoProject(SubElement):
35
- def __init__(self, elem=None):
36
- super(RepoProject, self).__init__('project', elem=elem)
37
-
38
- def get_diff(self):
39
- with self.tools.cwd(self.path_or_name):
40
- return self.tools.run("git diff --no-ext-diff HEAD", output_on_error=True)
41
- assert False, "git command failed"
42
-
43
- def get_head(self):
44
- with self.tools.cwd(self.path_or_name):
45
- return self.tools.run("git rev-parse HEAD", output_on_error=True).strip()
46
- assert False, "git command failed"
47
-
48
- def get_remote_branches(self, commit):
49
- with self.tools.cwd(self.path_or_name):
50
- result = self.tools.run("git branch -r --contains {0}", commit, output_on_error=True)
51
- if not result:
52
- return []
53
- result = result.strip().splitlines()
54
- result = [line.strip() for line in result]
55
- return result
56
- assert False, "git command failed"
57
-
58
- def get_local_commits(self):
59
- with self.tools.cwd(self.path_or_name):
60
- result = self.tools.run("git rev-list HEAD ^@{{upstream}}", output_on_error=True)
61
- if not result:
62
- return []
63
- result = result.strip("\r\n ")
64
- return result.splitlines()
65
- assert False, "git command failed"
66
-
67
- def has_local_ref(self, ref):
68
- with self.tools.cwd(self.path_or_name):
69
- try:
70
- return True if self.tools.run("git show-ref {0}", ref, output=False) else False
71
- except Exception:
72
- return False
73
-
74
- def get_remote_ref(self, commit, remote, pattern=None):
75
- with self.tools.cwd(self.path_or_name):
76
- result = self.tools.run(
77
- "git ls-remote {0}{1}",
78
- remote,
79
- " {0}".format(pattern) if pattern else "",
80
- output_on_error=True)
81
- if not result:
82
- return None
83
- result = result.strip().splitlines()
84
- result = [line.split("\t") for line in result]
85
- result = {line[0]: line[1] for line in result}
86
- return result.get(commit)
87
- assert False, "git command failed"
88
-
89
- @property
90
- def path_or_name(self):
91
- return self.path or self.name
92
-
93
-
94
- @Composition(RepoRemote, "remote")
95
- @Composition(RepoDefault, "default")
96
- @Composition(RepoProject, "project")
97
- class RepoManifest(ElementTree):
98
- def __init__(self, task, path):
99
- super(RepoManifest, self).__init__(element=Element('manifest'))
100
- self.path = path
101
- self.tools = task.tools
102
-
103
- def append(self, element):
104
- self.getroot().append(element)
105
-
106
- def get(self, key):
107
- self.getroot().get(key)
108
-
109
- def set(self, key, value):
110
- self.getroot().set(key, value)
111
-
112
- def parse(self, filename=".repo/manifest.xml"):
113
- with open(fs.path.join(self.tools.getcwd(), filename)) as f:
114
- root = ET.fromstring(f.read())
115
- self._setroot(root)
116
- for project in self.projects:
117
- project.tools = self.tools
118
- return self
119
- raise Exception("failed to parse xml file")
120
-
121
- def format(self):
122
- return minidom.parseString(ET.tostring(self.getroot())).toprettyxml(indent=" ")
123
-
124
- def write(self, filename):
125
- with open(filename, 'w') as f:
126
- f.write(self.format())
127
-
128
- def get_remote(self, project):
129
- if len(self.defaults) > 0:
130
- return project.remote or self.defaults[0].remote
131
- return project.remote
132
-
133
- def get_upstream(self, project):
134
- if len(self.defaults) > 0:
135
- return project.upstream or self.defaults[0].revision or "master"
136
- return project.upstream or "master"
137
-
138
- def assert_clean(self):
139
- for project in self.projects:
140
- assert not project.get_diff(), \
141
- "repo project '{0}' has local changes"\
142
- .format(project.path_or_name)
143
-
144
- def lock_revisions(self):
145
- for project in self.projects:
146
- head = project.get_head()
147
- if not project.get_remote_branches(head):
148
- remote_ref = project.get_remote_ref(
149
- head, self.get_remote(project))
150
- assert remote_ref, \
151
- "repo project '{0}' has unpublished commits"\
152
- .format(project.path_or_name)
153
- head = remote_ref
154
-
155
- if not project.upstream:
156
- if project.revision and project.has_local_ref(project.revision):
157
- project.upstream = project.revision
158
- else:
159
- project.upstream = self.get_upstream(project)
160
-
161
- if not project.revision.startswith("refs/changes"):
162
- project.revision = head
163
-
164
-
165
- _git_repos = {}
166
- _git_repo_lock = RLock()
167
-
168
- _repo_manifests = {}
169
- _repo_manifest_lock = RLock()
170
-
171
-
172
- class RepoInfluenceProvider(HashInfluenceProvider):
173
- name = "Repo"
174
- path = "."
175
-
176
- def __init__(self, path=None, include=None, exclude=None, network=True):
177
- self.path = path or self.__class__.path
178
- self.include = include
179
- self.exclude = exclude
180
- self.network = network
181
-
182
- def get_influence(self, task):
183
- self.tools = Tools(task, task.joltdir)
184
- try:
185
- manifest_path = fs.path.join(task.joltdir, task.expand(self.path))
186
- manifest = RepoManifest(task, manifest_path)
187
- manifest.parse(fs.path.join(manifest_path, ".repo", "manifest.xml"))
188
-
189
- result = []
190
- for project in sorted(manifest.projects, key=lambda p: p.name):
191
- if self.include is not None and project.path_or_name not in self.include:
192
- continue
193
- if self.exclude is not None and project.path_or_name in self.exclude:
194
- continue
195
-
196
- with _git_repo_lock:
197
- gip = _git_repos.get(project.path_or_name)
198
- if gip is None:
199
- gip = git.GitInfluenceProvider(project.path_or_name)
200
- _git_repos[project.path_or_name] = gip
201
- result.append(gip.get_influence(task))
202
-
203
- return "\n".join(result)
204
-
205
- except KeyError:
206
- log.exception()
207
- assert False, "failed to calculate hash influence for repo manifest at {0}".format(self.path)
208
-
209
- def get_manifest(self, task):
210
- manifest_path = fs.path.join(task.joltdir, task.expand(self.path))
211
- with _repo_manifest_lock:
212
- manifest = _repo_manifests.get(manifest_path)
213
- if manifest is None:
214
- manifest = RepoManifest(task, manifest_path)
215
- manifest.parse()
216
- manifest.assert_clean()
217
- manifest.lock_revisions()
218
- _repo_manifests[manifest_path] = manifest
219
- return manifest
220
-
221
-
222
- class RepoNetworkExecutorExtension(NetworkExecutorExtension):
223
- def get_parameters(self, task):
224
- rip = list(filter(
225
- lambda n: isinstance(n, RepoInfluenceProvider),
226
- task.task.influence))
227
- if rip:
228
- assert len(rip) == 1, "task influenced by multiple repo manifests"
229
- rip = rip[0]
230
- if rip.network:
231
- manifest = rip.get_manifest(task.task)
232
- return {"repo_manifest": manifest.format()}
233
- return {}
234
-
235
-
236
- @NetworkExecutorExtensionFactory.Register
237
- class RepoNetworkExecutorExtensionFactory(NetworkExecutorExtensionFactory):
238
- def create(self):
239
- return RepoNetworkExecutorExtension()
240
-
241
-
242
- def global_influence(path, include=None, exclude=None, network=True, cls=RepoInfluenceProvider):
243
- HashInfluenceRegistry.get().register(cls(path, include, exclude, network))
244
-
245
-
246
- def influence(path='.', include=None, exclude=None, network=True, cls=RepoInfluenceProvider):
247
- def _decorate(taskcls):
248
- if "influence" not in taskcls.__dict__:
249
- taskcls.influence = copy(taskcls.influence)
250
- provider = cls(path, include, exclude, network)
251
- taskcls.influence.append(provider)
252
- return taskcls
253
- return _decorate