Merge pull request #1789 from atom/linux-package

Add task to create .deb package
This commit is contained in:
Cheng Zhao
2014-03-25 07:42:01 +00:00
15 changed files with 104 additions and 20 deletions

View File

@@ -66,14 +66,17 @@ if [ $OS == 'Mac' ]; then
open -a "$ATOM_PATH/$ATOM_APP_NAME" -n --args --executed-from="$(pwd)" --pid=$$ "$@"
fi
elif [ $OS == 'Linux' ]; then
ATOM_PATH='/opt/Atom/atom'
SCRIPT=`readlink -f "$0"`
USR_DIRECTORY=`readlink -f $(dirname $SCRIPT)/..`
ATOM_PATH="$USR_DIRECTORY/share/atom/atom"
[ -x "$ATOM_PATH" ] || ATOM_PATH='/tmp/atom-build/Atom/atom'
if [ $EXPECT_OUTPUT ]; then
"$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@"
exit $?
else
nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > /dev/null &
nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > /dev/null 2>&1 &
fi
fi

View File

@@ -39,35 +39,33 @@ module.exports = (grunt) ->
if process.platform is 'win32'
appName = 'Atom'
tmpDir = os.tmpdir()
installRoot = process.env.ProgramFiles
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
symbolsDir = path.join(buildDir, 'Atom.breakpad.syms')
shellAppDir = path.join(buildDir, appName)
contentsDir = shellAppDir
appDir = path.join(shellAppDir, 'resources', 'app')
atomShellDownloadDir = path.join(os.tmpdir(), 'atom-cached-atom-shells')
installDir = path.join(process.env.ProgramFiles, appName)
else if process.platform is 'darwin'
appName = 'Atom.app'
tmpDir = '/tmp'
installRoot = '/Applications'
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
symbolsDir = path.join(buildDir, 'Atom.breakpad.syms')
shellAppDir = path.join(buildDir, appName)
contentsDir = path.join(shellAppDir, 'Contents')
appDir = path.join(contentsDir, 'Resources', 'app')
atomShellDownloadDir = '/tmp/atom-cached-atom-shells'
installDir = path.join('/Applications', appName)
else
appName = 'Atom'
tmpDir = '/tmp'
installRoot = '/opt'
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
symbolsDir = path.join(buildDir, 'Atom.breakpad.syms')
shellAppDir = path.join(buildDir, appName)
contentsDir = shellAppDir
appDir = path.join(shellAppDir, 'resources', 'app')
atomShellDownloadDir = '/tmp/atom-cached-atom-shells'
installDir = path.join(installRoot, appName)
installDir = process.env.INSTALL_PREFIX ? '/usr/local'
coffeeConfig =
options:

View File

@@ -15,7 +15,16 @@ module.exports = (grunt) ->
createShortcut = path.resolve 'script', 'create-shortcut.cmd'
runas('cmd', ['/c', createShortcut, path.join(installDir, 'atom.exe'), 'Atom'])
else
else if process.platform is 'darwin'
rm installDir
mkdir path.dirname(installDir)
cp shellAppDir, installDir
else
binDir = path.join(installDir, 'bin')
shareDir = path.join(installDir, 'share', 'atom')
mkdir binDir
cp 'atom.sh', path.join(binDir, 'atom')
rm shareDir
mkdir path.dirname(shareDir)
cp shellAppDir, shareDir

View File

@@ -0,0 +1,31 @@
fs = require 'fs'
path = require 'path'
_ = require 'underscore-plus'
fillTemplate = (filePath, data) ->
template = _.template(String(fs.readFileSync(filePath + '.in')))
filled = template(data)
fs.writeFileSync(filePath, filled)
module.exports = (grunt) ->
{spawn} = require('./task-helpers')(grunt)
grunt.registerTask 'mkdeb', 'Create debian package', ->
done = @async()
{name, version, description} = grunt.file.readJSON('package.json')
section = 'devel'
arch = 'amd64'
maintainer = 'GitHub <support@github.com>'
data = {name, version, description, section, arch, maintainer}
control = path.join('resources', 'linux', 'debian', 'control')
fillTemplate(control, data)
desktop = path.join('resources', 'linux', 'Atom.desktop')
fillTemplate(desktop, data)
icon = path.join('resources', 'atom.png')
buildDir = grunt.config.get('atom.buildDir')
cmd = path.join('script', 'mkdeb')
args = [version, control, desktop, icon, buildDir]
spawn({cmd, args}, done)

View File

@@ -2,6 +2,7 @@
"name": "atom",
"productName": "Atom",
"version": "0.77.0",
"description": "A hackable text editor for the 21st Century.",
"main": "./src/browser/main.js",
"repository": {
"type": "git",

View File

@@ -0,0 +1,8 @@
[Desktop Entry]
Name=Atom
Comment=<%= description %>
Exec=/usr/share/atom/atom %U
Icon=atom
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Utility;TextEditor;

View File

@@ -0,0 +1,8 @@
Package: <%= name %>
Version: <%= version %>
Section: <%= section %>
Priority: optional
Architecture: <%= arch %>
Installed-Size: `du -ks usr|cut -f 1`
Maintainer: <%= maintainer %>
Description: <%= description %>

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node --harmony_collections
#!/usr/bin/env node
var nodeMinorVersion = process.versions.node.split('.')[1]
if (nodeMinorVersion !== '10') {

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node --harmony_collections
#!/usr/bin/env node
var cp = require('./utils/child-process-wrapper.js');
var path = require('path');

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node --harmony_collections
#!/usr/bin/env node
var cp = require('./utils/child-process-wrapper.js');
var fs = require('fs');
var path = require('path');

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node --harmony_collections
#!/usr/bin/env node
var cp = require('./utils/child-process-wrapper.js');
var path = require('path');
var os = require('os');

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node --harmony_collections
#!/usr/bin/env node
var cp = require('./utils/child-process-wrapper.js');
var path = require('path');

31
script/mkdeb Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
# mkdeb version control-file-path deb-file-path
SCRIPT=`readlink -f "$0"`
ROOT=`readlink -f $(dirname $SCRIPT)/..`
cd $ROOT
VERSION="$1"
CONTROL_FILE="$2"
DESKTOP_FILE="$3"
ICON_FILE="$4"
DEB_PATH="$5"
TARGET_ROOT="`mktemp -d`"
TARGET="$TARGET_ROOT/atom-$VERSION"
mkdir -p "$TARGET/usr"
env INSTALL_PREFIX="$TARGET/usr" script/grunt install
mkdir -p "$TARGET/DEBIAN"
mv "$CONTROL_FILE" "$TARGET/DEBIAN/control"
mkdir -p "$TARGET/usr/share/applications"
mv "$DESKTOP_FILE" "$TARGET/usr/share/applications"
mkdir -p "$TARGET/usr/share/pixmaps"
cp "$ICON_FILE" "$TARGET/usr/share/pixmaps"
dpkg-deb -b "$TARGET"
mv "$TARGET_ROOT/atom-$VERSION.deb" "$DEB_PATH"
rm -rf $TARGET_ROOT

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node --harmony_collections
#!/usr/bin/env node
var safeExec = require('./utils/child-process-wrapper.js').safeExec;
var path = require('path');

View File

@@ -9,12 +9,7 @@ optimist = require 'optimist'
nslog = require 'nslog'
dialog = require 'dialog'
console.log = (args...) ->
# TODO: Make NSLog work as expected
output = args.map((arg) -> JSON.stringify(arg)).join(" ")
nslog(output)
if process.platform isnt 'darwin'
fs.writeFileSync('debug.log', output, flag: 'a')
console.log = nslog
process.on 'uncaughtException', (error={}) ->
nslog(error.message) if error.message?