npm-pkgbuild 7.11.13 → 7.12.0
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/content/node-modules-content-provider.mjs +5 -0
- package/src/content/npm-pack-content-provider.mjs +9 -0
- package/src/npm-pkgbuild-cli.mjs +6 -3
- package/src/output/arch.mjs +30 -27
- package/src/output/deb.mjs +1 -1
- package/src/output/rpm.mjs +11 -1
- package/src/util.mjs +4 -2
package/package.json
CHANGED
|
@@ -9,6 +9,15 @@ import { BufferContentEntry } from "content-entry";
|
|
|
9
9
|
* Content from npm pack.
|
|
10
10
|
*/
|
|
11
11
|
export class NPMPackContentProvider extends ContentProvider {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @return {string} name of the content provider
|
|
15
|
+
*/
|
|
16
|
+
static get name()
|
|
17
|
+
{
|
|
18
|
+
return "npm-pack";
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
async *[Symbol.asyncIterator]() {
|
|
13
22
|
//const m = await pacote.manifest(context.dir);
|
|
14
23
|
//console.log('got it', m);
|
package/src/npm-pkgbuild-cli.mjs
CHANGED
|
@@ -7,9 +7,8 @@ import program from "commander";
|
|
|
7
7
|
import { aggregateFifo } from "aggregate-async-iterator";
|
|
8
8
|
import { createContext } from "expression-expander";
|
|
9
9
|
import { packageDirectory } from "pkg-dir";
|
|
10
|
-
import { utf8StreamOptions, extractFromPackage } from "./util.mjs";
|
|
11
|
-
import { FileContentProvider, DEB, ARCH, RPM } from "npm-pkgbuild";
|
|
12
|
-
import { createExpressionTransformer } from "./util.mjs";
|
|
10
|
+
import { utf8StreamOptions, extractFromPackage, createExpressionTransformer } from "./util.mjs";
|
|
11
|
+
import { FileContentProvider, DEB, ARCH, RPM, NPMPackContentProvider, NodeModulesContentProvider } from "npm-pkgbuild";
|
|
13
12
|
|
|
14
13
|
const { version, description } = JSON.parse(
|
|
15
14
|
readFileSync(new URL("../package.json", import.meta.url).pathname),
|
|
@@ -18,6 +17,7 @@ const { version, description } = JSON.parse(
|
|
|
18
17
|
|
|
19
18
|
const cwd = process.cwd();
|
|
20
19
|
|
|
20
|
+
const allInputs = [NPMPackContentProvider, NodeModulesContentProvider];
|
|
21
21
|
const allOutputs = [DEB, ARCH, RPM];
|
|
22
22
|
|
|
23
23
|
program.description(description).version(version);
|
|
@@ -26,6 +26,9 @@ allOutputs.forEach(o =>
|
|
|
26
26
|
program.option(`--${o.name}`, `generate ${o.name} package`)
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
+
allInputs.forEach(i =>
|
|
30
|
+
program.option(`--${i.name}`, `input from ${i.name}`));
|
|
31
|
+
|
|
29
32
|
program
|
|
30
33
|
.option("--verbose", "be more verbose", false)
|
|
31
34
|
.option("-D --define <a=b>", "define property", str => Object.fromEntries([str.split(/=/)]))
|
package/src/output/arch.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { join
|
|
1
|
+
import { join } from "path";
|
|
2
2
|
import { createReadStream, createWriteStream } from "fs";
|
|
3
|
-
import { mkdir } from "fs/promises";
|
|
4
3
|
import { pipeline } from "stream/promises";
|
|
5
4
|
import { execa } from "execa";
|
|
6
5
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
@@ -27,13 +26,18 @@ export const pkgKeyValuePairOptions = {
|
|
|
27
26
|
}
|
|
28
27
|
},
|
|
29
28
|
keyValueLine: (key, value, lineEnding) =>
|
|
30
|
-
`${key}=${
|
|
29
|
+
`${keyPrefix(key)}=${
|
|
31
30
|
Array.isArray(value)
|
|
32
31
|
? "(" + value.map(v => quote(v)).join(",") + ")"
|
|
33
32
|
: quote(value)
|
|
34
33
|
}${lineEnding}`
|
|
35
34
|
};
|
|
36
35
|
|
|
36
|
+
function keyPrefix(key) {
|
|
37
|
+
const f = fields[key];
|
|
38
|
+
return f && f.prefix ? f.prefix + key : key;
|
|
39
|
+
}
|
|
40
|
+
|
|
37
41
|
export class ARCH extends Packager {
|
|
38
42
|
static get name() {
|
|
39
43
|
return "arch";
|
|
@@ -58,6 +62,9 @@ export class ARCH extends Packager {
|
|
|
58
62
|
if (properties.source) {
|
|
59
63
|
properties.md5sums = ["SKIP"];
|
|
60
64
|
}
|
|
65
|
+
if (properties.hooks) {
|
|
66
|
+
properties.install = `${properties.name}.install`;
|
|
67
|
+
}
|
|
61
68
|
|
|
62
69
|
const staging = await this.tmpdir;
|
|
63
70
|
|
|
@@ -76,31 +83,12 @@ package() {
|
|
|
76
83
|
`;
|
|
77
84
|
}
|
|
78
85
|
|
|
79
|
-
const fp = fieldProvider(properties, fields);
|
|
80
|
-
|
|
81
|
-
transformer.push({
|
|
82
|
-
match: entry => entry.name === "PKGBUILD",
|
|
83
|
-
transform: async entry =>
|
|
84
|
-
new ReadableStreamContentEntry(
|
|
85
|
-
entry.name,
|
|
86
|
-
keyValueTransformer(await entry.readStream, fp, {
|
|
87
|
-
...pkgKeyValuePairOptions,
|
|
88
|
-
trailingLines
|
|
89
|
-
})
|
|
90
|
-
),
|
|
91
|
-
createEntryWhenMissing: () => new EmptyContentEntry("PKGBUILD")
|
|
92
|
-
});
|
|
93
|
-
|
|
94
86
|
if (properties.hooks) {
|
|
95
87
|
async function* transformer(expression, remainder, source, cb) {
|
|
96
88
|
const value = properties[expression];
|
|
97
89
|
yield value === undefined ? "" : value;
|
|
98
90
|
}
|
|
99
91
|
|
|
100
|
-
const destination = join(staging, properties.hooks);
|
|
101
|
-
|
|
102
|
-
await mkdir(dirname(destination), { recursive: true });
|
|
103
|
-
|
|
104
92
|
await pipeline(
|
|
105
93
|
iterableStringInterceptor(
|
|
106
94
|
createReadStream(
|
|
@@ -109,13 +97,28 @@ package() {
|
|
|
109
97
|
),
|
|
110
98
|
transformer
|
|
111
99
|
),
|
|
112
|
-
createWriteStream(
|
|
100
|
+
createWriteStream(join(staging, properties.install), utf8StreamOptions)
|
|
113
101
|
);
|
|
114
102
|
}
|
|
115
103
|
|
|
104
|
+
const fp = fieldProvider(properties, fields);
|
|
105
|
+
|
|
106
|
+
transformer.push({
|
|
107
|
+
match: entry => entry.name === "PKGBUILD",
|
|
108
|
+
transform: async entry =>
|
|
109
|
+
new ReadableStreamContentEntry(
|
|
110
|
+
"../" + entry.name,
|
|
111
|
+
keyValueTransformer(await entry.readStream, fp, {
|
|
112
|
+
...pkgKeyValuePairOptions,
|
|
113
|
+
trailingLines
|
|
114
|
+
})
|
|
115
|
+
),
|
|
116
|
+
createEntryWhenMissing: () => new EmptyContentEntry("PKGBUILD")
|
|
117
|
+
});
|
|
118
|
+
|
|
116
119
|
for await (const file of copyEntries(
|
|
117
|
-
transform(sources, transformer
|
|
118
|
-
staging,
|
|
120
|
+
transform(sources, transformer),
|
|
121
|
+
join(staging, "src"),
|
|
119
122
|
expander
|
|
120
123
|
)) {
|
|
121
124
|
if (options.verbose) {
|
|
@@ -145,7 +148,7 @@ package() {
|
|
|
145
148
|
* https://www.archlinux.org/pacman/PKGBUILD.5.html
|
|
146
149
|
*/
|
|
147
150
|
const fields = {
|
|
148
|
-
Maintainer: { alias: "maintainer", type: "string" },
|
|
151
|
+
Maintainer: { alias: "maintainer", type: "string", prefix: "# " },
|
|
149
152
|
|
|
150
153
|
pkgname: { alias: "name", type: "string[]", mandatory: true },
|
|
151
154
|
pkgver: { alias: "version", type: "string", mandatory: true },
|
|
@@ -154,7 +157,7 @@ const fields = {
|
|
|
154
157
|
pkgdesc: { alias: "description", type: "string", mandatory: true },
|
|
155
158
|
url: { alias: "homepage", type: "string" },
|
|
156
159
|
license: { type: "string[]", mandatory: true },
|
|
157
|
-
install: {
|
|
160
|
+
install: { type: "string" },
|
|
158
161
|
changelog: { type: "string" },
|
|
159
162
|
source: { type: "string[]" },
|
|
160
163
|
validpgpkeys: { type: "string[]" },
|
package/src/output/deb.mjs
CHANGED
package/src/output/rpm.mjs
CHANGED
|
@@ -46,19 +46,28 @@ export class RPM extends Packager {
|
|
|
46
46
|
const staging = join(tmp, "BUILDROOT");
|
|
47
47
|
const specFileName = `${properties.name}.spec`;
|
|
48
48
|
|
|
49
|
+
const files = [];
|
|
50
|
+
|
|
49
51
|
async function* trailingLines() {
|
|
50
|
-
|
|
52
|
+
yield "%define _unpackaged_files_terminate_build 0\n";
|
|
51
53
|
|
|
52
54
|
for (const [name, options] of Object.entries(sections)) {
|
|
53
55
|
if (options.mandatory) {
|
|
54
56
|
yield `%${name}\n\n`;
|
|
55
57
|
|
|
56
58
|
if (name === "files") {
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
yield "/" + file + "\n";
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
for await (const file of copyEntries(
|
|
58
64
|
transform(sources, transformer),
|
|
59
65
|
staging,
|
|
60
66
|
expander
|
|
61
67
|
)) {
|
|
68
|
+
if (options.verbose) {
|
|
69
|
+
console.log(file);
|
|
70
|
+
}
|
|
62
71
|
yield file.destination + "\n";
|
|
63
72
|
}
|
|
64
73
|
}
|
|
@@ -86,6 +95,7 @@ export class RPM extends Packager {
|
|
|
86
95
|
staging,
|
|
87
96
|
expander
|
|
88
97
|
)) {
|
|
98
|
+
files.push(file.destination);
|
|
89
99
|
}
|
|
90
100
|
|
|
91
101
|
const rpmbuild = await execa("rpmbuild", [
|
package/src/util.mjs
CHANGED
|
@@ -92,7 +92,9 @@ export async function extractFromPackage(pkg, dir) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
if (pkg.repository) {
|
|
95
|
-
|
|
95
|
+
if(pkg.repository.url) {
|
|
96
|
+
properties.source = pkg.repository.url;
|
|
97
|
+
}
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
let dependencies = { ...pkg.engines };
|
|
@@ -213,7 +215,7 @@ export async function* copyEntries(
|
|
|
213
215
|
destinationDirectory,
|
|
214
216
|
expander = v => v
|
|
215
217
|
) {
|
|
216
|
-
for await (
|
|
218
|
+
for await (const entry of source) {
|
|
217
219
|
const name = expander(
|
|
218
220
|
entry.destination === undefined
|
|
219
221
|
? entry.name
|