Tristan971 / Lyrebird

A free, open-source, and multi-platform twitter client for the desktop!
https://tristan971.github.io/Lyrebird/
GNU General Public License v3.0
34 stars 8 forks source link

Add linux prompt for updating application via package manager #96

Open Tristan971 opened 6 years ago

Tristan971 commented 6 years ago

Is your feature request related to a problem? Please describe. Since repositories are now up for both dpkg-based and rpm-based distributions, add the appropriate update dialog for their users.

Describe the solution you'd like Some panel that gives simple-enough instructions on how to update via package manager.

Describe alternatives you've considered Integrated update but that would be too hard and a bad idea that would not follow the philosophy of application management on these platforms.

bbjubjub2494 commented 6 years ago

I think PackageKit is what you should look into. It's the abstraction layer most graphic software managers go through and it's standard across distros. On standardly-configured GNU/Linux boxen it should be already installed and should allow you to pop up the package manager dialog. It can be run over DBus, which should be possible to reach in Java.

Quick demo: Just install python-dbus on Ubuntu Bionic and run their demo Python2 script and you can launch an "install lyrebird" dialog in no time. Now we just need to do this from within a Java app.

Tristan971 commented 6 years ago

Thanks for the info! Will look it up!

bbjubjub2494 commented 6 years ago

Same demo works on Fedora 28 screenshot

You're welcome

Tristan971 commented 6 years ago

Sounds like this is a promising way to send dbus messages https://github.com/hypfvieh/dbus-java :-) Let's see what I can do then :-)

Tristan971 commented 6 years ago

Preliminary testing shows PackageKit might not actually always be available unfortunately...

org.freedesktop.dbus.exceptions.DBusException: Failed to create proxy object for /org/freedesktop/PackageKit exported by org.freedesktop.PackageKit. Reason: The name org.freedesktop.PackageKit was not provided by any .service files
bbjubjub2494 commented 6 years ago

getting the same error on my Arch box as well, despite installing PackageKit. There's prolly a way but idk rn. Try on a out-of-the-box distro tho, it should already be properly set up because Gnome Software Center &co wouldn't work otherwise.

Tristan971 commented 6 years ago

I'm surprised because I use Manjaro which comes with pretty much an OoTB setup based on Arch... Haven't tried restarting afterwards though, might be that DBus only loads available proxies on startup. Had you tried restarting ?

Tristan971 commented 6 years ago

Also if you are already using gnome (or don't mind temporary installation of it), can you try this out ? (I don't have a linux box with me right now unfortunately) https://www.archlinux.org/packages/community/x86_64/gnome-software-packagekit-plugin/

bbjubjub2494 commented 6 years ago

No I haven't tried restarting :man_facepalming:. And today it works since I restarted :man_facepalming: :man_facepalming:

bbjubjub2494 commented 6 years ago

Ok so now I have a Gnome Software Center over PacMan setup, but what do I do with it?

Also I have Ubuntu and Fedora boxen handy.

Tristan971 commented 6 years ago

Hahaha it happens to the best of us :-)

checkout branch update_workflow_linux, build with mvn clean install -DskipTests -Pdev execute server jar with java -jar lyrebird-api-server/target/<whateveritsnameis>-exec.jar run mvn spring-boot:run -DskipTests -Pdev in Lyrebird/lyrebird folder

Wait for green update button to appear on the lefthand side (poll starts 10 secs after initialization of the app iirc), click on it, then click update button on update window and check console to see if an exception is thrown :)

Will have a setup on my side in a few minutes hopefully

bbjubjub2494 commented 6 years ago

Got it capture d ecran de 2018-08-16 21-22-11

But then it just says


2018-08-16 21:22:33.939  INFO 10202 --- [onPool-worker-1] m.l.m.u.selfupdate.SelfupdateService     : Requesting selfupdate to version : LyrebirdVersion{version='UNIT_TEST', buildVersion='999', releaseUrl='https://github.com/Tristan971/Lyrebird/releases/tag/1.1.1', packages=[LyrebirdPackage{targetPlatform=WINDOWS, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/Lyrebird-1.1.1-Windows.exe}, LyrebirdPackage{targetPlatform=MACOS, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/Lyrebird-1.1.1-macOS.dmg}, LyrebirdPackage{targetPlatform=LINUX_DEB, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/lyrebird-1.1.1-DEB.deb}, LyrebirdPackage{targetPlatform=LINUX_RPM, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/lyrebird-1.1.1-1.x86_64-RPM.rpm}, LyrebirdPackage{targetPlatform=UNIVERSAL_JAVA, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/lyrebird-1.1.1-JAVA.jar}]}
Tristan971 commented 6 years ago

That's all when clicking on "update" button on this screen?? Very weird. I'll check but it might mean that the PackageKit was correctly contacted and that something got eaten in some asynchronous hell...

bbjubjub2494 commented 6 years ago

When clicking update yes.

Tristan971 commented 6 years ago

Alright I might have messed up then. Will check in a few minutes

Tristan971 commented 6 years ago

After checking all I get is the same error :

Requesting selfupdate to version : LyrebirdVersion{version='UNIT_TEST', buildVersion='999', releaseUrl='https://github.com/Tristan971/Lyrebird/releases/tag/1.1.1', packages=[LyrebirdPackage{targetPlatform=WINDOWS, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/Lyrebird-1.1.1-Windows.exe}, LyrebirdPackage{targetPlatform=MACOS, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/Lyrebird-1.1.1-macOS.dmg}, LyrebirdPackage{targetPlatform=LINUX_DEB, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/lyrebird-1.1.1-DEB.deb}, LyrebirdPackage{targetPlatform=LINUX_RPM, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/lyrebird-1.1.1-1.x86_64-RPM.rpm}, LyrebirdPackage{targetPlatform=UNIVERSAL_JAVA, packageUrl=https://github.com/Tristan971/Lyrebird/releases/download/1.1.1/lyrebird-1.1.1-JAVA.jar}]}
org.freedesktop.dbus.exceptions.DBusException: Failed to create proxy object for /org/freedesktop/PackageKit exported by org.freedesktop.PackageKit. Reason: The name org.freedesktop.PackageKit was not provided by any .service files
    at org.freedesktop.dbus.DBusConnection.dynamicProxy(DBusConnection.java:428)
    at org.freedesktop.dbus.DBusConnection.getRemoteObject(DBusConnection.java:599)
    at moe.lyrebird.model.update.selfupdate.linux.PackageKitService.showNativeUnixPackageKitPrompt(PackageKitService.java:36)
    at moe.lyrebird.model.update.selfupdate.SelfupdateService.selfupdate(SelfupdateService.java:70)
    at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:714)
    at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1603)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
bbjubjub2494 commented 6 years ago

So on your setup, the PackageKit port would be flat out not responding? Try running 'pkcon search java' in a shell and see if it fails at this level. If that's the case, my Arch box at least has a working PackageKit "daemon" or whatever the correct word is. Now the question is why aren't I getting a popup when I click update.

I'll test in my other boxen tomorrow.

Tristan971 commented 6 years ago

It does indeed find a bunch of stuff but somehow Java can't contact it. Must be dbus object naming issues... I'll enquire more over the weekend.

bbjubjub2494 commented 6 years ago

Got the attached logging output out of running a stripped-down jar. This is Fedora. All three boxen gave a similar result.

log.txt

Tristan971 commented 6 years ago

Very well done. Idk how you understood the weird documentation that was available! Well done thanks!

Tristan971 commented 6 years ago

So it seems to me that the method I just merged does not complete the task probably due to threading issues. I have still cleaned it up and added some logs if you want to try and see until where the logs go, but to me it seems that the InstallPackageNames method never finishes which is weird.

Also need to be careful with InstallPackageName(Long, String) and InstallPackageNames(Long, String[]).

I will try to expand on the version supplied in your stripped-down jar as it seems to at least provide some insight on what's happening on the DBus/PackageKit side of things in case the issue is not Java-related.

Tristan971 commented 6 years ago

Ok so it still doesn't work but it is likely not on Java side.

Trying the sample python and C implementations yield the same errors :

C :

$> gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -lgio-2.0 -lgobject-2.0 -lglib-2.0 session.c
$> ./a.out
** (process:94448): WARNING **: 20:56:20.598: failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PackageKit was not provided by any .service files

Python :

$> python2 session.py
Unable to use PackageKit: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PackageKit was not provided by any .service files

This happens while I am 200% sure that PackageKit is installed. I'm not sure what to do at this point...

Tristan971 commented 6 years ago

After refactoring stuff a bit to make sure it is not threading related this is the output I get on Java side :

21:09:28.126 [main] INFO moe.lyrebird.model.update.selfupdate.linux.PackageKitService - Calling native unix update prompt provided by PackageKit over DBus
21:09:28.137 [main] DEBUG org.freedesktop.dbus.DBusConnection - Creating new bus connection to: unix:path=/run/user/1000/bus
21:09:28.147 [main] DEBUG org.freedesktop.dbus.EfficientQueue - Shrinking
21:09:28.151 [main] DEBUG org.freedesktop.dbus.Transport - Connecting to unix: {path=/run/user/1000/bus}
21:09:28.232 [main] DEBUG org.freedesktop.dbus.MethodCall - Creating message with serial 1
21:09:28.232 [main] DEBUG org.freedesktop.dbus.MethodCall - Appending sig: yyyy data: [66, 1, 0, 1]
21:09:28.232 [main] DEBUG org.freedesktop.dbus.MethodCall - Appending sig: ua(yv) data: [1, [[1, [o, /org/freedesktop/DBus]], [6, [s, org.freedesktop.DBus]], [2, [s, org.freedesktop.DBus]], [3, [s, Hello]]]]
21:09:28.232 [main] DEBUG org.freedesktop.dbus.MethodCall - Appended body, type: null start: 128 end: 128 size: 0
21:09:28.232 [main] DEBUG org.freedesktop.dbus.MethodCall - marshalled size ([B@36902638): 000000   00 00 00 00                                            ....              

21:09:28.233 [main] DEBUG org.freedesktop.dbus.EfficientQueue - Enqueueing Message MethodCall(0,1) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>Hello, Destination=>org.freedesktop.DBus } { }
21:09:28.233 [main] DEBUG org.freedesktop.dbus.DBusConnection - Notifying outgoing thread
21:09:28.233 [Sender] DEBUG org.freedesktop.dbus.EfficientQueue - Dequeueing MethodCall(0,1) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>Hello, Destination=>org.freedesktop.DBus } { }
21:09:28.233 [Sender] DEBUG org.freedesktop.dbus.AbstractConnection$SenderThread - Got message: MethodCall(0,1) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>Hello, Destination=>org.freedesktop.DBus } { }
21:09:28.233 [Sender] INFO org.freedesktop.dbus.MessageWriter - <= MethodCall(0,1) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>Hello, Destination=>org.freedesktop.DBus } { }
21:09:28.235 [DBusConnection] DEBUG org.freedesktop.dbus.MessageReader - => MethodReturn(1,1) { Reply Serial=>1, Destination=>:1.191, Sender=>org.freedesktop.DBus, Signature=>s } { :1.191 }
21:09:28.236 [DBusConnection] DEBUG org.freedesktop.dbus.DBusConnection - Handling incoming method return: MethodReturn(1,1) { Reply Serial=>1, Destination=>:1.191, Sender=>org.freedesktop.DBus, Signature=>s } { :1.191 }
21:09:28.248 [DBusConnection] DEBUG org.freedesktop.dbus.MessageReader - => DBusSignal(1,2) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>NameAcquired, Destination=>:1.191, Sender=>org.freedesktop.DBus, Signature=>s } { :1.191 }
21:09:28.249 [DBusConnection] DEBUG org.freedesktop.dbus.DBusConnection - Handling incoming signal: DBusSignal(1,2) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>NameAcquired, Destination=>:1.191, Sender=>org.freedesktop.DBus, Signature=>s } { :1.191 }
21:09:28.252 [Thread-0] DEBUG org.freedesktop.dbus.DBusSignal - Converting signal to type: class org.freedesktop.DBus$NameAcquired
21:09:28.252 [Thread-0] DEBUG org.freedesktop.dbus.DBusSignal - Creating signal of type class org.freedesktop.DBus$NameAcquired with parameters [/org/freedesktop/DBus, :1.191]
21:09:28.253 [Thread-0] DEBUG org.freedesktop.DBus$NameAcquired - Creating message with serial 2
21:09:28.253 [Thread-0] DEBUG org.freedesktop.DBus$NameAcquired - Appending sig: yyyy data: [66, 4, 0, 1]
21:09:28.253 [Thread-0] DEBUG org.freedesktop.DBus$NameAcquired - Appending sig: ua(yv) data: [3, [[1, [o, /org/freedesktop/DBus]], [2, [s, org.freedesktop.DBus]], [3, [s, NameAcquired]], [8, [g, s]]]]
21:09:28.249 [main] DEBUG moe.lyrebird.model.update.selfupdate.linux.PackageKitService - Got DBus connection : org.freedesktop.dbus.DBusConnection@158d2680
21:09:28.263 [main] DEBUG moe.lyrebird.model.update.selfupdate.linux.PackageKitService - Got PackageKit interface binding : org.freedesktop.PackageKit:/org/freedesktop/PackageKit/Modify:interface moe.lyrebird.model.update.selfupdate.linux.PackageKitService$IPackageKit
21:09:28.263 [main] DEBUG moe.lyrebird.model.update.selfupdate.linux.PackageKitService - Will display update prompt on screen 0 [from $DISPLAY = :0]
21:09:28.264 [main] DEBUG org.freedesktop.dbus.MethodCall - Creating message with serial 3
21:09:28.265 [main] DEBUG org.freedesktop.dbus.MethodCall - Appending sig: yyyy data: [66, 1, 0, 1]
21:09:28.265 [main] DEBUG org.freedesktop.dbus.MethodCall - Appending arguments with signature: uass
21:09:28.265 [main] DEBUG org.freedesktop.dbus.MethodCall - Appending sig: ua(yv) data: [3, [[1, [o, /org/freedesktop/PackageKit/Modify]], [6, [s, org.freedesktop.PackageKit]], [2, [s, org.freedesktop.PackageKit.Modify]], [3, [s, InstallPackageNames]], [8, [g, uass]]]]
21:09:28.265 [main] DEBUG org.freedesktop.dbus.MethodCall - Appending sig: uass data: [0, [lyrebird], show-confirm-search,hide-finished]
21:09:28.265 [main] DEBUG org.freedesktop.dbus.MethodCall - Appended body, type: uass start: 200 end: 262 size: 62
21:09:28.265 [main] DEBUG org.freedesktop.dbus.MethodCall - marshalled size ([B@747ddf94): 000000   00 00 00 3e                                            ...>              

21:09:28.265 [main] DEBUG org.freedesktop.dbus.EfficientQueue - Enqueueing Message MethodCall(0,3) { Path=>/org/freedesktop/PackageKit/Modify, Interface=>org.freedesktop.PackageKit.Modify, Member=>InstallPackageNames, Destination=>org.freedesktop.PackageKit, Signature=>uass } { 0, [lyrebird], show-confirm-search,hide-finished }
21:09:28.265 [main] DEBUG org.freedesktop.dbus.DBusConnection - Notifying outgoing thread
21:09:28.266 [Sender] DEBUG org.freedesktop.dbus.EfficientQueue - Dequeueing MethodCall(0,3) { Path=>/org/freedesktop/PackageKit/Modify, Interface=>org.freedesktop.PackageKit.Modify, Member=>InstallPackageNames, Destination=>org.freedesktop.PackageKit, Signature=>uass } { 0, [lyrebird], show-confirm-search,hide-finished }
21:09:28.266 [Sender] DEBUG org.freedesktop.dbus.AbstractConnection$SenderThread - Got message: MethodCall(0,3) { Path=>/org/freedesktop/PackageKit/Modify, Interface=>org.freedesktop.PackageKit.Modify, Member=>InstallPackageNames, Destination=>org.freedesktop.PackageKit, Signature=>uass } { 0, [lyrebird], show-confirm-search,hide-finished }
21:09:28.266 [Sender] INFO org.freedesktop.dbus.MessageWriter - <= MethodCall(0,3) { Path=>/org/freedesktop/PackageKit/Modify, Interface=>org.freedesktop.PackageKit.Modify, Member=>InstallPackageNames, Destination=>org.freedesktop.PackageKit, Signature=>uass } { 0, [lyrebird], show-confirm-search,hide-finished }
21:09:28.267 [DBusConnection] DEBUG org.freedesktop.dbus.MessageReader - => Error(1,3) { Error Name=>org.freedesktop.DBus.Error.ServiceUnknown, Reply Serial=>3, Destination=>:1.191, Sender=>org.freedesktop.DBus, Signature=>s } { The name org.freedesktop.PackageKit was not provided by any .service files }
21:09:28.267 [DBusConnection] DEBUG org.freedesktop.dbus.DBusConnection - Handling incoming error: Error(1,3) { Error Name=>org.freedesktop.DBus.Error.ServiceUnknown, Reply Serial=>3, Destination=>:1.191, Sender=>org.freedesktop.DBus, Signature=>s } { The name org.freedesktop.PackageKit was not provided by any .service files }

org.freedesktop.DBus$Error$ServiceUnknown: The name org.freedesktop.PackageKit was not provided by any .service files

    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
    at org.freedesktop.dbus.Error.getException(Error.java:141)
    at org.freedesktop.dbus.Error.throwException(Error.java:171)
    at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:158)
    at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:222)
    at moe.lyrebird.model.update.selfupdate.linux.$Proxy8.InstallPackageNames(Unknown Source)
    at moe.lyrebird.model.update.selfupdate.linux.PackageKitService.showNativeUnixPackageKitPrompt(PackageKitService.java:33)
    at moe.lyrebird.model.update.selfupdate.linux.PackageKitServiceTest.showNativeUnixPackageKitPrompt(PackageKitServiceTest.java:9)
    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:564)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Which is basically the same other implementations. So the issue is on the system itself...

bbjubjub2494 commented 6 years ago

Do you have gnome-software (or an equivalent graphical software management tool) installed?