pmcf 6.38.5 → 6.39.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/README.md +2 -2
- package/bin/pmcf-info +24 -17
- package/package.json +1 -1
- package/src/base.mjs +0 -5
- package/src/content.mjs +48 -12
- package/src/core-service.mjs +1 -9
- package/src/core.mjs +4 -0
- package/src/host.mjs +1 -7
- package/src/initialization-context.mjs +2 -2
- package/src/host.install +0 -17
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ generates config packages for:
|
|
|
117
117
|
|
|
118
118
|
## Base
|
|
119
119
|
|
|
120
|
-
**Extends
|
|
120
|
+
**Extends core**
|
|
121
121
|
|
|
122
122
|
attributes: as declared in the types
|
|
123
123
|
properties: use defined values to support attribute value definitions
|
|
@@ -214,7 +214,7 @@ Walk the object graph in some directions and deliver seen nodes.
|
|
|
214
214
|
|
|
215
215
|
* `directions` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** (optional, default `["this","extends","owner"]`)
|
|
216
216
|
|
|
217
|
-
Returns **Iterable\<
|
|
217
|
+
Returns **Iterable\<core>** 
|
|
218
218
|
|
|
219
219
|
## mapFromDirections
|
|
220
220
|
|
package/bin/pmcf-info
CHANGED
|
@@ -112,25 +112,32 @@ function show(value, indent, options) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
} else {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
115
|
+
if (typeof v.get === "function") {
|
|
116
|
+
console.log(name(attribute));
|
|
117
|
+
for(const [k,o] of v) {
|
|
118
|
+
show(o,indent + 2, options);
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
try {
|
|
122
|
+
const l = [...v];
|
|
123
|
+
|
|
124
|
+
if (l.length > 1) {
|
|
125
|
+
console.log(name(attribute));
|
|
126
|
+
|
|
127
|
+
if (l.length >= options.maxEntries) {
|
|
128
|
+
l[options.maxEntries] = { fullName: "..." };
|
|
129
|
+
l.length = options.maxEntries + 1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
for (const o of l) {
|
|
133
|
+
console.log(prefix(indent + 2) + o.fullName);
|
|
134
|
+
}
|
|
135
|
+
} else if (l.length === 1) {
|
|
136
|
+
console.log(name(attribute) + l[0].fullName);
|
|
128
137
|
}
|
|
129
|
-
}
|
|
130
|
-
console.log(name(attribute)
|
|
138
|
+
} catch (e) {
|
|
139
|
+
console.log(name(attribute), v);
|
|
131
140
|
}
|
|
132
|
-
} catch (e) {
|
|
133
|
-
console.log(name(attribute), v);
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
143
|
} else {
|
package/package.json
CHANGED
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
|
|
|
@@ -101,10 +100,6 @@ export class Base extends core {
|
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
get root() {
|
|
105
|
-
return this.owner?.root;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
103
|
get host() {
|
|
109
104
|
return this.owner?.host;
|
|
110
105
|
}
|
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,9 +7,11 @@ 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;
|
|
14
|
+
static key = "pattern";
|
|
12
15
|
static attributes = {
|
|
13
16
|
pattern: { ...string_attribute_writable, key: true, name: "pattern" },
|
|
14
17
|
user: { ...string_attribute_writable, name: "user" },
|
|
@@ -20,7 +23,7 @@ export class permission extends core {
|
|
|
20
23
|
addType(this);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
get
|
|
26
|
+
get fullName() {
|
|
24
27
|
return this.pattern;
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -28,6 +31,7 @@ export class permission extends core {
|
|
|
28
31
|
export class content extends core {
|
|
29
32
|
static priority = 1.9;
|
|
30
33
|
static attributes = {
|
|
34
|
+
name: name_attribute_writable,
|
|
31
35
|
permissions: {
|
|
32
36
|
...default_collection_attribute_writable,
|
|
33
37
|
type: permission,
|
|
@@ -38,12 +42,13 @@ export class content extends core {
|
|
|
38
42
|
name: "access",
|
|
39
43
|
default: "private"
|
|
40
44
|
},
|
|
41
|
-
replaces: { ...string_set_attribute_writable, name: "replaces" },
|
|
42
45
|
depends: { ...string_set_attribute_writable, name: "depends" },
|
|
43
46
|
provides: { ...string_set_attribute_writable, name: "provides" },
|
|
47
|
+
replaces: { ...string_set_attribute_writable, name: "replaces" },
|
|
44
48
|
optional: { ...string_set_attribute_writable, name: "optional" },
|
|
45
49
|
groups: { ...string_set_attribute_writable, name: "groups" },
|
|
46
50
|
backup: { ...string_set_attribute_writable, name: "backup" },
|
|
51
|
+
hooks: { ...string_set_attribute_writable, name: "hooks" },
|
|
47
52
|
packaging: { ...string_set_attribute_writable, name: "packaging" }
|
|
48
53
|
};
|
|
49
54
|
|
|
@@ -58,14 +63,30 @@ export class content extends core {
|
|
|
58
63
|
_depends = new Set();
|
|
59
64
|
_optional = new Set();
|
|
60
65
|
_groups = new Set();
|
|
66
|
+
_hooks = new Set();
|
|
67
|
+
|
|
68
|
+
value(name) {
|
|
69
|
+
// console.log("CONTENT VALUE", this.name, this.owner.fullName, name, this.owner.name);
|
|
70
|
+
return this.owner.value(name) ?? super.value(name);
|
|
71
|
+
}
|
|
61
72
|
|
|
62
73
|
get name() {
|
|
63
|
-
|
|
74
|
+
let name = this.attribute("_name");
|
|
75
|
+
if (name !== undefined) {
|
|
76
|
+
return name;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const node = this.owner;
|
|
80
|
+
const nameParts = [node.typeName, node.owner?.name, node.name];
|
|
81
|
+
return nameParts.filter(n => n !== undefined && n.length > 0).join("-");
|
|
64
82
|
}
|
|
65
83
|
|
|
66
|
-
value
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
set name(value) {
|
|
85
|
+
this._name = value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get fullName() {
|
|
89
|
+
return this.name;
|
|
69
90
|
}
|
|
70
91
|
|
|
71
92
|
/**
|
|
@@ -84,7 +105,7 @@ export class content extends core {
|
|
|
84
105
|
}
|
|
85
106
|
|
|
86
107
|
get packaging() {
|
|
87
|
-
return this.unionFromDirections(["this", "extends"], "_packaging")
|
|
108
|
+
return this.unionFromDirections(["this", "extends"], "_packaging");
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
get outputs() {
|
|
@@ -151,6 +172,14 @@ export class content extends core {
|
|
|
151
172
|
);
|
|
152
173
|
}
|
|
153
174
|
|
|
175
|
+
set hooks(value) {
|
|
176
|
+
this._hooks = union(value, this._hooks);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
get hooks() {
|
|
180
|
+
return this.expand(this.unionFromDirections(["this", "extends"], "_hooks"));
|
|
181
|
+
}
|
|
182
|
+
|
|
154
183
|
get permissions() {
|
|
155
184
|
const p = this.mapFromDirections(["this", "extends"], "_permissions");
|
|
156
185
|
|
|
@@ -174,14 +203,12 @@ export class content extends core {
|
|
|
174
203
|
*/
|
|
175
204
|
}
|
|
176
205
|
|
|
177
|
-
packageData(node) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
return {
|
|
206
|
+
async packageData(node) {
|
|
207
|
+
const packageData = {
|
|
181
208
|
sources: [],
|
|
182
209
|
outputs: this.outputs,
|
|
183
210
|
properties: {
|
|
184
|
-
name:
|
|
211
|
+
name: this.name,
|
|
185
212
|
description: `${node.typeName} definitions for ${node.fullName}`,
|
|
186
213
|
access: this.access,
|
|
187
214
|
groups: [...this.groups],
|
|
@@ -192,5 +219,14 @@ export class content extends core {
|
|
|
192
219
|
backup: [...this.backup]
|
|
193
220
|
}
|
|
194
221
|
};
|
|
222
|
+
|
|
223
|
+
for (const hook of this.hooks) {
|
|
224
|
+
await loadHooks(
|
|
225
|
+
packageData,
|
|
226
|
+
new URL("host.install", import.meta.url).pathname
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return packageData;
|
|
195
231
|
}
|
|
196
232
|
}
|
package/src/core-service.mjs
CHANGED
|
@@ -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/core.mjs
CHANGED
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
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
resolveTypeLinks,
|
|
7
7
|
create
|
|
8
8
|
} from "pacc";
|
|
9
|
-
import {
|
|
9
|
+
import { core, root, assign } from "pmcf";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Keeps track of all in flight object creations and loose ends during config initialization.
|
|
@@ -122,7 +122,7 @@ export class InitializationContext {
|
|
|
122
122
|
this.instantiateAndAssign(object, attribute, v);
|
|
123
123
|
}
|
|
124
124
|
} else {
|
|
125
|
-
if (value instanceof
|
|
125
|
+
if (value instanceof core) {
|
|
126
126
|
assign(attribute, object, value);
|
|
127
127
|
} else {
|
|
128
128
|
for (const [objectName, objectData] of Object.entries(value)) {
|
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
|
-
}
|