Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdavies committed Aug 31, 2018
1 parent bfab464 commit 3535870
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/reporting/server/browsers/chromium/paths.js
Expand Up @@ -13,16 +13,19 @@ export const paths = {
platforms: ['darwin', 'freebsd', 'openbsd'],
archiveFilename: 'chromium-4747cc2-darwin.zip',
archiveChecksum: '3f509e2fa994da3a1399d18d03b6eef7',
rawChecksum: 'c657bdde14f10b555b9d7ecb644ef695',
binaryRelativePath: 'headless_shell-darwin/headless_shell',
}, {
platforms: ['linux'],
archiveFilename: 'chromium-4747cc2-linux.zip',
archiveChecksum: '8f361042d0fc8a84d60cd01777ec260f',
rawChecksum: '8dfa6f823c663aa860ccdfa11de6713f',
binaryRelativePath: 'headless_shell-linux/headless_shell'
}, {
platforms: ['win32'],
archiveFilename: 'chromium-4747cc2-windows.zip',
archiveChecksum: 'fac0967cd54bb2492a5a858fbefdf983',
rawChecksum: 'b46de931336a341503d740ec692acbbd',
binaryRelativePath: 'headless_shell-windows\\headless_shell.exe'
}]
};
20 changes: 9 additions & 11 deletions x-pack/plugins/reporting/server/browsers/install.js
Expand Up @@ -6,14 +6,12 @@

import fs from 'fs';
import path from 'path';
import { promisify } from 'bluebird';
import { extract } from './extract';
import { promisify } from 'util';
import { BROWSERS_BY_TYPE } from './browsers';
import { extract } from './extract';
import { md5 } from './download/checksum';

const fsp = {
access: promisify(fs.access, fs),
chmod: promisify(fs.chmod, fs),
};
const chmod = promisify(fs.chmod);

/**
* "install" a browser by type into installs path by extracting the downloaded
Expand All @@ -33,13 +31,13 @@ export async function installBrowser(logger, browserConfig, browserType, install
}

const binaryPath = path.join(installsPath, pkg.binaryRelativePath);
try {
await fsp.access(binaryPath, fs.X_OK);
} catch (accessErr) {
// error here means the binary does not exist, so install it
const rawChecksum = await md5(binaryPath).catch(() => '');

if (rawChecksum !== pkg.rawChecksum) {
logger.debug(`Extracting ${browserType} to ${binaryPath}`);
const archive = path.join(browser.paths.archivesPath, pkg.archiveFilename);
await extract(archive, installsPath);
await fsp.chmod(binaryPath, '755');
await chmod(binaryPath, '755');
}

return browser.createDriverFactory(binaryPath, logger, browserConfig);
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/reporting/server/browsers/phantom/paths.js
Expand Up @@ -13,16 +13,19 @@ export const paths = {
platforms: ['darwin', 'freebsd', 'openbsd'],
archiveFilename: 'phantomjs-2.1.1-macosx.zip',
archiveChecksum: 'b0c038bd139b9ecaad8fd321070c1651',
rawChecksum: 'bbebe2381435309431c9d4e989aefdeb',
binaryRelativePath: 'phantomjs-2.1.1-macosx/bin/phantomjs',
}, {
platforms: ['linux'],
archiveFilename: 'phantomjs-2.1.1-linux-x86_64.tar.bz2',
archiveChecksum: '1c947d57fce2f21ce0b43fe2ed7cd361',
rawChecksum: '3f4bbbe5acd45494d8e52941936235f2',
binaryRelativePath: 'phantomjs-2.1.1-linux-x86_64/bin/phantomjs'
}, {
platforms: ['win32'],
archiveFilename: 'phantomjs-2.1.1-windows.zip',
archiveChecksum: '4104470d43ddf2a195e8869deef0aa69',
rawChecksum: '339f74c735e683502c43512a508e53d6',
binaryRelativePath: 'phantomjs-2.1.1-windows\\bin\\phantomjs.exe'
}]
};

0 comments on commit 3535870

Please sign in to comment.