jolt 0.9.355__py3-none-any.whl → 0.9.370__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.
jolt/tasks.py CHANGED
@@ -782,6 +782,7 @@ class TaskRegistry(object):
782
782
  self.env = env
783
783
  self.tasks = {}
784
784
  self.instances = {}
785
+ self._workspace_resources = []
785
786
 
786
787
  @staticmethod
787
788
  def get(*args, **kwargs):
@@ -790,6 +791,21 @@ class TaskRegistry(object):
790
791
  return TaskRegistry._instance
791
792
 
792
793
  def add_task_class(self, cls):
794
+ """
795
+ Add a task class to the registry.
796
+
797
+ The class is decorated to require workspace resources.
798
+ """
799
+
800
+ registry = self
801
+
802
+ def _workspace_resources(self):
803
+ return registry._workspace_resources
804
+
805
+ if not issubclass(cls, WorkspaceResource):
806
+ cls = attributes.requires("_workspace_resources")(cls)
807
+ cls._workspace_resources = property(_workspace_resources)
808
+
793
809
  self.tasks[cls.name] = cls
794
810
 
795
811
  def add_task(self, task, extra_params):
@@ -798,6 +814,13 @@ class TaskRegistry(object):
798
814
  full_name = utils.format_task_name(name, params)
799
815
  self.instances[full_name] = task
800
816
 
817
+ def require_workspace_resource(self, taskname):
818
+ name, _ = utils.parse_task_name(taskname)
819
+ task = self.get_task_class(name)
820
+ raise_task_error_if(task is None, name, "Resource not found")
821
+ raise_task_error_if(not issubclass(task, WorkspaceResource), name, "Not a workspace resource")
822
+ self._workspace_resources.append(taskname)
823
+
801
824
  def get_task_class(self, name):
802
825
  return self.tasks.get(name)
803
826
 
jolt/tools.py CHANGED
@@ -83,11 +83,13 @@ class Reader(threading.Thread):
83
83
  self.logbuf.append((self, line))
84
84
 
85
85
 
86
- def _run(cmd, cwd, env, preexec_fn, *args, **kwargs):
86
+ def _run(cmd, cwd, env, *args, **kwargs):
87
87
  output = kwargs.get("output")
88
88
  output_on_error = kwargs.get("output_on_error")
89
89
  output_rstrip = kwargs.get("output_rstrip", True)
90
90
  output_stdio = kwargs.get("output_stdio", False)
91
+ output_stderr = kwargs.get("output_stderr", True)
92
+ output_stdout = kwargs.get("output_stdout", True)
91
93
  return_stderr = kwargs.get("return_stderr", False)
92
94
  output = output if output is not None else True
93
95
  output = False if output_on_error else output
@@ -130,11 +132,17 @@ def _run(cmd, cwd, env, preexec_fn, *args, **kwargs):
130
132
  shell=shell,
131
133
  cwd=cwd,
132
134
  env=env,
133
- preexec_fn=preexec_fn,
134
135
  )
135
136
 
136
- stdout_func = log.stdout if not output_stdio else stdout_write
137
- stderr_func = log.stderr if not output_stdio else stderr_write
137
+ if output_stdout:
138
+ stdout_func = log.stdout if not output_stdio else stdout_write
139
+ else:
140
+ stdout_func = None
141
+
142
+ if output_stderr:
143
+ stderr_func = log.stderr if not output_stdio else stderr_write
144
+ else:
145
+ stderr_func = None
138
146
 
139
147
  logbuf = []
140
148
  stdout = Reader(
@@ -160,7 +168,7 @@ def _run(cmd, cwd, env, preexec_fn, *args, **kwargs):
160
168
  p.wait(10)
161
169
  except subprocess.TimeoutExpired:
162
170
  kill(p.pid)
163
- p.wait()
171
+ utils.call_and_catch(p.wait, 10)
164
172
  raise
165
173
 
166
174
  except (subprocess.TimeoutExpired, JoltTimeoutError):
@@ -170,7 +178,7 @@ def _run(cmd, cwd, env, preexec_fn, *args, **kwargs):
170
178
  p.wait(10)
171
179
  except subprocess.TimeoutExpired:
172
180
  kill(p.pid)
173
- p.wait()
181
+ utils.call_and_catch(p.wait, 10)
174
182
 
175
183
  finally:
176
184
  if stdout:
@@ -471,7 +479,6 @@ class Tools(object):
471
479
  self._chroot_path = []
472
480
  self._deadline = None
473
481
  self._run_prefix = []
474
- self._preexec_fn = None
475
482
  self._cwd = fs.path.normpath(fs.path.join(config.get_workdir(), cwd or config.get_workdir()))
476
483
  self._env = copy.deepcopy(env or os.environ)
477
484
  self._task = task
@@ -1578,7 +1585,7 @@ class Tools(object):
1578
1585
  except Exception:
1579
1586
  pass
1580
1587
 
1581
- return _run(cmd, self._cwd, self._env, self._preexec_fn, *args, **kwargs)
1588
+ return _run(cmd, self._cwd, self._env, *args, **kwargs)
1582
1589
 
1583
1590
  finally:
1584
1591
  if stdi:
jolt/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.9.355"
1
+ __version__ = "0.9.370"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jolt
3
- Version: 0.9.355
3
+ Version: 0.9.370
4
4
  Summary: A task executor
5
5
  Home-page: https://github.com/srand/jolt
6
6
  Author: Robert Andersson
@@ -58,7 +58,7 @@ Requires-Dist: zstandard==0.23.0
58
58
  Provides-Extra: allure
59
59
  Requires-Dist: allure-python-commons; extra == "allure"
60
60
  Provides-Extra: conan
61
- Requires-Dist: conan<2.0; extra == "conan"
61
+ Requires-Dist: conan>=2.0; extra == "conan"
62
62
  Provides-Extra: dev
63
63
  Requires-Dist: check-manifest; extra == "dev"
64
64
  Provides-Extra: doc
@@ -1,29 +1,29 @@
1
- jolt/__init__.py,sha256=lR7MgoN3exnxhWdr74S4sEJgmb4Hl_OO6aeZvTM3Opg,2181
1
+ jolt/__init__.py,sha256=C1WNj-iUNT1gtK2v7zxlnyMLW9dsYcM_yzlltJEYY6Y,3267
2
2
  jolt/__main__.py,sha256=sAASLJ5dhK8jTKwh1vWAGQ2-qgLEgrAQlR-hIC75Ze0,1670
3
- jolt/cache.py,sha256=ofd-zmhiYCaWjadtlzWNcoyB4stbv4gJdqCCjnZUQO0,72090
3
+ jolt/cache.py,sha256=WwYkOhuSDF8M_cUjnij6Sj7rMUi6Lk6x2sg1iir9_hw,79401
4
4
  jolt/chroot.py,sha256=lnejhnjO3takDBZewBOvVlN2e8GWKhXnjFlqQp_zAJ4,4666
5
- jolt/cli.py,sha256=5VrVCq1SGW2DZNuDp3YHrkn0gx4hm2Nssp-VTBFqnfc,44052
5
+ jolt/cli.py,sha256=hdeVgd4ENdGoNZgaeGVNkCJfghFJ621rgjZ2e1BUrC0,41661
6
6
  jolt/colors.py,sha256=P6vhaILGoOn8odEwQ6-z871YQoTe3HRLgS6clavwVHs,737
7
7
  jolt/common_pb2.py,sha256=Oe9cyZ4qNyS2aTunjiO7tAO3XVw8XkZ1M7TaTmss3bs,6335
8
8
  jolt/common_pb2_grpc.py,sha256=1oboBPFxaTEXt9Aw7EAj8gXHDCNMhZD2VXqocC9l_gk,159
9
- jolt/config.py,sha256=2S8_bdcHaNzwDfkCkHNjFaWn9pykStA4rUa7pz3m5Sg,10367
9
+ jolt/config.py,sha256=khzo4BNfNZoClTHVJGTWLhLBLAWH7lWj5cIdxr73Phg,9981
10
10
  jolt/error.py,sha256=wbYU_ip3zGHlhmjQWjEeLlmLdTpiqIeFM5zJndVQdj4,2399
11
11
  jolt/expires.py,sha256=GDagfgJOlX_z2LLIFhKHBaXI96jo1S3ca2OGWQi1oj4,2330
12
12
  jolt/filesystem.py,sha256=BytxYk6Xq0peuRB9gUZ7EDsvbgirfp4EcjPANNDIstQ,5916
13
- jolt/graph.py,sha256=Gnp47hJyUqRwHh1ISvHmb7ZeMVDOaCmQgF5_l2rboQI,45515
13
+ jolt/graph.py,sha256=7OCfz_Q00tV1ewGUKjwKIhk6nbfd0KemprFTs3n3XTQ,45978
14
14
  jolt/hooks.py,sha256=jcCaNwlyFrWkXrO6MiO_roDQVohefbablfXnuQ3dmmM,11029
15
15
  jolt/influence.py,sha256=c5Vdizk9kK-8O7cSU9LAHhh8xkvchudstBn7HLIr9hg,16937
16
16
  jolt/inspection.py,sha256=QkOCXAbjJBdw1SMsb6xH_3GHXV5BcdzaGD7HrGmOJss,3931
17
- jolt/loader.py,sha256=davXBBvs2rpBh57taulVQDS1sqYUuWVG3M_xkWye1CI,21362
17
+ jolt/loader.py,sha256=F8JDCPjl4gdjs9X23iVb94iIqkasYTeEVaTjwfkmMH8,18962
18
18
  jolt/log.py,sha256=cqEfX__AWSA4onueTTdoL4HnovEtzT4yoRoyKQk2MH8,14592
19
- jolt/manifest.py,sha256=T2-JPiXmYU4DNYTKLnDi1ywCufLYaIIAdoGWYrTL6V0,8529
20
- jolt/options.py,sha256=P1uuxq7oJzlN4NTrZvj2NRH2CaVQObKy2DoETjwrBeA,434
21
- jolt/scheduler.py,sha256=HRC8dAl9asI1exn7AUqBO0hbYzBlaSaGHgNqDlpQ72Q,21470
22
- jolt/tasks.py,sha256=D3X1XHnSuDDWAEis-Y6ULGIXTlLNCZTikLHZkbWEoII,114916
19
+ jolt/manifest.py,sha256=V5fkvTE-cZt0IQbA8sBdC4WEaYrz7FEXQdSt6Uj-DWc,7256
20
+ jolt/options.py,sha256=BrsyKsj3sY5qogMreHGgbimQuyGjnyilCa8QXPVm1Y0,947
21
+ jolt/scheduler.py,sha256=2xehPvoJDLdv211UdP2cqqQs2M2L5Ozw2_GuE556Tjg,32513
22
+ jolt/tasks.py,sha256=sh5wjCw0qg8wjApS9ynNws10GfpOyEHrE6MY-UeTKdM,115758
23
23
  jolt/timer.py,sha256=PE-7vmsqZpF73e_cKSsrhd36-A7fJ9_XGYI_oBWJn5w,644
24
- jolt/tools.py,sha256=_ijnN47sDFaEDhPMPIkLKcqGOewk2MLzvvyp3kuoask,79867
24
+ jolt/tools.py,sha256=LpmBzeQCl--7y2wAbe1flufUfO7wDeP7v4tqzgbvdaI,80097
25
25
  jolt/utils.py,sha256=6TphNzqr2AAQ55bGDD36YoJSi8qQM3FRkrY1iIkhtNA,18771
26
- jolt/version.py,sha256=wUY_Z7rh-J9V9d7tO0yb3HiV_8QXXOk76zEkHeWxKPs,24
26
+ jolt/version.py,sha256=D5iQ6y59p6wJMv2PTSLGthqfYfZaZgffBUx6-CYKDMA,24
27
27
  jolt/version_utils.py,sha256=tNCGT6ZmSGFHW1aw2Hx1l19m-RR1UnTN6xJV1I54KRw,3900
28
28
  jolt/xmldom.py,sha256=SbygiDUMYczzWGxXa60ZguWS6Nztg8gDAirdbtjT15I,5982
29
29
  jolt/bin/fstree-darwin-x86_64,sha256=i4Ppbdr7CxsEhJzWpy3GMB5Gn5ikmskh41MyUwQS3-o,29549000
@@ -37,34 +37,33 @@ jolt/plugins/allure.py,sha256=nUYQEjGAAc9Mt7Yzz3rKdr_M3wHOjCjtQSnOulIlDUs,10230
37
37
  jolt/plugins/autoweight.py,sha256=LTpma3HM1jsAx1PatDIWcddAkRw1SPhHA4Dl9H9p2lo,1245
38
38
  jolt/plugins/cache.py,sha256=8voIlVS4fjJnQE1uMA4BvHJ2B4CQQXUF93IW-_if7fs,4242
39
39
  jolt/plugins/cmake.py,sha256=IAF8PhaaByJVwBYSEdVlu1MdIyhXp8Luv4ygIvtPkqo,2687
40
- jolt/plugins/conan.py,sha256=fTidFjF5lKYsrTRb_yokmnRUvMIt6FNhAPMT-5wz5_w,7654
40
+ jolt/plugins/conan.py,sha256=5d7TdQBV1dcwTFfyW-U3jrfJDTpLbnp08Ltra1zTZyc,16259
41
41
  jolt/plugins/cxx.py,sha256=UqcBIcjCphRB2ojknU4v5vRv_6i3CmIAFZS1T3dXWVc,30487
42
42
  jolt/plugins/cxxinfo.py,sha256=yuHkgT2Lqg2v1GmrjINXBF--KeSOfMya7_HN8AA2hbw,2398
43
43
  jolt/plugins/dashboard.py,sha256=5XxU7J33htfc7rxPXTob37rOpehtWZh6N-HVlNHAluM,642
44
- jolt/plugins/debian.py,sha256=5uzICZzFscV-HwLqvlqtLr7EpcUFm0N5qa2jDoHd3A8,11569
45
- jolt/plugins/docker.py,sha256=XhWZoV5pqMGGD8r0RYxX_IdNSeZX1Z_HQ38h-gFbtlg,21106
44
+ jolt/plugins/docker.py,sha256=Sy8zrfphimypP3k-tXVFSIdfJpRjucQIH8LRF6sEVi4,21100
46
45
  jolt/plugins/email.py,sha256=esONwpn7xKJLh4SYGZ0GpSZ2UwzWsckfsAPCeYdZSVw,3549
47
46
  jolt/plugins/email.xslt,sha256=3vrrfnG-KH_cfJq6RDOXHKQxKd-6s28qy4znapGaciM,8513
48
- jolt/plugins/environ.py,sha256=TKyajli6790VRMAVFKxKxUgdTR8Gg-4ftsgTd05cO74,3371
49
- jolt/plugins/gdb.py,sha256=EIsAGqMXKQ_EtdW_bsKXVU66J8JfUMFQjo-vzFHAADk,6151
47
+ jolt/plugins/environ.py,sha256=k382rvEKWj-nlibJcCUWcYtYheU8p9df9ZY0DAAkjDE,3561
48
+ jolt/plugins/gdb.py,sha256=pAoUSWvONCPXazdPVm7lAd6A9kPwZa7gfXtt8yMtwKI,6185
50
49
  jolt/plugins/gerrit.py,sha256=tc8NeIDAg3mZJINU5aZg1fs3YsaVxM_MvkHa149aAIs,768
51
50
  jolt/plugins/git.py,sha256=AiPzYl0eqPcrd1bw8il42cUUrBLcCQIAG4f54wSVhyQ,21204
52
51
  jolt/plugins/golang.py,sha256=vV4iRoJpWkyfrBa96s6jgU8Sz8GnGl-lzG_FSj5epzQ,2049
53
52
  jolt/plugins/googletest.py,sha256=9aV_T21JY84YgeSiaV4ppZhVs1XFt19m3pPrJW2iGfI,18708
54
53
  jolt/plugins/http.py,sha256=HwuABHR2tuWm_jBdQpCO3AMkjFdwOzUfEi26X-2v_y8,3816
55
54
  jolt/plugins/junit.py,sha256=_1vXMEQBNuLbwc8l4UFm1iONYdehxJxWDRgFtPy3do8,1342
55
+ jolt/plugins/linux.py,sha256=GfytBgIFcWjKDZ1ozTqksboQi80FHJHtmhJQ8QGSdzE,30363
56
56
  jolt/plugins/logstash.py,sha256=ShUdqSRyQL_ATlgHwLP-uI1mJXprs15knyWbk58nMFo,1847
57
- jolt/plugins/ninja-compdb.py,sha256=P2hBHaxCqXPqqmH8EWrR89SEO6olyy-3JQzf6ZQ1r6o,10851
57
+ jolt/plugins/ninja-compdb.py,sha256=ig3xGwxrfTQc287GwAFhsPJ-TFYAtsM8ITci2YeyXlA,10886
58
58
  jolt/plugins/ninja.py,sha256=7ToQS3Pl81R2qoSRvGvWlkITONjOwV2wRklrB64wURQ,102787
59
59
  jolt/plugins/nodejs.py,sha256=HHDbvmdlqnao3qOtpCD9UY7iyTIX4gb2WxKUBtn-3cM,1879
60
60
  jolt/plugins/paths.py,sha256=DgiPI5K5bV3lVuyNEMIjRO26iTwf6RL5-2WPQ3rSmj8,1920
61
- jolt/plugins/podman.py,sha256=ZI7rojgULOXpMg_A5wmZvuE_Byxved8yuTnSTUQ5aEM,23099
61
+ jolt/plugins/podman.py,sha256=4GnjSnhxTiQ_sCI9SaKwRFrt2tfIrejLHHprxggUNik,23073
62
62
  jolt/plugins/python.py,sha256=kLx1Y3ezMH9AOW36DH_cNyDlvbIdTkyvPjwLYolnCEU,3073
63
- jolt/plugins/repo.py,sha256=tBlNVrn5F1kU8D-kHOfUTMUcPdMnG_BbP44hirALHNA,8947
64
63
  jolt/plugins/report.py,sha256=EiPuZSoxEM-fXDsHBQuRTf1xtvN_gPBodMej3E9CGx0,2695
65
- jolt/plugins/scheduler.py,sha256=vwurV9dfED0hjjf_ApdmNHMjA0HOqVOdoQiNGoIb4uY,24574
66
- jolt/plugins/selfdeploy.py,sha256=yr-tcCCFu70h6KEMdJ8n48s5baLTBFu6l4ZSxlcjk-U,7180
67
- jolt/plugins/strings.py,sha256=yjUppvD8gE-SJM0EGrfbm66xOREDH8QCatfvK6RqxHw,1649
64
+ jolt/plugins/scheduler.py,sha256=SJdRb0taOF4zhKkPfc9zg8UyvDn7rJYtbyMPC93XXsk,24560
65
+ jolt/plugins/selfdeploy.py,sha256=Mpjxr3O4xqHiBf1wN-fXRp0slfvbH1usSGcthaLO6_c,6508
66
+ jolt/plugins/strings.py,sha256=sHDroW0srlQI1aRwu_WANkmR35sUxPvZGO28CYo-ClY,1783
68
67
  jolt/plugins/symlinks.py,sha256=u4lTcpkepf0_mr_RI85uiSkI_WAUGebAOsbH5WlAnzo,2399
69
68
  jolt/plugins/telemetry.py,sha256=xHgJVbSVRaPy67kblL4wj86mDESlFS1z3NGDJ2uDXZ8,3572
70
69
  jolt/plugins/timeline.py,sha256=pzCdyi_MTNBZ-lKRkdigi8xGRPLWy905stLTa8_eCB8,1851
@@ -81,13 +80,13 @@ jolt/plugins/remote_execution/scheduler_pb2_grpc.py,sha256=H7Is9caU681Qau5nZZ3Ks
81
80
  jolt/plugins/remote_execution/worker_pb2.py,sha256=FLPWimnmeJAa02SOnejC4aDA_taljLVZE3w-vdRpaPM,2926
82
81
  jolt/plugins/remote_execution/worker_pb2_grpc.py,sha256=A-XLtuLjI2jBUdLPH-oa1qcJeYI1bmtWDnUOka2bG_s,5047
83
82
  jolt/plugins/selfdeploy/README.rst,sha256=dAer5CQHPOOCUAMcVljKzn5ICzjsNKWhw2tAvBAL8So,3130
84
- jolt/plugins/selfdeploy/setup.py,sha256=eUcp1RZf0SIjCGO-FEtiVs17P9GVA41BrQUB0ZvdoJw,3134
83
+ jolt/plugins/selfdeploy/setup.py,sha256=d_Mr4gTFxmTS36OmP45lZBmWHrfJc5UrE71AUfIDR2g,3135
85
84
  jolt/templates/cxxexecutable.cmake.template,sha256=f0dg1VOFlamlF8fuHFTki5dsJ2ssSupiqk62QmRby4Y,1720
86
85
  jolt/templates/cxxlibrary.cmake.template,sha256=GMEG2G3QoY3E5fsNer52zOqgM221-abeCkV__mVbZ94,1750
87
86
  jolt/templates/export.sh.template,sha256=PKkflGXFbq70EIsowqcnLvzbnEDnqh_WgC4E_JNT0VE,1937
88
87
  jolt/templates/timeline.html.template,sha256=xdqvFBmhE8XRQaWgcIFBVbd__9HdRq6O-U0o276PyjU,1222
89
- jolt-0.9.355.dist-info/METADATA,sha256=3Pk9iWuY6U8hurXRxR071Io_WprGsY4ci6fuqkAYfC4,5557
90
- jolt-0.9.355.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
91
- jolt-0.9.355.dist-info/entry_points.txt,sha256=VZ-QH38Z9HJc1O57wfzr-soHn6exwc3N0TSrRum4tYg,44
92
- jolt-0.9.355.dist-info/top_level.txt,sha256=HwzVmAwUrvCUUHRi3zUfcpdKTsdNrZmPCvsrsWSFyqE,5
93
- jolt-0.9.355.dist-info/RECORD,,
88
+ jolt-0.9.370.dist-info/METADATA,sha256=bzR5nUAMaQx14y_xrP07UNTwwbmuoAiW0_o250iQv_0,5558
89
+ jolt-0.9.370.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
90
+ jolt-0.9.370.dist-info/entry_points.txt,sha256=VZ-QH38Z9HJc1O57wfzr-soHn6exwc3N0TSrRum4tYg,44
91
+ jolt-0.9.370.dist-info/top_level.txt,sha256=HwzVmAwUrvCUUHRi3zUfcpdKTsdNrZmPCvsrsWSFyqE,5
92
+ jolt-0.9.370.dist-info/RECORD,,
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)