Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protege: init at 5.6.4 #316647

Merged
merged 1 commit into from
Jun 4, 2024
Merged

protege: init at 5.6.4 #316647

merged 1 commit into from
Jun 4, 2024

Conversation

nessdoor
Copy link
Contributor

@nessdoor nessdoor commented Jun 2, 2024

Description of changes

The current protege-distribution package is derived directly from the upstream release archives, which include a number of pre-installed third-party plugins.

This PR introduces the "vanilla" Protégé build with no added plugins. More importantly, it is a source-based build, contrary to the current "distribution" build, and is better engineered overall.

This Protégé build is platform-independent and the derivation has been structured to support both Linux and Darwin, but, due to the lack of a Darwin machine at hand, I could not come up with a working installation for Darwin systems. Input from knowledgeable people is welcome and solicited.

I will try to refactor the old protege-distribution derivation into a source-based build as soon as technically possible, and maybe integrate it into the new derivation as a special case (maybe as a protegeFull package?).

Thanks go to @doronbehar for pointing me to maven.buildMavenPackage as a way to properly build Maven projects.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels Jun 2, 2024
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
@nessdoor nessdoor added the backport release-24.05 Backport PR automatically label Jun 2, 2024
stdenvNoCC.mkDerivation rec {
inherit pname version;

buildInputs = [ protege-build ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit weird, perhaps it'd be possible to combine the installPhase of this derivation to the installPhase of this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but I wanted to keep them separate according to the following reasoning:

  • the result of the Maven build contains a target-agnostic directory containing all the necessary jars plus a launcher script for every platform
  • what distinguishes an installation for a certain platform from one for another platform is just how the produced files are placed in the filesystem (e.g. where the icon files are copied)

So why not produce a perfectly agnostic build that is the same for all platforms, and then produce a platform-specific symlink structure that refers to its relevant components as part of a platform-specific derivation? This way, when Darwin systems will be supported by this package, both Linux and Darwin builds would share the same core derivation and access it via symlinks, organized according to their platform-specific filesystem conventions. This can save space and, potentially, computation, as a single multi-target derivation would need to be evaluated for every end platform and would duplicate perfectly agnostic Java bytecode for no reason.

I don't know if my explanation is clear...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but I wanted to keep them separate according to the following reasoning:

* the result of the Maven build contains a target-agnostic directory containing all the necessary jars plus a launcher script for every platform

How are you so sure that this protege-build is the same for all platforms?

* what distinguishes an installation for a certain platform from one for another platform is just how the produced files are placed in the filesystem (e.g. where the icon files are copied)

I'm not sure you gain anything with this. Do you want to save a few kilobytes on Hydra? What's important, is that both platforms have the same mvnHash.

So why not produce a perfectly agnostic build that is the same for all platforms, and then produce a platform-specific symlink structure that refers to its relevant components as part of a platform-specific derivation? This way, when Darwin systems will be supported by this package, both Linux and Darwin builds would share the same core derivation and access it via symlinks, organized according to their platform-specific filesystem conventions. This can save space and, potentially, computation,

Yes I agree with the computation argument, but I'm not sure it is worth the readabilty penalty, and the harder overriding capabilities.

as a single multi-target derivation would need to be evaluated for every end platform and would duplicate perfectly agnostic Java bytecode for no reason.

I don't know if my explanation is clear...

You were clear, it's just that since the java compiler is different between the platforms, I suspect that the derivations won't get the same hash (which is based on their inputs).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were clear, it's just that since the java compiler is different between the platforms, I suspect that the derivations won't get the same hash (which is based on their inputs).

When I wrote it, I was thinking more of optimised binary caches that de-duplicate based on content, and about future content-addressed derivations. This was based on the assumption that javac, not being a native compiler, would have produced identical bytecode irrespective of the "real" underlying platform.

How are you so sure that this protege-build is the same for all platforms?

I performed some experiments, and it turns out that you were right: something creeps into the compiled jars and makes them different for, apparently, no reason. On the bright side, optimised stores can properly detect duplication even with differing directory structures, so all JAR dependencies are correctly hard-linked.

At this point, the only gain from the split derivation would be a reduced dependency set. I don't think it's worth it anymore. I will simplify the derivation and resubmit it shortly.

Thank you!

P. S. It would be very interesting to investigate the sources of impurity in Java bytecode, so that we can aim at reproducible Java programs in the future. I don't know if anyone has ever made some research in that direction, but I find it likely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P. S. It would be very interesting to investigate the sources of impurity in Java bytecode, so that we can aim at reproducible Java programs in the future. I don't know if anyone has ever made some research in that direction, but I find it likely.

That's something to mention at #313216 .

Thank you!

You are welcome!

On the bright side, optimised stores can properly detect duplication even with differing directory structures, so all JAR dependencies are correctly hard-linked.

What is this optimise tool you are talking about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix-store --optimise

Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit picks essentially, but looks good overall!

pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/pr/protege/package.nix Outdated Show resolved Hide resolved
Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diff looks good. Great!

@doronbehar
Copy link
Contributor

BTW those maven patches are impressive :) Is there a chance you'd have an idea how to help here:

torakiki/pdfsam#583

?

@nessdoor
Copy link
Contributor Author

nessdoor commented Jun 3, 2024

Thank you~! They're nothing special really.

Ok, I started looking into it. I'll report back under the relevant issue as soon as I have any positive outcomes (or negative outcomes different from the ones you obtained).

'';
maintainers = with lib.maintainers; [ nessdoor ];
license = with lib.licenses; [ bsd2 ];
# TODO Protege is able to run on Darwin as well, but I (@nessdoor) had no
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that, I would suggest to set platforms to unix and broken = stdenv.isDarwin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that, I would suggest to set platforms to unix and broken = stdenv.isDarwin.

Further more, we can use platforms.unix, and see what ofborg's CI says. If it will fail on Darwin, we can set meta.broken and even quote in a comment an excerpt from the error we got from there, so Darwin users who will want to unbreak it will have a clue what they have to tackle with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how ofBorg behaves, but I see no reason for it failing in any obvious way. I think Darwin users would just find themselves with a bogus package that needs to be started directly from the store path, as the corresponding startup script is not getting copied into /bin (if that's where today's Darwin systems expect to find user applications, that is).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how ofBorg behaves, but I see no reason for it failing in any obvious way. I think Darwin users would just find themselves with a bogus package that needs to be started directly from the store path, as the corresponding startup script is not getting copied into /bin (if that's where today's Darwin systems expect to find user applications, that is).

Yes ideally Darwin users would want to put something in $out/Applications, but it's not so bad for them as a start to have something only in $out/bin.

@ofborg ofborg bot added 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin labels Jun 4, 2024
@doronbehar
Copy link
Contributor

Result of nixpkgs-review pr 316647 run on x86_64-linux 1

1 package failed to build:
  • protege

@doronbehar
Copy link
Contributor

[INFO] 
[INFO] --- enforcer:3.4.1:enforce (enforce-maven) @ protege-editor-core ---
[INFO] Rule 1: org.apache.maven.enforcer.rules.RequirePluginVersions passed
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ protege-editor-core ---
[INFO] Copying 188 resources from src/main/resources to target/classes
[INFO] 
[INFO] --- compiler:3.13.0:compile (default-compile) @ protege-editor-core ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 276 source files with javac [debug release 11] to target/classes
[WARNING] Supported source version 'RELEASE_8' from annotation processor 'org.glassfish.corba.annotation.processing.ExceptionWrapperProcessor' less than -source '11'
[INFO] /nix/tmp/nix-build-protege-5.6.4-maven-deps.drv-0/source/protege-editor-core/src/main/java/org/protege/editor/core/ui/workspace/Workspace.java: Some input files use or override a deprecated API.
[INFO] /nix/tmp/nix-build-protege-5.6.4-maven-deps.drv-0/source/protege-editor-core/src/main/java/org/protege/editor/core/ui/workspace/Workspace.java: Recompile with -Xlint:deprecation for details.
[INFO] /nix/tmp/nix-build-protege-5.6.4-maven-deps.drv-0/source/protege-editor-core/src/main/java/org/protege/editor/core/plugin/PluginUtilities.java: Some input files use unchecked or unsafe operations.
[INFO] /nix/tmp/nix-build-protege-5.6.4-maven-deps.drv-0/source/protege-editor-core/src/main/java/org/protege/editor/core/plugin/PluginUtilities.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ protege-editor-core ---
[INFO] skip non existing resourceDirectory /nix/tmp/nix-build-protege-5.6.4-maven-deps.drv-0/source/protege-editor-core/src/test/resources
[INFO] 
[INFO] --- compiler:3.13.0:testCompile (default-testCompile) @ protege-editor-core ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 4 source files with javac [debug release 11] to target/test-classes
[WARNING] Supported source version 'RELEASE_8' from annotation processor 'org.glassfish.corba.annotation.processing.ExceptionWrapperProcessor' less than -source '11'
[INFO] 
[INFO] --- surefire:3.2.5:test (default-test) @ protege-editor-core ---
[INFO] Using auto detected provider org.apache.maven.surefire.junit4.JUnit4Provider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.protege.editor.core.platform.apple.MacUIUtil_TestCase
[WARNING] Tests run: 3, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 0.056 s -- in org.protege.editor.core.platform.apple.MacUIUtil_TestCase
[INFO] Running org.protege.editor.core.prefs.PreferencesTest
Jun 04, 2024 4:22:11 AM java.util.prefs.FileSystemPreferences$1 run
WARNING: Couldn't create user preferences directory. User preferences are unusable.
Jun 04, 2024 4:22:11 AM java.util.prefs.FileSystemPreferences$1 run
WARNING: java.io.IOException: No such file or directory
Jun 04, 2024 4:22:12 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode
WARNING: Could not lock User prefs.  Unix error code 2.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.677 s <<< FAILURE! -- in org.protege.editor.core.prefs.PreferencesTest
[ERROR] org.protege.editor.core.prefs.PreferencesTest.testClearStringList -- Time elapsed: 1.674 s <<< ERROR!
java.lang.RuntimeException: java.util.prefs.BackingStoreException: Couldn't get file lock.
	at org.protege.editor.core.prefs.JavaBackedPreferencesImpl.clear(JavaBackedPreferencesImpl.java:42)
	at org.protege.editor.core.prefs.PreferencesTest.testClearStringList(PreferencesTest.java:18)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Caused by: java.util.prefs.BackingStoreException: Couldn't get file lock.
	at java.prefs/java.util.prefs.FileSystemPreferences.removeNode(FileSystemPreferences.java:690)
	at org.protege.editor.core.prefs.JavaBackedPreferencesImpl.clear(JavaBackedPreferencesImpl.java:38)
	... 29 more

[INFO] Running org.protege.editor.core.ui.menu.PopupMenuId_TestCase
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 s -- in org.protege.editor.core.ui.menu.PopupMenuId_TestCase
[INFO] Running org.protege.editor.core.util.StringAbbreviator_TestCase
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.004 s -- in org.protege.editor.core.util.StringAbbreviator_TestCase
[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   PreferencesTest.testClearStringList:18 ? Runtime java.util.prefs.BackingStoreException: Couldn't get file lock.
[INFO] 
[ERROR] Tests run: 24, Failures: 0, Errors: 1, Skipped: 3
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for protege-parent 5.6.4:
[INFO] 
[INFO] protege-parent ..................................... SUCCESS [  1.474 s]
[INFO] protege-launcher ................................... SUCCESS [ 24.004 s]
[INFO] protege-common ..................................... SUCCESS [  0.973 s]
[INFO] protege-editor-core ................................ FAILURE [  6.604 s]
[INFO] protege-editor-owl ................................. SKIPPED
[INFO] protege-desktop .................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  44.591 s
[INFO] Finished at: 2024-06-04T04:22:14Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test (default-test) on project protege-editor-core: 
[ERROR] 
[ERROR] Please refer to /nix/tmp/nix-build-protege-5.6.4-maven-deps.drv-0/source/protege-editor-core/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :protege-editor-core

But in the 2nd attempt it didn't fail... Something there is a bit flaky I suppose.

Other then that GUI seemed to work fine.


nativeBuildInputs = [
copyDesktopItems
iconConvTools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package is not supported on Darwin, making the build not even evaluate there (I don't mean to request to fix this issue, just pointing out this fact after seeing ofborg logs for x86_64-darwin).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guessed as much, since the icon format on Darwin is different

@doronbehar doronbehar merged commit b4d7dd8 into NixOS:master Jun 4, 2024
25 of 26 checks passed
Copy link
Contributor

github-actions bot commented Jun 4, 2024

Successfully created backport PR for release-24.05:

@nessdoor
Copy link
Contributor Author

nessdoor commented Jun 4, 2024

Thank you very much for the extensive review comments, @AndersonTorres, @doronbehar!

By the way, that (#316647 (comment)) failure sounds very weird. Seems like a concurrency problem in the tests? Well, but if the CI reported no issue, it means that everybody is going to get a correct package.

@doronbehar
Copy link
Contributor

By the way, that (#316647 (comment)) failure sounds very weird. Seems like a concurrency problem in the tests? Well, but if the CI reported no issue, it means that everybody is going to get a correct package.

Usually Hydra and perhaps also ofborg are more prone to concurrency problems then normal users' machines. Worst case we'll modify things in a later PR if the build fails on Hydra. Also it's possible that it will fail on Hydra and it won't fail locally, so users may not notice this issue.

Thank you very much for the extensive review comments, @AndersonTorres, @doronbehar!

You are welcome :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 1-10 10.rebuild-linux: 1 11.by: package-maintainer This PR was created by the maintainer of the package it changes backport release-24.05 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants