Closes #355 - Make bin/kibana executable in the tar and zip archives

grunt-compress is broken it does not honor the `mode` option when tyring
to set the permissions on a file. This is broken through out the entire
Grunt project (grunt-contrib-copy doesn't honor it, grunt-replace
doesn't honor it... as far as I can tell nothing does). SO instead of
wasting more time trying to get it to work (I already wasted an hour on
it) I decided to fall back to just writing a 10 minute script that
actually works. If you are intent on using a pure Grunt task to make it
work feel free to go do that rabit hole.
This commit is contained in:
Chris Cowan 2014-09-23 07:02:34 -07:00
parent 47b353fbcc
commit 5d39d334ea
7 changed files with 65 additions and 11 deletions

View file

@ -16,7 +16,6 @@ module.exports = function (grunt) {
'copy:dist',
'compile_dist_readme',
'chmod_kibana',
'compress:build_zip',
'compress:build_tarball'
'create_packages'
]);
};

View file

@ -3,7 +3,7 @@ var join = require('path').join;
module.exports = function (grunt) {
grunt.registerTask('chmod_kibana', 'Chmods bin/kibana', function () {
var done = this.async();
var path = join(grunt.config.get('build'), 'dist', 'bin', 'kibana');
var path = join(grunt.config.get('build'), 'dist', 'kibana', 'bin', 'kibana');
fs.chmod(path, 0755, done);
});
};

View file

@ -27,10 +27,10 @@ module.exports = function (grunt) {
var build = grunt.config.get('build');
var srcReadme = join(root, 'README.md');
var distReadme = join(build, 'dist', 'README');
var distReadme = join(build, 'dist', 'kibana', 'README.txt');
var srcLicense = join(root, 'LICENSE.md');
var distLicense = join(build, 'dist', 'LICENSE');
var distLicense = join(build, 'dist', 'kibana', 'LICENSE.txt');
marked.setOptions({
renderer: new TextRenderer(),

View file

@ -14,11 +14,34 @@ module.exports = function (grunt) {
archive: filename
},
files: [
{
flatten: true,
src: '<%= build %>/dist/bin/kibana',
dest: '<%= pkg.name %>/bin/kibana',
mode: 755
},
{
flatten: true,
src: '<%= build %>/dist/bin/kibana.bat',
dest: '<%= pkg.name %>/bin/kibana.bat'
},
{
expand: true,
cwd: '<%= build %>/dist/config',
src: ['**/*'],
dest: '<%= pkg.name %>/config'
},
{
expand: true,
cwd: '<%= build %>/dist/lib',
src: ['**/*'],
dest: '<%= pkg.name %>/lib'
},
{
expand: true,
cwd: '<%= build %>/dist',
src: ['**/*'],
dest: '<%= pkg.name %>' + (task === 'plugin' ? '/_site' : '')
src: ['*.txt'],
dest: '<%= pkg.name %>'
}
]
};

View file

@ -50,13 +50,13 @@ module.exports = function (grunt) {
expand: true,
cwd: '<%= build %>/kibana/',
src: '*.jar',
dest: '<%= build %>/dist/lib/'
dest: '<%= build %>/dist/kibana/lib/'
},
{
expand: true,
cwd: '<%= src %>/server/config/',
src: 'kibana.yml',
dest: '<%= build %>/dist/config/'
dest: '<%= build %>/dist/kibana/config/'
}
]
}

View file

@ -13,11 +13,12 @@ module.exports = function (grunt) {
files: [
{
src: [join(src, 'server', 'bin', 'kibana.sh')],
dest: join(build, 'dist', 'bin', 'kibana')
dest: join(build, 'dist', 'kibana', 'bin', 'kibana'),
mode: 0755
},
{
src: [join(src, 'server', 'bin', 'kibana.bat')],
dest: join(build, 'dist', 'bin', 'kibana.bat')
dest: join(build, 'dist', 'kibana', 'bin', 'kibana.bat')
}
]
}

31
tasks/create_packages.js Normal file
View file

@ -0,0 +1,31 @@
var child_process = require('child_process');
var Promise = require('bluebird');
var exec = Promise.promisify(child_process.exec);
var join = require('path').join;
var mkdirp = Promise.promisifyAll(require('mkdirp'));
module.exports = function (grunt) {
grunt.registerTask('create_packages', function () {
var done = this.async();
var target = grunt.config.get('target');
var packageName = grunt.config.get('pkg.name');
var version = grunt.config.get('pkg.version');
var archiveName = join(target, packageName + '-' + version);
var distPath = join(grunt.config.get('build'), 'dist');
var tgzCmd = 'tar -zcvf ' + archiveName + '.tar.gz kibana';
var zipCmd = 'zip -r ' + archiveName + '.zip kibana';
var options = { cwd: distPath };
mkdirp.mkdirpAsync(target)
.then(function (arg) {
return exec(tgzCmd, options);
})
.then(function (arg) {
return exec(zipCmd, options);
})
.finally(done);
});
};