pmcf 6.38.4 → 6.39.0

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": "6.38.4",
3
+ "version": "6.39.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -45,7 +45,6 @@ export class Base extends core {
45
45
  name: "template",
46
46
  private: true
47
47
  },
48
-
49
48
  content: { ...default_attribute_writable, type: "content", name: "content" }
50
49
  };
51
50
 
package/src/content.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ name_attribute_writable,
2
3
  string_attribute_writable,
3
4
  string_set_attribute_writable,
4
5
  default_collection_attribute_writable
@@ -6,6 +7,7 @@ import {
6
7
  import { allOutputs } from "npm-pkgbuild";
7
8
  import { core, addType } from "pmcf";
8
9
  import { union } from "./utils.mjs";
10
+ import { loadHooks } from "./hooks.mjs";
9
11
 
10
12
  export class permission extends core {
11
13
  static priority = 1.9;
@@ -28,6 +30,7 @@ export class permission extends core {
28
30
  export class content extends core {
29
31
  static priority = 1.9;
30
32
  static attributes = {
33
+ name: name_attribute_writable,
31
34
  permissions: {
32
35
  ...default_collection_attribute_writable,
33
36
  type: permission,
@@ -38,12 +41,13 @@ export class content extends core {
38
41
  name: "access",
39
42
  default: "private"
40
43
  },
41
- replaces: { ...string_set_attribute_writable, name: "replaces" },
42
44
  depends: { ...string_set_attribute_writable, name: "depends" },
43
45
  provides: { ...string_set_attribute_writable, name: "provides" },
46
+ replaces: { ...string_set_attribute_writable, name: "replaces" },
44
47
  optional: { ...string_set_attribute_writable, name: "optional" },
45
48
  groups: { ...string_set_attribute_writable, name: "groups" },
46
49
  backup: { ...string_set_attribute_writable, name: "backup" },
50
+ hooks: { ...string_set_attribute_writable, name: "hooks" },
47
51
  packaging: { ...string_set_attribute_writable, name: "packaging" }
48
52
  };
49
53
 
@@ -58,14 +62,26 @@ export class content extends core {
58
62
  _depends = new Set();
59
63
  _optional = new Set();
60
64
  _groups = new Set();
65
+ _hooks = new Set();
66
+
67
+ value(name) {
68
+ // console.log("CONTENT VALUE", this.name, this.owner.fullName, name, this.owner.name);
69
+ return this.owner.value(name) ?? super.value(name);
70
+ }
61
71
 
62
72
  get name() {
63
- return "content";
73
+ let name = this.attribute("_name");
74
+ if (name !== undefined) {
75
+ return name;
76
+ }
77
+
78
+ const node = this.owner;
79
+ const nameParts = [node.typeName, node.owner?.name, node.name];
80
+ return nameParts.filter(n => n !== undefined && n.length > 0).join("-");
64
81
  }
65
82
 
66
- value(name) {
67
- // console.log("CONTENT VALUE", this.name, this.owner.fullName, name, this.owner.name);
68
- return this.owner.value(name) ?? super.value(name);
83
+ set name(value) {
84
+ this._name = value;
69
85
  }
70
86
 
71
87
  /**
@@ -84,7 +100,7 @@ export class content extends core {
84
100
  }
85
101
 
86
102
  get packaging() {
87
- return this.unionFromDirections(["this", "extends"], "_packaging")
103
+ return this.unionFromDirections(["this", "extends"], "_packaging");
88
104
  }
89
105
 
90
106
  get outputs() {
@@ -151,6 +167,14 @@ export class content extends core {
151
167
  );
152
168
  }
153
169
 
170
+ set hooks(value) {
171
+ this._hooks = union(value, this._hooks);
172
+ }
173
+
174
+ get hooks() {
175
+ return this.expand(this.unionFromDirections(["this", "extends"], "_hooks"));
176
+ }
177
+
154
178
  get permissions() {
155
179
  const p = this.mapFromDirections(["this", "extends"], "_permissions");
156
180
 
@@ -174,14 +198,12 @@ export class content extends core {
174
198
  */
175
199
  }
176
200
 
177
- packageData(node) {
178
- const nameParts = [node.typeName, node.owner?.name, node.name];
179
-
180
- return {
201
+ async packageData(node) {
202
+ const packageData = {
181
203
  sources: [],
182
204
  outputs: this.outputs,
183
205
  properties: {
184
- name: nameParts.filter(n => n !== undefined && n.length > 0).join("-"),
206
+ name: this.name,
185
207
  description: `${node.typeName} definitions for ${node.fullName}`,
186
208
  access: this.access,
187
209
  groups: [...this.groups],
@@ -192,5 +214,14 @@ export class content extends core {
192
214
  backup: [...this.backup]
193
215
  }
194
216
  };
217
+
218
+ for (const hook of this.hooks) {
219
+ await loadHooks(
220
+ packageData,
221
+ new URL("host.install", import.meta.url).pathname
222
+ );
223
+ }
224
+
225
+ return packageData;
195
226
  }
196
227
  }
@@ -270,16 +270,8 @@ export class CoreService extends Base {
270
270
  );
271
271
  }
272
272
 
273
- get packageData() {
274
- const packageData = super.packageData;
275
- const name = `${this.owner.owner.name}-${this.owner.name}`;
276
- packageData.properties.name = `${this.name}-${name}`;
277
- packageData.properties.groups.push("config", name);
278
- return packageData;
279
- }
280
-
281
273
  async *preparePackages(dir) {
282
- const pd = this.packageData;
274
+ const pd = await this.packageData;
283
275
 
284
276
  pd.sources = await Array.fromAsync(
285
277
  this.templateContent(this.content.permissions)
package/src/host.mjs CHANGED
@@ -19,7 +19,6 @@ import {
19
19
  import { ServiceOwner } from "./service-owner.mjs";
20
20
  import { addHook } from "./hooks.mjs";
21
21
  import { domainFromDominName, domainName, writeLines } from "./utils.mjs";
22
- import { loadHooks } from "./hooks.mjs";
23
22
  import { generateKnownHosts } from "./host-utils.mjs";
24
23
 
25
24
  export class Host extends ServiceOwner {
@@ -312,7 +311,7 @@ export class Host extends ServiceOwner {
312
311
  }
313
312
 
314
313
  async *preparePackages(dir) {
315
- const packageData = this.packageData;
314
+ const packageData = await this.packageData;
316
315
 
317
316
  packageData.sources.push(
318
317
  await Array.fromAsync(this.templateContent()),
@@ -323,11 +322,6 @@ export class Host extends ServiceOwner {
323
322
  })
324
323
  );
325
324
 
326
- await loadHooks(
327
- packageData,
328
- new URL("host.install", import.meta.url).pathname
329
- );
330
-
331
325
  for (const ni of this.networkInterfaces.values()) {
332
326
  await ni.systemdDefinitions(dir, packageData);
333
327
  }
package/src/host.install DELETED
@@ -1,17 +0,0 @@
1
- post_install()
2
- {
3
- ls -l /etc/resolv.conf | grep -q /run/systemd/resolve/resolv.conf
4
- if [ $? = 1 ]
5
- then
6
- ln -f -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
7
- fi
8
- }
9
-
10
- post_upgrade()
11
- {
12
- ls -l /etc/resolv.conf | grep -q /run/systemd/resolve/resolv.conf
13
- if [ $? = 1 ]
14
- then
15
- ln -f -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
16
- fi
17
- }