Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #10725 from brave/widevine-0.18.x
Browse files Browse the repository at this point in the history
Integrate with the `signature_generator.py` script (for widevine).
  • Loading branch information
bbondy committed Aug 31, 2017
1 parent 1125521 commit 86a538d
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ httpse.leveldb

# sync bundle file should be built and copied from the brave/sync repo for now
app/extensions/brave/content/scripts/sync.js

# script used for signing for widevine
signature_generator.py
101 changes: 72 additions & 29 deletions tools/buildInstaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,51 @@ const isDarwin = process.platform === 'darwin'
const isLinux = process.platform === 'linux'
var outDir = 'dist'
var arch = 'x64'
var widevineCdmArch = 'win_x64'
var cmds

if (isWindows) {
if (process.env.TARGET_ARCH === 'ia32') {
arch = 'ia32'
widevineCdmArch = 'win_x86'
}
}
const buildDir = 'Brave-' + process.platform + '-' + arch

console.log('Building install and update for version ' + VersionInfo.braveVersion + ' in ' + buildDir + ' with Electron ' + VersionInfo.electronVersion)

const raiseError = (errorMessage) => {
console.error(errorMessage)
process.exit(1)
}

if (isDarwin || isWindows) {
const requiredText = 'is required for widevine signing'
if (!process.env.SIGN_WIDEVINE_PASSPHRASE) {
raiseError('SIGN_WIDEVINE_PASSPHRASE ' + requiredText)
}
if (!process.env.SIGN_WIDEVINE_CERT) {
raiseError('SIGN_WIDEVINE_CERT ' + requiredText)
}
if (!process.env.SIGN_WIDEVINE_KEY) {
raiseError('SIGN_WIDEVINE_KEY ' + requiredText)
}

// check if widevine script exists
const fs = require('fs')
if (!fs.existsSync('tools/signature_generator.py')) {
raiseError('`tools/signature_generator.py` ' + requiredText)
}
}

if (isDarwin) {
const identifier = process.env.IDENTIFIER
if (!identifier) {
console.error('IDENTIFIER needs to be set to the certificate organization')
process.exit(1)
raiseError('IDENTIFIER needs to be set to the certificate organization')
}

const wvBundle = buildDir + '/Brave.app/Contents/Frameworks/Brave Framework.framework/Brave Framework'
const wvPlugin = buildDir + '/Brave.app/Contents/Frameworks/Brave Framework.framework/Libraries/WidevineCdm/_platform_specific/mac_x64/widevinecdmadapter.plugin'
cmds = [
// Remove old
'rm -f ' + outDir + '/Brave.dmg',
Expand All @@ -36,8 +63,12 @@ if (isDarwin) {
'cd ../../..',
'codesign --deep --force --strict --verbose --sign $IDENTIFIER Brave.app/',

// Package it into a dmg
// sign for widevine
'cd ..',
'python tools/signature_generator.py --input_file "' + wvBundle + '" --flag 1',
'python tools/signature_generator.py --input_file "' + wvPlugin + '"',

// Package it into a dmg
'build ' +
'--prepackaged="' + buildDir + '/Brave.app" ' +
'--mac=dmg ' +
Expand All @@ -53,32 +84,46 @@ if (isDarwin) {
var cert = process.env.CERT || '../brave-authenticode.pfx'
var certPassword = process.env.CERT_PASSWORD
if (!certPassword) {
throw new Error('Certificate password required. Set environment variable CERT_PASSWORD.')
raiseError('Certificate password required. Set environment variable CERT_PASSWORD.')
}

// Because both x64 and ia32 creates a RELEASES and a .nupkg file we
// need to store the output files in separate directories
outDir = path.join(outDir, arch)
// sign for widevine
const wvExe = buildDir + '/Brave.exe'
const wvPlugin = buildDir + '/WidevineCdm/_platform_specific/' + widevineCdmArch + '/widevinecdmadapter.dll'
cmds = [
'python tools/signature_generator.py --input_file "' + wvExe + '" --flag 1',
'python tools/signature_generator.py --input_file "' + wvPlugin + '"'
]
execute(cmds, {}, (err) => {
if (err) {
raiseError('signing for widevine failed' + JSON.stringify(err))
return
}

// Because both x64 and ia32 creates a RELEASES and a .nupkg file we
// need to store the output files in separate directories
outDir = path.join(outDir, arch)

var muonInstaller = require('muon-winstaller')
var resultPromise = muonInstaller.createWindowsInstaller({
appDirectory: buildDir,
outputDirectory: outDir,
title: 'Brave',
authors: 'Brave Software',
loadingGif: 'res/brave_splash_installing.gif',
setupIcon: 'res/brave_installer.ico',
iconUrl: 'https://brave.com/favicon.ico',
signWithParams: format('-a -fd sha256 -f "%s" -p "%s" -t http://timestamp.verisign.com/scripts/timstamp.dll', path.resolve(cert), certPassword),
noMsi: true,
exe: 'Brave.exe'
var muonInstaller = require('muon-winstaller')
var resultPromise = muonInstaller.createWindowsInstaller({
appDirectory: buildDir,
outputDirectory: outDir,
title: 'Brave',
authors: 'Brave Software',
loadingGif: 'res/brave_splash_installing.gif',
setupIcon: 'res/brave_installer.ico',
iconUrl: 'https://brave.com/favicon.ico',
signWithParams: format('-a -fd sha256 -f "%s" -p "%s" -t http://timestamp.verisign.com/scripts/timstamp.dll', path.resolve(cert), certPassword),
noMsi: true,
exe: 'Brave.exe'
})
resultPromise.then(() => {
cmds = [
`mv ${outDir}/Setup.exe ${outDir}/BraveSetup-${arch}.exe`
]
execute(cmds, {}, console.log.bind(null, 'done'))
}, (e) => console.log(`No dice: ${e.message}`))
})
resultPromise.then(() => {
cmds = [
`mv ${outDir}/Setup.exe ${outDir}/BraveSetup-${arch}.exe`
]
execute(cmds, {}, console.log.bind(null, 'done'))
}, (e) => console.log(`No dice: ${e.message}`))
} else if (isLinux) {
console.log('Install with sudo dpkg -i dist/brave_' + VersionInfo.braveVersion + '_amd64.deb')
console.log('Or install with sudo dnf install dist/brave_' + VersionInfo.braveVersion + '.x86_64.rpm')
Expand All @@ -100,13 +145,11 @@ if (isDarwin) {
]
execute(cmds, {}, (err) => {
if (err) {
console.error('buildInstaller failed', err)
process.exit(1)
raiseError('buildInstaller failed' + JSON.stringify(err))
return
}
console.log('done')
})
} else {
console.log('Installer not supported for platform: ' + process.platform)
process.exit(1)
raiseError('Installer not supported for platform: ' + process.platform)
}

0 comments on commit 86a538d

Please sign in to comment.