From 55d88adbd4b1b008dbb76270b9a658299ba6b694 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Fri, 2 Oct 2020 16:51:28 +0200 Subject: [PATCH 1/5] Resolve snap build warnings --- snap/snapcraft.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 5b3ca923..3e7160ec 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -41,6 +41,7 @@ parts: - nodejs - libgconf-2-4 stage-packages: + - libusb-1.0-0 - libnotify4 - libappindicator1 - libxtst6 @@ -65,3 +66,6 @@ parts: prime: - -node_modules - -lib/node_modules + - -**/arm/** + - -**/arm64/** + - -**/ia32/** From e027da2c9dc9fd679fa69f5b27d282b87dc3113e Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Fri, 2 Oct 2020 16:53:25 +0200 Subject: [PATCH 2/5] EXTREMELY ugly hack to fix #1407 and fix #1409 --- buildconfig-generic.json | 5 ++++- src/utils.js | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/buildconfig-generic.json b/buildconfig-generic.json index e140a137..c31d39b1 100644 --- a/buildconfig-generic.json +++ b/buildconfig-generic.json @@ -9,5 +9,8 @@ "platform-tools/${os}/**/*", "build/icons/icon.*" ], - "asarUnpack": "platform-tools/${os}/**/*" + "asarUnpack": [ + "platform-tools/${os}/**/*", + "node_modules/7zip-min/*" + ] } diff --git a/src/utils.js b/src/utils.js index 692138d8..e560ceef 100644 --- a/src/utils.js +++ b/src/utils.js @@ -189,6 +189,12 @@ function errorToUser(error, errorLocation, restart, ignore) { global.mainEvent.emit("user:error", errorString, restart, ignore); } +// HACK: Oh my fucking god. This is stupid. This is, in fact, so stupid, that i almost cannot believe that i will have to commit this as-is. But here goes: We've long known that executing binaries in the asar package is not possible, so the binaries need to be unpacked. We can not, however, require the unpacked lib, hence we do a stupid hack to get the normal binary from node_modules when running from source and the unpacked one otherwise. I hate everything about this, but it works. If someone knows a better way, i'll be forever grateful. +const asarLibPathHack = lib => + global.packageInfo.package || isSnap() + ? path.join(__dirname, "../../app.asar.unpacked/node_modules/", lib) + : lib; + module.exports = { cleanInstallerCache, errorToUser, @@ -201,5 +207,5 @@ module.exports = { setUdevRules, getUpdateAvailable, die, - unpack: util.promisify(require("7zip-min").unpack) + unpack: util.promisify(require(asarLibPathHack("7zip-min")).unpack) }; From ba324eecfe6534eb7f0f95fdc8820235c9a4286d Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Fri, 2 Oct 2020 18:18:56 +0200 Subject: [PATCH 3/5] Streamline osstring, fixes #1408 --- package-lock.json | 5 +++ package.json | 1 + src/bugreport.js | 111 +++++++++++++++++++++++----------------------- 3 files changed, 61 insertions(+), 56 deletions(-) diff --git a/package-lock.json b/package-lock.json index a454161a..3295aea2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4920,6 +4920,11 @@ } } }, + "systeminformation": { + "version": "4.27.6", + "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-4.27.6.tgz", + "integrity": "sha512-uFs6VAt/hhsBqb+2i9oH+tXm/uCP6e6lw4olfor5s5OkkZxYqisGvtSNXsLnSe27anF+tzyXte764MNJqXU9eg==" + }, "table": { "version": "5.4.6", "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", diff --git a/package.json b/package.json index 454e6837..d69ab736 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "ps-tree": "^1.2.0", "sudo-prompt": "^9.2.1", "system-image-node-module": "^1.1.0", + "systeminformation": "^4.27.6", "ubports-api-node-module": "^3.0.2", "winston": "^3.3.3" } diff --git a/src/bugreport.js b/src/bugreport.js index 7f31ccde..ff791200 100644 --- a/src/bugreport.js +++ b/src/bugreport.js @@ -16,77 +16,74 @@ */ const axios = require("axios"); +const util = require("util"); const os = require("os"); +const { osInfo } = require("systeminformation"); const cp = require("child_process"); -const util = require("util"); const FormData = require("form-data"); -const getDeviceString = () => - global.installProperties.device - ? `%60${global.installProperties.device}%60` - : "Not detected"; - -const getTargetOsString = () => - !util.isUndefined(global.installProperties.osIndex) - ? global.installConfig.operating_systems[global.installProperties.osIndex] - .name - : "Not yet set"; +function getDeviceString() { + try { + return global.installProperties.device + ? `%60${global.installProperties.device}%60` + : "Not detected"; + } catch (e) { + return "unknown"; + } +} -const getSettingsString = () => - `%60${JSON.stringify(global.installProperties.settings || {})}%60`; +function getTargetOsString() { + try { + return !util.isUndefined(global.installProperties.osIndex) + ? global.installConfig.operating_systems[global.installProperties.osIndex] + .name + : "Not yet set"; + } catch (e) { + return "unknown"; + } +} -const getPackageString = () => - `%60${ - process.env.SNAP_NAME ? "snap" : global.packageInfo.package || "source" - }%60`; +function getSettingsString() { + try { + `%60${JSON.stringify(global.installProperties.settings || {})}%60`; + } catch (e) { + return "unknown"; + } +} -const getOsString = () => { +function getPackageString() { try { - let versionString = ""; - switch (process.platform) { - case "linux": - versionString = cp - .execSync("lsb_release -ds") - .toString() - .trim(); - break; - case "darwin": - versionString = - cp - .execSync("sw_vers -productVersion") - .toString() - .trim() + - cp - .execSync("sw_vers -buildVersion") - .toString() - .trim(); - break; - case "win32": - versionString = cp - .execSync("ver") - .toString() - .trim(); - break; - default: - break; - } - return ["%60", os.type(), versionString, os.release(), os.arch(), "%60"] - .filter(i => i) - .join(" "); - } catch (error) { - log.error(error); - return `%60${process.platform}%60`; + return `%60${ + process.env.SNAP_NAME ? "snap" : global.packageInfo.package || "source" + }%60`; + } catch (e) { + return "unknown"; } -}; +} + +function getOsString(hostOs) { + return [ + hostOs.distro, + hostOs.release, + hostOs.codename, + hostOs.platform, + hostOs.kernel, + hostOs.arch, + hostOs.build, + hostOs.servicepack + ] + .filter(i => i) + .join(" "); +} -const getDebugInfo = (reason, logurl) => +const getDebugInfo = (reason, logurl, hostOs) => `UBports Installer: %60${global.packageInfo.version}%60 %0D%0A Device: ${getDeviceString()} %0D%0A OS to install: ${getTargetOsString()} %0D%0A Settings: ${getSettingsString()} %0D%0A Package: ${getPackageString()} %0D%0A -Operating System: ${getOsString()} %0D%0A +Operating System: ${getOsString(hostOs)} %0D%0A NodeJS version: %60${process.version}%60 %0D%0A Error log: ${logurl} %0D%0A %60%60%60 %0D%0A @@ -121,7 +118,9 @@ function createBugReport(title, callback) { axios .post("http://paste.ubuntu.com", form, { headers: form.getHeaders() }) .then(r => `https://paste.ubuntu.com/${r.request.path}`) - .then(logurl => callback(getDebugInfo(title, logurl))) + .then(logurl => + osInfo(hostOs => callback(getDebugInfo(title, logurl, hostOs))) + ) .catch(() => callback(false)); }); } From 1c9087c9f11edf5941725e192cb9a31216696b7d Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Fri, 2 Oct 2020 18:21:24 +0200 Subject: [PATCH 4/5] Remove uneeded imports --- src/bugreport.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/bugreport.js b/src/bugreport.js index ff791200..ff8a6ed7 100644 --- a/src/bugreport.js +++ b/src/bugreport.js @@ -17,9 +17,7 @@ const axios = require("axios"); const util = require("util"); -const os = require("os"); const { osInfo } = require("systeminformation"); -const cp = require("child_process"); const FormData = require("form-data"); From 6e7b7c2bdda8fbbd84c5c3f77c50accd92208de6 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Fri, 2 Oct 2020 18:26:24 +0200 Subject: [PATCH 5/5] Bump version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3295aea2..1401221f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ubports-installer", - "version": "0.5.1-beta", + "version": "0.5.2-beta", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d69ab736..3e5acd05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ubports-installer", - "version": "0.5.1-beta", + "version": "0.5.2-beta", "description": "The easy way to install Ubuntu Touch on UBports devices. A friendly cross-platform Installer for Ubuntu Touch. Just connect a supported device to your PC, follow the on-screen instructions and watch this awesome tool do all the rest.", "keywords": [ "Ubuntu",