npm-pkgbuild 7.3.11 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-pkgbuild",
3
- "version": "7.3.11",
3
+ "version": "7.3.12",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -7,14 +7,9 @@ import { keyValueTransformer } from "key-value-transformer";
7
7
  import { Packager } from "./packager.mjs";
8
8
  import { copyEntries, transform } from "../util.mjs";
9
9
 
10
- const executableAttributes = { mode: 0o775 };
11
-
12
- const permissions = {
13
- "DEBIAN/preinst": executableAttributes,
14
- "DEBIAN/postinst": executableAttributes,
15
- "DEBIAN/prerm": executableAttributes,
16
- "DEBIAN/postrm": executableAttributes
17
- };
10
+ const attributes = [
11
+ { pattern: /DEBIAN\/.*(inst|rm)/, mode: 0o775 }
12
+ ];
18
13
 
19
14
  export class DEB extends Packager {
20
15
  static get name() {
@@ -65,7 +60,11 @@ export class DEB extends Packager {
65
60
  }
66
61
  ];
67
62
 
68
- await copyEntries(transform(this.source, transformers), staging);
63
+ await copyEntries(
64
+ transform(this.source, transformers),
65
+ staging,
66
+ attributes
67
+ );
69
68
 
70
69
  await execa("dpkg", ["-b", staging, options.destination]);
71
70
 
@@ -75,7 +74,7 @@ export class DEB extends Packager {
75
74
 
76
75
  /**
77
76
  * @see https://www.debian.org/doc/debian-policy/ch-controlfields.html
78
- * @ https://linux.die.net/man/5/deb-control
77
+ * @see https://linux.die.net/man/5/deb-control
79
78
  */
80
79
 
81
80
  const fields = {
@@ -22,12 +22,20 @@ export class PKG extends Packager {
22
22
  }
23
23
 
24
24
  async execute(options) {
25
- const tmp = await mkdtemp(join(tmpdir(), "pkg-"));
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
@@ -97,10 +97,26 @@ export async function* transform(source, transformers) {
97
97
  * @param {AsyncIterator<ContentEntry>} source
98
98
  * @param {string} destinationDirectory
99
99
  */
100
- export async function copyEntries(source, destinationDirectory) {
100
+ export async function copyEntries(
101
+ source,
102
+ destinationDirectory,
103
+ attributes = []
104
+ ) {
101
105
  for await (let entry of source) {
102
106
  const destName = join(destinationDirectory, entry.name);
103
107
  await mkdir(dirname(destName), { recursive: true });
104
- await pipeline(await entry.readStream, createWriteStream(destName, { mode: entry.mode }));
108
+
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;
114
+ }
115
+ }
116
+
117
+ await pipeline(
118
+ await entry.readStream,
119
+ createWriteStream(destName, options)
120
+ );
105
121
  }
106
122
  }