Skip to content

Commit

Permalink
Merge pull request #1412 from ubports/whatisbrokenwillbefixedagain
Browse files Browse the repository at this point in the history
Whatisbrokenwillbefixedagain
  • Loading branch information
NeoTheThird authored Oct 2, 2020
2 parents 6f9d1f9 + 6e7b7c2 commit cb01f9e
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 61 deletions.
5 changes: 4 additions & 1 deletion buildconfig-generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"platform-tools/${os}/**/*",
"build/icons/icon.*"
],
"asarUnpack": "platform-tools/${os}/**/*"
"asarUnpack": [
"platform-tools/${os}/**/*",
"node_modules/7zip-min/*"
]
}
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
Expand Down
4 changes: 4 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ parts:
- nodejs
- libgconf-2-4
stage-packages:
- libusb-1.0-0
- libnotify4
- libappindicator1
- libxtst6
Expand All @@ -65,3 +66,6 @@ parts:
prime:
- -node_modules
- -lib/node_modules
- -**/arm/**
- -**/arm64/**
- -**/ia32/**
111 changes: 54 additions & 57 deletions src/bugreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,77 +16,72 @@
*/

const axios = require("axios");
const os = require("os");
const cp = require("child_process");
const util = require("util");
const { osInfo } = require("systeminformation");

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
Expand Down Expand Up @@ -121,7 +116,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));
});
}
Expand Down
8 changes: 7 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -201,5 +207,5 @@ module.exports = {
setUdevRules,
getUpdateAvailable,
die,
unpack: util.promisify(require("7zip-min").unpack)
unpack: util.promisify(require(asarLibPathHack("7zip-min")).unpack)
};

0 comments on commit cb01f9e

Please sign in to comment.