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
)
@@ -208,15 +209,17 @@ def checkout(self):
208
209
self .vcs_repository .update_submodules (self .data .config )
209
210
210
211
def post_checkout (self ):
211
- commands = [] # self.data.config.build.jobs.post_checkout
212
+ commands = self .data .config .build .jobs .post_checkout
212
213
for command in commands :
213
- self .build_environment .run (command )
214
+ # TODO: we could make a helper `self.run(environment, command)`
215
+ # that handles split and escape command
216
+ self .vcs_environment .run (* shlex .split (command ), escape_command = False )
214
217
215
218
# System dependencies (``build.apt_packages``)
216
219
def pre_system_dependencies (self ):
217
- commands = [] # self.data.config.build.jobs.pre_system_dependencies
220
+ commands = self .data .config .build .jobs .pre_system_dependencies
218
221
for command in commands :
219
- self .build_environment .run (command )
222
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
220
223
221
224
# NOTE: `system_dependencies` should not be possible to override by the
222
225
# user because it's executed as ``RTD_DOCKER_USER`` (e.g. ``root``) user.
@@ -254,58 +257,60 @@ def system_dependencies(self):
254
257
)
255
258
256
259
def post_system_dependencies (self ):
257
- pass
260
+ commands = self .data .config .build .jobs .post_system_dependencies
261
+ for command in commands :
262
+ self .build_environment .run (* shlex .split (command ), escape_command = False )
258
263
259
264
# Language environment
260
265
def pre_create_environment (self ):
261
- commands = [] # self.data.config.build.jobs.pre_create_environment
266
+ commands = self .data .config .build .jobs .pre_create_environment
262
267
for command in commands :
263
- self .build_environment .run (command )
268
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
264
269
265
270
def create_environment (self ):
266
271
commands = [] # self.data.config.build.jobs.create_environment
267
272
for command in commands :
268
- self .build_environment .run (command )
273
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
269
274
270
275
if not commands :
271
276
self .language_environment .setup_base ()
272
277
273
278
def post_create_environment (self ):
274
- commands = [] # self.data.config.build.jobs.post_create_environment
279
+ commands = self .data .config .build .jobs .post_create_environment
275
280
for command in commands :
276
- self .build_environment .run (command )
281
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
277
282
278
283
# Install
279
284
def pre_install (self ):
280
- commands = [] # self.data.config.build.jobs.pre_install
285
+ commands = self .data .config .build .jobs .pre_install
281
286
for command in commands :
282
- self .build_environment .run (command )
287
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
283
288
284
289
def install (self ):
285
290
commands = [] # self.data.config.build.jobs.install
286
291
for command in commands :
287
- self .build_environment .run (command )
292
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
288
293
289
294
if not commands :
290
295
self .language_environment .install_core_requirements ()
291
296
self .language_environment .install_requirements ()
292
297
293
298
def post_install (self ):
294
- commands = [] # self.data.config.build.jobs.post_install
299
+ commands = self .data .config .build .jobs .post_install
295
300
for command in commands :
296
- self .build_environment .run (command )
301
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
297
302
298
303
# Build
299
304
def pre_build (self ):
300
- commands = [] # self.data.config.build.jobs.pre_build
305
+ commands = self .data .config .build .jobs .pre_build
301
306
for command in commands :
302
- self .build_environment .run (command )
307
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
303
308
304
309
def build_html (self ):
305
310
commands = [] # self.data.config.build.jobs.build.html
306
311
if commands :
307
312
for command in commands :
308
- self .build_environment .run (command )
313
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
309
314
return True
310
315
311
316
return self .build_docs_class (self .data .config .doctype )
@@ -317,7 +322,7 @@ def build_pdf(self):
317
322
commands = [] # self.data.config.build.jobs.build.pdf
318
323
if commands :
319
324
for command in commands :
320
- self .build_environment .run (command )
325
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
321
326
return True
322
327
323
328
# Mkdocs has no pdf generation currently.
@@ -336,7 +341,7 @@ def build_htmlzip(self):
336
341
commands = [] # self.data.config.build.jobs.build.htmlzip
337
342
if commands :
338
343
for command in commands :
339
- self .build_environment .run (command )
344
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
340
345
return True
341
346
342
347
# We don't generate a zip for mkdocs currently.
@@ -351,7 +356,7 @@ def build_epub(self):
351
356
commands = [] # self.data.config.build.jobs.build.epub
352
357
if commands :
353
358
for command in commands :
354
- self .build_environment .run (command )
359
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
355
360
return True
356
361
357
362
# Mkdocs has no epub generation currently.
@@ -360,9 +365,9 @@ def build_epub(self):
360
365
return False
361
366
362
367
def post_build (self ):
363
- commands = [] # self.data.config.build.jobs.post_build
368
+ commands = self .data .config .build .jobs .post_build
364
369
for command in commands :
365
- self .build_environment .run (command )
370
+ self .build_environment .run (* shlex . split ( command ), escape_command = False )
366
371
367
372
# Helpers
368
373
#
0 commit comments