Skip to content

Commit

Permalink
Merge pull request #7803 from elastic/jasper/backport/7317/4.x
Browse files Browse the repository at this point in the history
[backport] PR #7317 to 4.x - Apply -snapshot suffix during build task
  • Loading branch information
epixa authored Jul 22, 2016
2 parents ad36332 + 720a7ef commit cea7dae
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 46 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ Packages are built using fpm, pleaserun, dpkg, and rpm. fpm and pleaserun can b
apt-get install ruby-dev rpm
gem install fpm -v 1.5.0
gem install pleaserun -v 0.0.24
npm run build:ospackages
npm run build -- --skip-archives
```

To specify a package to build you can add `rpm` or `deb` as an argument.
```sh
npm run build:ospackages -- --rpm
npm run build -- --rpm
```

Distributable packages can be found in `target/` after the build completes.
Expand Down
5 changes: 4 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function (grunt) {
pkg: grunt.file.readJSON('package.json'),
root: __dirname,
src: __dirname + '/src',
build: __dirname + '/build', // temporary build directory
buildDir: __dirname + '/build', // temporary build directory
plugins: __dirname + '/src/plugins',
server: __dirname + '/src/server',
target: __dirname + '/target', // location of the compressed build targets
Expand Down Expand Up @@ -65,6 +65,9 @@ module.exports = function (grunt) {

grunt.config.merge(config);

// must run before even services/platforms
grunt.config.set('build', require('./tasks/config/build')(grunt));

config.packageScriptsDir = __dirname + '/tasks/build/package_scripts';
// ensure that these run first, other configs need them
config.services = require('./tasks/config/services')(grunt);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Kibana 4.6.0-snapshot
# Kibana 4.6.0

[![Build Status](https://travis-ci.org/elastic/kibana.svg?branch=master)](https://travis-ci.org/elastic/kibana?branch=master)

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": false,
"version": "4.6.0-snapshot",
"version": "4.6.0",
"build": {
"number": 8467,
"sha": "6cb7fec4e154faa0a4a3fee4b33dfef91b9870d9"
Expand Down Expand Up @@ -49,7 +49,6 @@
"test:server": "grunt test:server",
"test:coverage": "grunt test:coverage",
"build": "grunt build",
"build:ospackages": "grunt build --os-packages",
"start": "./bin/kibana --dev",
"precommit": "grunt precommit",
"karma": "karma start",
Expand Down
7 changes: 0 additions & 7 deletions tasks/build/getProps.js

This file was deleted.

7 changes: 3 additions & 4 deletions tasks/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module.exports = function (grunt) {

grunt.registerTask('build', 'Build packages', function () {
grunt.task.run(flatten([
'_build:getProps',
'clean:build',
'clean:target',
'_build:downloadNodeBuilds:start',
Expand All @@ -24,11 +23,11 @@ module.exports = function (grunt) {
'stop:optimizeBuild',
'_build:downloadNodeBuilds:finish',
'_build:versionedLinks',
'_build:archives',
grunt.option('os-packages') ? [
grunt.option('skip-archives') ? [] : ['_build:archives'],
grunt.option('skip-os-packages') ? [] : [
'_build:pleaseRun',
'_build:osPackages',
] : [],
],
'_build:shasums'
]));
});
Expand Down
42 changes: 22 additions & 20 deletions tasks/build/osPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import { indexBy } from 'lodash';
import exec from '../utils/exec';

export default (grunt) => {
const targetDir = grunt.config.get('target');
const { config } = grunt;
const exec = require('../utils/exec');
const targetDir = config.get('target');
const packageScriptsDir = grunt.config.get('packageScriptsDir');
const servicesByName = indexBy(grunt.config.get('services'), 'name');
const config = grunt.config.get('packages');
const servicesByName = indexBy(config.get('services'), 'name');
const packages = config.get('packages');
const fpm = args => exec('fpm', args);

grunt.registerTask('_build:osPackages', function () {
grunt.file.mkdir(targetDir);

grunt.config.get('platforms')
config.get('platforms')
.filter(({ name }) => /linux-x(86|64)$/.test(name))
.map(({ name, buildDir }) => {
const architecture = /x64$/.test(name) ? 'x86_64' : 'i386';
Expand All @@ -27,25 +29,25 @@ export default (grunt) => {
'--package', targetDir,
'-s', 'dir', // input type
'--architecture', architecture,
'--name', config.name,
'--description', config.description,
'--version', config.version,
'--url', config.site,
'--vendor', config.vendor,
'--maintainer', config.maintainer,
'--license', config.license,
'--name', packages.name,
'--description', packages.description,
'--version', packages.version,
'--url', packages.site,
'--vendor', packages.vendor,
'--maintainer', packages.maintainer,
'--license', packages.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', config.path.kibanaConfig,
'--template-value', `user=${config.user}`,
'--template-value', `group=${config.group}`,
'--template-value', `optimizeDir=${config.path.home}/optimize`,
'--template-value', `pluginsDir=${config.path.plugins}`,
'--template-value', `dataDir=${config.path.data}`,
'--config-files', packages.path.kibanaConfig,
'--template-value', `user=${packages.user}`,
'--template-value', `group=${packages.group}`,
'--template-value', `optimizeDir=${packages.path.home}/optimize`,
'--template-value', `pluginsDir=${packages.path.plugins}`,
'--template-value', `dataDir=${packages.path.data}`,
//uses relative path to --prefix, strip the leading /
'--exclude', `${config.path.home.slice(1)}/data`
'--exclude', `${packages.path.home.slice(1)}/data`
];
const debOptions = [
'-t', 'deb',
Expand All @@ -56,8 +58,8 @@ export default (grunt) => {
'--rpm-os', 'linux'
];
const args = [
`${buildDir}/=${config.path.home}/`,
`${buildDir}/data/=${config.path.data}/`,
`${buildDir}/=${packages.path.home}/`,
`${buildDir}/data/=${packages.path.data}/`,
`${servicesByName.sysv.outputDir}/etc/=/etc/`,
`${servicesByName.systemd.outputDir}/etc/=/etc/`
];
Expand Down
7 changes: 4 additions & 3 deletions tasks/build/packageJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ module.exports = function (grunt) {
let deepModules = grunt.config.get('deepModules');

grunt.registerTask('_build:packageJson', function () {
const { sha, number, version } = grunt.config.get('build');

grunt.file.write(
'build/kibana/package.json',
JSON.stringify({
name: pkg.name,
description: pkg.description,
keywords: pkg.keywords,
version: pkg.version,
version,
build: {
number: grunt.config.get('buildNum'),
sha: grunt.config.get('buildSha')
number,
sha
},
repository: pkg.repository,
engines: {
Expand Down
3 changes: 3 additions & 0 deletions tasks/build/shasums.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module.exports = function (grunt) {
grunt.registerTask('_build:shasums', function () {
var targetDir = grunt.config.get('target');

// for when shasums is run but archives and ospackages was not
grunt.file.mkdir(targetDir);

readdir(targetDir)
.map(function (archive) {
// only sha the archives and packages
Expand Down
5 changes: 1 addition & 4 deletions tasks/build/versionedLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ module.exports = function (grunt) {
return resolve(rootPath, file);
});

//We don't want to build os packages with symlinks
let transferFiles = (source, link) => grunt.option('os-packages')
? exec('cp', ['-r', source, link])
: exec('ln', ['-s', source, link]);
let transferFiles = (source, link) => exec('cp', ['-r', source, link]);

grunt.config.get('platforms').forEach(function (platform) {
grunt.file.mkdir(platform.buildDir);
Expand Down
15 changes: 15 additions & 0 deletions tasks/config/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { execSync as exec } from 'child_process';

export default (grunt) => {
const pkgVersion = grunt.config.get('pkg.version');

const sha = String(exec('git rev-parse HEAD')).trim();
const number = parseFloat(String(exec('git log --format="%h" | wc -l')).trim());
const version = buildVersion(grunt.option('release'), pkgVersion);

return { sha, number, version };
};

function buildVersion(isRelease, version) {
return isRelease ? version : `${version}-snapshot`;
}
2 changes: 1 addition & 1 deletion tasks/config/packages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default (grunt) => {
const VERSION = grunt.config.get('pkg.version');
const VERSION = grunt.config.get('build.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\./)[0]}x`;
Expand Down
2 changes: 1 addition & 1 deletion tasks/config/platforms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function (grunt) {
let { resolve } = require('path');

let version = grunt.config.get('pkg.version');
let { version } = grunt.config.get('build');
let nodeVersion = grunt.config.get('nodeVersion');
let rootPath = grunt.config.get('root');
let baseUri = `https://nodejs.org/dist/v${nodeVersion}`;
Expand Down

0 comments on commit cea7dae

Please sign in to comment.