git ssb

38+

cel / git-ssb



Commit 42671ef3ec834bd5350812e5769af6efd97e6609

Use pkg, with sodium-native loader

cel committed on 12/30/2019, 5:36:42 AM
Parent: 9b7c99d8b6a6f163f052456546ed18a0af06156b

Files changed

bin/git-ssbchanged
package.jsonchanged
build.jsadded
bin/git-ssbView
@@ -1,6 +1,40 @@
11 #!/usr/bin/env node
22
3 +// Install sodium-native prebuild
4 +if (process.env.SODIUM_NATIVE_PREBUILD == null) {
5 + var fs = require('fs')
6 + var os = require('os')
7 + var path = require('path')
8 + var mkdirp = require('mkdirp')
9 + var home = os.homedir()
10 + var pkgJson = require('../package')
11 + var sodiumDir = path.join(home, '.local', 'lib', 'sodium-native')
12 + // Copy sodium-native prebuild and libsodium shared library into local dir.
13 + // Set env var to make node-gyp-build look there for sodium-native prebuilds.
14 + process.env.SODIUM_NATIVE_PREBUILD = sodiumDir
15 + var prebuildsDir = path.join(sodiumDir, 'prebuilds')
16 + var abi = process.versions.modules
17 + var arch = os.arch()
18 + var platform = os.platform()
19 + var platformArch = platform + '-' + arch
20 + var libsodium = 'libsodium.so.' + pkgJson.libsodiumVersion
21 + var sodiumNative = 'node.abi' + abi + '.node'
22 + var archDir = path.join(prebuildsDir, platformArch)
23 + var libsodiumFile = path.join(archDir, libsodium)
24 + var sodiumNativeFile = path.join(archDir, sodiumNative)
25 + try {
26 + fs.accessSync(libsodiumFile)
27 + fs.accessSync(sodiumNativeFile)
28 + } catch(e) {
29 + mkdirp.sync(archDir)
30 + fs.writeFileSync(libsodiumFile,
31 + fs.readFileSync(path.join(__dirname, '../libsodium.so')))
32 + fs.writeFileSync(sodiumNativeFile,
33 + fs.readFileSync(path.join(__dirname, '../sodium.foolpkg')))
34 + }
35 +}
36 +
337 var u = require('../lib/util')
438 var config = require('ssb-config/inject')(u.getAppName())
539 var fn = require('../lib').fn
640 try {
package.jsonView
@@ -6,11 +6,23 @@
66 "git-ssb": "bin/git-ssb",
77 "git-remote-ssb": "bin/git-remote-ssb"
88 },
99 "main": "bin.js",
10 + "pkg": {
11 + "scripts": "lib/*.js",
12 + "assets": [
13 + "libsodium.so",
14 + "sodium.foolpkg"
15 + ]
16 + },
17 + "scripts": {
18 + "build": "node build.js"
19 + },
20 + "libsodiumVersion": "23",
1021 "dependencies": {
1122 "git-remote-ssb": "^2.1.1",
1223 "git-ssb-web": "^2.11.4",
24 + "mkdirp": "^0.5.1",
1325 "multicb": "^1.2.1",
1426 "pull-cat": "^1.1.11",
1527 "pull-git-repo": "^1.3.1",
1628 "pull-paramap": "^1.2.2",
@@ -26,8 +38,11 @@
2638 "ssb-pull-requests": "^1.0.0",
2739 "ssb-ref": "^2.11.1",
2840 "stream-to-pull-stream": "^1.7.2"
2941 },
42 + "devDependencies": {
43 + "pkg": "*"
44 + },
3045 "repository": {
3146 "type": "git",
3247 "url": "https://git.scuttlebot.io/%25n92DiQh7ietE%2BR%2BX%2FI403LQoyf2DtR3WQfCkDKlheQU%3D.sha256"
3348 },
build.jsView
@@ -1,0 +1,24 @@
1 +var os = require('os')
2 +var proc = require('child_process')
3 +var path = require('path')
4 +var fs = require('fs')
5 +var pkgJson = require('./package')
6 +
7 +var arch = os.arch()
8 +var platform = os.platform()
9 +var abi = process.versions.modules
10 +
11 +var prebuildsDir = path.join(__dirname,
12 + 'node_modules/sodium-native/prebuilds/' + platform + '-' + arch)
13 +fs.writeFileSync(path.join(__dirname, 'libsodium.so'),
14 + fs.readFileSync(path.join(prebuildsDir, 'libsodium.so.' + pkgJson.libsodiumVersion)))
15 +fs.writeFileSync(path.join(__dirname, 'sodium.foolpkg'),
16 + fs.readFileSync(path.join(prebuildsDir, 'node.abi' + abi + '.node')))
17 +
18 +proc.spawn('pkg', [
19 + path.join(__dirname, 'bin/git-ssb'),
20 + '-c', 'package.json',
21 + '--public',
22 + '-t', 'node10.15.3-linux-arm64',
23 + '-o', 'git-ssb'
24 +], {stdio: 'inherit'})

Built with git-ssb-web