• Stars
    star
    377
  • Rank 113,535 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create a Debian package for your Electron app.

Electron Installer for Debian

electron-installer-debian Version Build Status

Create a Debian package for your Electron app.


Usage | Options | Release Notes | License | Code of Conduct | Support

Requirements

This tool requires Node 10 or greater, fakeroot, and dpkg to build the .deb package.

I'd recommend building your packages on your target platform, but if you insist on using Mac OS X, you can install these tools through Homebrew:

$ brew install fakeroot dpkg

Installation

For use from command-line:

$ npm install -g electron-installer-debian

For use in npm scripts or programmatically:

$ npm install --save-dev electron-installer-debian

Usage

Say your Electron app lives in path/to/app, and has a structure like this:

.
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ node_modules
โ”‚ย ย  โ”œโ”€โ”€ electron-packager
โ”‚ย ย  โ””โ”€โ”€ electron
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ resources
โ”‚ย ย  โ”œโ”€โ”€ Icon.png
โ”‚ย ย  โ”œโ”€โ”€ IconTemplate.png
โ”‚ย ย  โ””โ”€โ”€ [email protected]
โ””โ”€โ”€ src
    โ”œโ”€โ”€ index.js
    โ”œโ”€โ”€ main
    โ”‚ย ย  โ””โ”€โ”€ index.js
    โ””โ”€โ”€ renderer
        โ”œโ”€โ”€ index.html
        โ””โ”€โ”€ index.js

You now run electron-packager to build the app for Debian:

$ electron-packager . app --platform linux --arch x64 --out dist/

And you end up with something like this in your dist folder:

.
โ””โ”€โ”€ dist
 ย ย  โ””โ”€โ”€ app-linux-x64
 ย ย      โ”œโ”€โ”€ LICENSE
 ย ย      โ”œโ”€โ”€ LICENSES.chromium.html
 ย ย      โ”œโ”€โ”€ content_shell.pak
 ย ย      โ”œโ”€โ”€ app
 ย ย      โ”œโ”€โ”€ icudtl.dat
 ย ย      โ”œโ”€โ”€ libgcrypt.so.11
 ย ย      โ”œโ”€โ”€ libnode.so
 ย ย      โ”œโ”€โ”€ locales
 ย ย      โ”œโ”€โ”€ natives_blob.bin
 ย ย      โ”œโ”€โ”€ resources
 ย ย      โ”œโ”€โ”€ snapshot_blob.bin
 ย ย      โ””โ”€โ”€ version

How do you turn that into a Debian package that your users can install?

Command-Line

If you want to run electron-installer-debian straight from the command-line, install the package globally:

$ npm install -g electron-installer-debian

And point it to your built app:

$ electron-installer-debian --src dist/app-linux-x64/ --dest dist/installers/ --arch amd64

You'll end up with the package at dist/installers/app_0.0.1_amd64.deb.

Scripts

If you want to run electron-installer-debian through npm, install the package locally:

$ npm install --save-dev electron-installer-debian

Edit the scripts section of your package.json:

{
  "name": "app",
  "description": "An awesome app!",
  "version": "0.0.1",
  "scripts": {
    "start": "electron .",
    "build": "electron-packager . app --platform linux --arch x64 --out dist/",
    "deb64": "electron-installer-debian --src dist/app-linux-x64/ --dest dist/installers/ --arch amd64"
  },
  "devDependencies": {
    "electron-installer-debian": "^0.6.0",
    "electron-packager": "^9.0.0",
    "electron": "~1.7.0"
  }
}

Note: The versions in devDependencies are examples only, please use the latest package versions when possible.

And run the script:

$ npm run deb64

You'll end up with the package at dist/installers/app_0.0.1_amd64.deb.

Programmatically

Install the package locally:

$ npm install --save-dev electron-installer-debian

And write something like this:

const installer = require('electron-installer-debian')

const options = {
  src: 'dist/app-linux-x64/',
  dest: 'dist/installers/',
  arch: 'amd64'
}

async function main (options) {
  console.log('Creating package (this may take a while)')
  try {
    await installer(options)
    console.log(`Successfully created package at ${options.dest}`)
  } catch (err) {
    console.error(err, err.stack)
    process.exit(1)
  }
}
main(options)

You'll end up with the package at dist/installers/app_0.0.1_amd64.deb.

Note: As of 1.0.0, the Node-style callback pattern is no longer available. You can use util.callbackify if this is required for your use case.

Options

Even though you can pass most of these options through the command-line interface, it may be easier to create a configuration file:

{
  "dest": "dist/installers/",
  "icon": "resources/Icon.png",
  "categories": [
    "Utility"
  ],
  "lintianOverrides": [
    "changelog-file-missing-in-native-package"
  ]
}

And pass that instead with the config option:

$ electron-installer-debian --src dist/app-linux-x64/ --arch amd64 --config config.json

Anyways, here's the full list of options:

src

Type: String Default: undefined

Path to the folder that contains your built Electron application.

dest

Type: String Default: undefined

Path to the folder that will contain your Debian installer.

rename

Type: Function Default: function (dest, src) { return path.join(dest, src); }

Function that renames all files generated by the task just before putting them in your dest folder.

options.name

Type: String Default: package.name || "electron"

Name of the package (e.g. atom), used in the Package field of the control specification.

According to the Debian Policy Manual:

Package names [...] must consist only of lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.). They must be at least two characters long and must start with an alphanumeric character.

electron-installer-debian will try to help conform to these requirements by lowercasing the name provided and replacing any invalid characters with -s.

options.productName

Type: String Default: package.productName || package.name

Name of the application (e.g. Atom), used in the Name field of the desktop specification.

options.genericName

Type: String Default: package.genericName || package.productName || package.name

Generic name of the application (e.g. Text Editor), used in the GenericName field of the desktop specification.

options.description

Type: String Default: package.description

Short description of the application, used in the Description field of the control specification.

options.productDescription

Type: String Default: package.productDescription || package.description

Long description of the application, used in the Description field of the control specification.

options.version

Type: String Default: package.version || "0.0.0"

Version number of the package, used in the Version field of the control specification.

options.revision

Type: String Default: undefined

Revision number of the package, used in the Version field of the control specification and, by default, the filename of the generated .deb file.

options.section

Type: String Default: "utils"

Application area into which the package has been classified, used in the Section field of the control specification.

You can read more about sections, and also check out the list of existing sections in Debian unstable.

options.priority

Type: String Default: "optional"

How important it is that the user have the package installed., used in the Priority field of the control specification.

You can read more about priorities.

options.arch

Type: String Default: undefined

Machine architecture the package is targeted to, used in the Architecture field of the control specification.

For possible values see the output of dpkg-architecture -L.

options.size

Type: Integer Default: size of the folder

Estimate of the total amount of disk space required to install the named package, used in the Installed-Size field of the control specification.

options.depends, recommends, suggests, enhances, preDepends

Type: Array[String] Default: For depends, the minimum set of packages necessary for Electron to run; See source code for recommends, suggests, enhances, and preDepends default values

Relationships to other packages, used in the Depends, Recommends, Suggests, Enhances and Pre-Depends fields of the control specification.

All user dependencies will be appended to the Default array of dependencies and any duplicates will be removed.

options.maintainer

Type: String Default: package.author.name <package.author.email>

Maintainer of the package, used in the Maintainer field of the control specification.

options.homepage

Type: String Default: package.homepage || package.author.url

URL of the homepage for the package, used in the Homepage field of the control specification.

options.bin

Type: String Default: package.name || "electron"

Relative path to the executable that will act as binary for the application, used in the Exec field of the desktop specification.

The generated package will contain a symlink /usr/bin/<%= options.name %> pointing to the path provided here.

For example, providing this configuration:

{
  src: '...',
  dest: '...',
  name: 'foo',
  bin: 'resources/cli/launcher.sh'
}

Will create a package with the following symlink:

usr/bin/foo@ -> ../lib/foo/resources/cli/launcher.sh

And a desktop specification with the following Exec key:

Exec=foo %U

options.icon

Type: String or Object[String:String] Default: resources/icon.png

Path to a single image that will act as icon for the application:

{
  icon: 'resources/Icon.png'
}

Or multiple images with their corresponding resolutions:

{
  icon: {
    '48x48': 'resources/Icon48.png',
    '64x64': 'resources/Icon64.png',
    '128x128': 'resources/Icon128.png',
    '256x256': 'resources/Icon256.png',
    'scalable': 'resources/Icon.svg'
  }
}

Note that the image files must be one of the types: PNG or SVG. The support for SVG works only on scalable resolution.

options.categories

Type: Array[String] Default: ['GNOME', 'GTK', 'Utility']

Categories in which the application should be shown in a menu, used in the Categories field of the desktop specification.

For possible values check out the Desktop Menu Specification.

options.mimeType

Type: Array[String] Default: []

MIME types the application is able to open, used in the MimeType field of the desktop specification.

options.lintianOverrides

Type: Array[String] Default: []

You can use these to quieten lintian.

options.scripts

Type: Object[String:String] Default: undefined

Path to package maintainer scripts with their corresponding name, used in the installation procedure:

{
  scripts: {
    'preinst': 'resources/preinst_script',
    'postinst': 'resources/postinst_script',
    'prerm': 'resources/prerm_script',
    'postrm': 'resources/postrm_script'
  }
}

You can read more about package maintainer scripts and general scripts

options.desktopTemplate

Type: String Default: resources/desktop.ejs

The absolute path to a custom template for the generated FreeDesktop.org desktop entry file.

Installed Package

The package installs the Electron application into /usr/lib, since there are architecture-specific files in the package. There was a discussion in the issue tracker about the installation directory.

In versions of electron-installer-debian prior to 0.5.0, the app was (incorrectly) installed in /usr/share.

Meta

Contributors

License

Copyright (c) 2016 Daniel Perez Alvarez (unindented.org). This is free software, and may be redistributed under the terms specified in the LICENSE file.

More Repositories

1

electron-builder

A complete solution to package and build a ready for distribution Electron app with โ€œauto updateโ€ support out of the box
TypeScript
13,564
star
2

devtron

[LOOKING FOR MAINTAINERS] An Electron DevTools Extension
JavaScript
1,728
star
3

spectron

DEPRECATED: ๐Ÿ”Ž Test Electron apps using ChromeDriver
JavaScript
1,677
star
4

electron-json-storage

๐Ÿ“ฆ Easily write and read user settings in Electron apps
JavaScript
1,433
star
5

electron-compile

DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
JavaScript
1,008
star
6

electron-webpack

Scripts and configurations to compile Electron applications using webpack
TypeScript
903
star
7

electron-prebuilt

๐ŸŽ‚ Retired project. See README
JavaScript
760
star
8

electron-webpack-quick-start

A bare minimum project structure to get started developing with electron-webpack.
JavaScript
729
star
9

electron-windows-store

๐Ÿ“ฆ Turn Electron Apps into Windows AppX Packages
JavaScript
678
star
10

electron-installer-windows

Create a Windows package for your Electron app.
JavaScript
470
star
11

electron-remote

DEPRECATED: Execute JavaScript in remote Electron processes, but more betterer
JavaScript
430
star
12

electron-wix-msi

๐Ÿ“€ Create traditional MSI installers for your Electron app
TypeScript
319
star
13

electron-installer-dmg

Create DMG installers for your electron apps using appdmg.
JavaScript
298
star
14

electron-spellchecker

Implement spellchecking, correctly
JavaScript
237
star
15

electron-builder-binaries

NSIS
172
star
16

electron-prebuilt-compile

electron-prebuilt with Babel and React built-in
JavaScript
169
star
17

electron-build-service

Package Electron applications in a distributable format on any platform for any platform
Go
138
star
18

electron-forge-templates

Templates bundled with Electron Forge <= 5 to create Electron apps using popular JavaScript frameworks
JavaScript
104
star
19

electron-installer-redhat

Create a Red Hat / RPM package for your Electron app.
JavaScript
81
star
20

electron-installer-snap

Build Snap packages for Electron applications
JavaScript
49
star
21

electrify

Step-by-step wizard to prepare Electron app for distribution, from packaging to auto-update.
TypeScript
48
star
22

electron-installer-zip

Create a ZIP file with support for symlinks required by Electron on macOS
JavaScript
46
star
23

welcome

Organization mission statement and contribution guidelines
45
star
24

electron-compilers

DEPRECATED: Compiler implementations for electron-compile
JavaScript
35
star
25

electron-installer-common

Common functionality for creating Node modules which create distributable Electron apps
JavaScript
9
star
26

electron-forge-container

Docker container for building Electron apps via Electron Forge
Dockerfile
7
star
27

create-electron-app

JavaScript
5
star
28

electron-forge-plugin-compile

Electron Compile plugin for Electron Forge
JavaScript
3
star
29

vue-cli-plugin-electron-forge

@vue/cli plugin to add Electron Forge
3
star