npm-pkgbuild 7.11.10 → 7.11.14

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.11.10",
3
+ "version": "7.11.14",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -54,7 +54,7 @@
54
54
  "tar-stream": "^2.2.0"
55
55
  },
56
56
  "devDependencies": {
57
- "ava": "^3.15.0",
57
+ "ava": "^4.0.0",
58
58
  "c8": "^7.11.0",
59
59
  "documentation": "^13.2.5",
60
60
  "semantic-release": "^18.0.1",
@@ -21,9 +21,9 @@ export const pkgKeyValuePairOptions = {
21
21
  ...equalSeparatedKeyValuePairOptions,
22
22
 
23
23
  extractKeyValue: line => {
24
- const m = line.match(/^(\w+)=\s*\((.*)\)|(.*)/);
24
+ const m = line.match(/^(#\s*)?(\w+)=\s*\((.*)\)|(.*)/);
25
25
  if (m) {
26
- return [m[1], m[2] ? [m[2].split(/\s*,\s*/)] : m[3]];
26
+ return [m[2], m[3] ? m[3].split(/\s*,\s*/) : m[4]];
27
27
  }
28
28
  },
29
29
  keyValueLine: (key, value, lineEnding) =>
@@ -58,49 +58,33 @@ export class ARCH extends Packager {
58
58
  if (properties.source) {
59
59
  properties.md5sums = ["SKIP"];
60
60
  }
61
+ if (properties.hooks) {
62
+ properties.install = `${properties.name}.install`;
63
+ }
61
64
 
62
65
  const staging = await this.tmpdir;
63
66
 
64
67
  async function* trailingLines() {
65
68
  yield `
66
69
  package() {
67
- depends=(${makeDepends(dependencies).map(v=>quote(v)).join(',')})
68
- cp -r $srcdir/* "$pkgdir"
70
+ depends=(${makeDepends(dependencies)
71
+ .map(v => quote(v))
72
+ .join(",")})
73
+
74
+ if [ "$(ls -A $srcdir)" ]
75
+ then
76
+ cp -rp $srcdir/* "$pkgdir"
77
+ fi
69
78
  }
70
79
  `;
71
80
  }
72
81
 
73
- await copyEntries(
74
- transform(sources, transformer),
75
- join(staging, "src"),
76
- expander
77
- );
78
-
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
82
  if (properties.hooks) {
95
83
  async function* transformer(expression, remainder, source, cb) {
96
84
  const value = properties[expression];
97
85
  yield value === undefined ? "" : value;
98
86
  }
99
87
 
100
- const destination = join(staging, properties.hooks);
101
-
102
- await mkdir(dirname(destination), { recursive: true });
103
-
104
88
  await pipeline(
105
89
  iterableStringInterceptor(
106
90
  createReadStream(
@@ -109,11 +93,34 @@ package() {
109
93
  ),
110
94
  transformer
111
95
  ),
112
- createWriteStream(destination, utf8StreamOptions)
96
+ createWriteStream(join(staging, properties.install), utf8StreamOptions)
113
97
  );
114
98
  }
115
99
 
116
- await copyEntries(transform(sources, transformer, true), staging, expander);
100
+ const fp = fieldProvider(properties, fields);
101
+
102
+ transformer.push({
103
+ match: entry => entry.name === "PKGBUILD",
104
+ transform: async entry =>
105
+ new ReadableStreamContentEntry(
106
+ "../" + entry.name,
107
+ keyValueTransformer(await entry.readStream, fp, {
108
+ ...pkgKeyValuePairOptions,
109
+ trailingLines
110
+ })
111
+ ),
112
+ createEntryWhenMissing: () => new EmptyContentEntry("PKGBUILD")
113
+ });
114
+
115
+ for await (const file of copyEntries(
116
+ transform(sources, transformer, true),
117
+ join(staging,'src'),
118
+ expander
119
+ )) {
120
+ if (options.verbose) {
121
+ console.log(file.destination);
122
+ }
123
+ }
117
124
 
118
125
  if (options.verbose) {
119
126
  console.log(`stagingDir: ${staging}`);
@@ -137,6 +144,8 @@ package() {
137
144
  * https://www.archlinux.org/pacman/PKGBUILD.5.html
138
145
  */
139
146
  const fields = {
147
+ Maintainer: { alias: "maintainer", type: "string" },
148
+
140
149
  pkgname: { alias: "name", type: "string[]", mandatory: true },
141
150
  pkgver: { alias: "version", type: "string", mandatory: true },
142
151
  pkgrel: { alias: "release", type: "integer", default: 1, mandatory: true },
@@ -144,7 +153,7 @@ const fields = {
144
153
  pkgdesc: { alias: "description", type: "string", mandatory: true },
145
154
  url: { alias: "homepage", type: "string" },
146
155
  license: { type: "string[]", mandatory: true },
147
- install: { alias: "hooks", type: "string" },
156
+ install: { type: "string" },
148
157
  changelog: { type: "string" },
149
158
  source: { type: "string[]" },
150
159
  validpgpkeys: { type: "string[]" },
@@ -43,8 +43,16 @@ export class DEB extends Packager {
43
43
  createEntryWhenMissing: () => new EmptyContentEntry(debianControlName)
44
44
  });
45
45
 
46
- await copyEntries(transform(sources, transformer), staging, expander);
47
-
46
+ for await (const file of copyEntries(
47
+ transform(sources, transformer, true),
48
+ staging,
49
+ expander
50
+ )) {
51
+ if (options.verbose) {
52
+ console.log(file.destination);
53
+ }
54
+ }
55
+
48
56
  const dpkg = await execa("dpkg", ["-b", staging, options.destination]);
49
57
 
50
58
  if(options.verbose) {
@@ -27,7 +27,13 @@ export class RPM extends Packager {
27
27
  return fields;
28
28
  }
29
29
 
30
- async execute(sources, transformer, dependencies, options, expander) {
30
+ async execute(
31
+ sources,
32
+ transformer,
33
+ dependencies,
34
+ options,
35
+ expander
36
+ ) {
31
37
  const properties = this.properties;
32
38
  const tmp = await this.tmpdir;
33
39
 
@@ -41,31 +47,46 @@ export class RPM extends Packager {
41
47
  const specFileName = `${properties.name}.spec`;
42
48
 
43
49
  async function* trailingLines() {
44
- yield "%define _unpackaged_files_terminate_build 0\n";
50
+ yield "%define _unpackaged_files_terminate_build 0\n";
45
51
 
46
52
  for (const [name, options] of Object.entries(sections)) {
47
53
  if (options.mandatory) {
48
54
  yield `%${name}\n\n`;
55
+
56
+ if (name === "files") {
57
+ for await (const file of copyEntries(
58
+ transform(sources, transformer),
59
+ staging,
60
+ expander
61
+ )) {
62
+ yield file.destination + "\n";
63
+ }
64
+ }
49
65
  }
50
66
  }
51
67
  }
52
68
 
53
69
  const fp = fieldProvider(properties, fields);
54
70
 
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
- });
67
-
68
- await copyEntries(transform(sources, transformer), staging, expander);
71
+ for await (const file of copyEntries(
72
+ transform(sources, [
73
+ {
74
+ match: entry => entry.name === specFileName,
75
+ transform: async entry =>
76
+ new ReadableStreamContentEntry(
77
+ entry.name,
78
+ keyValueTransformer(await entry.readStream, fp, {
79
+ ...colonSeparatedKeyValuePairOptions,
80
+ trailingLines
81
+ })
82
+ ),
83
+ createEntryWhenMissing: () => new EmptyContentEntry(specFileName)
84
+ }
85
+ ]),
86
+ staging,
87
+ expander
88
+ )) {
89
+ }
69
90
 
70
91
  const rpmbuild = await execa("rpmbuild", [
71
92
  "--define",
@@ -101,7 +122,8 @@ const fields = {
101
122
  Release: { alias: "release", type: "integer", default: 1, mandatory: true },
102
123
  Source0: { alias: "source", type: "string" },
103
124
  Group: { alias: "group", type: "string" },
104
- Packager: { type: "string" },
125
+ Packager: { alias: "maintainer", type: "string" },
126
+ Vendor: { alias: "vendor", type: "string" },
105
127
  BuildArch: {
106
128
  alias: "arch",
107
129
  default: "noarch",
package/src/util.mjs CHANGED
@@ -32,6 +32,10 @@ export function asArray(o) {
32
32
  * @returns {Function}
33
33
  */
34
34
  export function fieldProvider(properties, fields) {
35
+ function av(field, value) {
36
+ return field.type.endsWith("]") ? asArray(value) : value;
37
+ }
38
+
35
39
  return function* controlProperties(k, v, presentKeys) {
36
40
  if (k === undefined) {
37
41
  for (const [name, field] of Object.entries(fields)) {
@@ -46,17 +50,12 @@ export function fieldProvider(properties, fields) {
46
50
  yield [name, field.default];
47
51
  }
48
52
  } else {
49
- yield [
50
- name,
51
- field.type.endsWith("]") && !Array.isArray(value)
52
- ? [value]
53
- : value
54
- ];
53
+ yield [name, av(field, value)];
55
54
  }
56
55
  }
57
56
  }
58
57
  } else {
59
- yield [k, properties[k] || v];
58
+ yield [k, av(fields[k], properties[k] || v)];
60
59
  }
61
60
  };
62
61
  }
@@ -75,7 +74,9 @@ export async function extractFromPackage(pkg, dir) {
75
74
  );
76
75
 
77
76
  if (pkg.bugs) {
78
- properties.bugs = pkg.bugs.url;
77
+ if (pkg.bugs.url) {
78
+ properties.bugs = pkg.bugs.url;
79
+ }
79
80
  }
80
81
 
81
82
  Object.assign(properties, pkg.config);
@@ -207,19 +208,22 @@ export async function* transform(source, transformers = [], onlyMatching) {
207
208
  * @param {Expander} expander
208
209
  * @param {ContentEntryAttribute[]} attributes
209
210
  */
210
- export async function copyEntries(
211
+ export async function* copyEntries(
211
212
  source,
212
213
  destinationDirectory,
213
214
  expander = v => v
214
215
  ) {
215
216
  for await (let entry of source) {
216
- const destination = expander(
217
+ const name = expander(
217
218
  entry.destination === undefined
218
- ? join(destinationDirectory, entry.name)
219
+ ? entry.name
219
220
  : entry.destination.endsWith("/")
220
- ? join(destinationDirectory, entry.destination, entry.name)
221
- : join(destinationDirectory, entry.destination)
221
+ ? join(entry.destination, entry.name)
222
+ : entry.destination
222
223
  );
224
+
225
+ entry.destination = name;
226
+ const destination = join(destinationDirectory, name);
223
227
  await mkdir(dirname(destination), { recursive: true });
224
228
 
225
229
  const options = { mode: entry.mode };
@@ -228,5 +232,7 @@ export async function copyEntries(
228
232
  await entry.readStream,
229
233
  createWriteStream(destination, options)
230
234
  );
235
+
236
+ yield entry;
231
237
  }
232
238
  }