Sugarizer in Endless

Hi, I packaged a new application for Endless: Sugarizer.

Sugarizer (http://sugarizer.org/) is a learning platform aimed for children. It comes with many activities included.

Sugarizer has been packaged for other platforms, but there was no easy way to run it in GNU Linux. This package would solve this for any Linux64 as it is a flatpak. I made it using Endless electron-installer-flatpak .

I’m not uploading the package itself yet because its 229M size, but there are instructions on how to build it in the repository:
https://github.com/manuq/sugarizer-electron

If you see buttons without labels in the initial screen, this is a bug in Sugarizer itself. The screen is supposed to ask the user for a profile name and color.

I hope someone finds this useful.

5 Likes

Thanks so much Manuel, this is excellent. We have successfully reproduced the build according to your instructions. If there is a bug with the name/colour screens, I couldn’t spot it.

I’ll look at it getting this added to the Endless app center next week!

3 Likes

Wow, seeing Sugarizer in the Endless app center will be great news for Sugarlabs. I’m glad you find my contribution useful.

1 Like

Hi @manuq, sorry for the slow progress here.

Rather than figuring out the right way to get this on the Endless infrastructure I have been looking into having it built on flathub.org, which seems like the appropriate place for apps like this.

The first step here will be to move io.atom.electron.BaseApp to being a project built on flathub, since flathub also seems like the appropriate place and they probably wouldn’t want to retrieve the baseapp from Endless hosting. At the same time we should migrate it to freedesktop SDK v1.6. Should be easy.

The harder part is Sugarizer. I have adapted your work here, into a form where you feed a json file into flatpak-builder and it installs into /app, this is what flathub requires: https://github.com/dsd/org.sugarizer.Sugarizer

However flathub also requires that the build process doesn’t use network access. Right now it runs “npm install” and downloads a whole bunch of stuff. I am planning to look into the new features of npm 5 which might help here (https://github.com/npm/npm/releases/tag/v5.0.0) or yarn (https://yarnpkg.com/blog/2016/11/24/offline-mirror/). I guess ultimately we will need to find an easy way to capture everything that “npm install” wants to download and convert that into entries in the flatpak-builder json file. If that process can be scripted or automated in part, it will help for future updates.

If you are interested in looking into this your help would be gratefully received!

1 Like

@Daniel yes indeed flathub.org is the way to go. I’ve built another application in it (MyPaint).
You have already split the problem in smaller tasks, I’ll give them a try too, as this will be benefitial for other electron web applications in flathub.org.

1 Like

Does this imply we could get the Atom editor added to the app center as well? If so that would be great. If there is a dependency on io.atom.electron.BaseApp we should get Atom for free.

Then again, I don’t know if Electron/Atom have been ported to ARM yet, so the Mini would be left out.

1 Like

@MichaelChampigny

1 Like

Yep, as Leandro points out, we already have Atom (and some other Electron-based apps like Slack) in our app center.

1 Like

Why did I not see this when I looked? Is it also available for the ARM-based Mini? I did notice Slack but not Atom.

1 Like

3 posts were split to a new topic: Running Atom editor on ARM

I suspect we don’t have the infrastructure set up to build this kind of app on ARM, and the best approach going forward would be to move it to flathub. We’re working on it but any help with the prerequisites described above would be appreciated.

1 Like

Hi @Daniel,
I haven’t made any good progress yet but I thought about sharing my failed attempts so far.

I tried to make npm install to work offline. I took the npm5 path.

I wrote a script that creates a npm cache and bundles it in a tarball.
The cache is then re-created in the sandbox and used by calling npm install --offline.

https://github.com/manuq/org.sugarizer.Sugarizer/commit/1136ce0353f95c3a35c8331541c5313238b14b80

This trick works for simple dependencies, but unfortunately not for Electron.
This is because Electron postinstall script does use the network.
I tested being offline by running flatpak-builder --disable-download --disable-cache --build-only

I could try bundling the entire node_modules directory, but seems too much… I think my next step is trying the yarn path.

UPDATE

Adding more files to the previous commit I was able to build the Electron app offline. But the solution is platform specific.

  1. I passed node_modules/ directory with a tarball, like I did with the npm cache directory.

  2. The electron-packager command (called from npm run pack) also attempts to use the network
    to download a OS and architecture specific ZIP file (in my case electron-v1.6.10-linux-x64.zip).

This was sorted by downloading the ZIP and checksum and passing it to the electron-packager cache directory.
But again this is platform specific, flathub will fail for other platforms.
I guess all the files of an electron release have to be downloaded.

https://github.com/manuq/org.sugarizer.Sugarizer/commit/d36b6f31b34051d9608718530708d56ed13f85fb

1 Like

So I’m trying Yarn to install Node modules in offline mode.

I have a script that creates the Yarn “Offline mirror” as described in the blog post @Daniel referenced. And then adds one entry for each Node package dependency to the Flatpak manifest.

Again the showstopper is Electron. Yarn tries to use the network at installing Electron even when --offline is passed. And like the npm5 issue, I guess is the Electron postscript doing it. I created an issue for Yarn: https://github.com/yarnpkg/yarn/issues/3590

At least this script could be useful for some other Node based flatpaks that don’t use Electron.

My ongoing work is in this branch:
https://github.com/manuq/org.sugarizer.Sugarizer/tree/yarn

1 Like

Thanks for the update. Do you think there is some way we could patch electron so that it doesn’t need connectivity at that point?

Yes that’s my next step, try to patch electron.

So finally the Yarn issue above was sorted out and after more testing I managed to build Sugarizer fully offline. I wrote a blog post to wrap-up what was discussed until here:

http://blog.manuq.com.ar/posts/building-electron-apps-offline-for-flathub/

Next I will work on the tasks related to io.atom.electron.BaseApp and hopefully after that we’ll be able to start adding Electron apps in Flathub.org

3 Likes

Sweet! This is really cool. I’ve noticed from looking at the review comments when adding new apps to Flathub that the maintainers there prefer you to use the ‘simple’ buildsystem rather than makefiles as this keeps all the logic in the manifest. Simple just runs the commands in your build-commands one after another - here’s the barebones documentation and an example of the simple buildsystem in use.

Oh and if you’ve got more questions, feel free to hit up the #flatpak IRC channel - there’s lots of really helpful people. You can also get there pretty easily using a client like Riot.

Thanks @Nick_Richards, yes I use to be at #flatpak as manuq in my mornings. Thanks for reminding me the simple build, I already used it in the MyPaint manifest. Once I have a io.atom.electron.BaseApp working locally I will propose it for Flathub.

Sweet, feel free to send a PR to our github repo as well. We’d be happy to review and help integrate and test.

1 Like