endlessm/flatpak-bundler

Name: flatpak-bundler

Owner: endlessm

Description: Node module for creating flatpaks.

Created: 2016-09-21 21:02:10.0

Updated: 2018-05-16 15:45:46.0

Pushed: 2017-11-30 19:58:03.0

Homepage: null

Size: 40

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

flatpak-bundler Version Build Status

Build flatpaks from nodejs.

Quick Start

Install flatpak-bundler.

m install flatpak-bundler -g

Build a flatpak with a node script.

Install and run it!

atpak install --user --bundle hello.flatpak
atpak run org.world.Hello
o, world!
Overview

This modules allows building flatpaks programatically from node. It requires flatpak >= 0.6.13 to be installed on your system.

Under the hood, this is just a wrapper for the flatpak-builder tool with some extra sugar added.

With flatpak-builder you specify a runtime, sandbox permissions and software modules to build into you application, and build a flatpak from start to finish. This module provides a few additional features:

The latter is particularly useful for electron and nw.js style node applications, which often create packages from prebuilt binaries and do not attempt to follow an autotools-like build api.

This module should make it easy to plug flatpak support into a electron or nw.js app packaging phase.

Usage
bundle(manifest, buildOptions, callback)

flatpak-bundler provides a single method, bundle, which takes an app manifest, a build options object, and a completion callback.

Both the manifest and options objects support both camelCase and dash-separated variants of any option.

The callback with be called with callback(error, finalBuildOptions) arguments. The finalBuildOptions contains the build options after default values have been applied. Useful to read out the workingDir, for example.

Manifest

This matches the format for flatpak-builder app manifests, with a few extra options added and camelCase variants supported. For complete documentation of the manifest format read the flatpak-builder docs.

In addition to standard manifest options, the following extra options are supported.

Build Options
Logging

To turn on debugging output set the DEBUG environment variable

G=flatpak-bundler npm run my-flatpak-command
Examples
Hello world
rite a hello world script to disk
t fs = require('fs')
riteFileSync('hello',
bin/bash
 "Hello, world!"`, { mode: 0o755 })

ake a flapak with it!
t flatpakBundler = require('flatpak-bundler')
pakBundler.bundle({
: 'org.world.Hello',
ntime: 'org.freedesktop.Platform',
ntimeVersion: '1.4',
ntimeFlatpakref: 'https://raw.githubusercontent.com/endlessm/flatpak-bundler/master/refs/freedesktop-runtime-1.4.flatpakref',
k: 'org.freedesktop.Sdk',
les: [
['hello', '/bin/hello']


ndlePath: 'hello.flatpak'
unction (error) {
 (error) {
console.error('Error building flatpak', error)
return

nsole.log('Flatpak built successfully')

Electron app
t flatpakBundler = require('flatpak-bundler')

pakBundler.bundle({ // Manifest
: 'org.world.Hello',
se: 'io.atom.electron.BaseApp', // Electron base application
seFlatpakref: 'https://s3-us-west-2.amazonaws.com/electron-flatpak.endlessm.com/electron-base-app-master.flatpakref', // So we can auto install the runtime
ntime: 'org.freedesktop.Platform', // Use the freedesktop runtime
ntimeVersion: '1.4',
ntimeFlatpakref: 'https://raw.githubusercontent.com/endlessm/flatpak-bundler/master/refs/freedesktop-runtime-1.4.flatpakref',
k: 'org.freedesktop.Sdk',
les: [
[ 'static/linux', '/share/' ], // Desktop file and icons
[ packagedFileDir, '/share/bar' ] // Application binaries and assets

mlinks: [
[ '/share/bar/Bar', '/bin/Bar' ] // Create a symlink in /bin to to app executable

nishArgs: [
'--share=ipc', '--socket=x11', // Allow app to show windows with X11
'--socket=pulseaudio', // Allow audio output
'--filesystem=home', // Allow access to users home directory
'--share=network', // Allow network access
'--device=dri' // Allow OpenGL rendering

nameDesktopFile: 'hello.desktop', // Rename the desktop file to agree with the app id so flatpak will export it
nameIcon: 'hello' // Rename the icon to agree with the app id so flatpak will export it
 // Build options
ch: 'x86_64',
ndlePath: 'dist/hello_x86_64.flatpak',
gSign: '1234ABCD' // Gpg key to sign with
unction (error, finalAppOptions, finalBuildOptions) { // Callback
 (error) {
console.error('Error building flatpak')
console.error(error)
return

nsole.log('Flatpak built successfully.')
nsole.log('Build dir and repo in ' + finalBuildOptions.workingDir)


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.