-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuilder_ubuntu.ts
More file actions
123 lines (100 loc) · 3.86 KB
/
builder_ubuntu.ts
File metadata and controls
123 lines (100 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"use strict";
import * as async from "async";
import * as child_process from "child_process";
import * as fse from "fs-extra";
import * as path from "path";
import { Builder, IBuilderCallback } from "./builder";
import { BuilderError } from "./builder_error";
import { ICompilation } from "./compilation";
import * as globals from "./globals";
export class UbuntuBuilder extends Builder {
protected get getJson(): null {
return null;
}
public constructor(env: globals.CocoonEnvironment, data: ICompilation, configPath: string, logLevel?: string) {
super(env, data, configPath, logLevel);
this.name = "UbuntuBuilder";
}
protected build(cb: IBuilderCallback): void {
this.logger.debug("[build]");
const tasks: Array<async.AsyncFunction<any, {} | Error>> = [];
// If there is a key set we get add signing tasks
if (this.data.platform.key) {
tasks.push(
this.createCertsFolder.bind(this),
this.buildJson.bind(this),
);
}
tasks.push(
async.apply(this.compile.bind(this), {}),
this.archive.bind(this),
);
// Start building tasks sequence execution
async.waterfall(tasks, (err: BuilderError) => {
if (err) {
cb(err);
return;
}
cb();
});
}
protected pack(cb: IBuilderCallback): void {
this.logger.debug("[pack]");
const buildPath = path.join(globals.getCordovaProjectPath(this.env, this.data.code, this.data.starttime),
"platforms", "ubuntu", "native");
const buildPathContents: string[] = fse.readdirSync(buildPath);
const files: string[] = buildPathContents.filter((item) => {
return /^.*\.deb$/.test(item);
});
const filePaths: string[] = files.map((value: string) => {
return path.join(buildPath, value);
});
this.createOutputZip(filePaths, cb);
}
protected buildJson(cb: IBuilderCallback): void {
this.logger.debug("[build] create build.json");
cb();
}
private archive(cb: IBuilderCallback): void {
this.logger.debug("[build] create .deb");
const configParser: any = globals.getConfigParser(this.env, this.data.libVersion);
const cordovaUtil: any = globals.getCordovaUtil(this.env, this.data.libVersion);
const xml = cordovaUtil.projectConfig(globals.getProjectPath(this.env, this.data.code, this.data.starttime));
const cfg = new configParser(xml);
let cmd: string = "debuild";
if (!this.data.platform.key) {
cmd = "debuild -i -us -uc -b";
}
let log: string = "";
const debuild: child_process.ChildProcess = child_process.exec(cmd,
{
cwd: path.join(globals.getCordovaProjectPath(this.env, this.data.code, this.data.starttime),
"platforms", "ubuntu", "native", cfg.packageName()),
maxBuffer: 52428800, // 20MB
});
debuild.stdout.on("data", (buffer: Buffer) => {
log = log.concat(buffer.toString());
this.logger.info(buffer.toString("UTF8").trim());
});
debuild.stderr.on("data", (buffer: Buffer) => {
log = log.concat(buffer.toString());
this.logger.error(buffer.toString("UTF8").trim());
});
debuild.on("error", (err: Error) => {
cb(new BuilderError(
"Error calling debuild: " + err.message,
"Internal compiler error (code 0500)",
));
});
debuild.on("exit", (code: number) => {
if (code !== 0) {
cb(new BuilderError(
log,
log,
));
return;
}
cb();
});
}
}