npm-pkgbuild 7.8.1 → 7.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/output/deb.mjs +3 -15
- package/src/output/pkg.mjs +4 -15
- package/src/output/rpm.mjs +4 -15
- package/src/util.mjs +18 -1
package/package.json
CHANGED
package/src/output/deb.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { execa } from "execa";
|
|
|
3
3
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
4
4
|
import { keyValueTransformer } from "key-value-transformer";
|
|
5
5
|
import { Packager } from "./packager.mjs";
|
|
6
|
-
import { copyEntries, transform } from "../util.mjs";
|
|
6
|
+
import { copyEntries, transform, fieldProvider } from "../util.mjs";
|
|
7
7
|
|
|
8
8
|
const attributes = [{ pattern: /DEBIAN\/.*(inst|rm)/, mode: 0o775 }];
|
|
9
9
|
|
|
@@ -30,18 +30,7 @@ export class DEB extends Packager {
|
|
|
30
30
|
const mandatoryFields = this.mandatoryFields;
|
|
31
31
|
const staging = await this.tmpdir;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
if (k === undefined) {
|
|
35
|
-
for (const p of mandatoryFields) {
|
|
36
|
-
if (!presentKeys.has(p)) {
|
|
37
|
-
const v = properties[p];
|
|
38
|
-
yield [p, v === undefined ? fields[p].default : v];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
yield [k, properties[k] || v];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
33
|
+
const fp = fieldProvider(properties, fields, mandatoryFields);
|
|
45
34
|
|
|
46
35
|
const debianControlName = "DEBIAN/control";
|
|
47
36
|
const transformers = [
|
|
@@ -50,7 +39,7 @@ export class DEB extends Packager {
|
|
|
50
39
|
transform: async entry =>
|
|
51
40
|
new ReadableStreamContentEntry(
|
|
52
41
|
entry.name,
|
|
53
|
-
keyValueTransformer(await entry.readStream,
|
|
42
|
+
keyValueTransformer(await entry.readStream, fp)
|
|
54
43
|
),
|
|
55
44
|
createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
|
|
56
45
|
}
|
|
@@ -59,7 +48,6 @@ export class DEB extends Packager {
|
|
|
59
48
|
await copyEntries(transform(sources, transformers), staging, expander, attributes);
|
|
60
49
|
|
|
61
50
|
const dpkg = await execa("dpkg", ["-b", staging, options.destination]);
|
|
62
|
-
//console.log(dpkg.stdout);
|
|
63
51
|
|
|
64
52
|
return join(options.destination, this.packageFileName);
|
|
65
53
|
}
|
package/src/output/pkg.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
equalSeparatedKeyValuePairOptions
|
|
7
7
|
} from "key-value-transformer";
|
|
8
8
|
import { Packager } from "./packager.mjs";
|
|
9
|
-
import { copyEntries, transform } from "../util.mjs";
|
|
9
|
+
import { copyEntries, transform, fieldProvider } from "../util.mjs";
|
|
10
10
|
import { quote, createExpressionTransformer } from "../util.mjs";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -56,19 +56,6 @@ export class PKG extends Packager {
|
|
|
56
56
|
const mandatoryFields = this.mandatoryFields;
|
|
57
57
|
const staging = await this.tmpdir;
|
|
58
58
|
|
|
59
|
-
function* controlProperties(k, v, presentKeys) {
|
|
60
|
-
if (k === undefined) {
|
|
61
|
-
for (const p of mandatoryFields) {
|
|
62
|
-
if (!presentKeys.has(p)) {
|
|
63
|
-
const v = properties[p];
|
|
64
|
-
yield [p, v === undefined ? fields[p].default : v];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
yield [k, properties[k] || v];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
59
|
async function* trailingLines() {
|
|
73
60
|
yield `
|
|
74
61
|
package() {
|
|
@@ -79,13 +66,15 @@ package() {
|
|
|
79
66
|
|
|
80
67
|
await copyEntries(transform(sources, [createExpressionTransformer(properties)]), join(staging, "src"), expander);
|
|
81
68
|
|
|
69
|
+
const fp = fieldProvider(properties, fields, mandatoryFields);
|
|
70
|
+
|
|
82
71
|
const metaTransformers = [
|
|
83
72
|
{
|
|
84
73
|
match: entry => entry.name === "PKGBUILD",
|
|
85
74
|
transform: async entry =>
|
|
86
75
|
new ReadableStreamContentEntry(
|
|
87
76
|
entry.name,
|
|
88
|
-
keyValueTransformer(await entry.readStream,
|
|
77
|
+
keyValueTransformer(await entry.readStream, fp, {
|
|
89
78
|
...pkgKeyValuePairOptions,
|
|
90
79
|
trailingLines
|
|
91
80
|
})
|
package/src/output/rpm.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
colonSeparatedKeyValuePairOptions
|
|
8
8
|
} from "key-value-transformer";
|
|
9
9
|
import { Packager } from "./packager.mjs";
|
|
10
|
-
import { copyEntries, transform } from "../util.mjs";
|
|
10
|
+
import { copyEntries, transform, fieldProvider } from "../util.mjs";
|
|
11
11
|
|
|
12
12
|
export class RPM extends Packager {
|
|
13
13
|
static get name() {
|
|
@@ -40,18 +40,7 @@ export class RPM extends Packager {
|
|
|
40
40
|
|
|
41
41
|
const staging = join(tmp, "staging");
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
if (k === undefined) {
|
|
45
|
-
for (const p of mandatoryFields) {
|
|
46
|
-
if (!presentKeys.has(p)) {
|
|
47
|
-
const v = properties[p];
|
|
48
|
-
yield [p, v === undefined ? fields[p].default : v];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
yield [k, properties[k] || v];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
43
|
+
const fp = fieldProvider(properties, fields, mandatoryFields);
|
|
55
44
|
|
|
56
45
|
const specFileName = `${properties.name}.spec`;
|
|
57
46
|
|
|
@@ -67,7 +56,7 @@ export class RPM extends Packager {
|
|
|
67
56
|
transform: async entry =>
|
|
68
57
|
new ReadableStreamContentEntry(
|
|
69
58
|
entry.name,
|
|
70
|
-
keyValueTransformer(await entry.readStream,
|
|
59
|
+
keyValueTransformer(await entry.readStream, fp, {
|
|
71
60
|
...colonSeparatedKeyValuePairOptions,
|
|
72
61
|
trailingLines
|
|
73
62
|
})
|
|
@@ -89,7 +78,7 @@ export class RPM extends Packager {
|
|
|
89
78
|
await cp(
|
|
90
79
|
join(tmp, "RPMS", properties.arch, this.packageFileName),
|
|
91
80
|
join(options.destination, this.packageFileName),
|
|
92
|
-
{preserveTimestamps
|
|
81
|
+
{ preserveTimestamps: true }
|
|
93
82
|
);
|
|
94
83
|
return join(options.destination, this.packageFileName);
|
|
95
84
|
}
|
package/src/util.mjs
CHANGED
|
@@ -25,6 +25,24 @@ export function asArray(o) {
|
|
|
25
25
|
return Array.isArray(o) ? o : [o];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export function fieldProvider(properties, fields, mandatoryFields) {
|
|
29
|
+
return function* controlProperties(k, v, presentKeys) {
|
|
30
|
+
if (k === undefined) {
|
|
31
|
+
for (const p of mandatoryFields) {
|
|
32
|
+
if (!presentKeys.has(p)) {
|
|
33
|
+
const v = properties[p];
|
|
34
|
+
if (v === undefined && fields[p].default === undefined) {
|
|
35
|
+
console.log(`Missing value for mandatory field ${p}`);
|
|
36
|
+
}
|
|
37
|
+
yield [p, v === undefined ? fields[p].default : v];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
yield [k, properties[k] || v];
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
/**
|
|
29
47
|
* Extract package definition from package.json.
|
|
30
48
|
* @param {Object} pkg package.json content
|
|
@@ -178,7 +196,6 @@ export async function copyEntries(
|
|
|
178
196
|
}
|
|
179
197
|
}
|
|
180
198
|
|
|
181
|
-
console.log(destName);
|
|
182
199
|
await pipeline(
|
|
183
200
|
await entry.readStream,
|
|
184
201
|
createWriteStream(destName, options)
|