diff --git a/automation/build-bin.ts b/automation/build-bin.ts index 82aefebf..506dd536 100755 --- a/automation/build-bin.ts +++ b/automation/build-bin.ts @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import * as Bluebird from 'bluebird'; import * as filehound from 'filehound'; import * as fs from 'fs-extra'; import * as path from 'path'; @@ -24,12 +25,22 @@ const ROOT = path.join(__dirname, '..'); console.log('Building package...\n'); execPkg(['--target', 'host', '--output', 'build-bin/balena', 'package.json']) - .then(() => - fs.copy( - path.join(ROOT, 'node_modules', 'opn', 'xdg-open'), - path.join(ROOT, 'build-bin', 'xdg-open'), - ), - ) + .then(() => { + const xpaths: Array<[string, string[]]> = [ + // [platform, [path, to, file]] + ['*', ['opn', 'xdg-open']], + ['darwin', ['denymount', 'bin', 'denymount']], + ]; + return Bluebird.map(xpaths, ([platform, xpath]) => { + if (platform === '*' || platform === process.platform) { + // eg copy from node_modules/opn/xdg-open to build-bin/xdg-open + return fs.copy( + path.join(ROOT, 'node_modules', ...xpath), + path.join(ROOT, 'build-bin', xpath.pop()!), + ); + } + }).return(); + }) .then(() => { return filehound .create() diff --git a/package.json b/package.json index ad3fb2d7..948b31de 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ ] }, "scripts": { - "prebuild": "rimraf build/ build-bin/ build-zip/", + "prebuild": "rimraf build/ build-bin/ build-zip/ && patch-package", "build": "npm run build:src && npm run build:bin", "build:src": "npm run prettify && npm run lint && npm run build:fast && npm run build:doc", "build:fast": "gulp build && tsc", @@ -91,6 +91,7 @@ "gulp-mocha": "^2.0.0", "gulp-shell": "^0.5.2", "mochainon": "^2.0.0", + "patch-package": "^6.1.2", "pkg": "^4.3.8", "prettier": "^1.17.0", "publish-release": "^1.3.3", @@ -125,7 +126,7 @@ "color-hash": "^1.0.3", "columnify": "^1.5.2", "common-tags": "^1.7.2", - "denymount": "^2.2.0", + "denymount": "~2.2.0", "docker-progress": "^4.0.0", "docker-qemu-transpose": "^0.5.3", "docker-toolbelt": "^3.3.7", diff --git a/patches/denymount+2.2.0.patch b/patches/denymount+2.2.0.patch new file mode 100644 index 00000000..2e166ab4 --- /dev/null +++ b/patches/denymount+2.2.0.patch @@ -0,0 +1,38 @@ +diff --git a/node_modules/denymount/lib/index.js b/node_modules/denymount/lib/index.js +index 93b8e59..86d53dc 100644 +--- a/node_modules/denymount/lib/index.js ++++ b/node_modules/denymount/lib/index.js +@@ -24,7 +24,9 @@ var utils = require('./utils'); + * @module denymount + */ + +-var EXECUTABLE_PATH = path.join(__dirname, '..', 'bin', 'denymount'); ++var EXECUTABLE_PATH = process.pkg ++ ? path.join(path.dirname(process.execPath), 'denymount') ++ : path.join(__dirname, '..', 'bin', 'denymount'); + + /** + * @summary Prevent automatic mounting of an OS X disk +diff --git a/node_modules/denymount/lib/index.js.rej b/node_modules/denymount/lib/index.js.rej +new file mode 100644 +index 0000000..a2c0516 +--- /dev/null ++++ b/node_modules/denymount/lib/index.js.rej +@@ -0,0 +1,17 @@ ++*************** ++*** 24,30 **** ++ * @module denymount ++ */ ++ ++- var EXECUTABLE_PATH = path.join(__dirname, '..', 'bin', 'denymount'); ++ ++ /** ++ * @summary Prevent automatic mounting of an OS X disk ++--- 24,30 ---- ++ * @module denymount ++ */ ++ +++ var EXECUTABLE_PATH = path.join(path.dirname(process.execPath), 'denymount', 'bin', 'denymount'); ++ ++ /** ++ * @summary Prevent automatic mounting of an OS X disk