Skip to content

Commit d49fb6d

Browse files
Thomas Strangergalak
Thomas Stranger
authored andcommitted
scripts: minor fixes to be able to execute series_update on linux
On linux the script crashes, when subprocess.check_call() parameters are passed as list and shell=True is set, or if subprocess.check_call() parameters are passed as string and shell=True is not set. These changes fix that.
1 parent e3e435a commit d49fb6d

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

scripts/serie_update.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def os_cmd(cmd, cwd=None, shell=False):
3030
Args:
3131
cmd: string command to execute.
3232
cwd: directory where to run command
33+
shell: boolean to enable command interpretation by the shell
3334
3435
Returns:
3536
return the returncode of the command after execution.
@@ -147,7 +148,8 @@ def clone_cube_repo(self):
147148
# with the most recent one created being the last entry.
148149
os_cmd(("git", "checkout", branch), cwd=self.stm32cube_serie_path)
149150
self.version_tag = subprocess.check_output(
150-
"git tag -l", cwd=self.stm32cube_serie_path
151+
("git", "tag", "-l"),
152+
cwd=self.stm32cube_serie_path
151153
).splitlines()
152154
self.version_tag = [x.decode("utf-8") for x in self.version_tag]
153155
# Set latest version
@@ -275,11 +277,12 @@ def extract_source(self):
275277
)
276278
os_cmd(
277279
(
278-
"cp",
279-
"-r",
280-
str(stm32cube_drivers_src_path) + "/*.*",
281-
str(temp_drivers_src_path),
282-
)
280+
"cp " +
281+
"-r " +
282+
str(stm32cube_drivers_src_path) + "/*.* " +
283+
str(temp_drivers_src_path)
284+
),
285+
shell=True,
283286
)
284287

285288
def build_from_current_cube_version(self):
@@ -342,18 +345,10 @@ def build_patch_from_current_zephyr_version(self):
342345
"Building patch from " + self.current_version + " to current module"
343346
)
344347
os_cmd(
345-
(
346-
"git",
347-
"diff",
348-
"--ignore-space-at-eol",
349-
"HEAD~1",
350-
">>",
351-
"module.patch",
352-
),
348+
"git diff --ignore-space-at-eol HEAD~1 >> module.patch",
353349
shell=True,
354350
cwd=self.stm32cube_temp,
355351
)
356-
357352
os_cmd(("dos2unix", "module.patch"), cwd=self.stm32cube_temp)
358353

359354
hal_conf = (
@@ -366,13 +361,13 @@ def build_patch_from_current_zephyr_version(self):
366361
if hal_conf.exists():
367362
os_cmd(
368363
(
369-
"git",
370-
"diff",
371-
"HEAD@{1}",
372-
"--",
373-
str(hal_conf),
374-
">>",
375-
str(hal_conf_patch),
364+
"git " +
365+
"diff " +
366+
"HEAD@{1} " +
367+
"-- " +
368+
str(hal_conf) +
369+
" >> " +
370+
str(hal_conf_patch)
376371
),
377372
shell=True,
378373
cwd=self.stm32cube_temp,
@@ -542,7 +537,8 @@ def build_from_latest_version(self):
542537

543538
# Get the commit id of this latest version
544539
self.latest_commit = subprocess.check_output(
545-
"git rev-parse HEAD", cwd=self.stm32cube_serie_path
540+
("git", "rev-parse", "HEAD"),
541+
cwd=self.stm32cube_serie_path
546542
).decode("utf-8")
547543

548544
# clear previous version content before populating with latest version
@@ -605,7 +601,7 @@ def apply_zephyr_patch(self):
605601
# Generate a patch for each file in the module
606602

607603
os_cmd(
608-
("git", "diff", "HEAD~1", ">>", "new_version.patch"),
604+
"git diff HEAD~1 >> new_version.patch",
609605
shell=True,
610606
cwd=self.stm32cube_temp,
611607
)

0 commit comments

Comments
 (0)