npm-pkgbuild 22.1.17 → 22.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 +2 -2
- package/src/output/alpm.mjs +110 -56
- package/src/output/debian.mjs +86 -53
- package/src/output/docker.mjs +3 -1
- package/src/output/packager.mjs +11 -109
- package/src/output/rpm.mjs +29 -22
- package/src/types.mjs +85 -0
- package/src/util.mjs +15 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "22.1
|
|
3
|
+
"version": "22.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": false
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"key-value-transformer": "^3.3.2",
|
|
62
62
|
"npm-package-walker": "^8.0.11",
|
|
63
63
|
"npm-packlist": "^11.3.0",
|
|
64
|
-
"pacc": "^11.
|
|
64
|
+
"pacc": "^11.13.0",
|
|
65
65
|
"package-directory": "^8.2.0",
|
|
66
66
|
"pacote": "^22.0.0",
|
|
67
67
|
"picomatch": "^4.0.7",
|
package/src/output/alpm.mjs
CHANGED
|
@@ -15,13 +15,14 @@ import {
|
|
|
15
15
|
equalSeparatedKeyValuePairOptions,
|
|
16
16
|
Uint8ArraysToLines
|
|
17
17
|
} from "key-value-transformer";
|
|
18
|
+
import { Packager } from "./packager.mjs";
|
|
18
19
|
import {
|
|
19
|
-
Packager,
|
|
20
20
|
pkgbuild_version_attribute,
|
|
21
21
|
pkgbuild_description_attribute,
|
|
22
22
|
pkgbuild_name_attribute,
|
|
23
|
-
dependency_attribute_collection_writable
|
|
24
|
-
|
|
23
|
+
dependency_attribute_collection_writable,
|
|
24
|
+
arch_attribute_writable
|
|
25
|
+
} from "../types.mjs";
|
|
25
26
|
import {
|
|
26
27
|
copyEntries,
|
|
27
28
|
fieldProvider,
|
|
@@ -88,88 +89,141 @@ export class ALPM extends Packager {
|
|
|
88
89
|
* https://www.archlinux.org/pacman/PKGBUILD.5.html
|
|
89
90
|
*/
|
|
90
91
|
static attributes = {
|
|
91
|
-
|
|
92
|
+
name: {
|
|
93
|
+
...pkgbuild_name_attribute,
|
|
94
|
+
collection: true,
|
|
95
|
+
externalName: "pkgname"
|
|
96
|
+
},
|
|
97
|
+
description: { ...pkgbuild_description_attribute, externalName: "pkgdesc" },
|
|
98
|
+
version: { ...pkgbuild_version_attribute, externalName: "pkgver" },
|
|
99
|
+
maintainer: {
|
|
92
100
|
...string_collection_attribute_writable,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
prefix: "# "
|
|
101
|
+
externalName: "Maintainer",
|
|
102
|
+
name: "maintainer",
|
|
103
|
+
prefix: "# ",
|
|
104
|
+
skipEmpty: true
|
|
96
105
|
},
|
|
97
106
|
packager: {
|
|
98
107
|
...string_collection_attribute_writable,
|
|
99
108
|
name: "packager",
|
|
100
|
-
alias: "maintainer"
|
|
109
|
+
alias: "maintainer",
|
|
110
|
+
skipEmpty: true
|
|
101
111
|
},
|
|
102
|
-
|
|
103
|
-
pkgver: { ...pkgbuild_version_attribute, name: "pkgver" },
|
|
104
|
-
pkgrel: {
|
|
112
|
+
release: {
|
|
105
113
|
...integer_attribute,
|
|
106
|
-
name: "
|
|
107
|
-
|
|
114
|
+
name: "release",
|
|
115
|
+
externalName: "pkgrel",
|
|
108
116
|
default: 1,
|
|
109
117
|
mandatory: true
|
|
110
118
|
},
|
|
111
119
|
epoch: { ...integer_attribute, name: "epoch", default: 0 },
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
url: {
|
|
121
|
+
...string_attribute,
|
|
122
|
+
name: "url",
|
|
123
|
+
alias: "homepage",
|
|
124
|
+
skipEmpty: true
|
|
125
|
+
},
|
|
114
126
|
license: {
|
|
115
127
|
...string_collection_attribute_writable,
|
|
128
|
+
separator: undefined,
|
|
116
129
|
name: "license",
|
|
117
|
-
|
|
130
|
+
skipEmpty: true
|
|
131
|
+
},
|
|
132
|
+
install: { ...string_attribute, name: "install", skipEmpty: true },
|
|
133
|
+
changelog: { ...string_attribute, name: "changelog", skipEmpty: true },
|
|
134
|
+
source: {
|
|
135
|
+
...string_collection_attribute_writable,
|
|
136
|
+
name: "source",
|
|
137
|
+
skipEmpty: true
|
|
118
138
|
},
|
|
119
|
-
install: { ...string_attribute, name: "install" },
|
|
120
|
-
changelog: { ...string_attribute, name: "changelog" },
|
|
121
|
-
source: { ...string_collection_attribute_writable, name: "source" },
|
|
122
139
|
validpgpkeys: {
|
|
123
140
|
...string_collection_attribute_writable,
|
|
124
|
-
name: "validpgpkeys"
|
|
141
|
+
name: "validpgpkeys",
|
|
142
|
+
skipEmpty: true
|
|
125
143
|
},
|
|
126
|
-
noextract: { ...default_attribute, name: "noextract" },
|
|
127
|
-
cksums: {
|
|
128
|
-
md5sums: { ...string_collection_attribute_writable, name: "md5sums" },
|
|
129
|
-
sha1sums: { ...string_collection_attribute_writable, name: "sha1sums" },
|
|
130
|
-
sha256sums: { ...string_collection_attribute_writable, name: "sha256sums" },
|
|
131
|
-
sha384sums: { ...string_collection_attribute_writable, name: "sha384sums" },
|
|
132
|
-
sha512sums: { ...string_collection_attribute_writable, name: "sha512sums" },
|
|
133
|
-
groups: { ...string_collection_attribute_writable, name: "groups" },
|
|
134
|
-
arch: {
|
|
144
|
+
noextract: { ...default_attribute, name: "noextract", skipEmpty: true },
|
|
145
|
+
cksums: {
|
|
135
146
|
...string_collection_attribute_writable,
|
|
136
|
-
name: "
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
name: "cksums",
|
|
148
|
+
skipEmpty: true
|
|
149
|
+
},
|
|
150
|
+
md5sums: {
|
|
151
|
+
...string_collection_attribute_writable,
|
|
152
|
+
name: "md5sums",
|
|
153
|
+
default: ["SKIP"]
|
|
154
|
+
// skipEmpty: true
|
|
155
|
+
},
|
|
156
|
+
sha1sums: {
|
|
157
|
+
...string_collection_attribute_writable,
|
|
158
|
+
name: "sha1sums",
|
|
159
|
+
skipEmpty: true
|
|
160
|
+
},
|
|
161
|
+
sha256sums: {
|
|
162
|
+
...string_collection_attribute_writable,
|
|
163
|
+
name: "sha256sums",
|
|
164
|
+
skipEmpty: true
|
|
165
|
+
},
|
|
166
|
+
sha384sums: {
|
|
167
|
+
...string_collection_attribute_writable,
|
|
168
|
+
name: "sha384sums",
|
|
169
|
+
skipEmpty: true
|
|
170
|
+
},
|
|
171
|
+
sha512sums: {
|
|
172
|
+
...string_collection_attribute_writable,
|
|
173
|
+
name: "sha512sums",
|
|
174
|
+
skipEmpty: true
|
|
175
|
+
},
|
|
176
|
+
groups: {
|
|
177
|
+
...string_collection_attribute_writable,
|
|
178
|
+
name: "groups",
|
|
179
|
+
skipEmpty: true
|
|
180
|
+
},
|
|
181
|
+
arch: {
|
|
182
|
+
...arch_attribute_writable,
|
|
183
|
+
default: ["any"]
|
|
139
184
|
},
|
|
140
185
|
backup: {
|
|
141
186
|
...string_collection_attribute_writable,
|
|
142
187
|
name: "backup",
|
|
143
188
|
skipEmpty: true
|
|
144
189
|
},
|
|
145
|
-
|
|
146
|
-
...dependency_attribute_collection_writable
|
|
147
|
-
name: "
|
|
190
|
+
dependencies: {
|
|
191
|
+
...dependency_attribute_collection_writable,
|
|
192
|
+
name: "dependencies",
|
|
193
|
+
externalName: "depends",
|
|
194
|
+
skipEmpty: true
|
|
148
195
|
},
|
|
149
196
|
makedepends: {
|
|
150
197
|
...dependency_attribute_collection_writable,
|
|
151
|
-
name: "makedepends"
|
|
198
|
+
name: "makedepends",
|
|
199
|
+
skipEmpty: true
|
|
152
200
|
},
|
|
153
201
|
checkdepends: {
|
|
154
202
|
...dependency_attribute_collection_writable,
|
|
155
|
-
name: "checkdepends"
|
|
203
|
+
name: "checkdepends",
|
|
204
|
+
skipEmpty: true
|
|
156
205
|
},
|
|
157
206
|
optdepends: {
|
|
158
207
|
...dependency_attribute_collection_writable,
|
|
159
|
-
name: "optdepends"
|
|
208
|
+
name: "optdepends",
|
|
209
|
+
skipEmpty: true
|
|
160
210
|
},
|
|
161
211
|
conflicts: {
|
|
162
212
|
...dependency_attribute_collection_writable,
|
|
163
213
|
name: "conflicts",
|
|
164
214
|
skipEmpty: true
|
|
165
215
|
},
|
|
166
|
-
provides: {
|
|
216
|
+
provides: {
|
|
217
|
+
...dependency_attribute_collection_writable,
|
|
218
|
+
name: "provides",
|
|
219
|
+
skipEmpty: true
|
|
220
|
+
},
|
|
167
221
|
replaces: {
|
|
168
222
|
...dependency_attribute_collection_writable,
|
|
169
223
|
name: "replaces",
|
|
170
224
|
skipEmpty: true
|
|
171
225
|
},
|
|
172
|
-
options: { ...default_attribute, name: "options" }
|
|
226
|
+
options: { ...default_attribute, name: "options", skipEmpty: true }
|
|
173
227
|
};
|
|
174
228
|
|
|
175
229
|
static async prepare(options = {}, variant = {}) {
|
|
@@ -209,8 +263,8 @@ export class ALPM extends Packager {
|
|
|
209
263
|
}
|
|
210
264
|
|
|
211
265
|
get packageFileName() {
|
|
212
|
-
const p = this.
|
|
213
|
-
return `${p.
|
|
266
|
+
const p = this.externalProperties;
|
|
267
|
+
return `${p.pkgname}-${p.pkgver}-${p.pkgrel}-${p.arch}${this.fileNameExtension}`;
|
|
214
268
|
}
|
|
215
269
|
|
|
216
270
|
dependencyExpression(name, expression) {
|
|
@@ -220,9 +274,9 @@ export class ALPM extends Packager {
|
|
|
220
274
|
async create(sources, transformer, publishingDetails, options, expander) {
|
|
221
275
|
const { properties, staging, destination } = await this.prepare(options);
|
|
222
276
|
|
|
223
|
-
if (properties.source) {
|
|
277
|
+
/*if (properties.source) {
|
|
224
278
|
properties.md5sums = ["SKIP"];
|
|
225
|
-
}
|
|
279
|
+
}*/
|
|
226
280
|
if (properties.hooks) {
|
|
227
281
|
properties.install = `${properties.name}.install`;
|
|
228
282
|
|
|
@@ -287,18 +341,18 @@ package() {
|
|
|
287
341
|
join(staging, "src"),
|
|
288
342
|
expander
|
|
289
343
|
)) {
|
|
290
|
-
if(file.destination !==
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
344
|
+
if (file.destination !== "../PKGBUILD") {
|
|
345
|
+
if (file.owner || file.group) {
|
|
346
|
+
permission.push(
|
|
347
|
+
` chown ${[file.owner ?? "", file.group ?? ""].join(":")} \"$pkgdir/${file.destination}\"`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
const mode = (await file.mode) & 0o7777;
|
|
351
|
+
if (mode) {
|
|
352
|
+
permission.push(
|
|
353
|
+
` chmod ${Number(mode).toString(8)} \"$pkgdir/${file.destination}\"`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
302
356
|
}
|
|
303
357
|
|
|
304
358
|
if (options.verbose) {
|
package/src/output/debian.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
yesno_attribute_writable,
|
|
7
7
|
string_attribute_writable,
|
|
8
8
|
string_collection_attribute_writable,
|
|
9
|
-
|
|
9
|
+
types
|
|
10
10
|
} from "pacc";
|
|
11
11
|
import { ContentEntry, IteratorContentEntry } from "content-entry";
|
|
12
12
|
import {
|
|
@@ -14,15 +14,15 @@ import {
|
|
|
14
14
|
createPropertiesTransformer
|
|
15
15
|
} from "content-entry-transform";
|
|
16
16
|
import { keyValueTransformer, Uint8ArraysToLines } from "key-value-transformer";
|
|
17
|
+
import { Packager } from "./packager.mjs";
|
|
18
|
+
import { copyEntries, fieldProvider, aggregate } from "../util.mjs";
|
|
17
19
|
import {
|
|
18
|
-
Packager,
|
|
19
20
|
pkgbuild_version_attribute,
|
|
20
21
|
pkgbuild_description_attribute,
|
|
21
22
|
pkgbuild_name_attribute,
|
|
22
23
|
dependency_attribute_collection_writable,
|
|
23
|
-
|
|
24
|
-
} from "
|
|
25
|
-
import { copyEntries, fieldProvider, aggregate } from "../util.mjs";
|
|
24
|
+
arch_attribute_writable
|
|
25
|
+
} from "../types.mjs";
|
|
26
26
|
|
|
27
27
|
const debian_dependency_attribute_collection_writable = {
|
|
28
28
|
...dependency_attribute_collection_writable,
|
|
@@ -52,85 +52,126 @@ export class DEBIAN extends Packager {
|
|
|
52
52
|
* @see https://linux.die.net/man/5/deb-control
|
|
53
53
|
*/
|
|
54
54
|
static attributes = {
|
|
55
|
-
|
|
55
|
+
name: {
|
|
56
56
|
...pkgbuild_name_attribute,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
externalName: "Package",
|
|
58
|
+
type: types["lowercase-string"]
|
|
59
|
+
},
|
|
60
|
+
description: {
|
|
61
|
+
...pkgbuild_description_attribute,
|
|
62
|
+
externalName: "Description",
|
|
63
|
+
skipEmpty: true
|
|
59
64
|
},
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
version: { ...pkgbuild_version_attribute, externalName: "Version" },
|
|
66
|
+
maintainer: {
|
|
62
67
|
...string_attribute_writable,
|
|
63
|
-
name: "
|
|
64
|
-
|
|
68
|
+
name: "maintainer",
|
|
69
|
+
externalName: "Maintainer",
|
|
65
70
|
mandatory: true
|
|
66
71
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Essential: { ...yesno_attribute_writable, name: "Essential" },
|
|
71
|
-
Origin: { ...string_attribute_writable, name: "Origin" },
|
|
72
|
-
Architecture: {
|
|
73
|
-
...string_attribute_writable,
|
|
74
|
-
name: "Architecture",
|
|
75
|
-
alias: "arch",
|
|
72
|
+
arch: {
|
|
73
|
+
...arch_attribute_writable,
|
|
74
|
+
externalName: "Architecture",
|
|
76
75
|
default: "all",
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
mapping: { aarch64: "arm64", any: "all" }
|
|
77
|
+
},
|
|
78
|
+
groups: {
|
|
79
|
+
...string_attribute_writable,
|
|
80
|
+
name: "groups",
|
|
81
|
+
externalName: "Section",
|
|
82
|
+
skipEmpty: true
|
|
83
|
+
},
|
|
84
|
+
Priority: {
|
|
85
|
+
...string_attribute_writable,
|
|
86
|
+
name: "Priority",
|
|
87
|
+
skipEmpty: true
|
|
88
|
+
},
|
|
89
|
+
Essential: {
|
|
90
|
+
...yesno_attribute_writable,
|
|
91
|
+
name: "Essential",
|
|
92
|
+
skipEmpty: true
|
|
80
93
|
},
|
|
81
|
-
|
|
94
|
+
Origin: { ...string_attribute_writable, name: "Origin", skipEmpty: true },
|
|
95
|
+
homepage: {
|
|
82
96
|
...string_attribute_writable,
|
|
83
|
-
name: "
|
|
84
|
-
|
|
97
|
+
name: "homepage",
|
|
98
|
+
externalName: "Homepage",
|
|
99
|
+
skipEmpty: true
|
|
85
100
|
},
|
|
86
|
-
Bugs: {
|
|
87
|
-
|
|
101
|
+
Bugs: {
|
|
102
|
+
...string_attribute_writable,
|
|
103
|
+
name: "bugs",
|
|
104
|
+
externalName: "Bugs",
|
|
105
|
+
skipEmpty: true
|
|
106
|
+
},
|
|
107
|
+
dependencies: {
|
|
88
108
|
...debian_dependency_attribute_collection_writable,
|
|
89
|
-
name: "
|
|
109
|
+
name: "dependencies",
|
|
110
|
+
externalName: "Depends",
|
|
111
|
+
skipEmpty: true
|
|
90
112
|
},
|
|
91
113
|
"Pre-Depends": {
|
|
92
114
|
...debian_dependency_attribute_collection_writable,
|
|
93
|
-
name: "Pre-Depends"
|
|
115
|
+
name: "Pre-Depends",
|
|
116
|
+
skipEmpty: true
|
|
94
117
|
},
|
|
95
118
|
"Build-Depends": {
|
|
96
119
|
...debian_dependency_attribute_collection_writable,
|
|
97
|
-
name: "Build-Depends"
|
|
120
|
+
name: "Build-Depends",
|
|
121
|
+
skipEmpty: true
|
|
98
122
|
},
|
|
99
123
|
"Build-Depends-Indep": {
|
|
100
124
|
...debian_dependency_attribute_collection_writable,
|
|
101
|
-
name: "Build-Depends-Indep"
|
|
125
|
+
name: "Build-Depends-Indep",
|
|
126
|
+
skipEmpty: true
|
|
102
127
|
},
|
|
103
128
|
"Build-Depends-Arch": {
|
|
104
129
|
...debian_dependency_attribute_collection_writable,
|
|
105
|
-
name: "Build-Depends-Arch"
|
|
130
|
+
name: "Build-Depends-Arch",
|
|
131
|
+
skipEmpty: true
|
|
106
132
|
},
|
|
107
133
|
Recommends: {
|
|
108
134
|
...debian_dependency_attribute_collection_writable,
|
|
109
|
-
name: "Recommends"
|
|
135
|
+
name: "Recommends",
|
|
136
|
+
skipEmpty: true
|
|
110
137
|
},
|
|
111
138
|
Suggests: {
|
|
112
139
|
...debian_dependency_attribute_collection_writable,
|
|
113
|
-
name: "Suggests"
|
|
140
|
+
name: "Suggests",
|
|
141
|
+
skipEmpty: true
|
|
114
142
|
},
|
|
115
143
|
Provides: {
|
|
116
144
|
...debian_dependency_attribute_collection_writable,
|
|
117
|
-
name: "Provides"
|
|
145
|
+
name: "Provides",
|
|
146
|
+
skipEmpty: true
|
|
118
147
|
},
|
|
119
148
|
Breaks: {
|
|
120
149
|
...debian_dependency_attribute_collection_writable,
|
|
121
|
-
name: "Breaks"
|
|
150
|
+
name: "Breaks",
|
|
151
|
+
skipEmpty: true
|
|
122
152
|
},
|
|
123
153
|
Replaces: {
|
|
124
154
|
...debian_dependency_attribute_collection_writable,
|
|
125
|
-
name: "Replaces"
|
|
155
|
+
name: "Replaces",
|
|
156
|
+
skipEmpty: true
|
|
157
|
+
},
|
|
158
|
+
source: {
|
|
159
|
+
...string_attribute_writable,
|
|
160
|
+
name: "source",
|
|
161
|
+
externalName: "Source",
|
|
162
|
+
skipEmpty: true
|
|
126
163
|
},
|
|
127
|
-
Source: { ...string_attribute_writable, name: "Source", alias: "source" },
|
|
128
164
|
Uploaders: {
|
|
129
165
|
...string_collection_attribute_writable,
|
|
130
166
|
name: "Uploaders",
|
|
131
|
-
mandatory: false
|
|
167
|
+
mandatory: false,
|
|
168
|
+
skipEmpty: true
|
|
132
169
|
},
|
|
133
|
-
"Installed-Size": {
|
|
170
|
+
"Installed-Size": {
|
|
171
|
+
...integer_attribute_writable,
|
|
172
|
+
name: "Installed-Size",
|
|
173
|
+
skipEmpty: true
|
|
174
|
+
}
|
|
134
175
|
};
|
|
135
176
|
|
|
136
177
|
/**
|
|
@@ -153,13 +194,8 @@ export class DEBIAN extends Packager {
|
|
|
153
194
|
}
|
|
154
195
|
|
|
155
196
|
get packageFileName() {
|
|
156
|
-
const p = this.
|
|
157
|
-
|
|
158
|
-
// TODO utility to provide final values
|
|
159
|
-
const arch = toExternal(p.arch, this.attributes.Architecture);
|
|
160
|
-
|
|
161
|
-
// @ts-ignore
|
|
162
|
-
return `${p.name}_${p.version}_${arch}${this.constructor.fileNameExtension}`;
|
|
197
|
+
const p = this.externalProperties;
|
|
198
|
+
return `${p.Package}_${p.Version}_${p.Architecture}${this.constructor.fileNameExtension}`;
|
|
163
199
|
}
|
|
164
200
|
|
|
165
201
|
/**
|
|
@@ -192,10 +228,7 @@ export class DEBIAN extends Packager {
|
|
|
192
228
|
)
|
|
193
229
|
);
|
|
194
230
|
|
|
195
|
-
|
|
196
|
-
if (depends.length) {
|
|
197
|
-
properties.Depends = depends;
|
|
198
|
-
}
|
|
231
|
+
properties.dependencies = this.makeDepends(properties.dependencies);
|
|
199
232
|
|
|
200
233
|
const fp = fieldProvider(properties, this.attributes);
|
|
201
234
|
|
package/src/output/docker.mjs
CHANGED
|
@@ -12,10 +12,12 @@ import {
|
|
|
12
12
|
} from "key-value-transformer";
|
|
13
13
|
import {
|
|
14
14
|
Packager,
|
|
15
|
+
} from "./packager.mjs";
|
|
16
|
+
import {
|
|
15
17
|
pkgbuild_version_attribute,
|
|
16
18
|
pkgbuild_description_attribute,
|
|
17
19
|
pkgbuild_name_attribute
|
|
18
|
-
} from "
|
|
20
|
+
} from "../types.mjs";
|
|
19
21
|
import {
|
|
20
22
|
fieldProvider,
|
|
21
23
|
copyEntries,
|
package/src/output/packager.mjs
CHANGED
|
@@ -2,14 +2,7 @@ import { join } from "node:path";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { mkdtemp, mkdir } from "node:fs/promises";
|
|
4
4
|
import { createReadStream } from "node:fs";
|
|
5
|
-
import {
|
|
6
|
-
expand,
|
|
7
|
-
expandContextDoubbleCurly,
|
|
8
|
-
string_collection_attribute_writable,
|
|
9
|
-
name_attribute,
|
|
10
|
-
description_attribute,
|
|
11
|
-
version_attribute_writable
|
|
12
|
-
} from "pacc";
|
|
5
|
+
import { expand, expandContextDoubbleCurly, iterateToExternal } from "pacc";
|
|
13
6
|
import { StringContentEntry } from "content-entry";
|
|
14
7
|
import { publish } from "../publish.mjs";
|
|
15
8
|
import {
|
|
@@ -58,7 +51,7 @@ export class Packager {
|
|
|
58
51
|
return false;
|
|
59
52
|
}
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
properties;
|
|
62
55
|
#prepared;
|
|
63
56
|
|
|
64
57
|
/**
|
|
@@ -66,7 +59,13 @@ export class Packager {
|
|
|
66
59
|
* @param {Object} properties
|
|
67
60
|
*/
|
|
68
61
|
constructor(properties) {
|
|
69
|
-
this
|
|
62
|
+
this.properties = { ...properties, type: this.constructor.name };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get externalProperties() {
|
|
66
|
+
return Object.fromEntries([
|
|
67
|
+
...iterateToExternal(this.properties, this.constructor.attributes)
|
|
68
|
+
]);
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
/**
|
|
@@ -165,41 +164,6 @@ export class Packager {
|
|
|
165
164
|
return this.constructor.attributes;
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
get properties() {
|
|
169
|
-
const properties = this.#properties;
|
|
170
|
-
|
|
171
|
-
for (const [name, field] of Object.entries(this.attributes)) {
|
|
172
|
-
if (field.set) {
|
|
173
|
-
if (properties[name] !== undefined) {
|
|
174
|
-
properties[name] = field.set(properties[name]);
|
|
175
|
-
} else if (
|
|
176
|
-
field.alias !== undefined &&
|
|
177
|
-
properties[field.alias] !== undefined
|
|
178
|
-
) {
|
|
179
|
-
properties[field.alias] = field.set(properties[field.alias]);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const e = properties[field.alias || name];
|
|
184
|
-
|
|
185
|
-
if (e !== undefined) {
|
|
186
|
-
properties[name] = field.set ? field.set(e) : e;
|
|
187
|
-
} else {
|
|
188
|
-
if (field.default !== undefined) {
|
|
189
|
-
const vak = field.alias || name;
|
|
190
|
-
if (
|
|
191
|
-
(Array.isArray(properties[vak]) && properties[vak].length === 0) ||
|
|
192
|
-
properties[vak] === undefined
|
|
193
|
-
) {
|
|
194
|
-
properties[vak] = field.default;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return properties;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
167
|
/**
|
|
204
168
|
* Create tmp directory.
|
|
205
169
|
* @return {Promise<string>} directory path
|
|
@@ -225,9 +189,9 @@ export class Packager {
|
|
|
225
189
|
|
|
226
190
|
const out = {
|
|
227
191
|
properties: this.properties,
|
|
228
|
-
destination: options.destination
|
|
192
|
+
destination: options.destination ?? tmpdir,
|
|
229
193
|
tmpdir,
|
|
230
|
-
staging: options.staging
|
|
194
|
+
staging: options.staging ?? tmpdir
|
|
231
195
|
};
|
|
232
196
|
|
|
233
197
|
// @ts-ignore
|
|
@@ -273,65 +237,3 @@ export class Packager {
|
|
|
273
237
|
return publish(artifact, publishingDetails, this.properties, logger);
|
|
274
238
|
}
|
|
275
239
|
}
|
|
276
|
-
|
|
277
|
-
export const pkgbuild_name_attribute = {
|
|
278
|
-
...name_attribute,
|
|
279
|
-
alias: "name",
|
|
280
|
-
mandatory: true,
|
|
281
|
-
pattern: /^[a-z_][a-z0-9_\-]*$/i
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
export const dependency_type = {
|
|
285
|
-
name: "dependency",
|
|
286
|
-
primitive: false,
|
|
287
|
-
toExternal: (value, attribute) => {
|
|
288
|
-
switch (typeof value) {
|
|
289
|
-
case "string":
|
|
290
|
-
case "undefined":
|
|
291
|
-
return value;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (Array.isArray(value)) {
|
|
295
|
-
return value;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return Object.entries(value).map(([name, expression]) =>
|
|
299
|
-
typeof expression === "string" ? `${name}${expression}` : name
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
export const architectureType = {
|
|
305
|
-
name: "dependency",
|
|
306
|
-
primitive: true,
|
|
307
|
-
|
|
308
|
-
toInternal: (value, attribute) => {
|
|
309
|
-
// console.log("architectureType toInternal", value);
|
|
310
|
-
return value;
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
toExternal: (value, attribute) => {
|
|
314
|
-
// console.log("architectureType toExternal", value);
|
|
315
|
-
return attribute.mapping[value] ?? value;
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
export const dependency_attribute_collection_writable = {
|
|
320
|
-
...string_collection_attribute_writable,
|
|
321
|
-
type: dependency_type,
|
|
322
|
-
separator: " ",
|
|
323
|
-
pattern: /^[a-z_][a-z0-9_\-]*$/i
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
export const pkgbuild_version_attribute = {
|
|
327
|
-
...version_attribute_writable,
|
|
328
|
-
alias: "version",
|
|
329
|
-
mandatory: true,
|
|
330
|
-
set: v => v.replace("-semantic-release", "")
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
export const pkgbuild_description_attribute = {
|
|
334
|
-
...description_attribute,
|
|
335
|
-
alias: "description",
|
|
336
|
-
mandatory: true
|
|
337
|
-
};
|
package/src/output/rpm.mjs
CHANGED
|
@@ -15,12 +15,13 @@ import {
|
|
|
15
15
|
colonSeparatedKeyValuePairOptionsDoublingKeys,
|
|
16
16
|
Uint8ArraysToLines
|
|
17
17
|
} from "key-value-transformer";
|
|
18
|
+
import { Packager } from "./packager.mjs";
|
|
18
19
|
import {
|
|
19
|
-
Packager,
|
|
20
20
|
pkgbuild_version_attribute,
|
|
21
21
|
pkgbuild_description_attribute,
|
|
22
|
-
pkgbuild_name_attribute
|
|
23
|
-
|
|
22
|
+
pkgbuild_name_attribute,
|
|
23
|
+
arch_attribute_writable
|
|
24
|
+
} from "../types.mjs";
|
|
24
25
|
import {
|
|
25
26
|
copyEntries,
|
|
26
27
|
fieldProvider,
|
|
@@ -61,35 +62,41 @@ export class RPM extends Packager {
|
|
|
61
62
|
* @see https://rpm-packaging-guide.github.io
|
|
62
63
|
*/
|
|
63
64
|
static attributes = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
name: { ...pkgbuild_name_attribute, externalName: "Name" },
|
|
66
|
+
description: { ...pkgbuild_description_attribute, externalName: "Summary" },
|
|
67
|
+
license: {
|
|
67
68
|
...string_attribute,
|
|
68
|
-
name: "
|
|
69
|
-
|
|
69
|
+
name: "license",
|
|
70
|
+
externalName: "License",
|
|
70
71
|
mandatory: true
|
|
71
72
|
},
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
version: { ...pkgbuild_version_attribute, externalName: "Version" },
|
|
74
|
+
release: {
|
|
74
75
|
...integer_attribute,
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
externalName: "Release",
|
|
77
|
+
name: "release",
|
|
77
78
|
default: 1,
|
|
78
79
|
mandatory: true
|
|
79
80
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Vendor: { ...string_attribute, name: "Vendor", alias: "vendor" },
|
|
84
|
-
BuildArch: {
|
|
81
|
+
source: { ...string_attribute, externalName: "Source0", name: "source" },
|
|
82
|
+
groups: { ...string_attribute, externalName: "Group", name: "groups" },
|
|
83
|
+
maintainer: {
|
|
85
84
|
...string_attribute,
|
|
86
|
-
name: "
|
|
87
|
-
|
|
85
|
+
name: "maintainer",
|
|
86
|
+
externalName: "Packager"
|
|
87
|
+
},
|
|
88
|
+
vendor: { ...string_attribute, externalName: "Vendor", name: "vendor" },
|
|
89
|
+
arch: {
|
|
90
|
+
...arch_attribute_writable,
|
|
91
|
+
externalName: "BuildArch",
|
|
88
92
|
default: "noarch",
|
|
89
|
-
|
|
93
|
+
mapping: { any: "noarch" }
|
|
90
94
|
},
|
|
91
95
|
URL: { ...url_attribute, name: "URL", alias: "homepage" },
|
|
92
|
-
|
|
96
|
+
dependencies: {
|
|
97
|
+
...string_collection_attribute_writable,
|
|
98
|
+
externalName: "Requires"
|
|
99
|
+
},
|
|
93
100
|
Obsoletes: { ...string_collection_attribute_writable, name: "Obsoletes" },
|
|
94
101
|
Conflicts: { ...string_collection_attribute_writable, name: "Conflicts" }
|
|
95
102
|
};
|
|
@@ -152,7 +159,7 @@ export class RPM extends Packager {
|
|
|
152
159
|
const { properties, tmpdir, staging, destination } =
|
|
153
160
|
await this.prepare(options);
|
|
154
161
|
|
|
155
|
-
properties.
|
|
162
|
+
properties.dependencies = this.makeDepends(properties.dependencies);
|
|
156
163
|
|
|
157
164
|
if (properties.Packager?.length > 1) {
|
|
158
165
|
// TODO how to write several Packages ?
|
package/src/types.mjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
types,
|
|
3
|
+
primitive_type,
|
|
4
|
+
string_collection_attribute_writable,
|
|
5
|
+
name_attribute,
|
|
6
|
+
description_attribute,
|
|
7
|
+
version_attribute_writable,
|
|
8
|
+
string_attribute_writable
|
|
9
|
+
} from "pacc";
|
|
10
|
+
|
|
11
|
+
export const dependency_type = {
|
|
12
|
+
...primitive_type,
|
|
13
|
+
name: "dependency",
|
|
14
|
+
toExternal: (value, attribute) => {
|
|
15
|
+
switch (typeof value) {
|
|
16
|
+
case "string":
|
|
17
|
+
case "undefined":
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
if (value.length === 0 && attribute.skipEmpty) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return Object.entries(value).map(([name, expression]) =>
|
|
30
|
+
typeof expression === "string" ? `${name}${expression}` : name
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const architecture_type = {
|
|
36
|
+
...primitive_type,
|
|
37
|
+
name: "architecture",
|
|
38
|
+
|
|
39
|
+
toInternal: (value, attribute) => {
|
|
40
|
+
// console.log("architectureType toInternal", value);
|
|
41
|
+
return value;
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
toExternal: (value, attribute) => {
|
|
45
|
+
// console.log("architectureType toExternal", value);
|
|
46
|
+
return attribute.mapping?.[value] ?? value;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const arch_attribute_writable = {
|
|
51
|
+
...string_attribute_writable,
|
|
52
|
+
name: "arch",
|
|
53
|
+
default: "all",
|
|
54
|
+
mandatory: true,
|
|
55
|
+
type: architecture_type
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const pkgbuild_name_attribute = {
|
|
59
|
+
...name_attribute,
|
|
60
|
+
mandatory: true,
|
|
61
|
+
pattern: /^[a-z_][a-z0-9_\-]*$/i
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const dependency_attribute_collection_writable = {
|
|
65
|
+
...string_collection_attribute_writable,
|
|
66
|
+
type: dependency_type,
|
|
67
|
+
separator: " ",
|
|
68
|
+
pattern: /^[a-z_][a-z0-9_\-]*$/i
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const pkgbuild_version_attribute = {
|
|
72
|
+
...version_attribute_writable,
|
|
73
|
+
mandatory: true,
|
|
74
|
+
type: {
|
|
75
|
+
...types.string,
|
|
76
|
+
toExternal: (value, attribute) => {
|
|
77
|
+
return value.replace("-semantic-release", "");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const pkgbuild_description_attribute = {
|
|
83
|
+
...description_attribute,
|
|
84
|
+
mandatory: true
|
|
85
|
+
};
|
package/src/util.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdir } from "node:fs/promises";
|
|
|
3
3
|
import { pipeline } from "node:stream/promises";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
5
|
import { createWriteStream } from "node:fs";
|
|
6
|
-
import {
|
|
6
|
+
import { asArray, iterateToExternal } from "pacc";
|
|
7
7
|
import { ContentEntry } from "content-entry";
|
|
8
8
|
import { aggregateFifo } from "aggregate-async-iterator";
|
|
9
9
|
|
|
@@ -145,44 +145,21 @@ export function quote(v, qc = "'") {
|
|
|
145
145
|
* @returns {Function}
|
|
146
146
|
*/
|
|
147
147
|
export function fieldProvider(properties, attributes) {
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
}
|
|
148
|
+
return function* controlProperties(key, value, presentKeys) {
|
|
149
|
+
let filter;
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
if (attribute.skipEmpty) {
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
yield [name, toExternal(attribute.default, attribute)];
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
if (attribute.mapping) {
|
|
173
|
-
const mappedValue = attribute.mapping[value];
|
|
174
|
-
if (mappedValue !== undefined) {
|
|
175
|
-
value = mappedValue;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
yield [name, av(attribute, toExternal(value, attribute))];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
const attribute = attributes[k];
|
|
185
|
-
yield [k, av(attribute, toExternal(properties[k] ?? v, attribute))];
|
|
151
|
+
if (key) {
|
|
152
|
+
filter = attribute => attribute.name === key;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
for (const [name, value] of iterateToExternal(
|
|
156
|
+
properties,
|
|
157
|
+
attributes,
|
|
158
|
+
filter
|
|
159
|
+
)) {
|
|
160
|
+
//if (!presentKeys.has(name)) { }
|
|
161
|
+
|
|
162
|
+
yield [name, value];
|
|
186
163
|
}
|
|
187
164
|
};
|
|
188
165
|
}
|