npm-pkgbuild 7.11.1 → 7.11.5
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 +2 -2
- package/src/output/deb.mjs +3 -3
- package/src/output/packager.mjs +0 -13
- package/src/output/pkg.mjs +39 -14
- package/src/output/rpm.mjs +20 -20
- package/src/util.mjs +37 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.11.
|
|
3
|
+
"version": "7.11.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"ava": "^3.15.0",
|
|
58
|
-
"c8": "^7.
|
|
58
|
+
"c8": "^7.11.0",
|
|
59
59
|
"documentation": "^13.2.5",
|
|
60
60
|
"semantic-release": "^18.0.1",
|
|
61
61
|
"stream-buffers": "^3.0.2"
|
package/src/output/deb.mjs
CHANGED
|
@@ -25,13 +25,13 @@ export class DEB extends Packager {
|
|
|
25
25
|
|
|
26
26
|
async execute(sources, transformer, options, expander) {
|
|
27
27
|
const properties = this.properties;
|
|
28
|
-
const mandatoryFields = this.mandatoryFields;
|
|
29
28
|
const staging = await this.tmpdir;
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/)));
|
|
31
|
+
|
|
32
|
+
const fp = fieldProvider(properties, fields);
|
|
32
33
|
const debianControlName = "DEBIAN/control";
|
|
33
34
|
|
|
34
|
-
transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/)));
|
|
35
35
|
transformer.push(
|
|
36
36
|
{
|
|
37
37
|
match: entry => entry.name === debianControlName,
|
package/src/output/packager.mjs
CHANGED
|
@@ -43,19 +43,6 @@ export class Packager {
|
|
|
43
43
|
return properties;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/**
|
|
47
|
-
* @return {Set<string,Field>} mandatory fields
|
|
48
|
-
*/
|
|
49
|
-
get mandatoryFields() {
|
|
50
|
-
const mandatoryFields = new Set(
|
|
51
|
-
Object.entries(this.fields)
|
|
52
|
-
.filter(([k, v]) => v.mandatory)
|
|
53
|
-
.map(([k, v]) => k)
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return mandatoryFields;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
46
|
/**
|
|
60
47
|
* Create tmp directory.
|
|
61
48
|
* @return {Promise<string>} directory path
|
package/src/output/pkg.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
|
-
import {
|
|
1
|
+
import { join, dirname } from "path";
|
|
2
|
+
import { createReadStream, createWriteStream } from "fs";
|
|
3
|
+
import { mkdir } from "fs/promises";
|
|
4
|
+
import { pipeline } from "stream/promises";
|
|
3
5
|
import { execa } from "execa";
|
|
4
6
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
7
|
+
import { iterableStringInterceptor } from "iterable-string-interceptor";
|
|
5
8
|
import {
|
|
6
9
|
keyValueTransformer,
|
|
7
10
|
equalSeparatedKeyValuePairOptions
|
|
8
11
|
} from "key-value-transformer";
|
|
9
12
|
import { Packager } from "./packager.mjs";
|
|
10
13
|
import { copyEntries, transform, fieldProvider } from "../util.mjs";
|
|
11
|
-
import { quote } from "../util.mjs";
|
|
14
|
+
import { quote, utf8StreamOptions } from "../util.mjs";
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* @type KeyValueTransformOptions
|
|
@@ -52,9 +55,12 @@ export class PKG extends Packager {
|
|
|
52
55
|
async execute(sources, transformer, options, expander) {
|
|
53
56
|
const properties = this.properties;
|
|
54
57
|
|
|
58
|
+
if (properties.source) {
|
|
59
|
+
properties.md5sums = ["SKIP"];
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
//properties.depends = makeDepends({ ...pkg.engines });
|
|
56
63
|
|
|
57
|
-
const mandatoryFields = this.mandatoryFields;
|
|
58
64
|
const staging = await this.tmpdir;
|
|
59
65
|
|
|
60
66
|
async function* trailingLines() {
|
|
@@ -71,7 +77,7 @@ package() {
|
|
|
71
77
|
expander
|
|
72
78
|
);
|
|
73
79
|
|
|
74
|
-
const fp = fieldProvider(properties, fields
|
|
80
|
+
const fp = fieldProvider(properties, fields);
|
|
75
81
|
|
|
76
82
|
transformer.push({
|
|
77
83
|
match: entry => entry.name === "PKGBUILD",
|
|
@@ -87,19 +93,41 @@ package() {
|
|
|
87
93
|
});
|
|
88
94
|
|
|
89
95
|
if (properties.hooks) {
|
|
96
|
+
async function* transformer(expression, remainder, source, cb) {
|
|
97
|
+
const value = properties[expression];
|
|
98
|
+
yield value === undefined ? "" : value;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const destination = join(staging, properties.hooks);
|
|
102
|
+
|
|
103
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
104
|
+
|
|
105
|
+
await pipeline(
|
|
106
|
+
iterableStringInterceptor(
|
|
107
|
+
createReadStream(
|
|
108
|
+
join(options.pkgdir, properties.hooks),
|
|
109
|
+
utf8StreamOptions
|
|
110
|
+
),
|
|
111
|
+
transformer
|
|
112
|
+
),
|
|
113
|
+
createWriteStream(destination, utf8StreamOptions)
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
/*
|
|
90
117
|
await cp(
|
|
91
118
|
join(options.pkgdir, properties.hooks),
|
|
92
|
-
join(staging,
|
|
119
|
+
join(staging, properties.hooks),
|
|
93
120
|
{
|
|
94
121
|
preserveTimestamps: true
|
|
95
122
|
}
|
|
96
123
|
);
|
|
124
|
+
*/
|
|
97
125
|
}
|
|
98
126
|
|
|
99
127
|
await copyEntries(transform(sources, transformer, true), staging, expander);
|
|
100
128
|
|
|
101
129
|
if (options.verbose) {
|
|
102
|
-
console.log(staging);
|
|
130
|
+
console.log(`stagingDir: ${staging}`);
|
|
103
131
|
}
|
|
104
132
|
|
|
105
133
|
const makepkg = await execa("makepkg", ["-f"], {
|
|
@@ -122,19 +150,18 @@ package() {
|
|
|
122
150
|
const fields = {
|
|
123
151
|
pkgname: { alias: "name", type: "string[]", mandatory: true },
|
|
124
152
|
pkgver: { alias: "version", type: "string", mandatory: true },
|
|
125
|
-
pkgrel: { alias: "release", type: "integer", default:
|
|
153
|
+
pkgrel: { alias: "release", type: "integer", default: 1, mandatory: true },
|
|
126
154
|
epoch: { type: "integer", default: 0 },
|
|
127
155
|
pkgdesc: { alias: "description", type: "string", mandatory: true },
|
|
128
156
|
url: { alias: "homepage", type: "string" },
|
|
129
|
-
license: {
|
|
157
|
+
license: { type: "string[]", mandatory: true },
|
|
130
158
|
install: { alias: "hooks", type: "string" },
|
|
131
159
|
changelog: { type: "string" },
|
|
132
|
-
source: {
|
|
133
|
-
validpgpkeys: { type: "string[]" },
|
|
160
|
+
source: { type: "string[]" },
|
|
134
161
|
validpgpkeys: { type: "string[]" },
|
|
135
162
|
noextract: { type: "string[]" },
|
|
136
163
|
cksums: { type: "string[]" },
|
|
137
|
-
md5sums: {
|
|
164
|
+
md5sums: { type: "string[]" },
|
|
138
165
|
sha1sums: { type: "string[]" },
|
|
139
166
|
sha256sums: { type: "string[]" },
|
|
140
167
|
sha384sums: { type: "string[]" },
|
|
@@ -178,8 +205,6 @@ package() {
|
|
|
178
205
|
mkdir -p \${pkgdir}${installdir}
|
|
179
206
|
npx npm-pkgbuild --package \${srcdir}/\${pkgname}${directory} --staging \${pkgdir} content
|
|
180
207
|
}
|
|
181
|
-
`
|
|
182
|
-
);
|
|
183
208
|
*/
|
|
184
209
|
|
|
185
210
|
const mapping = {
|
package/src/output/rpm.mjs
CHANGED
|
@@ -29,7 +29,6 @@ export class RPM extends Packager {
|
|
|
29
29
|
|
|
30
30
|
async execute(sources, transformer, options, expander) {
|
|
31
31
|
const properties = this.properties;
|
|
32
|
-
const mandatoryFields = this.mandatoryFields;
|
|
33
32
|
const tmp = await this.tmpdir;
|
|
34
33
|
|
|
35
34
|
await Promise.all(
|
|
@@ -39,45 +38,46 @@ export class RPM extends Packager {
|
|
|
39
38
|
);
|
|
40
39
|
|
|
41
40
|
const staging = join(tmp, "BUILDROOT");
|
|
42
|
-
|
|
43
|
-
const fp = fieldProvider(properties, fields, mandatoryFields);
|
|
44
|
-
|
|
45
41
|
const specFileName = `${properties.name}.spec`;
|
|
46
42
|
|
|
47
43
|
async function* trailingLines() {
|
|
44
|
+
yield "%define _unpackaged_files_terminate_build 0\n";
|
|
45
|
+
|
|
48
46
|
for (const [name, options] of Object.entries(sections)) {
|
|
49
|
-
if(options.mandatory) {
|
|
47
|
+
if (options.mandatory) {
|
|
50
48
|
yield `%${name}\n\n`;
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
|
|
53
|
+
const fp = fieldProvider(properties, fields);
|
|
54
|
+
|
|
55
|
+
transformer.push({
|
|
56
|
+
match: entry => entry.name === specFileName,
|
|
57
|
+
transform: async entry =>
|
|
58
|
+
new ReadableStreamContentEntry(
|
|
59
|
+
entry.name,
|
|
60
|
+
keyValueTransformer(await entry.readStream, fp, {
|
|
61
|
+
...colonSeparatedKeyValuePairOptions,
|
|
62
|
+
trailingLines
|
|
63
|
+
})
|
|
64
|
+
),
|
|
65
|
+
createEntryWhenMissing: () => new EmptyContentEntry(specFileName)
|
|
66
|
+
});
|
|
68
67
|
|
|
69
68
|
await copyEntries(transform(sources, transformer), staging, expander);
|
|
70
69
|
|
|
71
70
|
const rpmbuild = await execa("rpmbuild", [
|
|
72
71
|
"--define",
|
|
73
72
|
`_topdir ${tmp}`,
|
|
74
|
-
|
|
73
|
+
"--buildroot",
|
|
74
|
+
staging,
|
|
75
75
|
"-vv",
|
|
76
76
|
"-bb",
|
|
77
77
|
join(staging, specFileName)
|
|
78
78
|
]);
|
|
79
79
|
|
|
80
|
-
if(options.verbose) {
|
|
80
|
+
if (options.verbose) {
|
|
81
81
|
console.log(rpmbuild.stdout);
|
|
82
82
|
}
|
|
83
83
|
|
package/src/util.mjs
CHANGED
|
@@ -25,16 +25,34 @@ export function asArray(o) {
|
|
|
25
25
|
return Array.isArray(o) ? o : [o];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} properties
|
|
31
|
+
* @param {Object} fields
|
|
32
|
+
* @returns {Function}
|
|
33
|
+
*/
|
|
34
|
+
export function fieldProvider(properties, fields) {
|
|
29
35
|
return function* controlProperties(k, v, presentKeys) {
|
|
30
36
|
if (k === undefined) {
|
|
31
|
-
for (const
|
|
32
|
-
if (!presentKeys.has(
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
37
|
+
for (const [name, field] of Object.entries(fields)) {
|
|
38
|
+
if (!presentKeys.has(name)) {
|
|
39
|
+
const value = properties[field.alias || name];
|
|
40
|
+
if (value === undefined) {
|
|
41
|
+
if (field.default === undefined) {
|
|
42
|
+
if (field.mandatory) {
|
|
43
|
+
console.log(`Missing value for mandatory field ${name}`);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
yield [name, field.default];
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
yield [
|
|
50
|
+
name,
|
|
51
|
+
field.type.endsWith("]") && !Array.isArray(value)
|
|
52
|
+
? [value]
|
|
53
|
+
: value
|
|
54
|
+
];
|
|
36
55
|
}
|
|
37
|
-
yield [p, v === undefined ? fields[p].default : v];
|
|
38
56
|
}
|
|
39
57
|
}
|
|
40
58
|
} else {
|
|
@@ -61,7 +79,7 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
61
79
|
}
|
|
62
80
|
|
|
63
81
|
Object.assign(properties, pkg.config);
|
|
64
|
-
|
|
82
|
+
|
|
65
83
|
if (properties.name) {
|
|
66
84
|
properties.name = properties.name.replace(/^\@\w+\//, "");
|
|
67
85
|
}
|
|
@@ -111,12 +129,11 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
111
129
|
return { properties, sources, dependencies, output };
|
|
112
130
|
}
|
|
113
131
|
|
|
114
|
-
export function createModeTransformer(mode, match)
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
};
|
|
132
|
+
export function createModeTransformer(mode, match) {
|
|
133
|
+
return {
|
|
134
|
+
match,
|
|
135
|
+
transform: async entry => Object.create(entry, { mode: { value: mode } })
|
|
136
|
+
};
|
|
120
137
|
}
|
|
121
138
|
|
|
122
139
|
export function createExpressionTransformer(
|
|
@@ -136,9 +153,11 @@ export function createExpressionTransformer(
|
|
|
136
153
|
iterableStringInterceptor(
|
|
137
154
|
await entry.getReadStream(utf8StreamOptions),
|
|
138
155
|
transformer
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
ne.destination = entry.destination; // TODO all the other attributes ?
|
|
159
|
+
return ne;
|
|
160
|
+
}
|
|
142
161
|
};
|
|
143
162
|
}
|
|
144
163
|
|
|
@@ -177,7 +196,7 @@ export async function* transform(source, transformers = [], onlyMatching) {
|
|
|
177
196
|
|
|
178
197
|
/**
|
|
179
198
|
* @typedef {Function} Expander
|
|
180
|
-
* @param {string} path
|
|
199
|
+
* @param {string} path
|
|
181
200
|
* @return {string}
|
|
182
201
|
*/
|
|
183
202
|
|