From 8a2d500cf18211dcd564afb4f2dfb3a1d1018bf6 Mon Sep 17 00:00:00 2001 From: SReject Date: Thu, 2 Mar 2023 09:27:06 -0500 Subject: [PATCH 1/3] fix: bless for arm64 machines --- lib/appdmg.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/appdmg.js b/lib/appdmg.js index 77748bf..a227f77 100644 --- a/lib/appdmg.js +++ b/lib/appdmg.js @@ -4,6 +4,8 @@ const fs = require('fs') const os = require('os') const path = require('path') +const execFile = require('child_process').execFile + const async = require('async') const DSStore = require('ds-store') const sizeOf = require('image-size') @@ -69,6 +71,8 @@ module.exports = exports = function (options) { const global = parseOptions(options) const resolvePath = (to) => path.resolve(global.resolveBase, to) + let isRosetta = false; + const pipeline = new Pipeline() /** @@ -391,6 +395,26 @@ module.exports = exports = function (options) { ds.write(path.join(global.temporaryMountPath, '.DS_Store'), (err) => next(err)) }) + /** + ** + **/ + + pipeline.addStep('Checking if running under Rosetta', function (next) { + execFile( + 'sysctl', + ['-ni', 'sysctl.proc_translated'], + (error, stdout, stderr) => { + + const result = stdout.trim(); + if (!error && !stderr && result != null) { + isRosetta = result == 1 || result == 0; + } + + next() + } + ); + }); + /** ** **/ @@ -402,7 +426,7 @@ module.exports = exports = function (options) { '--folder', global.temporaryMountPath ] - if (os.arch() !== 'arm64') { + if (!isRosetta && os.arch() !== 'arm64') { args.push('--openfolder', global.temporaryMountPath) } From 1f5eaeb054a74ec917db7c75a8619b6d009f0f73 Mon Sep 17 00:00:00 2001 From: SReject Date: Thu, 2 Mar 2023 09:41:07 -0500 Subject: [PATCH 2/3] feat: generalize sysctl output check --- lib/appdmg.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/appdmg.js b/lib/appdmg.js index a227f77..53bc053 100644 --- a/lib/appdmg.js +++ b/lib/appdmg.js @@ -406,8 +406,8 @@ module.exports = exports = function (options) { (error, stdout, stderr) => { const result = stdout.trim(); - if (!error && !stderr && result != null) { - isRosetta = result == 1 || result == 0; + if (!error && !stderr && result != null && result !== '') { + isRosetta = true; } next() From 872599493f64dbd192fd69adea33633a563e3a5d Mon Sep 17 00:00:00 2001 From: SReject Date: Fri, 3 Mar 2023 07:59:05 -0500 Subject: [PATCH 3/3] feat: switch to using util.sh --- lib/appdmg.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/appdmg.js b/lib/appdmg.js index 53bc053..238ad68 100644 --- a/lib/appdmg.js +++ b/lib/appdmg.js @@ -4,8 +4,6 @@ const fs = require('fs') const os = require('os') const path = require('path') -const execFile = require('child_process').execFile - const async = require('async') const DSStore = require('ds-store') const sizeOf = require('image-size') @@ -400,19 +398,20 @@ module.exports = exports = function (options) { **/ pipeline.addStep('Checking if running under Rosetta', function (next) { - execFile( + util.sh( 'sysctl', ['-ni', 'sysctl.proc_translated'], - (error, stdout, stderr) => { - - const result = stdout.trim(); - if (!error && !stderr && result != null && result !== '') { + (error, result) => { + if ( + error == null && + result.errno === 0 && + result.stdout !== '' + ) { isRosetta = true; } - next() - } - ); + next(); + }); }); /**