npm-pkgbuild 11.1.17 → 11.2.1

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": "11.1.17",
3
+ "version": "11.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,7 +36,11 @@ program
36
36
  Object.assign(former, Object.fromEntries([str.split(/=/)]))
37
37
  )
38
38
  .option("-p --dir <dir>", "which package to use", process.cwd())
39
- .option("-a --available", "only execute availabe output/arch combintions", false)
39
+ .option(
40
+ "-a --available",
41
+ "only execute availabe output/arch combintions",
42
+ false
43
+ )
40
44
  .option("--continue", "continue on error")
41
45
  .option(
42
46
  "-c --content <dir>",
@@ -72,7 +76,10 @@ program
72
76
  for (const outputFactory of allOutputs.filter(
73
77
  o => options[o.name] === true || output[o.name] !== undefined
74
78
  )) {
75
- if (options.available && !(await outputFactory.prepare(options))) {
79
+ if (
80
+ options.available &&
81
+ !(await outputFactory.prepare(options, variant))
82
+ ) {
76
83
  continute;
77
84
  }
78
85
 
@@ -127,11 +134,11 @@ program
127
134
 
128
135
  if (options.verbose) {
129
136
  console.log("variant:");
130
- console.log(kv(variant," "));
137
+ console.log(kv(variant, " "));
131
138
  console.log("sources:");
132
139
  console.log(" " + sources.join("\n "));
133
140
  console.log("dependencies:");
134
- console.log(kv(dependencies," "));
141
+ console.log(kv(dependencies, " "));
135
142
  console.log(kv(output.properties));
136
143
  }
137
144
 
@@ -166,8 +173,10 @@ function handleError(e, options) {
166
173
  }
167
174
  }
168
175
 
169
- function kv(object, prefix="") {
170
- return object ? Object.entries(object)
171
- .map(([k, v]) => `${prefix}${k}: ${v}`)
172
- .join("\n"): "";
176
+ function kv(object, prefix = "") {
177
+ return object
178
+ ? Object.entries(object)
179
+ .map(([k, v]) => `${prefix}${k}: ${v}`)
180
+ .join("\n")
181
+ : "";
173
182
  }
@@ -56,6 +56,7 @@ const PKGBUILD = "PKGBUILD";
56
56
 
57
57
  let _ext = ".pkg.tar.xz";
58
58
  let _prepared;
59
+ let _architecture = "aarch64";
59
60
 
60
61
  export class ARCH extends Packager {
61
62
  static get name() {
@@ -74,7 +75,7 @@ export class ARCH extends Packager {
74
75
  return fields;
75
76
  }
76
77
 
77
- static async prepare(options) {
78
+ static async prepare(options, variant) {
78
79
  if (_prepared === undefined) {
79
80
  try {
80
81
  await execa("makepkg", ["-V"]);
@@ -83,20 +84,25 @@ export class ARCH extends Packager {
83
84
  if (options.verbose) {
84
85
  console.log(cfg);
85
86
  }
86
- const i = cfg.indexOf("PKGEXT='");
87
- if (i > 0) {
88
- const m = cfg
89
- .substring(i)
90
- .split(/\n/)[0]
91
- .match(/='([^']+)'/);
92
- _ext = m[1];
87
+
88
+ function getValue(key) {
89
+ const i = cfg.indexOf(`${key}='`);
90
+ if (i > 0) {
91
+ const m = cfg
92
+ .substring(i)
93
+ .split(/\n/)[0]
94
+ .match(/='([^'"]+)['"]/);
95
+ return m[1];
96
+ }
93
97
  }
98
+ _ext = getValue("PKGEXT");
99
+ _architecture = getValue("CARCH");
94
100
  _prepared = true;
95
101
  } catch {
96
102
  _prepared = false;
97
103
  }
98
104
  }
99
- return _prepared;
105
+ return _prepared && !variant || variant.arch === _architecture;
100
106
  }
101
107
 
102
108
  get packageFileName() {
@@ -172,9 +178,7 @@ package() {
172
178
  }
173
179
 
174
180
  if (options.verbose) {
175
- console.log(
176
- await readFile(join(staging, PKGBUILD), utf8StreamOptions)
177
- );
181
+ console.log(await readFile(join(staging, PKGBUILD), utf8StreamOptions));
178
182
  }
179
183
 
180
184
  if (!options.dry) {
@@ -80,9 +80,13 @@ export class RPM extends Packager {
80
80
  * Check for rpmbuild presence.
81
81
  * @returns {boolean} true when rpmbuild is present
82
82
  */
83
- static async prepare() {
83
+ static async prepare(options, variant) {
84
84
  try {
85
85
  await execa("rpmbuild", ["--version"]);
86
+ if (variant?.arch) {
87
+ const uname = await execa("uname", ["-m"]);
88
+ return uname.stdout.match(variant.arch);
89
+ }
86
90
  return true;
87
91
  } catch {}
88
92
 
@@ -184,10 +188,13 @@ export class RPM extends Packager {
184
188
  }
185
189
 
186
190
  await cp(
187
- join(tmpdir, "RPMS",
191
+ join(
192
+ tmpdir,
193
+ "RPMS",
188
194
  // TODO handle arrays ?
189
195
  Array.isArray(properties.arch) ? properties.arch[0] : properties.arch,
190
- this.packageFileName),
196
+ this.packageFileName
197
+ ),
191
198
  packageFile,
192
199
  { preserveTimestamps: true }
193
200
  );