-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
74 lines (61 loc) · 2.12 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var path = require('path');
var gulp = require('gulp');
var rimraf = require('rimraf');
var npm = require('gulp-brass-npm');
var brass = require('../../index');
var pkg, options, rpm;
pkg = require('./package.json');
options = npm.getOptions(pkg);
options.installDir = '/usr/lib/'+ options.name;
options.service = {
type : 'systemd',
name : options.name,
description : options.description,
exec : '/usr/bin/node-advanced',
user : 'node', // will be allocated dynamically
group : 'node' // will be allocated dynamically
};
rpm = brass.create(options);
gulp.task('clean', function () {
return gulp.src([ rpm.buildDir, '*.tgz', '*.log' ], { read: false })
.pipe(brass.util.stream(function (file, done) {
this.push(file);
rimraf(file.path, done);
}));
});
gulp.task('setup', [ 'clean' ], rpm.setupTask());
gulp.task('source', [ 'setup' ], npm.sourceTask(pkg, rpm));
gulp.task('files', [ 'setup', 'source' ], function () {
var globs = [
'**/*'
];
return gulp.src(globs, rpm.globOptions)
.pipe(gulp.dest(path.join(rpm.buildRoot, options.installDir)))
.pipe(brass.util.stream(function (file, done) {
if (file.relative == 'bin/node-advanced') {
file.attr = [ '0775', 'root', 'root' ];
}
done(null, file);
}))
.pipe(rpm.files());
});
// Customize systemd service unit file.
gulp.task('service', [ 'setup' ], function () {
return gulp.src('assets/unit.service')
.pipe(brass.util.template(options.service))
.pipe(brass.util.rename(options.service.name +'.service'))
.pipe(gulp.dest(path.join(rpm.buildRoot, '/lib/systemd/system')))
.pipe(rpm.files());
});
gulp.task('binaries', [ 'files' ], npm.binariesTask(pkg, rpm));
// Customize spec file to dynamically allocate user.
// See more: https://fedoraproject.org/wiki/Packaging:UsersAndGroups
gulp.task('spec', [ 'files', 'binaries', 'service' ], function () {
return gulp.src('assets/spec')
.pipe(rpm.spec())
.pipe(gulp.dest(rpm.buildDir_SPECS));
});
gulp.task('build', [ 'spec' ], rpm.buildTask());
gulp.task('default', [ 'build' ], function () {
console.log('build finished');
});