graalvm / mandrel-packaging

6 stars 8 forks source link

Better handling of MANIFEST.MF attributes #435

Closed jerboaa closed 1 month ago

jerboaa commented 1 month ago

Previously, the build script would add these two attributes irrespective whether or not they'd exist in the Graal artefacts:

  Specification-Version
  Implementation-Version

With this patch, only updates to the Implementation-Version attribute are done based on the maven version in use. Specification-Version is only added if it's not yet there in a jar or source jar file.

Closes: https://github.com/Karm/mandrel-integration-tests/issues/270

jerboaa commented 1 month ago

The GraalVM maven artifact's MANIFEST.MF entries before the patch:

$ for i in $(find -name \*.jar); do echo "Inspecting $i"; unzip -d test $i 2>&1 > /dev/null; pushd test > /dev/null; grep -E 'Implementation-Version|Specification-Version' META-INF/MANIFEST.MF; popd > /dev/null; rm -rf test; done
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/mandrel-packaging-wrapper-linux-amd64/24.2.0.SNAPSHOT/mandrel-packaging-wrapper-linux-amd64-24.2.0.SNAPSHOT.jar
grep: META-INF/MANIFEST.MF: No such file or directory
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT-sources.jar
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT-sources.jar
grep: META-INF/MANIFEST.MF: No such file or directory

Note for example this:

Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Specification-Version: 0.0
Implementation-Version: 24.2.0.SNAPSHOT

That is, library-support-24.2.0.SNAPSHOT.jar has duplicate Specification-Version. One at 0.0 which is added by mandrel packaging. Also for Implementation-Version: 24.2.0-dev where it should only have one entry like so:

Implementation-Version: 24.2.0.SNAPSHOT

After the patch

$ for i in $(find -name \*.jar); do echo "Inspecting $i"; unzip -d test $i 2>&1 > /dev/null; pushd test > /dev/null; grep -E 'Implementation-Version|Specification-Version' META-INF/MANIFEST.MF; popd > /dev/null; rm -rf test; done
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/jvmti-agent-base/24.2.0.SNAPSHOT/jvmti-agent-base-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/native-image-base/24.2.0.SNAPSHOT/native-image-base-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/objectfile/24.2.0.SNAPSHOT/objectfile-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/pointsto/24.2.0.SNAPSHOT/pointsto-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./nativeimage/svm/24.2.0.SNAPSHOT/svm-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-agent/24.2.0.SNAPSHOT/svm-agent-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-configure/24.2.0.SNAPSHOT/svm-configure-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-diagnostics-agent/24.2.0.SNAPSHOT/svm-diagnostics-agent-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-driver/24.2.0.SNAPSHOT/svm-driver-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./nativeimage/svm-foreign/24.2.0.SNAPSHOT/svm-foreign-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./compiler/compiler/24.2.0.SNAPSHOT/compiler-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./truffle/truffle-compiler/24.2.0.SNAPSHOT/truffle-compiler-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/collections/24.2.0.SNAPSHOT/collections-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/graal-sdk/24.2.0.SNAPSHOT/graal-sdk-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/mandrel-packaging-wrapper-linux-amd64/24.2.0.SNAPSHOT/mandrel-packaging-wrapper-linux-amd64-24.2.0.SNAPSHOT.jar
grep: META-INF/MANIFEST.MF: No such file or directory
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/nativeimage/24.2.0.SNAPSHOT/nativeimage-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT
Inspecting ./sdk/word/24.2.0.SNAPSHOT/word-24.2.0.SNAPSHOT-sources.jar
Implementation-Version: 24.2.0.SNAPSHOT
Specification-Version: 0.0
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0-dev
Inspecting ./polyglot/polyglot/24.2.0.SNAPSHOT/polyglot-24.2.0.SNAPSHOT-sources.jar
grep: META-INF/MANIFEST.MF: No such file or directory

That is we have after the patch for library-support-24.2.0.SNAPSHOT.jar:

Inspecting ./nativeimage/library-support/24.2.0.SNAPSHOT/library-support-24.2.0.SNAPSHOT.jar
Specification-Version: 24.2.0-dev
Implementation-Version: 24.2.0.SNAPSHOT

No more the duplicate entries and the Implementation-Version matches the maven version.

Thoughts?

jerboaa commented 1 month ago

LGTM. My only hesitation is about the Specification-Version not being the same with the Implementation-Version.

Thanks for the review! This is pre-existing. We were adding Specification-Version: 0.0 unconditionally before while setting "Implementation-Version: " + options.mavenVersion. The comment of the method suggests it wasn't important. Also, what would we set the specification version to if it's not there in the original jar?