-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using re2 for Timelion regular expressions (#55208)
* Using re2 for Timelion's regexs * Patching native modules * Restructuring to be more generic * Fixing download_node_builds_task tests * Updating linux sha after properly gzipping the archive * Using a Centos7 machine with devtoolset-6. That's what node does * Using new archives which Travis built for us * Not using a standard import to prevent Kibana from not starting up If the "portable" version of RE2 for some reason isn't truly portable and can't load, we don't want to prevent the rest of Kibana from working properly. This will only prevent Timelion from working, which isn't great, but is less worse * Isolating the require even further * Detecting the package version mismatches, thanks Larry! Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
73d1013
commit 728d073
Showing
12 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import util from 'util'; | ||
import { deleteAll, download, untar } from '../lib'; | ||
|
||
const BASE_URL = `https://storage.googleapis.com/native-modules`; | ||
const DOWNLOAD_DIRECTORY = '.native_modules'; | ||
|
||
const packages = [ | ||
{ | ||
name: 're2', | ||
version: '1.10.5', | ||
destinationPath: 'node_modules/re2/build/Release/', | ||
shas: { | ||
darwin: '066533b592094f91e00412499e44c338ce2466d63c9eaf0dc32be8214bde2099', | ||
linux: '0322cac3c2e106129b650a8eac509f598ed283791d6116984fec4c151b24e574', | ||
windows: '65b5bef7de2352f4787224c2c76a619b6683a868c8d4d71e0fdd500786fc422b', | ||
}, | ||
}, | ||
]; | ||
|
||
async function getInstalledVersion(config, packageName) { | ||
const packageJSONPath = config.resolveFromRepo( | ||
path.join('node_modules', packageName, 'package.json') | ||
); | ||
const buffer = await util.promisify(fs.readFile)(packageJSONPath); | ||
const packageJSON = JSON.parse(buffer); | ||
return packageJSON.version; | ||
} | ||
|
||
async function patchModule(config, log, build, platform, pkg) { | ||
const installedVersion = await getInstalledVersion(config, pkg.name); | ||
if (installedVersion !== pkg.version) { | ||
throw new Error( | ||
`Can't patch ${pkg.name}'s native module, we were expecting version ${pkg.version} and found ${installedVersion}` | ||
); | ||
} | ||
const platformName = platform.getName(); | ||
const archiveName = `${pkg.version}-${platformName}.tar.gz`; | ||
const downloadUrl = `${BASE_URL}/${pkg.name}/${archiveName}`; | ||
const downloadPath = config.resolveFromRepo(DOWNLOAD_DIRECTORY, archiveName); | ||
const extractedPath = build.resolvePathForPlatform(platform, pkg.destinationPath); | ||
log.debug(`Patching ${pkg.name} binaries from ${downloadUrl} to ${extractedPath}`); | ||
|
||
await deleteAll([extractedPath], log); | ||
await download({ | ||
log, | ||
url: downloadUrl, | ||
destination: downloadPath, | ||
sha256: pkg.shas[platformName], | ||
retries: 3, | ||
}); | ||
await untar(downloadPath, extractedPath); | ||
} | ||
|
||
export const PatchNativeModulesTask = { | ||
description: 'Patching platform-specific native modules', | ||
async run(config, log, build) { | ||
for (const pkg of packages) { | ||
await Promise.all( | ||
config.getTargetPlatforms().map(async platform => { | ||
await patchModule(config, log, build, platform, pkg); | ||
}) | ||
); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters