Skip to content

Commit

Permalink
[build] consolidate package config
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed May 27, 2016
1 parent 6d293af commit 8f0be48
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 45 deletions.
31 changes: 16 additions & 15 deletions tasks/build/os_packages.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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\ \<info@elastic.co\>',
'--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/`
];
Expand Down
20 changes: 8 additions & 12 deletions tasks/build/pleaserun.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
});
};
58 changes: 45 additions & 13 deletions tasks/config/packages.js
Original file line number Diff line number Diff line change
@@ -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\ \<info@elastic.co\>',
license: 'Apache\ 2.0',
version: VERSION,
path: {
conf: FOLDER_CONFIG,
logs: FOLDER_LOGS,
home: FOLDER_HOME,
kibanaBin: FILE_KIBANA_BINARY,
kibanaConfig: FILE_KIBANA_CONF
}
};
};
10 changes: 5 additions & 5 deletions tasks/release_packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 8f0be48

Please sign in to comment.