mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-07 17:05:33 +02:00
chore: Update createMarFile function to include github parameter
This commit is contained in:
parent
6de5d11274
commit
62c50b6a84
3 changed files with 82 additions and 32 deletions
|
@ -6,7 +6,7 @@ import { copyFile, mkdir, readdir, unlink } from 'node:fs/promises'
|
||||||
import { join, resolve } from 'node:path'
|
import { join, resolve } from 'node:path'
|
||||||
|
|
||||||
import { bin_name, config } from '..'
|
import { bin_name, config } from '..'
|
||||||
import { DIST_DIR, ENGINE_DIR, OBJ_DIR } from '../constants'
|
import { DIST_DIR, ENGINE_DIR, OBJ_DIR, MAR_TMP_FILE } from '../constants'
|
||||||
import { log } from '../log'
|
import { log } from '../log'
|
||||||
import {
|
import {
|
||||||
configDispatch,
|
configDispatch,
|
||||||
|
@ -14,7 +14,9 @@ import {
|
||||||
dynamicConfig,
|
dynamicConfig,
|
||||||
windowsPathToUnix,
|
windowsPathToUnix,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
import { generateBrowserUpdateFiles } from './updates/browser'
|
import { generateBrowserUpdateFiles, getReleaseMarURL } from './updates/browser'
|
||||||
|
import { downloadFileToLocation } from '../utils/download'
|
||||||
|
import { moveSync } from 'fs-extra'
|
||||||
|
|
||||||
const machPath = resolve(ENGINE_DIR, 'mach')
|
const machPath = resolve(ENGINE_DIR, 'mach')
|
||||||
|
|
||||||
|
@ -138,6 +140,7 @@ function getCurrentBrandName(): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createMarFile(version: string, channel: string, github?: { repo: string }) {
|
async function createMarFile(version: string, channel: string, github?: { repo: string }) {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
log.info(`Creating mar file...`)
|
log.info(`Creating mar file...`)
|
||||||
let marBinary: string = windowsPathToUnix(
|
let marBinary: string = windowsPathToUnix(
|
||||||
join(OBJ_DIR, 'dist/host/bin', 'mar')
|
join(OBJ_DIR, 'dist/host/bin', 'mar')
|
||||||
|
@ -168,6 +171,52 @@ async function createMarFile(version: string, channel: string, github?: { repo:
|
||||||
MAR_CHANNEL_ID: channel,
|
MAR_CHANNEL_ID: channel,
|
||||||
MAR: marBinary,
|
MAR: marBinary,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
return marPath
|
|
||||||
|
// Download the latest MAR from the github release and run make_incremental_update.sh
|
||||||
|
const brandingKey = dynamicConfig.get('brand') as string
|
||||||
|
const brandingDetails = config.brands[brandingKey]
|
||||||
|
const releaseInfo = brandingDetails.release
|
||||||
|
|
||||||
|
console.log(releaseInfo)
|
||||||
|
const releaseUrl = getReleaseMarURL(releaseInfo);
|
||||||
|
// Try downloading the file
|
||||||
|
const oldMarFile = "output-old.mar";
|
||||||
|
await downloadFileToLocation(releaseUrl, oldMarFile).catch((error) => {
|
||||||
|
log.warning(`Failed to download the MAR file from ${releaseUrl}`)
|
||||||
|
resolve(marPath)
|
||||||
|
}).then(async () => {
|
||||||
|
log.info(`Downloaded the MAR file from ${releaseUrl}`)
|
||||||
|
// Extract both the old and new mar files into MAR_TMP_FILE/A and MAR_TMP_FILE/B
|
||||||
|
const oldMarPath = join(MAR_TMP_FILE, 'A')
|
||||||
|
const newMarPath = join(MAR_TMP_FILE, 'B')
|
||||||
|
|
||||||
|
await configDispatch(marBinary, {
|
||||||
|
args: ['-x', oldMarFile],
|
||||||
|
cwd: MAR_TMP_FILE,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run the make_incremental_update.sh script
|
||||||
|
await configDispatch('./tools/update-packaging/make_incremental_update.sh', {
|
||||||
|
args: [
|
||||||
|
// The mar output location
|
||||||
|
windowsPathToUnix(join(DIST_DIR)),
|
||||||
|
oldMarPath,
|
||||||
|
marPath,
|
||||||
|
newMarPath,
|
||||||
|
],
|
||||||
|
cwd: ENGINE_DIR,
|
||||||
|
env: {
|
||||||
|
MOZ_PRODUCT_VERSION: version,
|
||||||
|
MAR_CHANNEL_ID: channel,
|
||||||
|
MAR: marBinary,
|
||||||
|
},
|
||||||
|
}).then(() => {
|
||||||
|
resolve(marPath)
|
||||||
|
}).catch((error) => {
|
||||||
|
log.error(`Failed to create the incremental update: ${error}`)
|
||||||
|
resolve(marPath)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ function getReleaseMarName(releaseInfo: ReleaseInfo): string | undefined {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReleaseMarURL(releaseInfo: ReleaseInfo) {
|
export function getReleaseMarURL(releaseInfo: ReleaseInfo) {
|
||||||
const releaseMarName = getReleaseMarName(releaseInfo)
|
const releaseMarName = getReleaseMarName(releaseInfo)
|
||||||
let completeMarURL = `https://${config.updateHostname || 'localhost:8000'}/${
|
let completeMarURL = `https://${config.updateHostname || 'localhost:8000'}/${
|
||||||
releaseMarName || 'output.mar'
|
releaseMarName || 'output.mar'
|
||||||
|
|
|
@ -31,6 +31,7 @@ export const CONFIGS_DIR = resolve(process.cwd(), 'configs')
|
||||||
export const MELON_DIR = resolve(process.cwd(), '.surfer')
|
export const MELON_DIR = resolve(process.cwd(), '.surfer')
|
||||||
export const MELON_TMP_DIR = resolve(MELON_DIR, 'engine')
|
export const MELON_TMP_DIR = resolve(MELON_DIR, 'engine')
|
||||||
export const DIST_DIR = resolve(process.cwd(), 'dist')
|
export const DIST_DIR = resolve(process.cwd(), 'dist')
|
||||||
|
export const MAR_TMP_FILE = resolve(process.cwd(), 'dist-old')
|
||||||
|
|
||||||
mkdirSync(MELON_TMP_DIR, { recursive: true })
|
mkdirSync(MELON_TMP_DIR, { recursive: true })
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue