chore: further enhanced repack-juggler script (#7188)
With this change, the script is now 2-stage: - first, prepare browser build with `repack-juggler.js --prepare` - afterwards, run the script to repack tot juggler version with the bubild
This commit is contained in:
parent
82a50b0e1d
commit
5002420a6f
|
|
@ -51,34 +51,49 @@ const DOWNLOAD_URLS = {
|
||||||
'win64': 'https://playwright.azureedge.net/builds/firefox/%s/firefox-win64.zip',
|
'win64': 'https://playwright.azureedge.net/builds/firefox/%s/firefox-win64.zip',
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildNumber = (await fs.promises.readFile(path.join(__dirname, 'BUILD_NUMBER'), 'utf8')).split('\n').shift();
|
|
||||||
|
|
||||||
if (process.argv[2] === '--help' || process.argv[2] === '-h') {
|
if (process.argv[2] === '--help' || process.argv[2] === '-h') {
|
||||||
console.log(`usage: ${path.basename(process.argv[1])} [platform]`);
|
console.log(`usage: ${path.basename(process.argv[1])} [--prepare] [build number]`);
|
||||||
console.log(``);
|
console.log(``);
|
||||||
console.log(`Repackages firefox r${buildNumber} with tip-of-tree Juggler implementation`);
|
console.log(`Repackages Firefox with tip-of-tree Juggler implementation`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildPlatform = process.argv[2] || getHostPlatform();
|
if (process.argv[2] === '--prepare')
|
||||||
|
await prepareFirefoxBuild(process.argv[3], process.argv[4]);
|
||||||
|
else
|
||||||
|
await repackageJuggler();
|
||||||
|
|
||||||
|
async function prepareFirefoxBuild(buildNumber, buildPlatform) {
|
||||||
|
if (!buildNumber)
|
||||||
|
buildNumber = (await fs.promises.readFile(path.join(__dirname, 'BUILD_NUMBER'), 'utf8')).split('\n').shift();
|
||||||
|
if (!buildPlatform)
|
||||||
|
buildPlatform = getHostPlatform();
|
||||||
const currentBuildInfo = await fs.promises.readFile(BUILD_INFO_PATH).then(text => JSON.parse(text)).catch(e => ({ buildPlatform: '', buildNumber: '' }));
|
const currentBuildInfo = await fs.promises.readFile(BUILD_INFO_PATH).then(text => JSON.parse(text)).catch(e => ({ buildPlatform: '', buildNumber: '' }));
|
||||||
|
|
||||||
if (currentBuildInfo.buildPlatform !== buildPlatform || currentBuildInfo.buildNumber !== buildNumber) {
|
if (currentBuildInfo.buildPlatform === buildPlatform && currentBuildInfo.buildNumber === buildNumber)
|
||||||
|
return;
|
||||||
await fs.promises.rm(BUILD_DIRECTORY, { recursive: true }).catch(e => {});
|
await fs.promises.rm(BUILD_DIRECTORY, { recursive: true }).catch(e => {});
|
||||||
await fs.promises.mkdir(BUILD_DIRECTORY);
|
await fs.promises.mkdir(BUILD_DIRECTORY);
|
||||||
const buildZipPath = path.join(BUILD_DIRECTORY, 'firefox.zip');
|
const buildZipPath = path.join(BUILD_DIRECTORY, 'firefox.zip');
|
||||||
console.log(`Downloading Firefox r${buildNumber} for ${buildPlatform} - it might take a few minutes`);
|
|
||||||
|
|
||||||
const urlTemplate = DOWNLOAD_URLS[buildPlatform];
|
const urlTemplate = DOWNLOAD_URLS[buildPlatform];
|
||||||
if (!urlTemplate)
|
if (!urlTemplate)
|
||||||
throw new Error(`ERROR: repack-juggler does not support ${buildPlatform}`);
|
throw new Error(`ERROR: repack-juggler does not support ${buildPlatform}`);
|
||||||
const url = util.format(urlTemplate, buildNumber);
|
const url = util.format(urlTemplate, buildNumber);
|
||||||
|
console.log(`Downloading Firefox r${buildNumber} for ${buildPlatform} - it might take a few minutes`);
|
||||||
await downloadFile(url, buildZipPath);
|
await downloadFile(url, buildZipPath);
|
||||||
await spawnAsync('unzip', [ buildZipPath ], {cwd: BUILD_DIRECTORY});
|
await spawnAsync('unzip', [ buildZipPath ], {cwd: BUILD_DIRECTORY});
|
||||||
await fs.promises.writeFile(BUILD_INFO_PATH, JSON.stringify({ buildNumber, buildPlatform }), 'utf8');
|
await fs.promises.writeFile(BUILD_INFO_PATH, JSON.stringify({ buildNumber, buildPlatform }), 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function repackageJuggler() {
|
||||||
|
const currentBuildInfo = await fs.promises.readFile(BUILD_INFO_PATH).then(text => JSON.parse(text)).catch(e => null);
|
||||||
|
if (!currentBuildInfo) {
|
||||||
|
console.log('ERROR: build is not prepared!');
|
||||||
|
console.log(`run ${path.basename(process.argv[1])} --prepare`);
|
||||||
|
}
|
||||||
|
const {buildNumber, buildPlatform} = currentBuildInfo;
|
||||||
|
|
||||||
// Find all omni.ja files in the Firefox build.
|
// Find all omni.ja files in the Firefox build.
|
||||||
const omniPaths = await spawnAsync('find', ['.', '-name', 'omni.ja'], {
|
const omniPaths = await spawnAsync('find', ['.', '-name', 'omni.ja'], {
|
||||||
cwd: BUILD_DIRECTORY,
|
cwd: BUILD_DIRECTORY,
|
||||||
|
|
@ -129,6 +144,7 @@ console.log(`
|
||||||
buildPlatform: ${buildPlatform}
|
buildPlatform: ${buildPlatform}
|
||||||
executablePath: ${path.join(BUILD_DIRECTORY, ...EXECUTABLE_PATHS[buildPlatform])}
|
executablePath: ${path.join(BUILD_DIRECTORY, ...EXECUTABLE_PATHS[buildPlatform])}
|
||||||
`);
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function httpRequest(url, method, response) {
|
function httpRequest(url, method, response) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue