Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Initial Linux installer #1677

Merged
merged 1 commit into from
May 27, 2016
Merged

Initial Linux installer #1677

merged 1 commit into from
May 27, 2016

Conversation

adomenech73
Copy link
Contributor

@adomenech73 adomenech73 commented May 15, 2016

Kitematic Linux installer

Description

This pull request adds native packaging for Debian/Ubuntu and CentOS/Fedora/RedHat Linux distributions for both ia32 and amd64 architectures.

The packaging is automatically triggered with the grunt release task call and makes use of additional node modules like, electron-packager to package the electron app for different archs, or electron-installer-debian and electron-installer-redhat to generate packages on this distributions.

To detect the different distributions during the release trigger, it checks for existence of /etc/lsb-release and /etc/debian_version for Debian derived distributions and /etc/redhat-release for RedHat derived distributions.

Build requirements

General requirements

  • Docker:
# download and exec installation script
wget -qO- https://get.docker.com/ | sh
# add unprivileged user to docker group
sudo usermod -aG docker $(whoami)
# service enable
sudo systemctl enable docker.service
# service start
sudo systemctl start docker.service
  • JavaScript environment
# download and install nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
# electron-packager requisite, but worked with lower
nvm install 5.5
# install global grunt
npm install -g grunt jshint cover
# install local package.json dependencies
cd /path/to/kitematic
npm install

Distribution especific requierements

  • Debian/Ubuntu based
# distribution package requirements
sudo apt-get install curl git dpkg fakeroot
  • Centos/Fedora/Redhat based
# distribution package requirements
sudo yum install git rpm-build lsb-redhat

Package build

grunt release

Debug package building

You can always debug gruntfile execution by defining a DEBUG environment variable prior to use grunt. For full debugging information you can define as follows

export DEBUG=*

Package installation

  • Debian/Ubuntu
# Install package
sudo dpkg -i dist/Kitematic_0.10.2-1_amd64.deb
# uninstall package
sudo apt-get remove --purge Kitematic 
  • CentOS/Fedora/Redhat
# install package
sudo rpm -i dist/Kitematic_0.10.2-1_x86_64.rpm
# uninstall package
sudo rpm -e Kitematic

Execution notes

  • Centos/Fedora/Redhat: You need to start Kitematic with sudo because restrictions on that distribution, you can also modify sudoers file to use automaticaly use sudo without password.

Checking generated package

All packages where created with "grunt release" task launch on diferent systems, installed with the common distribution package management tools.

  • Ubuntu x64
$ uname -a
Linux M11xR3 4.4.0-22-generic #40-Ubuntu SMP Thu May 12 22:03:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


$ file dist/Kitematic-linux-x64/Kitematic 
dist/Kitematic-linux-x64/Kitematic: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=1deed185c781c71d4130295e57c3f2f181610626, stripped

$ dpkg -I dist/Kitematic_0.10.2-1_amd64.deb 
 paquete debian nuevo, versión 2.0.
 tamaño 31404242 bytes: archivo de control= 493 bytes.
     554 bytes,    13 líneas     control              
 Package: Kitematic
 Version: 0.10.2-1
 Section: devel
 Priority: optional
 Architecture: amd64
 Depends: git, gconf2, gconf-service, gvfs-bin, libc6, libcap2, libgtk2.0-0, libudev0 | libudev1, libgcrypt11 | libgcrypt20, libnotify4, libnss3, libxtst6, python, xdg-utils
 Recommends: lsb-release
 Suggests: gir1.2-gnomekeyring-1.0, libgnome-keyring0
 Installed-Size: 116594
 Maintainer: Kitematic
 Homepage: https://kitematic.com/
 Description: Simple Docker Container management for Mac OS X.
  Run containers through a simple, yet powerful graphical user interface.
  • Debian ia32
$ uname -a
Linux debian 3.16.0-4-586 #1 Debian 3.16.7-ckt25-2 (2016-04-08) i686 GNU/Linux

$ file dist/Kitematic-linux-ia32/Kitematic 
dist/Kitematic-linux-ia32/Kitematic: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.26, BuildID[sha1]=e1d82d44f0ddcfb4a577196b69c1b5d893d3bacc, stripped

 $ dpkg -I dist/Kitematic_0.10.2-1_i386.deb 
 paquete debian nuevo, versión 2.0.
 tamaño 31072956 bytes: archivo de control= 547 bytes.
     553 bytes,    13 líneas     control              
 Package: Kitematic
 Version: 0.10.2-1
 Section: devel
 Priority: optional
 Architecture: i386
 Depends: git, gconf2, gconf-service, gvfs-bin, libc6, libcap2, libgtk2.0-0, libudev0 | libudev1, libgcrypt11 | libgcrypt20, libnotify4, libnss3, libxtst6, python, xdg-utils
 Recommends: lsb-release
 Suggests: gir1.2-gnomekeyring-1.0, libgnome-keyring0
 Installed-Size: 114433
 Maintainer: Kitematic
 Homepage: https://kitematic.com/
 Description: Simple Docker Container management for Mac OS X.
  Run containers through a simple, yet powerful graphical user interface.
  • Centos x64
$ uname -a
Linux centos7.localdomain 3.10.0-327.13.1.el7.x86_64 #1 SMP Thu Mar 31 16:04:38 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ file dist/Kitematic-linux-x64/Kitematic 
dist/Kitematic-linux-x64/Kitematic: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=1deed185c781c71d4130295e57c3f2f181610626, stripped


$ rpm -qpi dist/Kitematic_0.10.2-1_x86_64.rpm
Name        : Kitematic
Version     : 0.10.2
Release     : 1.el7.centos
Architecture: x86_64
Install Date: (not installed)
Group       : Unspecified
Size        : 111975982
License     : Apache-2.0
Signature   : (none)
Source RPM  : Kitematic-0.10.2-1.el7.centos.src.rpm
Build Date  : Sat 21 May 2016 01:18:54 PM CEST
Build Host  : localhost
Relocations : (not relocatable)
URL         : https://kitematic.com/
Summary     : Simple Docker Container management for Mac OS X.
Description :
Run containers through a simple, yet powerful graphical user interface.

@adomenech73 adomenech73 mentioned this pull request May 15, 2016
@fradelg
Copy link

fradelg commented May 16, 2016

Awesome!

It works perfectly, but could you address this warning?

grunt-electron-debian-installer@0.1.2: This package has been renamed to grunt-electron-installer-debian@0.3.0

Moreover, the Kitematic icon is replaced by the electron icon in the desktop but I guess this is an issue with the .icon file

@adomenech73
Copy link
Contributor Author

Unfortunately the icon issue seems to be a problem on how electron-packager manages the icon file as @fradelg well pointed. I tried to add another image path but with same results

@FrenchBen
Copy link
Contributor

Regarding the ICON, we had similar issues when packaging the Windows installer.
You can try to link to the raw image withing github:
https://raw.githubusercontent.com/kitematic/kitematic/master/util/kitematic.ico

@nshiell
Copy link

nshiell commented May 16, 2016

Does this require a seperate install of nodejs, and does it need to be v4.2.2?

@adomenech73
Copy link
Contributor Author

adomenech73 commented May 17, 2016

@FrenchBen I'am not sure is the same issue as in windows I've tried diferent files and formats and allways the same result.
I found this in electron-packager readme that suggest different problem, but I've to check a bit more

"`icon` - *String*
  ···
 Linux: this option is not required, as the dock/window list icon is set via [the icon option in the BrowserWindow contructor](http://electron.atom.io/docs/v0.30.0/api/browser-window/#new-browserwindow-options). Setting the icon in the file manager is not currently supported."

Also the official electron documentation says:

"Currently png and jpeg images formats are supported. Png is recommended because of its support for transparency and lossless compression.
On Windows, you can also load an ico icon from file path"

Based on that, I've tried to export the ico file to png and use that last one on the build process. Unfortunately with same result electron icon is always showed

@adomenech73
Copy link
Contributor Author

I'm sorry @nshiell I don't understand very well your question. I've used the same node installation I've always had in my laptop. In this moment v6.1.0 but I understand other versions will work as well.
If you are refering to about shell:linux_npm that's necesary to load the node libraries Kitematic uses.

@adomenech73
Copy link
Contributor Author

adomenech73 commented May 17, 2016

@FrenchBen Got it!! after debugging a bit. The problem was that the icon must be defined on electron-installer-debian task. Anyway, I still had to export the ico file to png because according with the electron documentation this is the linux recommended format.

@FrenchBen
Copy link
Contributor

@adomenech73 Do you mind doing 2 things?

  1. Squash your commits into a concise list. Having 2-3 commits that explain the progression of the code changes is good. Having commits that change a package version or small tweaks, isn't
  2. Sign your commit according to https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work

Thanks 👍

@adomenech73
Copy link
Contributor Author

@FrenchBen I squashed everything in a single commit and used "git commit -s" to sign, I hope everything is fine now.

@adomenech73
Copy link
Contributor Author

@nshiell My test on ia32 arch I did on Debian 8 with node v4.2.2 and despite some deprecation warnings generated and installable and functional package, hope it helps!!

@adomenech73
Copy link
Contributor Author

@FrenchBen I think we can use electron-installer-redhat similar as what I did, this time to generate centos/redhat rpm

@adomenech73 adomenech73 changed the title Initial debian/ubuntu installer Initial Linux installer May 21, 2016
@adomenech73
Copy link
Contributor Author

adomenech73 commented May 21, 2016

@FrenchBen Squashed again to guarantee pull request is signed (sorry for that!, tried my best as newie)
Just added RPM support, couldn't try for ia32 arch yet, but I think should work fine
And renewed pull request comment to be more operational and helpful for testing

@FrenchBen
Copy link
Contributor

Setting up a new debian box to qa this pr and will then merge. Thanks again for the help! 🎉

@adomenech73
Copy link
Contributor Author

Avec plaisir!!

@FrenchBen
Copy link
Contributor

Doing some QA on this, I missed a few things and added some in-line notes.

The Windows built was separated so that Kitematic could be build in Windows, without having to build the Mac release.
It looks like your PR is making a similar exception, but doesn't full-fill the other side of it which is the Mac build should build all: OSX+Win+Linux.

This line:
https://github.com/adomenech73/kitematic/blob/2ccf907ab0656284761a0ecd4a854ed7c3784f62/Gruntfile.js#L354

Shows the complete build of OSX + Windows.

We can be opinionated in choosing 64bit instead of 32.

},
'electron-packager': {
build: {
options:{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space here

@adomenech73
Copy link
Contributor Author

adomenech73 commented May 25, 2016

I didn't realise about that. Actually the quickest way to do what you say is to add electro-packager in macosx custom task. I'm not close to my laptop at this moment but when I arrive home I can push it for you.

On the other hand I don't understand very well how you can build for windows and Linux from mac, are you using docker for that?

@FrenchBen
Copy link
Contributor

The windows build only requires mono - brew install mono works :)

@adomenech73
Copy link
Contributor Author

adomenech73 commented May 25, 2016

This triggers Linux binary build from OSX custom task. If packaging is also needed, it would be necessary to add additional 'electron-installer-debian:linux64' or 'electron-installer-debian:linux32' task at the end. I also revised the : as you pointed on your note and the absent space from the inline note. Finally squashed and signed

Hope this helps, I'm sorry I have no way to test it.

I understand mono as the way to build the win version, never tried but smart way
So, can you build for Linux from OSX also? seems awesome didn't know that, Do you use additional gnu build software for that?

@adomenech73
Copy link
Contributor Author

@FrenchBen Now I've seen your conversation with jhipster people, so I understand why multi platform packaging is needed from OSX, for release purposes I presuppose

If you can confirm me, that electron-packager works fine and generates functional Linux binary launched from OSX, the only problem I see for that is the PR line 272, but if you can bypass that in any way, there wouldn't be any problem to generate deb package with electron-installer-debian:linux64 and even rpm package with electron-installer-redhat:linux64

@FrenchBen
Copy link
Contributor

FrenchBen commented May 25, 2016

Hmm got a Kitematic (Alpha)-linux-x64 folder, but didn't see any .deb?
Last line after linux_shell:

Running "electron-packager:build" (electron-packager) task
Packaging app for platform darwin x64 using electron v0.35.4
    dist/Kitematic-darwin-x64

Done, without errors.

If I add the electron-installer-debian line to Mac OSX, I get the following error:

Running "electron-packager:build" (electron-packager) task
Packaging app for platform darwin x64 using electron v0.35.4
    dist/Kitematic-darwin-x64

Running "electron-installer-debian:linux64" (electron-installer-debian) task
Creating package (this may take a while)
>> Error creating package: Error reading package metadata: ENOENT: no such file or directory, open 'dist/Kitematic-linux-x64/resources/app/package.json'

This is because the electron-packager builds something based on the platform+arch, which is incorrect when ran on OSX.

@adomenech73
Copy link
Contributor Author

adomenech73 commented May 26, 2016

That's because despite the name of the task electron-packager it just build the binary, and after you have to package it with electron-installer-debian or electron-installer-redhat

About the OSX specific build platform arch problem, that's why I was talking about PR line 272
"platform: process.platform".

I think I can add something like

osxlnx: {
   options: {
          platform: 'linux',
          arch: 'x64'
          ...
   }
}

on electron-packager task, and call something like .... electron-packager:osxlnx from the OSX custom task. Today you have it

@adomenech73
Copy link
Contributor Author

adomenech73 commented May 26, 2016

This must do the job!

added packaging (debian 64) and better legibility for linux distribution conditional

@FrenchBen
Copy link
Contributor

Error when trying to create this:

Running "electron-installer-debian:linux64" (electron-installer-debian) task
Creating package (this may take a while)
>> Error creating package: Error executing command (spawn fakeroot ENOENT):
>> fakeroot dpkg-deb --build /var/folders/kl/4fm2zyxs3_5dd869x992dvvw0000gn/T/electron-116426-7519-otee50/Kitematic_0.10.2_amd64
Warning: Error executing command (spawn fakeroot ENOENT):
fakeroot dpkg-deb --build /var/folders/kl/4fm2zyxs3_5dd869x992dvvw0000gn/T/electron-116426-7519-otee50/Kitematic_0.10.2_amd64
 Use --force to continue.

Aborted due to warnings.

But then Brew to the rescue!
brew install dpkg fakeroot

Running "shell:linux_npm" (shell) task
>> npm
>>
>> WARN
>> package.json
>> Kitematic@0.10.2 No README data
mixpanel@0.3.1 node_modules/mixpanel

Running "electron-packager:osxlnx" (electron-packager) task
Packaging app for platform linux x64 using electron v0.35.4
    dist/Kitematic-linux-x64

Running "electron-installer-debian:linux64" (electron-installer-debian) task
Creating package (this may take a while)
>> Successfully created package at ./dist/

Done, without errors.

If you don't mind checking that this package installs properly for you that would be HUGE!!
https://goo.gl/oSQy86

So pumped about this, thank you again for all of the hard work 🎉 🎉 🎉


if (!IS_WINDOWS && !IS_LINUX) {
grunt.registerTask('release', ['clean:release', 'babel', 'less', 'copy:dev', 'electron', 'copy:osx', 'shell:sign', 'shell:zip', 'copy:windows', 'rcedit:exes', 'compress', 'shell:linux_npm', 'electron-packager:osxlnx', 'electron-installer-debian:linux64']);
}else if(IS_LINUX){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, can you fix spacing?
} else if () {

- Used grunt-packager and grunt-electron-installer-debian

- Added debian/ubuntu ai32 arch support

- Added Redhat/Centos/Fedora rpm support

- Added electron-packager to MacOSX custom task

- Fixed OSX Linux build and better conditional legibility

- Fixed ESLint indications

Signed-off-by: Albert Domenech <adomenech@gmail.com>
@adomenech73
Copy link
Contributor Author

adomenech73 commented May 27, 2016

I've installed the deb package without problem:

albert@M11xR3:~/Descargas/Code/pull_request/kitematic$ sudo dpkg -i /home/albert/Descargas/Kitematic.deb 
Seleccionando el paquete kitematic previamente no seleccionado.
(Leyendo la base de datos ... 519221 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../albert/Descargas/Kitematic.deb ...
Desempaquetando kitematic (0.10.2-1) ...
Configurando kitematic (0.10.2-1) ...
Procesando disparadores para bamfdaemon (0.5.3~bzr0+16.04.20160415-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Procesando disparadores para desktop-file-utils (0.22-1ubuntu5) ...
Procesando disparadores para gnome-menus (3.13.3-6ubuntu3) ...
Procesando disparadores para mime-support (3.59ubuntu1) ...

And Kitematic works as expected

I included dpkg and fakeroot as requisites on the PR comment, even that they can be included in debian/ubuntu just out of the box, but it will be more clear

I also used Sublime eslint plugin to check the code, it's a really helpful tool, thanks for the nice tip, I didn't realise while I was coding, and it will help me a lot with better syntax practices (have to work this kind of distractions)

@FrenchBen FrenchBen merged commit 745cfa0 into docker:master May 27, 2016
@adomenech73 adomenech73 deleted the ubuntu-installer branch May 27, 2016 22:04
@gni
Copy link

gni commented May 30, 2016

npm install --> OK
Used: npm install -g grunt-electron-debian-installer
Builded with: grunt release electron-installer-debian:linux64
cd dist; ls -a
sudo dpkg -i Kitematic_0.10.4_amd64.deb
Reboot
All ok.
Issue only with the terminal exec. Didn't find shell, but i'm using manually docker exec -it containerID /bin/bash
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants