1
1
import os
2
+ import shlex
2
3
from collections import defaultdict
3
4
4
5
import structlog
@@ -65,7 +66,7 @@ def setup_vcs(self):
65
66
),
66
67
)
67
68
68
- environment = self .data .environment_class (
69
+ self . vcs_environment = self .data .environment_class (
69
70
project = self .data .project ,
70
71
version = self .data .version ,
71
72
build = self .data .build ,
@@ -74,17 +75,17 @@ def setup_vcs(self):
74
75
# ca-certificate package which is compatible with Lets Encrypt
75
76
container_image = settings .RTD_DOCKER_BUILD_SETTINGS ["os" ]["ubuntu-20.04" ],
76
77
)
77
- with environment :
78
+ with self . vcs_environment :
78
79
before_vcs .send (
79
80
sender = self .data .version ,
80
- environment = environment ,
81
+ environment = self . vcs_environment ,
81
82
)
82
83
83
84
# Create the VCS repository where all the commands are going to be
84
85
# executed for a particular VCS type
85
86
self .vcs_repository = self .data .project .vcs_repo (
86
87
version = self .data .version .slug ,
87
- environment = environment ,
88
+ environment = self . vcs_environment ,
88
89
verbose_name = self .data .version .verbose_name ,
89
90
version_type = self .data .version .type ,
90
91
)
@@ -207,15 +208,17 @@ def checkout(self):
207
208
self .vcs_repository .update_submodules (self .data .config )
208
209
209
210
def post_checkout (self ):
210
- commands = [] # self.data.config.build.jobs.post_checkout
211
+ commands = self .data .config .build .jobs .post_checkout
211
212
for command in commands :
212
- self .build_environment .run (command )
213
+ # TODO: we could make a helper `self.run(environment, command)`
214
+ # that handles split and escape command
215
+ self .vcs_environment .run (* shlex .split (command ), escape_command = False )
213
216
214
217
# System dependencies (``build.apt_packages``)
215
218
def pre_system_dependencies (self ):
216
- commands = [] # self.data.config.build.jobs.pre_system_dependencies
219
+ commands = self .data .config .build .jobs .pre_system_dependencies
217
220
for command in commands :
218
- self .build_environment .run (command )
221
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
219
222
220
223
# NOTE: `system_dependencies` should not be possible to override by the
221
224
# user because it's executed as ``RTD_DOCKER_USER`` (e.g. ``root``) user.
@@ -253,58 +256,60 @@ def system_dependencies(self):
253
256
)
254
257
255
258
def post_system_dependencies (self ):
256
- pass
259
+ commands = self .data .config .build .jobs .post_system_dependencies
260
+ for command in commands :
261
+ self .build_environment .run (* shlex .split (command ), escape_command = False )
257
262
258
263
# Language environment
259
264
def pre_create_environment (self ):
260
- commands = [] # self.data.config.build.jobs.pre_create_environment
265
+ commands = self .data .config .build .jobs .pre_create_environment
261
266
for command in commands :
262
- self .build_environment .run (command )
267
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
263
268
264
269
def create_environment (self ):
265
270
commands = [] # self.data.config.build.jobs.create_environment
266
271
for command in commands :
267
- self .build_environment .run (command )
272
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
268
273
269
274
if not commands :
270
275
self .language_environment .setup_base ()
271
276
272
277
def post_create_environment (self ):
273
- commands = [] # self.data.config.build.jobs.post_create_environment
278
+ commands = self .data .config .build .jobs .post_create_environment
274
279
for command in commands :
275
- self .build_environment .run (command )
280
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
276
281
277
282
# Install
278
283
def pre_install (self ):
279
- commands = [] # self.data.config.build.jobs.pre_install
284
+ commands = self .data .config .build .jobs .pre_install
280
285
for command in commands :
281
- self .build_environment .run (command )
286
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
282
287
283
288
def install (self ):
284
289
commands = [] # self.data.config.build.jobs.install
285
290
for command in commands :
286
- self .build_environment .run (command )
291
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
287
292
288
293
if not commands :
289
294
self .language_environment .install_core_requirements ()
290
295
self .language_environment .install_requirements ()
291
296
292
297
def post_install (self ):
293
- commands = [] # self.data.config.build.jobs.post_install
298
+ commands = self .data .config .build .jobs .post_install
294
299
for command in commands :
295
- self .build_environment .run (command )
300
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
296
301
297
302
# Build
298
303
def pre_build (self ):
299
- commands = [] # self.data.config.build.jobs.pre_build
304
+ commands = self .data .config .build .jobs .pre_build
300
305
for command in commands :
301
- self .build_environment .run (command )
306
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
302
307
303
308
def build_html (self ):
304
309
commands = [] # self.data.config.build.jobs.build.html
305
310
if commands :
306
311
for command in commands :
307
- self .build_environment .run (command )
312
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
308
313
return True
309
314
310
315
return self .build_docs_class (self .data .config .doctype )
@@ -316,7 +321,7 @@ def build_pdf(self):
316
321
commands = [] # self.data.config.build.jobs.build.pdf
317
322
if commands :
318
323
for command in commands :
319
- self .build_environment .run (command )
324
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
320
325
return True
321
326
322
327
# Mkdocs has no pdf generation currently.
@@ -335,7 +340,7 @@ def build_htmlzip(self):
335
340
commands = [] # self.data.config.build.jobs.build.htmlzip
336
341
if commands :
337
342
for command in commands :
338
- self .build_environment .run (command )
343
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
339
344
return True
340
345
341
346
# We don't generate a zip for mkdocs currently.
@@ -350,7 +355,7 @@ def build_epub(self):
350
355
commands = [] # self.data.config.build.jobs.build.epub
351
356
if commands :
352
357
for command in commands :
353
- self .build_environment .run (command )
358
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
354
359
return True
355
360
356
361
# Mkdocs has no epub generation currently.
@@ -359,9 +364,9 @@ def build_epub(self):
359
364
return False
360
365
361
366
def post_build (self ):
362
- commands = [] # self.data.config.build.jobs.post_build
367
+ commands = self .data .config .build .jobs .post_build
363
368
for command in commands :
364
- self .build_environment .run (command )
369
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
365
370
366
371
# Helpers
367
372
#
0 commit comments