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

Consider a Gtk+ plugin #2

Open
probonopd opened this Issue Jun 10, 2018 · 16 comments

Comments

Projects
None yet
3 participants
@probonopd

probonopd commented Jun 10, 2018

(Low priority, mainly a placeholder for the link below I just stumbled across)

Consider a Gtk+ plugin that would bundle the subset of Gtk+ that is needed.
Maybe some code (or inspiration) from https://github.com/jralls/gtk-mac-bundler could be adopted.

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Jun 10, 2018

Member

I'd love to see someone maintain such a plugin externally. Do you know anybody who might be interested in that?

Member

TheAssassin commented Jun 10, 2018

I'd love to see someone maintain such a plugin externally. Do you know anybody who might be interested in that?

@probonopd

This comment has been minimized.

Show comment
Hide comment
@probonopd

probonopd commented Jun 10, 2018

Maybe @aferrero2707?

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Jun 18, 2018

Member

Such a plugin might use https://github.com/TheAssassin/linuxdeploy-plugin-qt for inspiration. This plugin re-uses facilities maintained by the linuxdeploy authors to deploy files into the AppDir.

Member

TheAssassin commented Jun 18, 2018

Such a plugin might use https://github.com/TheAssassin/linuxdeploy-plugin-qt for inspiration. This plugin re-uses facilities maintained by the linuxdeploy authors to deploy files into the AppDir.

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Jun 28, 2018

Member

@probonopd is there any code that showcases what needs to be done to bundle Gtk+?

Member

TheAssassin commented Jun 28, 2018

@probonopd is there any code that showcases what needs to be done to bundle Gtk+?

@probonopd

This comment has been minimized.

Show comment
Hide comment
@probonopd

probonopd Jun 29, 2018

Not that I am aware of

probonopd commented Jun 29, 2018

Not that I am aware of

@aferrero2707

This comment has been minimized.

Show comment
Hide comment
@aferrero2707

aferrero2707 Jul 1, 2018

@TheAssassin @probonopd I think that my GIMP AppImage script can be taken as a good example of bundled GTK+ app, which is also fully relocatable.

Is there a specific reason for using C/C++ for [the Qt plug-in[(https://github.com/TheAssassin/linuxdeploy-plugin-qt), instead of simple bash?

aferrero2707 commented Jul 1, 2018

@TheAssassin @probonopd I think that my GIMP AppImage script can be taken as a good example of bundled GTK+ app, which is also fully relocatable.

Is there a specific reason for using C/C++ for [the Qt plug-in[(https://github.com/TheAssassin/linuxdeploy-plugin-qt), instead of simple bash?

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Jul 1, 2018

Member

The Qt plugin makes use of the linuxdeploy_core library which provides an AppDir class that allows for easy deployment of libraries and their dependencies. This is useful for deploying Qt plugin libraries. Also, it copies copyright files for the files it bundles.

Because I wanted to experiment a bit, I wrote the AppImage plugin https://github.com/TheAssassin/linuxdeploy-plugin-appimage in C++ as well. It could be a shell script though, too.

I am working on a bash plugin at the moment, see https://github.com/TheAssassin/linuxdeploy-plugin-checkrt.

Member

TheAssassin commented Jul 1, 2018

The Qt plugin makes use of the linuxdeploy_core library which provides an AppDir class that allows for easy deployment of libraries and their dependencies. This is useful for deploying Qt plugin libraries. Also, it copies copyright files for the files it bundles.

Because I wanted to experiment a bit, I wrote the AppImage plugin https://github.com/TheAssassin/linuxdeploy-plugin-appimage in C++ as well. It could be a shell script though, too.

I am working on a bash plugin at the moment, see https://github.com/TheAssassin/linuxdeploy-plugin-checkrt.

@aferrero2707

This comment has been minimized.

Show comment
Hide comment
@aferrero2707

aferrero2707 Sep 12, 2018

@TheAssassin @probonopd I have recently done some more work that attempts to generalise the bundling of GTK applications, partly also inspired by your linuxdeploy-plugin-checkrt code.

The current scripts can be found here: https://github.com/aferrero2707/appimage-helper-scripts, and an example of bundling script here: https://github.com/aferrero2707/pf-build-appimage/blob/master/package-appimage.sh

In particular, I took your environment hacking code, but changed a couple of details:

  • the initial environment is saved with an explicit redirection of env | tr '\n' '\0' into a temporary file, which is then read back by read_env_from_process() (see here)
  • the APPDIR environment variable is replaced by a colon-separated list of paths in APPDIRS

The custom functions.sh and bundle-gtk2.sh scripts provide a set of standard functions that help automating the bundling process, while apprun-helper.sh provides some helper functions for the main AppRun script, as shown for example here.

I can explain all the details if you are interested.

aferrero2707 commented Sep 12, 2018

@TheAssassin @probonopd I have recently done some more work that attempts to generalise the bundling of GTK applications, partly also inspired by your linuxdeploy-plugin-checkrt code.

The current scripts can be found here: https://github.com/aferrero2707/appimage-helper-scripts, and an example of bundling script here: https://github.com/aferrero2707/pf-build-appimage/blob/master/package-appimage.sh

In particular, I took your environment hacking code, but changed a couple of details:

  • the initial environment is saved with an explicit redirection of env | tr '\n' '\0' into a temporary file, which is then read back by read_env_from_process() (see here)
  • the APPDIR environment variable is replaced by a colon-separated list of paths in APPDIRS

The custom functions.sh and bundle-gtk2.sh scripts provide a set of standard functions that help automating the bundling process, while apprun-helper.sh provides some helper functions for the main AppRun script, as shown for example here.

I can explain all the details if you are interested.

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Sep 12, 2018

Member

It would be great if you could convert your code into a linuxdeploy plugin to make deploying GTK software as easy as never before. It would be great if you as a sort-of-GTK-expert could maintain that. Also, we'd have a consistent user experience.
If you implemented it in C++, you could even save yourself quite some code as linuxdeploy provides a lot of it already in its core library.

Not sure what you mean with $APPDIRS.

Member

TheAssassin commented Sep 12, 2018

It would be great if you could convert your code into a linuxdeploy plugin to make deploying GTK software as easy as never before. It would be great if you as a sort-of-GTK-expert could maintain that. Also, we'd have a consistent user experience.
If you implemented it in C++, you could even save yourself quite some code as linuxdeploy provides a lot of it already in its core library.

Not sure what you mean with $APPDIRS.

@probonopd

This comment has been minimized.

Show comment
Hide comment
@probonopd

probonopd Sep 14, 2018

Would help the cause if you could closely work together on this, @aferrero2707 and @TheAssassin. From what I observed, the Gtk+ developer community does not really embrace C++ but uses C with glib. Hence it might be worthwhile to implement the Gtk+ plugin using that stack, so that it comes naturally to Gtk+ developers.

probonopd commented Sep 14, 2018

Would help the cause if you could closely work together on this, @aferrero2707 and @TheAssassin. From what I observed, the Gtk+ developer community does not really embrace C++ but uses C with glib. Hence it might be worthwhile to implement the Gtk+ plugin using that stack, so that it comes naturally to Gtk+ developers.

@aferrero2707

This comment has been minimized.

Show comment
Hide comment
@aferrero2707

aferrero2707 Sep 15, 2018

I'm maybe too pessimistic, but I don't expect much help from the GTK devs on this, so I would go for whatever language is more appropriate.

No problem to collaborate with @TheAssassin.

One technical question: does the code support hooks for custom scripts to be run during the bundling process, or should one always implement a plugin?

aferrero2707 commented Sep 15, 2018

I'm maybe too pessimistic, but I don't expect much help from the GTK devs on this, so I would go for whatever language is more appropriate.

No problem to collaborate with @TheAssassin.

One technical question: does the code support hooks for custom scripts to be run during the bundling process, or should one always implement a plugin?

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Sep 15, 2018

Member

does the code support hooks for custom scripts to be run during the bundling process, or should one always implement a plugin?

I'm not sure if I understand. In terms of linuxdeploy, the only way to add functionality is to write plugins. The plugins can do whatever they want. liblinuxdeploy_core is quite flexible, though, you can implement any workflow you can imagine.

Member

TheAssassin commented Sep 15, 2018

does the code support hooks for custom scripts to be run during the bundling process, or should one always implement a plugin?

I'm not sure if I understand. In terms of linuxdeploy, the only way to add functionality is to write plugins. The plugins can do whatever they want. liblinuxdeploy_core is quite flexible, though, you can implement any workflow you can imagine.

@aferrero2707

This comment has been minimized.

Show comment
Hide comment
@aferrero2707

aferrero2707 Sep 15, 2018

@TheAssassin
Let me give you a practical example. In the GIMP case, on top of the "standard" GTK libraries/configuration files I need to bundle some folders that are specific to GIMP.
Moreover, since GIMP is compiled from sources they are in a different prefix.

Here is an example: https://github.com/aferrero2707/gimp-appimage/blob/master/package-appimage.sh#L285

Such cases cannot be handled by a "generic" GTK linuxdeploy plug-in, hence the need of some "hooks" that allow to run some application-specific commands/actions on top of the generic ones.

I hope it is more clear now.

Anyway, I am planning to start coding some GTK plugin during next week, following the Qt example.

aferrero2707 commented Sep 15, 2018

@TheAssassin
Let me give you a practical example. In the GIMP case, on top of the "standard" GTK libraries/configuration files I need to bundle some folders that are specific to GIMP.
Moreover, since GIMP is compiled from sources they are in a different prefix.

Here is an example: https://github.com/aferrero2707/gimp-appimage/blob/master/package-appimage.sh#L285

Such cases cannot be handled by a "generic" GTK linuxdeploy plug-in, hence the need of some "hooks" that allow to run some application-specific commands/actions on top of the generic ones.

I hope it is more clear now.

Anyway, I am planning to start coding some GTK plugin during next week, following the Qt example.

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Sep 15, 2018

Member

@aferrero2707 at the moment it's possible to have plugins create an AppRun file, which linuxdeploy will not replace (unlike linuxdeploy, that's a feature for users who ship their own AppRun anyway). See e.g., https://github.com/TheAssassin/linuxdeploy-plugin-checkrt.

The problem is that if multiple plugins try to create an AppRun file, they either have to replace them (losing the functionality other plugins might have installed) or not place their file. We have been discussing some strategies, but didn't like any of them really. If you have a suggestion how we could implement some "install your own startup hooks" feature thingy, please post them.
The best I could come up is to add a directory in the AppDir (e.g., AppDir/startup/myhook.sh), and if that directory is found, instead of a symlink, a shell script (bourne shell syntax for maximum compatibility) is put into the AppDir as AppRun. That script sources all files in that directory, and then parses the root desktop file and executes the application in there.

Edit: if we come up with a solution, we should include it into the plugin specification.

Member

TheAssassin commented Sep 15, 2018

@aferrero2707 at the moment it's possible to have plugins create an AppRun file, which linuxdeploy will not replace (unlike linuxdeploy, that's a feature for users who ship their own AppRun anyway). See e.g., https://github.com/TheAssassin/linuxdeploy-plugin-checkrt.

The problem is that if multiple plugins try to create an AppRun file, they either have to replace them (losing the functionality other plugins might have installed) or not place their file. We have been discussing some strategies, but didn't like any of them really. If you have a suggestion how we could implement some "install your own startup hooks" feature thingy, please post them.
The best I could come up is to add a directory in the AppDir (e.g., AppDir/startup/myhook.sh), and if that directory is found, instead of a symlink, a shell script (bourne shell syntax for maximum compatibility) is put into the AppDir as AppRun. That script sources all files in that directory, and then parses the root desktop file and executes the application in there.

Edit: if we come up with a solution, we should include it into the plugin specification.

@aferrero2707

This comment has been minimized.

Show comment
Hide comment
@aferrero2707

aferrero2707 Sep 17, 2018

The best I could come up is to add a directory in the AppDir

This si also what I was thinking about: a folder populated by hook scripts, that can be prioritised with a numerical prefix.

By the way, as I was trying to explain, a similar problem exists when populating the AppDir, because there can be some application-specific things that need to be bundled and that cannot be handled by a generic infrastructure. For example, GIMP has its own configuration files that need to be copied into the AppDir.

My idea would be to solve this problem in the same way, i.e. a folder where to put hook scripts prior to running linuxdeploy.

I will try to come up with a working example during the next days.

aferrero2707 commented Sep 17, 2018

The best I could come up is to add a directory in the AppDir

This si also what I was thinking about: a folder populated by hook scripts, that can be prioritised with a numerical prefix.

By the way, as I was trying to explain, a similar problem exists when populating the AppDir, because there can be some application-specific things that need to be bundled and that cannot be handled by a generic infrastructure. For example, GIMP has its own configuration files that need to be copied into the AppDir.

My idea would be to solve this problem in the same way, i.e. a folder where to put hook scripts prior to running linuxdeploy.

I will try to come up with a working example during the next days.

@TheAssassin

This comment has been minimized.

Show comment
Hide comment
@TheAssassin

TheAssassin Sep 17, 2018

Member

that can be prioritised with a numerical prefix.

I think we should standardize that hooks must not expect to be run in a specific order. If we combine that with a rule that scripts must allow for multiple execution, scripts could check for other scripts, and run them before they make their own changes. Then, you can have a guaranteed, script-specified order of execution.

Member

TheAssassin commented Sep 17, 2018

that can be prioritised with a numerical prefix.

I think we should standardize that hooks must not expect to be run in a specific order. If we combine that with a rule that scripts must allow for multiple execution, scripts could check for other scripts, and run them before they make their own changes. Then, you can have a guaranteed, script-specified order of execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment