gm-vm / openfortivpn-webview

MIT License
87 stars 19 forks source link

alpine linux package ? #22

Open caywin25 opened 8 months ago

caywin25 commented 8 months ago

Hello Is it possible to release a package for alpine linux please? Indeed the package is not present in basic Alpine Linux. Thanks

gm-vm commented 8 months ago

Hi, there are no distro specific packages and I'd rather not start making them.

The AppImage and the tar.xz should work on pretty much every distro, they are both statically linked and if there is any external dependency, it is probably something that is everywhere.

So please try them, or else I'm afraid you have to build the application yourself following the instructions.

gm-vm commented 8 months ago

I want to also add that I'm releasing binaries only for the electron app because the main advantage of the Qt app is that you can get a tiny executable by not statically linking the Qt framework.

The Qt app with statically linked libraries is probably as big as the electron app, so there is no point in it. It is also more complex to make, everything is setup to link the framework dynamically. I definitely don't want to release binaries with dynamically linked Qt libraries, I'd have to release one package per distro and keep up with system updates.

I could use Flatpak or Snap, but it's not something I want to do right now. The binaries that you can grab here should be enough if you don't want to build the application.

gm-vm commented 8 months ago

I noticed that Alpine Linux uses musl, so I'm not sure the binaries will work there, I haven't tried.

I'll keep this open in case someone wants to do the needful.

fluxion-t commented 6 months ago

Hello,

I noticed that Alpine Linux uses musl, so I'm not sure the binaries will work there, I haven't tried.

Tried and didn't work. Tried to build it from code. npm install worked well, though needed to run npm audit fix after that. But npm start resulted in this:

> openfortivpn-webview@1.2.0 start
> electron index.js

node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: spawn /path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/node_modules/electron/dist/electron ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/node_modules/electron/dist/electron',
  path: '/path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/node_modules/electron/dist/electron',
  spawnargs: [ 'index.js' ]
}

Node.js v21.4.0
gm-vm commented 6 months ago

It seems that npm is trying to start electron, but it is failing. I don't know why.

What happens if you do things manually? Go to the directory with index.js and run:

/path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/node_modules/electron/dist/electron index.js
fluxion-t commented 6 months ago
$ /path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/node_modules/electron/dist/electron index.js

bash: node_modules/electron/dist/electron: cannot execute: required file not found

There is package called electron, and if executed as $ electron, it says To run a local app, execute the following on the command line: $ /usr/lib/electron/electron path-to-app. Then, I do

/usr/lib/electron/electron /path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/index.js

but it says I need to specify [host:port], so I run (choosing a random port)

/usr/lib/electron/electron /path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/index.js localhost:2020

Then I get a blank electron window open, but also this error:

https://localhost:2020/remote/saml/start
(node:6264) electron: Failed to load URL: https://localhost:2020/remote/saml/start with error: ERR_CONNECTION_REFUSED
(Use electron --trace-warnings ... to show where the warning was created)
gm-vm commented 6 months ago

It looks like it's working then. [host:port] is a mandatory argument and the program errors out if you don't pass it. You should see all the options in the output, as if you passed --help.

You see a blank screen because you don't have a webserver (or one that can handle remote/saml/start) running on port 2020. If you want to quickly check that the browser works, provide a complete and valid URL using the --url option:

/usr/lib/electron/electron /path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/index.js --url https://example.com/
fluxion-t commented 6 months ago
/usr/lib/electron/electron /path/to/openfortivpn-webview-1.2.0-electron/openfortivpn-webview-electron/index.js --url https://example.com/

This worked!

Under Debian, just specifying the root URL (and without https://) automatically redirected to https://root-url/saml/start. However, here I had to write everything explicitly.

Many, many thanks.

fluxion-t commented 6 months ago

For completeness (though this is related to openfortivpn and not with its webview), in Alpine you need to start the ppp daemon (and add it to boot):

rc-service pppd start
rc-update add pppd

Only then you can call openfortivpn and use the cookie generated by the webview.

gm-vm commented 6 months ago

Under Debian, just specifying the root URL (and without https://) automatically redirected to https://root-url/saml/start. However, here I had to write everything explicitly.

It should be the same here. If you execute electron index.js root-url, the application builds the URL for you as https://root-url/remote/saml/start.

fluxion-t commented 6 months ago

Sorry for the delay. In my case, using only the root-urldidn't work, but I think this is because the institution I needed to access has set up a different login page than in root-url/saml/start.

Many thanks for your feedback.

gm-vm commented 1 week ago

I quickly looked at this and I don't think electron-builder, which is what I'm using to package the electron-based app, really supports Alpine. Not to mention the fact that even the electron executable downloaded by npm does not work, as shown here above.

For what is worth, building the Qt variant for alpine is way simpler, given that qt is supported officialy:

apk add qt6-qtwebengine-dev g++ make git
git clone https://github.com/gm-vm/openfortivpn-webview
cd openfortivpn-webview/openfortivpn-webview-qt
qmake6 .
make
# There is now an executable named openfortivpn-webview