2015-08-14 06:16:54 +02:00
|
|
|
module.exports = function (grunt) {
|
2015-12-29 22:32:06 +01:00
|
|
|
const { resolve } = require('path');
|
|
|
|
const { indexBy } = require('lodash');
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2015-12-29 22:32:06 +01:00
|
|
|
const { config } = grunt;
|
|
|
|
const exec = require('../utils/exec');
|
|
|
|
const targetDir = config.get('target');
|
|
|
|
const version = config.get('pkg.version');
|
2016-03-28 04:06:16 +02:00
|
|
|
const packageScriptsDir = config.get('packageScriptsDir');
|
2015-12-29 22:32:06 +01:00
|
|
|
const servicesByName = indexBy(config.get('services'), 'name');
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2015-08-14 22:27:41 +02:00
|
|
|
grunt.registerTask('_build:osPackages', function () {
|
2015-08-14 06:16:54 +02:00
|
|
|
grunt.config.get('platforms').forEach(({ name, buildDir }) => {
|
2015-08-14 22:27:41 +02:00
|
|
|
// TODO(sissel): Check if `fpm` is available
|
2015-12-29 22:32:06 +01:00
|
|
|
if (!(/linux-x(86|64)$/.test(name))) return;
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2016-03-09 22:40:16 +01:00
|
|
|
const arch = /x64$/.test(name) ? 'x86_64' : 'i386';
|
2015-12-29 22:32:06 +01:00
|
|
|
const fpm = args => exec('fpm', args);
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2015-12-29 22:32:06 +01:00
|
|
|
const args = [
|
2015-08-14 22:27:41 +02:00
|
|
|
'--force',
|
|
|
|
'--package', targetDir,
|
|
|
|
'-s', 'dir', // input type
|
|
|
|
'--name', 'kibana',
|
2016-05-02 18:27:58 +02:00
|
|
|
'--description', 'Explore\ and\ visualize\ your\ Elasticsearch\ data',
|
2015-08-14 22:27:41 +02:00
|
|
|
'--version', version,
|
2016-02-08 16:17:59 +01:00
|
|
|
'--url', 'https://www.elastic.co',
|
2016-02-04 20:22:29 +01:00
|
|
|
'--vendor', 'Elasticsearch,\ Inc.',
|
|
|
|
'--maintainer', 'Kibana Team\ \<info@elastic.co\>',
|
|
|
|
'--license', 'Apache\ 2.0',
|
2016-03-28 04:06:16 +02:00
|
|
|
'--after-install', resolve(packageScriptsDir, 'post_install.sh'),
|
|
|
|
'--before-remove', resolve(packageScriptsDir, 'pre_remove.sh'),
|
|
|
|
'--after-remove', resolve(packageScriptsDir, 'post_remove.sh'),
|
2016-05-02 17:57:16 +02:00
|
|
|
'--config-files', '/opt/kibana/config/kibana.yml',
|
2016-05-02 18:27:58 +02:00
|
|
|
'--template-value', 'user=kibana',
|
|
|
|
'--template-value', 'group=kibana'
|
2015-08-14 06:16:54 +02:00
|
|
|
];
|
|
|
|
|
2015-12-29 22:32:06 +01:00
|
|
|
const files = buildDir + '/=/opt/kibana';
|
|
|
|
const sysv = servicesByName.sysv.outputDir + '/etc/=/etc/';
|
|
|
|
const systemd = servicesByName.systemd.outputDir + '/lib/=/lib/';
|
2015-08-14 06:16:54 +02:00
|
|
|
|
2015-12-29 22:32:06 +01:00
|
|
|
//Manually find flags, multiple args without assignment are not entirely parsed
|
|
|
|
var flags = grunt.option.flags().join(',');
|
|
|
|
|
|
|
|
const buildDeb = !!flags.match('deb');
|
|
|
|
const buildRpm = !!flags.match('rpm');
|
|
|
|
const noneSpecified = !buildRpm && !buildDeb;
|
|
|
|
|
|
|
|
grunt.file.mkdir(targetDir);
|
|
|
|
if (buildDeb || noneSpecified) {
|
2016-02-05 19:31:52 +01:00
|
|
|
fpm(args.concat('-t', 'deb', '--deb-priority', 'optional', '-a', arch, files, sysv, systemd));
|
2015-08-14 06:16:54 +02:00
|
|
|
}
|
2015-12-29 22:32:06 +01:00
|
|
|
if (buildRpm || noneSpecified) {
|
|
|
|
fpm(args.concat('-t', 'rpm', '-a', arch, '--rpm-os', 'linux', files, sysv, systemd));
|
|
|
|
}
|
|
|
|
|
2015-08-14 06:16:54 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|