From 8f0be48768fb6bdff49cf509ff5fe84d540ee1ee Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Wed, 25 May 2016 14:21:36 -0500 Subject: [PATCH] [build] consolidate package config --- tasks/build/os_packages.js | 31 ++++++++++---------- tasks/build/pleaserun.js | 20 ++++++------- tasks/config/packages.js | 58 +++++++++++++++++++++++++++++--------- tasks/release_packages.js | 10 +++---- 4 files changed, 74 insertions(+), 45 deletions(-) diff --git a/tasks/build/os_packages.js b/tasks/build/os_packages.js index 62ba385c99cd9..11546ed1df76a 100644 --- a/tasks/build/os_packages.js +++ b/tasks/build/os_packages.js @@ -1,16 +1,16 @@ module.exports = function (grunt) { const { resolve } = require('path'); const { indexBy } = require('lodash'); - const { config } = grunt; const exec = require('../utils/exec'); + const targetDir = config.get('target'); - const version = config.get('pkg.version'); const packageScriptsDir = config.get('packageScriptsDir'); const servicesByName = indexBy(config.get('services'), 'name'); + const packageConfig = config.get('packages'); grunt.registerTask('_build:osPackages', function () { - grunt.config.get('platforms').forEach(({ name, buildDir }) => { + config.get('platforms').forEach(({ name, buildDir }) => { // TODO(sissel): Check if `fpm` is available if (!(/linux-x(86|64)$/.test(name))) return; @@ -21,28 +21,29 @@ module.exports = function (grunt) { '--force', '--package', targetDir, '-s', 'dir', // input type - '--name', 'kibana', - '--description', 'Explore\ and\ visualize\ your\ Elasticsearch\ data', - '--version', version, - '--url', 'https://www.elastic.co', - '--vendor', 'Elasticsearch,\ Inc.', - '--maintainer', 'Kibana Team\ \', - '--license', 'Apache\ 2.0', + '--name', packageConfig.name, + '--description', packageConfig.description, + '--version', packageConfig.version, + '--url', packageConfig.site, + '--vendor', packageConfig.vendor, + '--maintainer', packageConfig.maintainer, + '--license', packageConfig.license, '--after-install', resolve(packageScriptsDir, 'post_install.sh'), '--before-install', resolve(packageScriptsDir, 'pre_install.sh'), '--before-remove', resolve(packageScriptsDir, 'pre_remove.sh'), '--after-remove', resolve(packageScriptsDir, 'post_remove.sh'), - '--config-files', '/etc/kibana/kibana.yml', + '--config-files', packageConfig.path.kibanaConfig, '--template-value', 'user=kibana', '--template-value', 'group=kibana' - //uses relative path to --prefix - '--exclude', 'usr/share/kibana/config' + //config folder is moved to path.conf, exclude {path.home}/config + //uses relative path to --prefix, strip the leading / + '--exclude', `${packageConfig.path.home.slice(1)}/config` ]; const files = [ - `${buildDir}/=/usr/share/kibana/`, - `${buildDir}/config/=/etc/kibana/`, + `${buildDir}/=${packageConfig.path.home}/`, + `${buildDir}/config/=${packageConfig.path.conf}/`, `${servicesByName.sysv.outputDir}/etc/=/etc/`, `${servicesByName.systemd.outputDir}/lib/=/lib/` ]; diff --git a/tasks/build/pleaserun.js b/tasks/build/pleaserun.js index 907ebc7b2ec25..27f94b3d0d0b4 100644 --- a/tasks/build/pleaserun.js +++ b/tasks/build/pleaserun.js @@ -3,6 +3,9 @@ module.exports = function createServices(grunt) { const { appendFileSync } = require('fs'); const exec = require('../utils/exec'); + const userScriptsDir = grunt.config.get('userScriptsDir'); + const { path, user, group } = grunt.config.get('packages'); + grunt.registerTask('_build:pleaseRun', function () { // TODO(sissel): Detect if 'pleaserun' is found, and provide a useful error // to the user if it is missing. @@ -14,21 +17,14 @@ module.exports = function createServices(grunt) { '--no-install-actions', '--install-prefix', service.outputDir, '--overwrite', - '--user', 'kibana', - '--group', 'kibana', - '--sysv-log-path', '/var/log/kibana/', + '--user', user, + '--group', group, + '--sysv-log-path', path.logs, '-p', service.name, '-v', service.version, - '/usr/share/kibana/bin/kibana', - '-c /etc/kibana/kibana.yml' + path.kibanaBin, + `-c ${path.kibanaConfig}` ]); }); -<<<<<<< a9f1c863a78d71b9d350badac9d65a204898e566 -======= - - grunt.file.mkdir(userScriptsDir); - exec('please-manage-user', ['--output', userScriptsDir, 'kibana']); - appendFileSync(resolve(userScriptsDir, 'installer.sh'), 'chown -R kibana:kibana /usr/share/kibana/optimize'); ->>>>>>> [build] move install to /usr/share, config to /etc/kibana }); }; diff --git a/tasks/config/packages.js b/tasks/config/packages.js index c1b327747a60d..1c847168b33cd 100644 --- a/tasks/config/packages.js +++ b/tasks/config/packages.js @@ -1,20 +1,52 @@ export default (grunt) => { - const version = grunt.config.get('pkg.version'); - const productionPath = `kibana/${version.match(/\d\.\d/)[0]}`; - const stagingPath = `kibana/staging/${version.match(/\d\.\d\.\d/)[0]}-XXXXXXX/repos/${version.match(/\d\./)[0]}x`; - const rpmFolder = 'centos'; - const debFolder = 'debian'; + const VERSION = grunt.config.get('pkg.version'); + + const FOLDER_STAGING = `kibana/staging/${VERSION.match(/\d\.\d\.\d/)[0]}-XXXXXXX/repos/${VERSION.match(/\d\./)[0]}x`; + const FOLDER_PRODUCTION = `kibana/${VERSION.match(/\d\.\d/)[0]}`; + + const FOLDERNAME_DEB = 'debian'; + const FOLDERNAME_RPM = 'centos'; + + const PREFIX_STAGING_DEB = `${FOLDER_STAGING}/${FOLDERNAME_DEB}`; + const PREFIX_STAGING_RPM = `${FOLDER_STAGING}/${FOLDERNAME_RPM}`; + const PREFIX_PRODUCTION_DEB = `${FOLDER_PRODUCTION}/${FOLDERNAME_DEB}`; + const PREFIX_PRODUCTION_RPM = `${FOLDER_PRODUCTION}/${FOLDERNAME_RPM}`; + + const FOLDER_CONFIG = '/etc/kibana'; + const FOLDER_LOGS = '/var/log/kibana'; + const FOLDER_HOME = '/usr/share/kibana'; + + const FILE_KIBANA_CONF = `${FOLDER_CONFIG}/kibana.yml`; + const FILE_KIBANA_BINARY = `${FOLDER_HOME}/bin/kibana`; return { - staging: { - bucket: 'download.elasticsearch.org', - debPrefix: `${stagingPath}/${debFolder}`, - rpmPrefix: `${stagingPath}/${rpmFolder}` + publish: { + staging: { + bucket: 'download.elasticsearch.org', + debPrefix: PREFIX_STAGING_DEB, + rpmPrefix: PREFIX_STAGING_RPM + }, + production: { + bucket: 'packages.elasticsearch.org', + debPrefix: PREFIX_STAGING_DEB, + rpmPrefix: PREFIX_STAGING_RPM + } }, - production: { - bucket: 'packages.elasticsearch.org', - debPrefix: `${productionPath}/${debFolder}`, - rpmPrefix: `${productionPath}/${rpmFolder}` + user: 'kibana', + group: 'kibana', + name: 'kibana', + description: 'Explore\ and\ visualize\ your\ Elasticsearch\ data', + site: 'https://www.elastic.co', + vendor: 'Elasticsearch,\ Inc.', + maintainer: 'Kibana Team\ \', + license: 'Apache\ 2.0', + version: VERSION, + path: { + conf: FOLDER_CONFIG, + logs: FOLDER_LOGS, + home: FOLDER_HOME, + kibanaBin: FILE_KIBANA_BINARY, + kibanaConfig: FILE_KIBANA_CONF } }; }; diff --git a/tasks/release_packages.js b/tasks/release_packages.js index 372fbc9f785ee..f542481d7007a 100644 --- a/tasks/release_packages.js +++ b/tasks/release_packages.js @@ -4,7 +4,7 @@ import { promisify } from 'bluebird'; import readline from 'readline'; export default (grunt) => { - const packages = grunt.config.get('packages'); + const publishConfig = grunt.config.get('packages').publish; const platforms = grunt.config.get('platforms'); function debS3(deb) { @@ -87,8 +87,8 @@ export default (grunt) => { if (platform.debPath) { debS3({ filePath: platform.debPath, - bucket: packages[environment].bucket, - prefix: packages[environment].debPrefix.replace('XXXXXXX', trimmedHash), + bucket: publishConfig[environment].bucket, + prefix: publishConfig[environment].debPrefix.replace('XXXXXXX', trimmedHash), signatureKeyId: signature.id, arch: platform.name.match('x64') ? 'amd64' : 'i386', awsKey: aws.key, @@ -99,8 +99,8 @@ export default (grunt) => { if (platform.rpmPath) { rpmS3({ filePath: platform.rpmPath, - bucket: packages[environment].bucket, - prefix: packages[environment].rpmPrefix.replace('XXXXXXX', trimmedHash), + bucket: publishConfig[environment].bucket, + prefix: publishConfig[environment].rpmPrefix.replace('XXXXXXX', trimmedHash), signingKeyName: signature.name, awsKey: aws.key, awsSecret: aws.secret