Skip to content

Commit

Permalink
Merge pull request #945 from ubports/snap-nocompile
Browse files Browse the repository at this point in the history
Fix snap build
  • Loading branch information
NeoTheThird authored Oct 24, 2019
2 parents 612dc1b + d3a6469 commit 26eda98
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
3 changes: 2 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ function extractPlatformTools(platformToolsArray, callback) {
overwrite: true
}, (e) => {
fs.removeSync(path.join(i.path, i.target + "_tmp"));
if (i.target != "win") {
if (cli.os !== "win") {
fs.chmodSync(path.join(i.path, i.target, "fastboot"), 0o755);
fs.chmodSync(path.join(i.path, i.target, "adb"), 0o755);
fs.chmodSync(path.join(i.path, i.target, "mke2fs"), 0o755);
}
if (platformToolsArray.length <= 1) {
callback()
Expand Down
3 changes: 2 additions & 1 deletion buildconfig-generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"node_modules/**/*",
"platform-tools/${os}/**/*",
"build/icons/icon.*"
]
],
"asarUnpack": "platform-tools/${os}/**/*"
}
12 changes: 0 additions & 12 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,3 @@ parts:
prime:
- -node_modules
- -lib/node_modules
android-tools:
source: https://github.com/ubports/android-tools.git
plugin: make
build-packages:
- gir1.2-glib-2.0
- libglib2.0-dev
- libselinux-dev
- libhybris-dev
- libsystemd-dev
- libssl-dev
- python
- zlib1g-dev
15 changes: 2 additions & 13 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const Fastboot = require('promise-android-tools').Fastboot;
const Api = require("ubports-api-node-module").Installer;

var winston = require('winston');
const exec = require('child_process').exec;
const path = require('path');
const url = require('url');
const events = require("events");
Expand All @@ -50,19 +49,11 @@ const devices = require('./devices.js');
const api = new Api();
global.api = api;
var adb = new Adb({
exec: (args, callback) => { exec(
[(path.join(utils.getUbuntuTouchDir(), 'platform-tools', 'adb'))].concat(args).join(" "),
{options: {maxBuffer: 1024*1024*2}},
callback
); }
exec: (args, callback) => { utils.execTool("adb", args, callback); }
});
global.adb = adb;
var fastboot = new Fastboot({
exec: (args, callback) => { exec(
[(path.join(utils.getUbuntuTouchDir(), 'platform-tools', 'fastboot'))].concat(args).join(" "),
{options: {maxBuffer: 1024*1024*2}},
callback
); }
exec: (args, callback) => { utils.execTool("fastboot", args, callback); }
});
global.fastboot = fastboot;

Expand Down Expand Up @@ -96,8 +87,6 @@ global.installProperties = {

global.packageInfo.isSnap = utils.isSnap();

utils.exportExecutablesFromPackage();

//==============================================================================
// WINSTOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOON!
//==============================================================================
Expand Down
25 changes: 11 additions & 14 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

const http = require("request");
const download = require("download");
const exec = require('child_process').exec;
const os = require("os");
const fs = require("fs-extra");
const path = require("path");
Expand Down Expand Up @@ -75,7 +76,7 @@ function createBugReport(title, installProperties, callback) {
"UBports Installer Version: " + global.packageInfo.version + " %0D%0A" +
"Device: " + (installProperties.device ? installProperties.device : "Not detected") + "%0D%0A" +
"Channel: " + (installProperties.settings && installProperties.settings.channel ? installProperties.settings.channel : "Not yet set") + "%0D%0A" +
"Package: " + (isSnap() ? "snap" : (packageInfo.package || "source")) + "%0D%0A" +
"Package: " + (isSnap() ? "snap" : (global.packageInfo.package || "source")) + "%0D%0A" +
"Operating System: " + getCleanOs() + " " + os.arch() + " %0D%0A" +
"NodeJS version: " + process.version + " %0D%0A%0D%0A" +
"Error log: https://paste.ubuntu.com/" + res.headers.location + " %0D%0A");
Expand Down Expand Up @@ -153,18 +154,14 @@ function die(e) {
process.exit(-1);
}

// WORKAROUND: the chile spawned by child_process.exec can not access files inside the asar package
function exportExecutablesFromPackage() {
fs.copy(
path.join(__dirname, "..", "platform-tools", platforms[os.platform()]),
path.join(utils.getUbuntuTouchDir(), 'platform-tools'),
() => {
if (os.platform() !== "win32") {
["adb", "fastboot", "mke2fs"].map(exe => path.join(utils.getUbuntuTouchDir(), 'platform-tools', exe)).forEach((tool) => {
fs.chmodSync(tool, 0o755);
});
}
}
let toolpath = global.packageInfo.package ?
path.join(__dirname, "../../app.asar.unpacked/platform-tools", platforms[os.platform()]) :
path.join(__dirname, "..", "platform-tools", platforms[os.platform()]);
function execTool(tool, args, callback) {
exec(
[path.join(toolpath, tool)].concat(args).join(" "),
{options: {maxBuffer: 1024*1024*2}},
callback
);
}

Expand Down Expand Up @@ -269,10 +266,10 @@ function errorToUser(error, errorLocation) {

module.exports = {
errorToUser: errorToUser,
exportExecutablesFromPackage: exportExecutablesFromPackage,
downloadFiles: downloadFiles,
log: log,
isSnap: isSnap,
execTool: execTool,
getUbuntuTouchDir: getUbuntuTouchDir,
createBugReport: createBugReport,
getUpdateAvailable: getUpdateAvailable,
Expand Down

0 comments on commit 26eda98

Please sign in to comment.