summaryrefslogtreecommitdiffstats
path: root/source-builder
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2019-10-25 09:11:28 +1100
committerChris Johns <chrisj@rtems.org>2019-10-25 14:12:33 +1100
commit591deae6d7411af04fd31d2a68dee9520b33c657 (patch)
treec566e676f8c0a29d7b2c49d40080426c9ae70c84 /source-builder
parent5/bsps: Add Xilinx Zynq ZC702 BSP. (diff)
downloadrtems-source-builder-591deae6d7411af04fd31d2a68dee9520b33c657.tar.bz2
sb/build: Add -E to '%source setup' to handle tar dependency errors.
Tar on Windows raises an error if a symlink appears before the target. Windows needs the target to exist before a link can be created. This patch adds support via the -E option to catch the error and rerun the tar command a second time. The symlink should work as the target should exist on the second pass.
Diffstat (limited to 'source-builder')
-rw-r--r--source-builder/sb/build.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py
index 69f95cf..d9753cc 100644
--- a/source-builder/sb/build.py
+++ b/source-builder/sb/build.py
@@ -276,7 +276,7 @@ class build:
setup_name = args[1]
args = args[1:]
try:
- opts, args = getopt.getopt(args[1:], 'qDcn:bas:g')
+ opts, args = getopt.getopt(args[1:], 'qDcn:bas:gE')
except getopt.GetoptError as ge:
raise error.general('source setup error: %s' % str(ge))
quiet = False
@@ -286,6 +286,7 @@ class build:
deleted_dir = False
created_dir = False
changed_dir = False
+ no_errors = False
strip_components = 0
opt_name = None
download_only = False
@@ -302,6 +303,8 @@ class build:
unpack_before_chdir = True
elif o[0] == '-a':
unpack_before_chdir = False
+ elif o[0] == '-E':
+ no_errors = True
elif o[0] == '-s':
if not o[1].isdigit():
raise error.general('source setup error: invalid strip count: %s' % \
@@ -332,7 +335,28 @@ class build:
name is not None:
self.script_build.append(self.config.expand('cd ' + name))
changed_dir = True
+ #
+ # On Windows tar can fail on links if the link appears in the
+ # tar file before the target of the link exists. We can assume the
+ # tar file is correct, that is all files and links are valid,
+ # so on error redo the untar a second time.
+ #
+ if options.host_windows or no_errors:
+ self.script_build.append('set +e')
self.script_build.append(self.config.expand(source['script']))
+ if options.host_windows or not no_errors:
+ self.script_build.append('tar_exit=$?')
+ if options.host_windows or no_errors:
+ self.script_build.append('set -e')
+ if options.host_windows:
+ if no_errors:
+ self.script_build.append(' set +e')
+ self.script_build.append(' ' + self.config.expand(source['script']))
+ self.script_build.append(' set -e')
+ else:
+ self.script_build.append('if test $tar_exit != 0; then')
+ self.script_build.append(' ' + self.config.expand(source['script']))
+ self.script_build.append('fi')
if not changed_dir and (unpack_before_chdir and not create_dir) and \
name is not None and not download_only:
self.script_build.append(self.config.expand('cd ' + name))