npm-pkgbuild 7.3.9 → 7.3.10
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 +5 -43
- package/src/util.mjs +25 -7
package/package.json
CHANGED
package/src/output/deb.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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 executableAttributes = {
|
|
10
|
+
const executableAttributes = { mode: 0o775 };
|
|
12
11
|
|
|
13
12
|
const permissions = {
|
|
14
13
|
"DEBIAN/preinst": executableAttributes,
|
|
@@ -62,48 +61,11 @@ export class DEB extends Packager {
|
|
|
62
61
|
entry.name,
|
|
63
62
|
keyValueTransformer(await entry.readStream, controlProperties)
|
|
64
63
|
),
|
|
65
|
-
createEntryWhenMissing: new EmptyContentEntry(debianControlName)
|
|
64
|
+
createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
|
|
66
65
|
}
|
|
67
66
|
];
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for await (const entry of this.source) {
|
|
72
|
-
const destName = join(staging, entry.name);
|
|
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)
|
|
106
|
-
);
|
|
68
|
+
await copyEntries(transform(this.source, transformers), staging);
|
|
107
69
|
|
|
108
70
|
await execa("dpkg", ["-b", staging, options.destination]);
|
|
109
71
|
|
package/src/util.mjs
CHANGED
|
@@ -67,22 +67,40 @@ export function extractFromPackage(pkg) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Apply transformers
|
|
71
71
|
* @param {AsyncIterator<ContentEntry>} source
|
|
72
|
-
* @param {string} destinationDirectory
|
|
73
72
|
* @param {Transformer[]} transformers
|
|
74
73
|
*/
|
|
75
|
-
export async function
|
|
76
|
-
|
|
77
|
-
const destName = join(destinationDirectory, entry.name);
|
|
78
|
-
await mkdir(dirname(destName), { recursive: true });
|
|
74
|
+
export async function* transform(source, transformers) {
|
|
75
|
+
const usedTransformers = new Set();
|
|
79
76
|
|
|
77
|
+
for await (let entry of source) {
|
|
80
78
|
for (const t of transformers) {
|
|
81
79
|
if (t.match(entry)) {
|
|
82
80
|
entry = await t.transform(entry);
|
|
81
|
+
usedTransformers.add(t);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
|
|
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
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Copy content from source into destinationDirectory
|
|
97
|
+
* @param {AsyncIterator<ContentEntry>} source
|
|
98
|
+
* @param {string} destinationDirectory
|
|
99
|
+
*/
|
|
100
|
+
export async function copyEntries(source, destinationDirectory) {
|
|
101
|
+
for await (let entry of source) {
|
|
102
|
+
const destName = join(destinationDirectory, entry.name);
|
|
103
|
+
await mkdir(dirname(destName), { recursive: true });
|
|
104
|
+
await pipeline(await entry.readStream, createWriteStream(destName, { mode: entry.unixMode }));
|
|
87
105
|
}
|
|
88
106
|
}
|