pmcf 4.15.12 → 4.15.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": "pmcf",
3
- "version": "4.15.12",
3
+ "version": "4.15.14",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  import { FileContentProvider } from "npm-pkgbuild";
8
8
  import {
9
9
  getAttribute,
10
+ toInternal,
10
11
  typeFactory,
11
12
  addType,
12
13
  parse,
@@ -114,6 +115,7 @@ export class Base {
114
115
  }
115
116
 
116
117
  const assign = (name, attribute, value) => {
118
+ value = toInternal(value, attribute);
117
119
  value ??= attribute.default;
118
120
 
119
121
  if (value !== undefined) {
@@ -132,7 +134,11 @@ export class Base {
132
134
  break;
133
135
  case "object":
134
136
  if (Array.isArray(current)) {
135
- current.push(value);
137
+ if (Array.isArray(value)) {
138
+ current.push(...value);
139
+ } else {
140
+ current.push(value);
141
+ }
136
142
  } else {
137
143
  if (current instanceof Set) {
138
144
  // TODO
@@ -370,8 +376,8 @@ export class Base {
370
376
  }
371
377
 
372
378
  /**
373
- *
374
- * @param {string} name
379
+ *
380
+ * @param {string} name
375
381
  * @returns {any}
376
382
  */
377
383
  extendedAttribute(name) {
@@ -548,8 +554,7 @@ export class Base {
548
554
 
549
555
  async *preparePackages(stagingDir) {}
550
556
 
551
- get templateTransformers()
552
- {
557
+ get templateTransformers() {
553
558
  return [
554
559
  createExpressionTransformer(
555
560
  e => e.isBlob,
package/src/host.mjs CHANGED
@@ -17,7 +17,8 @@ import {
17
17
  domainFromDominName,
18
18
  domainName,
19
19
  writeLines,
20
- asArray
20
+ asArray,
21
+ union
21
22
  } from "./utils.mjs";
22
23
  import { loadHooks } from "./hooks.mjs";
23
24
  import { generateKnownHosts } from "./host-utils.mjs";
@@ -203,11 +204,7 @@ export class Host extends ServiceOwner {
203
204
  }
204
205
 
205
206
  set aliases(value) {
206
- if (value instanceof Set) {
207
- this._aliases = this._aliases.union(value);
208
- } else {
209
- this._aliases.add(value);
210
- }
207
+ this._aliases = union(value, this._aliases);
211
208
  }
212
209
 
213
210
  get aliases() {
@@ -215,11 +212,7 @@ export class Host extends ServiceOwner {
215
212
  }
216
213
 
217
214
  set provides(value) {
218
- if (value instanceof Set) {
219
- this._provides = this._provides.union(value);
220
- } else {
221
- this._provides.add(value);
222
- }
215
+ this._provides = union(value, this._provides);
223
216
  }
224
217
 
225
218
  get provides() {
@@ -229,11 +222,7 @@ export class Host extends ServiceOwner {
229
222
  }
230
223
 
231
224
  set replaces(value) {
232
- if (value instanceof Set) {
233
- this._replaces = this._replaces.union(value);
234
- } else {
235
- this._replaces.add(value);
236
- }
225
+ this._replaces = union(value, this._replaces);
237
226
  }
238
227
 
239
228
  get replaces() {
@@ -243,11 +232,7 @@ export class Host extends ServiceOwner {
243
232
  }
244
233
 
245
234
  set depends(value) {
246
- if (value instanceof Set) {
247
- this._depends = this._depends.union(value);
248
- } else {
249
- this._depends.add(value);
250
- }
235
+ this._depends = union(value, this._depends);
251
236
  }
252
237
 
253
238
  get depends() {
@@ -460,7 +445,7 @@ export class Host extends ServiceOwner {
460
445
  );
461
446
 
462
447
  for (const ni of this.networkInterfaces.values()) {
463
- await ni.systemdDefinitions(packageData);
448
+ await ni.systemdDefinitions(dir, packageData);
464
449
  }
465
450
 
466
451
  if (this.keymap) {
@@ -506,3 +491,4 @@ export class Host extends ServiceOwner {
506
491
  }
507
492
  }
508
493
  }
494
+
package/src/location.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FileContentProvider } from "npm-pkgbuild";
2
- import { string_collection_attribute_writable, addType } from "pacc";
2
+ import { addType } from "pacc";
3
3
  import { Owner } from "pmcf";
4
4
  import { loadHooks } from "./hooks.mjs";
5
5
 
@@ -9,7 +9,6 @@ const LocationTypeDefinition = {
9
9
  extends: Owner.typeDefinition,
10
10
  key: "name",
11
11
  attributes: {
12
- locales: string_collection_attribute_writable
13
12
  }
14
13
  };
15
14
 
@@ -197,10 +197,10 @@ export class NetworkInterface extends SkeletonNetworkInterface {
197
197
  return this.extendedAttribute("_kind") ?? this.network?.kind;
198
198
  }
199
199
 
200
- async systemdDefinitions(packageData) {
201
- await super.systemdDefinitions(packageData);
200
+ async systemdDefinitions(dir, packageData) {
201
+ await super.systemdDefinitions(dir, packageData);
202
202
 
203
- const networkDir = join(packageData.dir, "etc/systemd/network");
203
+ const networkDir = join(dir, "etc/systemd/network");
204
204
 
205
205
  if (this.name !== "eth0" && this.hwaddr) {
206
206
  const disabled = {};
@@ -96,8 +96,8 @@ export class SkeletonNetworkInterface extends ServiceOwner {
96
96
  return [...this.ipAddresses].map(([address]) => address);
97
97
  }
98
98
 
99
- async systemdDefinitions(packageData) {
100
- const networkDir = join(packageData.dir, "etc/systemd/network");
99
+ async systemdDefinitions(dir) {
100
+ const networkDir = join(dir, "etc/systemd/network");
101
101
 
102
102
  if (this.name !== "eth0" && this.hwaddr) {
103
103
  await writeLines(networkDir, `${this.name}.link`, [
@@ -23,5 +23,5 @@ export class TUNNetworkInterface extends NetworkInterface {
23
23
  return TUNdNetworkInterfaceTypeDefinition.name;
24
24
  }
25
25
 
26
- async systemdDefinitions(packageData) {}
26
+ async systemdDefinitions(dir, packageData) {}
27
27
  }
@@ -74,20 +74,20 @@ export class WLANNetworkInterface extends EthernetNetworkInterface {
74
74
  return this.extendedAttribute("_psk") ?? this.network?.psk;
75
75
  }
76
76
 
77
- async systemdDefinitions(packageData) {
78
- await super.systemdDefinitions(packageData);
79
- await mkdir(join(packageData.dir, "var/lib/iwd/"), { recursive: true });
77
+ async systemdDefinitions(dir, packageData) {
78
+ await super.systemdDefinitions(dir, packageData);
79
+ await mkdir(join(dir, "var/lib/iwd/"), { recursive: true });
80
80
 
81
81
  const secretName = this.secretName;
82
82
 
83
- await writeLines(join(packageData.dir, "/etc/iwd"), "main.conf", [
83
+ await writeLines(join(dir, "/etc/iwd"), "main.conf", [
84
84
  sectionLines("General", {
85
85
  SystemdEncrypt: secretName
86
86
  })
87
87
  ]);
88
88
 
89
89
  await writeLines(
90
- join(packageData.dir, "usr/lib/systemd/system/iwd.service.d/"),
90
+ join(dir, "usr/lib/systemd/system/iwd.service.d/"),
91
91
  "pmcf.conf",
92
92
  [
93
93
  sectionLines("Service", {
package/src/owner.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  addType,
9
9
  types
10
10
  } from "pacc";
11
- import { asIterator } from "./utils.mjs";
11
+ import { asIterator, union } from "./utils.mjs";
12
12
  import { Base } from "./base.mjs";
13
13
  import { Subnet, SUBNET_GLOBAL_IPV4, SUBNET_GLOBAL_IPV6 } from "./subnet.mjs";
14
14
  import { networks_attribute } from "./network-support.mjs";
@@ -364,11 +364,7 @@ export class Owner extends Base {
364
364
  _locales = new Set();
365
365
 
366
366
  set locales(value) {
367
- if (value instanceof Set) {
368
- this._locales = this._locales.union(value);
369
- } else {
370
- this._locales.add(value);
371
- }
367
+ this._locales = union(value, this._locales);
372
368
  }
373
369
 
374
370
  get locales() {
@@ -443,13 +439,7 @@ export class Owner extends Base {
443
439
  _architectures;
444
440
 
445
441
  set architectures(value) {
446
- if (value instanceof Set) {
447
- this._architectures = this._architectures
448
- ? this._architectures.union(value)
449
- : value;
450
- } else {
451
- this._architectures = new Set(value);
452
- }
442
+ this._architectures = union(value, this._architectures);
453
443
  }
454
444
 
455
445
  get architectures() {
@@ -328,12 +328,14 @@ export class BindService extends ExtraSourceService {
328
328
  access: "private"
329
329
  };
330
330
 
331
- yield this.generateZoneDefs(newOutputControl(packageData), sources);
331
+ yield this.generateZoneDefs(newOutputControl(packageData, zonesPackageDir), sources);
332
332
 
333
333
  const location = "outfacing";
334
334
 
335
+ const outfacingZonesPackageDir = join(dir, location) + "/";
336
+
335
337
  packageData.sources = [
336
- new FileContentProvider(join(dir, location) + "/", ...filePermissions)
338
+ new FileContentProvider(outfacingZonesPackageDir, ...filePermissions)
337
339
  ];
338
340
  packageData.properties = {
339
341
  name: `named-zones-${name}-${location}`,
@@ -341,7 +343,7 @@ export class BindService extends ExtraSourceService {
341
343
  access: "private"
342
344
  };
343
345
 
344
- yield* this.generateOutfacingDefs(newOutputControl(packageData), sources);
346
+ yield* this.generateOutfacingDefs(newOutputControl(packageData, outfacingZonesPackageDir), sources);
345
347
  }
346
348
 
347
349
  async *generateOutfacingDefs(outputControl, sources) {
@@ -366,7 +368,7 @@ export class BindService extends ExtraSourceService {
366
368
  .join(" ")}`
367
369
  );
368
370
 
369
- await this.writeZones(outputControl.packageData, outputControl.configs);
371
+ await this.writeZones(outputControl);
370
372
 
371
373
  yield outputControl.packageData;
372
374
  }
@@ -511,7 +513,7 @@ export class BindService extends ExtraSourceService {
511
513
  }
512
514
  }
513
515
 
514
- await this.writeZones(outputControl.packageData, outputControl.configs);
516
+ await this.writeZones(outputControl);
515
517
 
516
518
  return outputControl.packageData;
517
519
  }
@@ -617,8 +619,8 @@ export class BindService extends ExtraSourceService {
617
619
  return [SOARecord, NSRecord];
618
620
  }
619
621
 
620
- async writeZones(packageData, configs) {
621
- for (const config of configs) {
622
+ async writeZones(outputControl) {
623
+ for (const config of outputControl.configs) {
622
624
  console.log(`config: ${config.view.name}/${config.name}`);
623
625
 
624
626
  const content = [];
@@ -652,7 +654,7 @@ export class BindService extends ExtraSourceService {
652
654
  }
653
655
 
654
656
  await writeLines(
655
- join(packageData.dir, "var/lib/named"),
657
+ join(outputControl.dir, "var/lib/named"),
656
658
  zone.file,
657
659
  [...zone.records]
658
660
  .sort(sortZoneRecords)
@@ -661,7 +663,7 @@ export class BindService extends ExtraSourceService {
661
663
  }
662
664
 
663
665
  await writeLines(
664
- join(packageData.dir, `etc/named/${config.view.name}`),
666
+ join(outputControl.dir, `etc/named/${config.view.name}`),
665
667
  config.name,
666
668
  content
667
669
  );
@@ -669,6 +671,6 @@ export class BindService extends ExtraSourceService {
669
671
  }
670
672
  }
671
673
 
672
- function newOutputControl(packageData) {
673
- return { configs: [], catalogs: new Map(), packageData };
674
+ function newOutputControl(packageData, dir) {
675
+ return { configs: [], catalogs: new Map(), packageData, dir };
674
676
  }
@@ -93,7 +93,7 @@ export class SystemdResolvedService extends ExtraSourceService {
93
93
  services: `in("dns",types) && priority>=${lower} && priority<=${upper}`,
94
94
  endpoints: e =>
95
95
  e.family == "IPv4" &&
96
- // e.networkInterface &&
96
+ e.networkInterface &&
97
97
  e.networkInterface.kind !== "loopback",
98
98
  //e.family !== "dns",
99
99
  select: endpoint => endpoint.address,
package/src/utils.mjs CHANGED
@@ -120,3 +120,14 @@ export function asIterator(value) {
120
120
 
121
121
  export const filterConfigurable = (name, attribute) =>
122
122
  !attribute.private & attribute.configurable;
123
+
124
+
125
+ export function union(value, present= new Set()) {
126
+ if (value instanceof Set) {
127
+ return present.union(value);
128
+ } else if (value instanceof Array) {
129
+ return present.union(new Set(value));
130
+ }
131
+ present.add(value);
132
+ return present;
133
+ }
@@ -344,9 +344,7 @@ export class Location extends Owner {
344
344
  };
345
345
  };
346
346
  key: string;
347
- attributes: {
348
- locales: import("pacc").AttributeDefinition;
349
- };
347
+ attributes: {};
350
348
  };
351
349
  get location(): this;
352
350
  preparePackages(dir: any): AsyncGenerator<{
@@ -1106,6 +1106,7 @@ export class NetworkInterface extends SkeletonNetworkInterface {
1106
1106
  get class(): any;
1107
1107
  set kind(value: any);
1108
1108
  get kind(): any;
1109
+ systemdDefinitions(dir: any, packageData: any): Promise<void>;
1109
1110
  }
1110
1111
  import { Base } from "pmcf";
1111
1112
  import { SkeletonNetworkInterface } from "./skeleton.mjs";
@@ -23,7 +23,7 @@ export class SkeletonNetworkInterface extends ServiceOwner {
23
23
  networkAddress(filter: any): NetworkAddress;
24
24
  get address(): any;
25
25
  get addresses(): any[];
26
- systemdDefinitions(packageData: any): Promise<void>;
26
+ systemdDefinitions(dir: any): Promise<void>;
27
27
  }
28
28
  import { ServiceOwner } from "../service-owner.mjs";
29
29
  import { Host } from "pmcf";
@@ -1512,6 +1512,6 @@ export class BindService extends ExtraSourceService {
1512
1512
  values: any[];
1513
1513
  toString: (maxKeyLength?: number, ttl?: string) => string;
1514
1514
  }[];
1515
- writeZones(packageData: any, configs: any): Promise<void>;
1515
+ writeZones(outputControl: any): Promise<void>;
1516
1516
  }
1517
1517
  import { ExtraSourceService } from "pmcf";
package/types/utils.d.mts CHANGED
@@ -33,4 +33,5 @@ export function asArray(value: any): Array<any>;
33
33
  * @returns {Iterable<any>}
34
34
  */
35
35
  export function asIterator(value: any): Iterable<any>;
36
+ export function union(value: any, present?: Set<any>): Set<any>;
36
37
  export function filterConfigurable(name: any, attribute: any): number;