Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Apple Silicon package support #257

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"description": "Brave IPFS local node component",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2qqbXvEZP1dlJW7FhKLB+8ZTRF4mZjxRwU9VMyPrymWhAyhurtp2eIaAY2YiFMAfg4v3Eragxlt4+fL0QETclkmRUTvZ4wm93HODXPfL8LvKoFDBsjv9vnsT+PDonnpQBKdgRGpVYxxDY3vYu4AIKuLLY1tOGnC7XNiQWPSnagSycdQfTxdmPaiEwDde1jYcBVyIbZPkiE2F+np9jQahSKJJOKGmBaL/YO9xmjIBfPopwVVyVJPAIH6SPxI+XQMpYA1zagih5ULm+wXBNYcqXn9W/KQPkB4HKZ0eVgcKKS6T8lwDhB2oYAaTtxRno5Fu6wlEQBGmdFxqJw8KNPu2JQIDAQAB",
"manifest_version": 2,
"name": "Brave IPFS local node (macOS)",
"version": "0.0.0"
}
26 changes: 14 additions & 12 deletions scripts/downloadIpfsDaemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,29 @@ const util = require('../lib/util')
const ipfsVersion = '0.10.0'

// Downloads the current (platform-specific) Ipfs Daemon from ipfs.io
const downloadIpfsDaemon = (platform) => {
const downloadIpfsDaemon = (platform, arch) => {
const ipfsPath = path.join('build', 'ipfs-daemon-updater', 'downloads')

const ipfsDistPrefix = `https://cloudflare-ipfs.com/ipns/dist.ipfs.io/go-ipfs/v${ipfsVersion}/`

const zipSuffix = platform === 'win32' ? '.zip' : '.tar.gz'
const myplatform = platform === 'win32' ? 'windows' : platform

const ipfsFilename = `go-ipfs_v${ipfsVersion}_${myplatform}-amd64`
const build = `${myplatform}-${arch}`
const ipfsFilename = `go-ipfs_v${ipfsVersion}_${build}`
const ipfsURL = ipfsDistPrefix + ipfsFilename + zipSuffix

let sha512IPFS = ''

switch (platform) {
case 'darwin':
switch (build) {
case 'darwin-amd64':
sha512IPFS = '5a010789a0b91c859fd131abb51118b5ff1fe865ebee9ba3bc9283685abbc673f0a95ea4113a4bb16c6c4b4627bbae062d0a1fc00d2c1f82371913e9dc43a8a7'
break
case 'linux':
case 'darwin-arm64':
sha512IPFS = '30f83d12ce90aec6c0e9e65d9e8bfba5b9f3039f82472a602dfb95818351dd93c1151630425af6511f030fb2d9baacb65fc068bc6c7ba2686e2030824075df64'
break
case 'linux-amd64':
sha512IPFS = 'bb0fe78a3142489fd6b7f608053b2e20cd9a4788febbeb4a0413783ac00306842451678f0953a917c459dfa69e4308f381ca0b6385f221dd70f7e01190bce2d1'
break
case 'win32':
case 'windows-amd64':
sha512IPFS = '7b0c17696330652af1c8709aaea8bee460e51cd3091e8128e4603b6f5c5d774344500e139f0aba1e98e7cabe6ee56f2b2958bad5dea1df7e773d747fbec9058b'
break
default:
Expand All @@ -48,7 +50,6 @@ const downloadIpfsDaemon = (platform) => {

// Download and decompress the client
execSync(cmd)

// Verify the checksum
if (!verifyChecksum(ipfsDaemon, sha512IPFS)) {
console.error('Ipfs Daemon checksum verification failed')
Expand All @@ -69,9 +70,10 @@ const verifyChecksum = (file, hash) => {

util.installErrorHandlers()

downloadIpfsDaemon('darwin')
downloadIpfsDaemon('linux')
downloadIpfsDaemon('win32')
downloadIpfsDaemon('darwin', 'amd64')
downloadIpfsDaemon('darwin', 'arm64')
downloadIpfsDaemon('linux', 'amd64')
downloadIpfsDaemon('win32', 'amd64')

module.exports = {
ipfsVersion,
Expand Down
18 changes: 10 additions & 8 deletions scripts/packageIpfsDaemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@ const replace = require('replace-in-file')
const util = require('../lib/util')
const ipfsVersion = '0.10.0'

const getIpfsDaemonPath = (platform) => {
const getIpfsDaemonPath = (os, arch) => {
const ipfsPath = path.join('build', 'ipfs-daemon-updater', 'downloads')
const myplatform = platform === 'win32' ? 'windows' : platform
const ipfsFilename = `go-ipfs_v${ipfsVersion}_${myplatform}-amd64`
const myplatform = os === 'win32' ? 'windows' : os
const ipfsFilename = `go-ipfs_v${ipfsVersion}_${myplatform}-${arch}`
return path.join(ipfsPath, ipfsFilename)
}

const getOriginalManifest = (platform) => {
return path.join('manifests', 'ipfs-daemon-updater', `ipfs-daemon-updater-${platform}-manifest.json`)
}

const packageIpfsDaemon = (binary, endpoint, region, platform, key) => {
const packageIpfsDaemon = (binary, endpoint, region, os, arch, key) => {
const platform = `${os}-${arch}`
const originalManifest = getOriginalManifest(platform)
const parsedManifest = util.parseManifest(originalManifest)
const id = util.getIDFromBase64PublicKey(parsedManifest.key)

util.getNextVersion(endpoint, region, id).then((version) => {
const stagingDir = path.join('build', 'ipfs-daemon-updater', platform)
const ipfsDaemon = getIpfsDaemonPath(platform)
const ipfsDaemon = getIpfsDaemonPath(os, arch)
const crxOutputDir = path.join('build', 'ipfs-daemon-updater')
const crxFile = path.join(crxOutputDir, `ipfs-daemon-updater-${platform}.crx`)
const privateKeyFile = !fs.lstatSync(key).isDirectory() ? key : path.join(key, `ipfs-daemon-updater-${platform}.pem`)
Expand Down Expand Up @@ -85,7 +86,8 @@ if (!commander.binary) {
}

util.createTableIfNotExists(commander.endpoint, commander.region).then(() => {
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'darwin', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'linux', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'win32', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'darwin', 'amd64', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'linux', 'amd64', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'win32', 'amd64', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'darwin', 'arm64', keyParam)
})