Skip to content

Commit

Permalink
[GR-47522] Extend layout distribution file list entry by POSIX permis…
Browse files Browse the repository at this point in the history
…sions.

PullRequest: mx/1641
  • Loading branch information
tzezula committed Jul 24, 2023
2 parents 707e3ac + 8c9dcdb commit 9357e33
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
11 changes: 9 additions & 2 deletions ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ local common_json = import "../common.json";
"*.log",
],

packages+: if self.os == "linux" && self.arch == "amd64" then {
packages+: if self.os == "linux" && self.arch == "amd64" && std.objectHas(self, "os_distro") && self.os_distro == "ol" then {
"00:devtoolset": "==7",
"01:binutils": ">=2.34",
} else if self.os == "linux" && self.arch == "aarch64" then {
} else if self.os == "linux" && self.arch == "aarch64" && std.objectHas(self, "os_distro") && self.os_distro == "ol" then {
"00:devtoolset": "==7",
} else {},
},
Expand Down Expand Up @@ -239,6 +239,12 @@ local common_json = import "../common.json";
mount_modules: true,
},
},
local ubuntu22 = {
docker: {
image: "buildslave_ubuntu22",
mount_modules: true,
},
},
local deps_linux = {
},
local deps_darwin = {
Expand All @@ -255,6 +261,7 @@ local common_json = import "../common.json";
local aarch64 = { arch:: "aarch64", capabilities+: [self.arch] },

linux_amd64: linux + amd64 + ol7,
linux_amd64_ubuntu: linux + amd64 + ubuntu22,
linux_aarch64: linux + aarch64,

darwin_amd64: darwin + amd64,
Expand Down
2 changes: 1 addition & 1 deletion common.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+30-jvmci-23.1-b10-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+30-jvmci-23.1-b10-sulong", "platformspecific": true },

"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "1", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "2", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
},

"eclipse": {
Expand Down
29 changes: 23 additions & 6 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -15569,7 +15569,7 @@ def __init__(self, path, file_list_entry, hash_entry, delegate):
self.path = path
self.file_list_entry = file_list_entry
self.hash_entry = hash_entry
self.filelist = [] if path or file_list_entry else None
self.filelist = OrderedDict() if path or file_list_entry else None
self.sha256 = hashlib.sha256() if hash_entry else None
self.delegate = delegate

Expand All @@ -15584,21 +15584,27 @@ def _file_hash(self, filename):

def add(self, filename, archive_name, provenance):
if self.filelist is not None:
self.filelist.append(archive_name)
# We only need the 9 lowest bits of the st_mode, which encode the POSIX permissions.
perms = (os.lstat(filename).st_mode & 0o777) if self.file_list_entry else None
self.filelist[archive_name] = perms
if self.sha256:
self._file_hash(filename)
self.delegate.add(filename, archive_name, provenance)

def add_str(self, data, archive_name, provenance):
if self.filelist is not None:
self.filelist.append(archive_name)
# The default permissions for add_str are rw-rw-rw-.
perms = 0o664 if self.file_list_entry else None
self.filelist[archive_name] = perms
if self.sha256:
self.sha256.update(data.encode('utf-8'))
self.delegate.add_str(data, archive_name, provenance)

def add_link(self, target, archive_name, provenance):
if self.filelist is not None:
self.filelist.append(archive_name)
# The default permissions for add_link are rwxrwxrwx.
perms = 0o777 if self.file_list_entry else None
self.filelist[archive_name] = perms
if self.sha256:
self.sha256.update(target.encode('utf-8'))
self.delegate.add_link(target, archive_name, provenance)
Expand All @@ -15610,16 +15616,27 @@ def _add_entry(self, entry, data):
f.write(data)
self.delegate.add_str(data, target, None)

@staticmethod
def _perm_str(perms):
perm_str = ''
bit_index = 8
while bit_index >= 0:
for letter in ['r', 'w', 'x']:
perm_str += letter if perms & (1 << bit_index) else '-'
bit_index -= 1
return perm_str

def __exit__(self, exc_type, exc_value, traceback):
if self.sha256:
assert self.hash_entry, "Hash entry path must be given"
self._add_entry(self.hash_entry, self.sha256.hexdigest())

if self.filelist is not None:
_filelist_str = os.linesep.join(self.filelist)
if self.file_list_entry:
_filelist_str = os.linesep.join([k + ' = ' + self._perm_str(v) for k, v in self.filelist.items()])
self._add_entry(self.file_list_entry, _filelist_str)
if self.path:
_filelist_str = os.linesep.join(self.filelist.keys())
with SafeFileCreation(self.path + ".filelist") as sfc, io_open(sfc.tmpFd, mode='w', closefd=False, encoding='utf-8') as f:
f.write(_filelist_str)

Expand Down Expand Up @@ -18504,7 +18521,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.32.0") # Support useModulePath property with jar distributions.
version = VersionSpec("6.33.0") # Extend layout distribution file list entry by POSIX permissions.

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

0 comments on commit 9357e33

Please sign in to comment.