🐧 Add mkdeb task to create debian package.

This commit is contained in:
Cheng Zhao
2014-03-24 18:44:44 +08:00
parent 03b9a25897
commit 67d8db8b9a
3 changed files with 53 additions and 0 deletions

View File

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

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 %>

21
script/mkdeb Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# mkdeb version control-file-path
SCRIPT=`readlink -f "$0"`
ROOT=`readlink -f $(dirname $SCRIPT)/..`
cd $ROOT
VERSION="$1"
CONTROL_FILE="$2"
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"
dpkg-deb -b "$TARGET"
mv "$TARGET_ROOT/atom-$VERSION.deb" /tmp/atom-build/
rm -rf $TARGET_ROOT