npm-pkgbuild 7.11.2 → 7.11.6
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 -2
- package/src/output/packager.mjs +0 -13
- package/src/output/pkg.mjs +33 -16
- package/src/output/rpm.mjs +19 -21
- 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.6",
|
|
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
|
@@ -27,10 +27,11 @@ export class DEB extends Packager {
|
|
|
27
27
|
const properties = this.properties;
|
|
28
28
|
const staging = await this.tmpdir;
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/)));
|
|
31
|
+
|
|
32
|
+
const fp = fieldProvider(properties, fields);
|
|
31
33
|
const debianControlName = "DEBIAN/control";
|
|
32
34
|
|
|
33
|
-
transformer.push(createModeTransformer(0o775, entry => entry.name.match(/DEBIAN\/.*(inst|rm)/)));
|
|
34
35
|
transformer.push(
|
|
35
36
|
{
|
|
36
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,6 +55,10 @@ 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
64
|
const staging = await this.tmpdir;
|
|
@@ -70,7 +77,7 @@ package() {
|
|
|
70
77
|
expander
|
|
71
78
|
);
|
|
72
79
|
|
|
73
|
-
const fp = fieldProvider(properties, fields
|
|
80
|
+
const fp = fieldProvider(properties, fields);
|
|
74
81
|
|
|
75
82
|
transformer.push({
|
|
76
83
|
match: entry => entry.name === "PKGBUILD",
|
|
@@ -86,12 +93,24 @@ package() {
|
|
|
86
93
|
});
|
|
87
94
|
|
|
88
95
|
if (properties.hooks) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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)
|
|
95
114
|
);
|
|
96
115
|
}
|
|
97
116
|
|
|
@@ -101,7 +120,7 @@ package() {
|
|
|
101
120
|
console.log(`stagingDir: ${staging}`);
|
|
102
121
|
}
|
|
103
122
|
|
|
104
|
-
const makepkg = await execa("makepkg", ["-f"], {
|
|
123
|
+
const makepkg = await execa("makepkg", ["-f", "-e"], {
|
|
105
124
|
cwd: staging,
|
|
106
125
|
env: { PKGDEST: options.destination }
|
|
107
126
|
});
|
|
@@ -121,14 +140,14 @@ package() {
|
|
|
121
140
|
const fields = {
|
|
122
141
|
pkgname: { alias: "name", type: "string[]", mandatory: true },
|
|
123
142
|
pkgver: { alias: "version", type: "string", mandatory: true },
|
|
124
|
-
pkgrel: { alias: "release", type: "integer", default:
|
|
143
|
+
pkgrel: { alias: "release", type: "integer", default: 1, mandatory: true },
|
|
125
144
|
epoch: { type: "integer", default: 0 },
|
|
126
145
|
pkgdesc: { alias: "description", type: "string", mandatory: true },
|
|
127
146
|
url: { alias: "homepage", type: "string" },
|
|
128
|
-
license: {
|
|
147
|
+
license: { type: "string[]", mandatory: true },
|
|
129
148
|
install: { alias: "hooks", type: "string" },
|
|
130
149
|
changelog: { type: "string" },
|
|
131
|
-
source: {
|
|
150
|
+
source: { type: "string[]" },
|
|
132
151
|
validpgpkeys: { type: "string[]" },
|
|
133
152
|
noextract: { type: "string[]" },
|
|
134
153
|
cksums: { type: "string[]" },
|
|
@@ -176,8 +195,6 @@ package() {
|
|
|
176
195
|
mkdir -p \${pkgdir}${installdir}
|
|
177
196
|
npx npm-pkgbuild --package \${srcdir}/\${pkgname}${directory} --staging \${pkgdir} content
|
|
178
197
|
}
|
|
179
|
-
`
|
|
180
|
-
);
|
|
181
198
|
*/
|
|
182
199
|
|
|
183
200
|
const mapping = {
|
package/src/output/rpm.mjs
CHANGED
|
@@ -38,48 +38,46 @@ export class RPM extends Packager {
|
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
const staging = join(tmp, "BUILDROOT");
|
|
41
|
-
|
|
42
|
-
const fp = fieldProvider(properties, fields, this.mandatoryFields);
|
|
43
|
-
|
|
44
41
|
const specFileName = `${properties.name}.spec`;
|
|
45
42
|
|
|
46
43
|
async function* trailingLines() {
|
|
47
|
-
|
|
48
44
|
yield "%define _unpackaged_files_terminate_build 0\n";
|
|
49
|
-
|
|
45
|
+
|
|
50
46
|
for (const [name, options] of Object.entries(sections)) {
|
|
51
|
-
if(options.mandatory) {
|
|
47
|
+
if (options.mandatory) {
|
|
52
48
|
yield `%${name}\n\n`;
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
});
|
|
70
67
|
|
|
71
68
|
await copyEntries(transform(sources, transformer), staging, expander);
|
|
72
69
|
|
|
73
70
|
const rpmbuild = await execa("rpmbuild", [
|
|
74
71
|
"--define",
|
|
75
72
|
`_topdir ${tmp}`,
|
|
76
|
-
"--buildroot",
|
|
73
|
+
"--buildroot",
|
|
74
|
+
staging,
|
|
77
75
|
"-vv",
|
|
78
76
|
"-bb",
|
|
79
77
|
join(staging, specFileName)
|
|
80
78
|
]);
|
|
81
79
|
|
|
82
|
-
if(options.verbose) {
|
|
80
|
+
if (options.verbose) {
|
|
83
81
|
console.log(rpmbuild.stdout);
|
|
84
82
|
}
|
|
85
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
|
|