Skip to content

Commit

Permalink
Added Apple Silicon package
Browse files Browse the repository at this point in the history
  • Loading branch information
spylogsster committed Oct 5, 2021
1 parent 45fcfc2 commit 3f11b04
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 24 deletions.
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
26 changes: 14 additions & 12 deletions scripts/packageIpfsDaemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,29 @@ const replace = require('replace-in-file')
const util = require('../lib/util')
const ipfsVersion = '0.10.0'

const getIpfsDaemonPath = (platform) => {
const getIpfsDaemonPath = (platform, 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 build = `${myplatform}-${arch}`
const ipfsFilename = `go-ipfs_v${ipfsVersion}_${build}`
return path.join(ipfsPath, ipfsFilename)
}

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

const packageIpfsDaemon = (binary, endpoint, region, platform, key) => {
const originalManifest = getOriginalManifest(platform)
const packageIpfsDaemon = (binary, endpoint, region, platform, arch, key) => {
const originalManifest = getOriginalManifest(platform, arch)
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(platform, 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`)
const crxFile = path.join(crxOutputDir, `ipfs-daemon-updater-${platform}-${arch}.crx`)
const privateKeyFile = !fs.lstatSync(key).isDirectory() ? key : path.join(key, `ipfs-daemon-updater-${platform}-${arch}.pem`)
stageFiles(platform, ipfsDaemon, version, stagingDir)
util.generateCRXFile(binary, crxFile, privateKeyFile, stagingDir)
console.log(`Generated ${crxFile} with version number ${version}`)
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, 'darwin', 'arm64', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'linux', 'amd64', keyParam)
packageIpfsDaemon(commander.binary, commander.endpoint, commander.region, 'win32', 'amd64', keyParam)
})

0 comments on commit 3f11b04

Please sign in to comment.