npm-pkgbuild 7.3.8 → 7.3.12
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 +3 -3
- package/src/output/deb.mjs +11 -50
- package/src/output/pkg.mjs +9 -1
- package/src/util.mjs +40 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"aggregate-async-iterator": "^1.1.7",
|
|
42
42
|
"commander": "^8.3.0",
|
|
43
|
-
"content-entry": "^2.
|
|
44
|
-
"content-entry-filesystem": "^3.1.
|
|
43
|
+
"content-entry": "^2.10.0",
|
|
44
|
+
"content-entry-filesystem": "^3.1.11",
|
|
45
45
|
"execa": "^6.0.0",
|
|
46
46
|
"expression-expander": "^7.0.9",
|
|
47
47
|
"globby": "^12.0.2",
|
package/src/output/deb.mjs
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { join, dirname } from "path";
|
|
2
2
|
import { tmpdir } from "os";
|
|
3
|
-
import {
|
|
4
|
-
import { mkdtemp, mkdir, chmod } from "fs/promises";
|
|
5
|
-
import { pipeline } from "stream/promises";
|
|
3
|
+
import { mkdtemp } from "fs/promises";
|
|
6
4
|
import { execa } from "execa";
|
|
7
5
|
import { EmptyContentEntry, ReadableStreamContentEntry } from "content-entry";
|
|
8
6
|
import { keyValueTransformer } from "key-value-transformer";
|
|
9
7
|
import { Packager } from "./packager.mjs";
|
|
8
|
+
import { copyEntries, transform } from "../util.mjs";
|
|
10
9
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"DEBIAN/preinst": executableAttributes,
|
|
15
|
-
"DEBIAN/postinst": executableAttributes,
|
|
16
|
-
"DEBIAN/prerm": executableAttributes,
|
|
17
|
-
"DEBIAN/postrm": executableAttributes
|
|
18
|
-
};
|
|
10
|
+
const attributes = [
|
|
11
|
+
{ pattern: /DEBIAN\/.*(inst|rm)/, mode: 0o775 }
|
|
12
|
+
];
|
|
19
13
|
|
|
20
14
|
export class DEB extends Packager {
|
|
21
15
|
static get name() {
|
|
@@ -62,47 +56,14 @@ export class DEB extends Packager {
|
|
|
62
56
|
entry.name,
|
|
63
57
|
keyValueTransformer(await entry.readStream, controlProperties)
|
|
64
58
|
),
|
|
65
|
-
createEntryWhenMissing: new EmptyContentEntry(debianControlName)
|
|
59
|
+
createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
|
|
66
60
|
}
|
|
67
61
|
];
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await mkdir(dirname(destName), { recursive: true });
|
|
75
|
-
|
|
76
|
-
if (entry.name === debianControlName) {
|
|
77
|
-
debianControlEntry = entry;
|
|
78
|
-
} else {
|
|
79
|
-
console.log("ENTRY", entry.name, entry.basename);
|
|
80
|
-
await pipeline(await entry.readStream, createWriteStream(destName));
|
|
81
|
-
|
|
82
|
-
await Promise.all(
|
|
83
|
-
Object.entries(permissions).map(async ([pattern, option]) => {
|
|
84
|
-
if (destName.endsWith(pattern)) {
|
|
85
|
-
return chmod(destName, option.chmod);
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (!debianControlEntry) {
|
|
93
|
-
debianControlEntry = new EmptyContentEntry(debianControlName);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let destName = join(staging, debianControlEntry.name);
|
|
97
|
-
|
|
98
|
-
await mkdir(dirname(destName), { recursive: true });
|
|
99
|
-
|
|
100
|
-
await pipeline(
|
|
101
|
-
keyValueTransformer(
|
|
102
|
-
await debianControlEntry.readStream,
|
|
103
|
-
controlProperties
|
|
104
|
-
),
|
|
105
|
-
createWriteStream(destName)
|
|
63
|
+
await copyEntries(
|
|
64
|
+
transform(this.source, transformers),
|
|
65
|
+
staging,
|
|
66
|
+
attributes
|
|
106
67
|
);
|
|
107
68
|
|
|
108
69
|
await execa("dpkg", ["-b", staging, options.destination]);
|
|
@@ -113,7 +74,7 @@ export class DEB extends Packager {
|
|
|
113
74
|
|
|
114
75
|
/**
|
|
115
76
|
* @see https://www.debian.org/doc/debian-policy/ch-controlfields.html
|
|
116
|
-
* @ https://linux.die.net/man/5/deb-control
|
|
77
|
+
* @see https://linux.die.net/man/5/deb-control
|
|
117
78
|
*/
|
|
118
79
|
|
|
119
80
|
const fields = {
|
package/src/output/pkg.mjs
CHANGED
|
@@ -22,12 +22,20 @@ export class PKG extends Packager {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async execute(options) {
|
|
25
|
-
const
|
|
25
|
+
const properties = this.properties;
|
|
26
|
+
const mandatoryFields = this.mandatoryFields;
|
|
27
|
+
const tmp = await mkdtemp(join(tmpdir(), "deb-"));
|
|
28
|
+
const staging = join(tmp, `${properties.name}-${properties.version}`);
|
|
29
|
+
|
|
26
30
|
|
|
27
31
|
const pkgbuildFileName = join(tmp, "PKGBUILD");
|
|
28
32
|
|
|
29
33
|
this.writePkbuild(pkgbuildFileName);
|
|
30
34
|
|
|
35
|
+
const transformers = [];
|
|
36
|
+
|
|
37
|
+
await copyEntries(transform(this.source, transformers), staging);
|
|
38
|
+
|
|
31
39
|
await execa("makepkg", [], { cwd: tmp });
|
|
32
40
|
}
|
|
33
41
|
|
package/src/util.mjs
CHANGED
|
@@ -66,25 +66,57 @@ export function extractFromPackage(pkg) {
|
|
|
66
66
|
return { properties, sources };
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Apply transformers
|
|
71
|
+
* @param {AsyncIterator<ContentEntry>} source
|
|
72
|
+
* @param {Transformer[]} transformers
|
|
73
|
+
*/
|
|
74
|
+
export async function* transform(source, transformers) {
|
|
75
|
+
const usedTransformers = new Set();
|
|
76
|
+
|
|
77
|
+
for await (let entry of source) {
|
|
78
|
+
for (const t of transformers) {
|
|
79
|
+
if (t.match(entry)) {
|
|
80
|
+
entry = await t.transform(entry);
|
|
81
|
+
usedTransformers.add(t);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
yield entry;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for (const t of transformers) {
|
|
89
|
+
if (!usedTransformers.has(t) && t.createEntryWhenMissing !== undefined) {
|
|
90
|
+
yield t.transform(await t.createEntryWhenMissing());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
69
95
|
/**
|
|
70
96
|
* Copy content from source into destinationDirectory
|
|
71
97
|
* @param {AsyncIterator<ContentEntry>} source
|
|
72
98
|
* @param {string} destinationDirectory
|
|
73
|
-
* @param {Transformer[]} transformers
|
|
74
99
|
*/
|
|
75
|
-
export async function copyEntries(
|
|
100
|
+
export async function copyEntries(
|
|
101
|
+
source,
|
|
102
|
+
destinationDirectory,
|
|
103
|
+
attributes = []
|
|
104
|
+
) {
|
|
76
105
|
for await (let entry of source) {
|
|
77
106
|
const destName = join(destinationDirectory, entry.name);
|
|
78
|
-
|
|
79
107
|
await mkdir(dirname(destName), { recursive: true });
|
|
80
108
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
const options = { mode: entry.mode };
|
|
110
|
+
|
|
111
|
+
for (const a of attributes) {
|
|
112
|
+
if (entry.name.match(a.pattern)) {
|
|
113
|
+
options.mode = a.mode;
|
|
85
114
|
}
|
|
86
115
|
}
|
|
87
116
|
|
|
88
|
-
await pipeline(
|
|
117
|
+
await pipeline(
|
|
118
|
+
await entry.readStream,
|
|
119
|
+
createWriteStream(destName, options)
|
|
120
|
+
);
|
|
89
121
|
}
|
|
90
122
|
}
|