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

Overriding the shell script? #7

Open
obra opened this issue Mar 14, 2023 · 4 comments
Open

Overriding the shell script? #7

obra opened this issue Mar 14, 2023 · 4 comments
Assignees
Labels
📦️ package:maker-appimage Associated to @reforged/maker-appimage 🏷️ type:feat New feature or request

Comments

@obra
Copy link

obra commented Mar 14, 2023

Hi!

Thank you so much for building this AppImage maker.

I'm in the process of porting a project from electron-webpack to forge and AppImages were definitely one of the trickier "missing bits"

One thing I can't figure out how to do is to inject a custom shell script in as the launcher for the electron app. Is that something there's a way to do?

When we used electron-builder, they had a hook in between building the content of the AppImage and the final packaging we could hook into.

Thanks!

@SpacingBat3 SpacingBat3 added the 🏷️ type:feat New feature or request label Mar 14, 2023
@SpacingBat3 SpacingBat3 added the 📦️ package:maker-appimage Associated to @reforged/maker-appimage label Mar 28, 2023
@SpacingBat3 SpacingBat3 self-assigned this Mar 29, 2023
SpacingBat3 added a commit that referenced this issue Mar 30, 2023
• Handle `mksquashfs` exit codes (might affect #7).
• Improve readability of some errors.
@SpacingBat3
Copy link
Owner

Hi, sorry for the late response, I've been actually considering if I really want to allow for replacing the whole script rather than allow for injection into the existing one – the thing is, I want the script to be kept minimal but generic enough to guarantee similar results when executing any of the AppImages produced by my maker – after all, all of them are Electron apps. This means:

  • I want to use POSIX-compatible syntax for shell scripts (hence #!/bin/sh), giving the choice to people who use different shells who can work as POSIX shell, so whenever users use e.g. DASH, ZSH or BASH, they can use it to run my script (either when running in POSIX compatibility mode like in case of ZSH or normally if shell is already POSIX-compilant), therefore avoiding the dependence on one specific shell. I would prefer for developers depending on my maker not to switch to another shell, an assumption that everyone uses BASH on Linux isn't always the best.
  • The implementation for finding Electron binary and executing it is generic enough to work for many applications, so in most cases if some application finds a better implementation it would be better to improve it at upstream so other apps can benefit from it.

I saw your fork and since I saw you mostly need this for initializing Electron with custom flags based on OS, like using Wayland Native. I think simply injecting the script would be enough for that task (you could use set -- <args> "$@" to set custom command-line flags).

Also I plan to mimic a bit the way how original Electron Forge makers work (at least oddities people might be used to or way you configure my maker) and I'm kinda curious how e.g. Debian maker resolve this? Does bin field works different from mine?

@SpacingBat3
Copy link
Owner

Also, injecting would probably simplify coexistence with recently introduced flagsFile option that is going to be usable in future release.

@obra
Copy link
Author

obra commented May 4, 2023 via email

@SpacingBat3
Copy link
Owner

When we used electron-builder, they had a hook in between building the content of the AppImage and the final packaging we could hook into.

@obra Electron Forge has hooks as well, forgot to mention that. And if you plan to use official makers (and probably most community-based ones) and make your configuration more global than specific to given maker, you probably should be using that instead. In your case (similar to what you've described), there's a postPackage hook you can use yourself – it happens after Electron Forge packs your app into ASAR (if configured to do so) and bundles it with Electron binary, but before you build anything (like Electron Forge maker).

I've been personally using hooks myself to implement features Forge didn't supported before or to mitigate bugs with some Forge's maker design, like producing Squirrel installers with the same name, making it unable to host on GitHub with the publisher when supporting multi-arch builds.

But as this maker is using the script by itself, I'll still plan to implement this feature, yet it might take a while as I'll be also ditching the shell script use if not really needed (I'll use symlinks instead, like Forge did). Here's a table that might illustrate the conditions maker will have to handle (includeFile is a non-definitife name for future property name):

flagsFile === false flagsFile === true
includeFile === false Use symlink Use shell script + .conf support.
includeFile === true Use shell script + user overrides Use shell script + .conf support + user overrides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦️ package:maker-appimage Associated to @reforged/maker-appimage 🏷️ type:feat New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants