summaryrefslogtreecommitdiff
path: root/mesonbuild/scripts
diff options
context:
space:
mode:
authorBenjamin Gilbert <bgilbert@backtick.net>2022-12-13 21:12:41 -0500
committerBenjamin Gilbert <bgilbert@backtick.net>2022-12-14 15:37:59 -0500
commit35e230e48ca42f4ccb872d1d01f9280f8015b417 (patch)
treea55a759f1f3a37e6a8d2b1f3ebd4268fc0df57c6 /mesonbuild/scripts
parent51c889ddbc8e83a73ef4d1f2556609bae2a046ce (diff)
downloadmeson-35e230e48ca42f4ccb872d1d01f9280f8015b417.tar.gz
depfixer: silence fix_jar() and make it do something
fix_jar() tries to remove an existing Class-Path entry from the jar manifest by postprocessing the manifest and passing it to `jar -um`. However, `jar -um` can only add/replace manifest entries, not remove them, and it also complains loudly when replacing an entry: Dec 13, 2022 7:11:19 PM java.util.jar.Attributes read WARNING: Duplicate name in Manifest: Manifest-Version. Ensure that the manifest does not have duplicate entries, and that blank lines separate individual sections in both your manifest and in the META-INF/MANIFEST.MF entry in the jar file. Thus fix_jar() produces one such warning for each entry in the manifest and accomplishes nothing else. Use jar -uM instead. This completely removes the manifest from the jar and allows adding it back as a normal zip member, fixing fix_jar() and avoiding the warnings. Fixes: https://github.com/mesonbuild/meson/issues/10491 Fixes: c70a051e93 ("java: remove manifest classpath from installed jar")
Diffstat (limited to 'mesonbuild/scripts')
-rw-r--r--mesonbuild/scripts/depfixer.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py
index 702afeb80..8d9c90fe3 100644
--- a/mesonbuild/scripts/depfixer.py
+++ b/mesonbuild/scripts/depfixer.py
@@ -465,7 +465,12 @@ def fix_jar(fname: str) -> None:
if not line.startswith('Class-Path:'):
f.write(line)
f.truncate()
- subprocess.check_call(['jar', 'ufm', fname, 'META-INF/MANIFEST.MF'])
+ # jar -um doesn't allow removing existing attributes. Use -uM instead,
+ # which a) removes the existing manifest from the jar and b) disables
+ # special-casing for the manifest file, so we can re-add it as a normal
+ # archive member. This puts the manifest at the end of the jar rather
+ # than the beginning, but the spec doesn't forbid that.
+ subprocess.check_call(['jar', 'ufM', fname, 'META-INF/MANIFEST.MF'])
def fix_rpath(fname: str, rpath_dirs_to_remove: T.Set[bytes], new_rpath: T.Union[str, bytes], final_path: str, install_name_mappings: T.Dict[str, str], verbose: bool = True) -> None:
global INSTALL_NAME_TOOL # pylint: disable=global-statement