From f44c2b777f17e3f4a7f8420fc63385e797efdc87 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Wed, 11 Mar 2020 01:12:07 +0000 Subject: [PATCH] Fix 'balena login' web auth on Linux standalone zip install (xdg-open ENOENT) Resolves: #1657 Change-type: patch --- automation/build-bin.ts | 1 + package.json | 2 ++ patches/open+7.0.2.patch | 15 +++++++++++++++ patches/opn-cli++opn+4.0.2.patch | 14 ++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 patches/open+7.0.2.patch create mode 100644 patches/opn-cli++opn+4.0.2.patch diff --git a/automation/build-bin.ts b/automation/build-bin.ts index 376f41b4..4705a77a 100644 --- a/automation/build-bin.ts +++ b/automation/build-bin.ts @@ -98,6 +98,7 @@ async function buildPkg() { const paths: Array<[string, string[], string[]]> = [ // [platform, [source path], [destination path]] ['*', ['open', 'xdg-open'], ['xdg-open']], + ['*', ['opn-cli', 'node_modules', 'opn', 'xdg-open'], ['xdg-open-402']], ['darwin', ['denymount', 'bin', 'denymount'], ['denymount']], ]; await Bluebird.map(paths, ([platform, source, dest]) => { diff --git a/package.json b/package.json index 4ba098a7..aefbaa79 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,8 @@ "build/auth/pages/*.ejs", "build/hooks", "node_modules/resin-discoverable-services/services/**/*", + "node_modules/opn-cli/node_modules/opn/xdg-open", + "node_modules/open/xdg-open", "node_modules/windosu/*.bat", "node_modules/windosu/*.cmd" ] diff --git a/patches/open+7.0.2.patch b/patches/open+7.0.2.patch new file mode 100644 index 00000000..bec1363f --- /dev/null +++ b/patches/open+7.0.2.patch @@ -0,0 +1,15 @@ +diff --git a/node_modules/open/index.js b/node_modules/open/index.js +index 5fe49ad..c9194ba 100644 +--- a/node_modules/open/index.js ++++ b/node_modules/open/index.js +@@ -10,7 +10,9 @@ const pAccess = promisify(fs.access); + const pExecFile = promisify(childProcess.execFile); + + // Path to included `xdg-open`. +-const localXdgOpenPath = path.join(__dirname, 'xdg-open'); ++const localXdgOpenPath = process.pkg ++ ? path.join(path.dirname(process.execPath), 'xdg-open') ++ : path.join(__dirname, 'xdg-open'); + + // Convert a path from WSL format to Windows format: + // `/mnt/c/Program Files/Example/MyApp.exe` → `C:\Program Files\Example\MyApp.exe` diff --git a/patches/opn-cli++opn+4.0.2.patch b/patches/opn-cli++opn+4.0.2.patch new file mode 100644 index 00000000..f17438e9 --- /dev/null +++ b/patches/opn-cli++opn+4.0.2.patch @@ -0,0 +1,14 @@ +diff --git a/node_modules/opn-cli/node_modules/opn/index.js b/node_modules/opn-cli/node_modules/opn/index.js +index 13dcb66..16c5b2a 100644 +--- a/node_modules/opn-cli/node_modules/opn/index.js ++++ b/node_modules/opn-cli/node_modules/opn/index.js +@@ -52,6 +52,9 @@ module.exports = function (target, opts) { + cmd = opts.app; + } else { + cmd = path.join(__dirname, 'xdg-open'); ++ cmd = process.pkg ++ ? path.join(path.dirname(process.execPath), 'xdg-open-402') ++ : path.join(__dirname, 'xdg-open'); + } + + if (appArgs.length > 0) {