mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
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.
This commit is contained in:
parent
6bfc817f65
commit
591deae6d7
@ -276,7 +276,7 @@ class build:
|
|||||||
setup_name = args[1]
|
setup_name = args[1]
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(args[1:], 'qDcn:bas:g')
|
opts, args = getopt.getopt(args[1:], 'qDcn:bas:gE')
|
||||||
except getopt.GetoptError as ge:
|
except getopt.GetoptError as ge:
|
||||||
raise error.general('source setup error: %s' % str(ge))
|
raise error.general('source setup error: %s' % str(ge))
|
||||||
quiet = False
|
quiet = False
|
||||||
@ -286,6 +286,7 @@ class build:
|
|||||||
deleted_dir = False
|
deleted_dir = False
|
||||||
created_dir = False
|
created_dir = False
|
||||||
changed_dir = False
|
changed_dir = False
|
||||||
|
no_errors = False
|
||||||
strip_components = 0
|
strip_components = 0
|
||||||
opt_name = None
|
opt_name = None
|
||||||
download_only = False
|
download_only = False
|
||||||
@ -302,6 +303,8 @@ class build:
|
|||||||
unpack_before_chdir = True
|
unpack_before_chdir = True
|
||||||
elif o[0] == '-a':
|
elif o[0] == '-a':
|
||||||
unpack_before_chdir = False
|
unpack_before_chdir = False
|
||||||
|
elif o[0] == '-E':
|
||||||
|
no_errors = True
|
||||||
elif o[0] == '-s':
|
elif o[0] == '-s':
|
||||||
if not o[1].isdigit():
|
if not o[1].isdigit():
|
||||||
raise error.general('source setup error: invalid strip count: %s' % \
|
raise error.general('source setup error: invalid strip count: %s' % \
|
||||||
@ -332,7 +335,28 @@ class build:
|
|||||||
name is not None:
|
name is not None:
|
||||||
self.script_build.append(self.config.expand('cd ' + name))
|
self.script_build.append(self.config.expand('cd ' + name))
|
||||||
changed_dir = True
|
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']))
|
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 \
|
if not changed_dir and (unpack_before_chdir and not create_dir) and \
|
||||||
name is not None and not download_only:
|
name is not None and not download_only:
|
||||||
self.script_build.append(self.config.expand('cd ' + name))
|
self.script_build.append(self.config.expand('cd ' + name))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user