Skip to content

Commit

Permalink
[GR-46518] Add 'defaultDereference' property to layout distributions.
Browse files Browse the repository at this point in the history
PullRequest: mx/1623
  • Loading branch information
rschatz committed Jun 12, 2023
2 parents 2a288e7 + 9822966 commit 7d8b7c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/layout-distributions.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ For `extracted-dependency`, the `dereference` property can set to:
* `"root"` (default) to only de-reference the root matches of the recursive copy (like `cp -H`)
* `"always"` always follow symlinks in the source before copying (like `cp -L`)

The default of the `dereference` property can be overridden for all sources with the `defaultDereference` property on the layout distribution.

## Archive types

By default, the distribution containing the `layout` will be a JAR. If it has `native` attribute set to `True`, it will be a TAR.
Expand Down
18 changes: 10 additions & 8 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5922,7 +5922,7 @@ def needsBuild(self, newestInput):
class LayoutDistribution(AbstractDistribution):
_linky = AbstractDistribution

def __init__(self, suite, name, deps, layout, path, platformDependent, theLicense, excludedLibs=None, path_substitutions=None, string_substitutions=None, archive_factory=None, compress=False, fileListPurpose=None, **kw_args):
def __init__(self, suite, name, deps, layout, path, platformDependent, theLicense, excludedLibs=None, path_substitutions=None, string_substitutions=None, archive_factory=None, compress=False, fileListPurpose=None, defaultDereference=None, **kw_args):
"""
See docs/layout-distribution.md
:type layout: dict[str, str]
Expand All @@ -5942,6 +5942,12 @@ def __init__(self, suite, name, deps, layout, path, platformDependent, theLicens
self.compress = compress
self._removed_deps = set()
self.fileListPurpose = fileListPurpose
if defaultDereference is None:
self.defaultDereference = "root"
elif defaultDereference not in ("root", "never", "always"):
raise abort(f"Unsupported defaultDereference mode: '{self.defaultDereference}' in '{name}'", context=suite)
else:
self.defaultDereference = defaultDereference

def getBuildTask(self, args):
return LayoutArchiveTask(args, self)
Expand Down Expand Up @@ -5999,8 +6005,6 @@ def _as_source_dict(source, distribution_name, destination, path_substitutions=N
source_dict["dependency"], source_dict["path"] = source_spec.split('/', 1)
else:
source_dict["dependency"], source_dict["path"] = source_spec, None
if source_type == 'extracted-dependency':
source_dict["dereference"] = "root"
source_dict["optional"] = False
elif source_type == 'file':
source_dict["path"] = source_spec
Expand All @@ -6017,9 +6021,7 @@ def _as_source_dict(source, distribution_name, destination, path_substitutions=N
if source_type in ('dependency', 'extracted-dependency', 'skip'):
source_dict['_str_'] = source_type + ":" + source_dict['dependency']
if source_type == 'extracted-dependency':
if 'dereference' not in source_dict:
source_dict["dereference"] = "root"
elif source_dict["dereference"] not in ("root", "never", "always"):
if 'dereference' in source_dict and source_dict["dereference"] not in ("root", "never", "always"):
raise abort(f"Unsupported dereference mode: '{source_dict['dereference']}' in '{destination}'", context=context)
if source_dict['path']:
source_dict['_str_'] += f"/{source_dict['path']}"
Expand Down Expand Up @@ -6203,7 +6205,7 @@ def _install_source_files(files, include=None, excludes=None, optional=False, ar
" - or '{source_type}:{d}/path/to/file/in/archive' as a source (i.e., extracting /path/to/file/in/archive from '{d}' to '{destination}')",
context=self)
unarchiver_dest_directory = dirname(unarchiver_dest_directory)
dereference = source.get("dereference", "root")
dereference = source.get("dereference", self.defaultDereference)
ensure_dir_exists(unarchiver_dest_directory)
ext = get_file_extension(source_archive_file)
output_done = False
Expand Down Expand Up @@ -18370,7 +18372,7 @@ def alarm_handler(signum, frame):
abort(1, killsig=signal.SIGINT)

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("6.26.1") # mx build should print resolved java homes
version = VersionSpec("6.26.2") # GR-46518 defaultDereference attribute

_mx_start_datetime = datetime.utcnow()
_last_timestamp = _mx_start_datetime
Expand Down

0 comments on commit 7d8b7c8

Please sign in to comment.