penguins-eggs 10.0.38 → 10.0.41
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/.oclif.manifest.json +1 -1
- package/README.md +31 -30
- package/addons/eggs/theme/livecd/isolinux.main.simple.cfg +1 -1
- package/conf/derivatives.yaml +5 -2
- package/conf/distros/rolling/calamares/modules/finished.yml +2 -1
- package/conf/distros/rolling/calamares/modules/partition.yml +1 -1
- package/conf/distros/rolling/calamares/settings.yml +3 -1
- package/conf/distros/voidlinux/README.md +1 -0
- package/dist/classes/bleach.js +9 -1
- package/dist/classes/cli-autologin.js +33 -27
- package/dist/classes/distro.d.ts +0 -4
- package/dist/classes/distro.js +75 -134
- package/dist/classes/families/fedora.js +1 -1
- package/dist/classes/families/voidlinux.d.ts +48 -0
- package/dist/classes/families/voidlinux.js +84 -0
- package/dist/classes/ovary.d.ts +6 -13
- package/dist/classes/ovary.js +63 -60
- package/dist/classes/pacman.js +27 -13
- package/dist/classes/pxe.js +3 -3
- package/dist/classes/tailor.d.ts +11 -14
- package/dist/classes/tailor.js +184 -247
- package/dist/classes/utils.js +9 -0
- package/dist/commands/config.js +26 -94
- package/dist/commands/produce.js +1 -1
- package/dist/commands/wardrobe/wear.js +3 -0
- package/dist/interfaces/i-distro.d.ts +0 -4
- package/dist/interfaces/i-install.d.ts +2 -2
- package/dist/interfaces/i-materia.d.ts +9 -14
- package/dist/krill/modules/add-user.js +9 -12
- package/dist/krill/modules/bootloader-config.js +15 -0
- package/dist/krill/modules/bootloader.js +2 -2
- package/dist/krill/modules/fstab.js +2 -0
- package/dist/krill/modules/initramfs-cfg.js +0 -3
- package/dist/krill/modules/initramfs.js +32 -26
- package/dist/krill/modules/machine-id.js +2 -2
- package/dist/krill/prepare.js +2 -2
- package/dist/krill/sequence.js +25 -26
- package/dracut/README.md +2 -2
- package/dracut/dracut.conf.d/01-live.conf +3 -2
- package/dracut/sidecar.sh +19 -0
- package/manpages/doc/man/eggs.1.gz +0 -0
- package/manpages/doc/man/eggs.html +4 -4
- package/mkinitcpio/arch/README.md +48 -0
- package/mkinitcpio/arch/live.conf +3 -8
- package/mkinitcpio/biglinux/live.conf +4 -74
- package/mkinitcpio/manjarolinux/live.conf +4 -9
- package/mkinitfs/initramfs-init.in +4 -3
- package/package.json +8 -8
- package/syslinux/README.md +3 -0
- package/syslinux/lpxelinux.0 +0 -0
- package/syslinux/memdisk +0 -0
- package/syslinux/pxelinux.0 +0 -0
- package/dracut/test.sh +0 -40
- package/mkinitcpio/arch/mkinitcpio.conf +0 -4
- package/mkinitcpio/biglinux/mkinitcpio.conf +0 -73
- package/mkinitcpio/manjarolinux/mkinitcpio.conf +0 -7
package/dist/classes/tailor.js
CHANGED
|
@@ -6,18 +6,14 @@
|
|
|
6
6
|
* license: MIT
|
|
7
7
|
*/
|
|
8
8
|
import chalk from 'chalk';
|
|
9
|
-
import yaml from 'js-yaml';
|
|
10
9
|
import fs from 'node:fs';
|
|
11
|
-
|
|
12
|
-
import { createRequire } from 'node:module';
|
|
10
|
+
import yaml from 'js-yaml';
|
|
13
11
|
import path from 'node:path';
|
|
14
12
|
import { exec } from '../lib/utils.js';
|
|
15
13
|
import Distro from './distro.js';
|
|
16
14
|
import Pacman from './pacman.js';
|
|
17
15
|
import SourcesList from './sources_list.js';
|
|
18
16
|
import Utils from './utils.js';
|
|
19
|
-
const require = createRequire(import.meta.url);
|
|
20
|
-
const pjson = require('../../package.json');
|
|
21
17
|
/**
|
|
22
18
|
*
|
|
23
19
|
*/
|
|
@@ -26,8 +22,10 @@ export default class Tailor {
|
|
|
26
22
|
category = 'costume';
|
|
27
23
|
costume = '';
|
|
28
24
|
echo = {};
|
|
25
|
+
toNull = ' > /dev/null 2>&1';
|
|
29
26
|
verbose = false;
|
|
30
27
|
wardrobe = '';
|
|
28
|
+
log = '';
|
|
31
29
|
/**
|
|
32
30
|
* @param wardrobe
|
|
33
31
|
* @param costume
|
|
@@ -35,98 +33,24 @@ export default class Tailor {
|
|
|
35
33
|
constructor(costume, category = 'costume') {
|
|
36
34
|
this.costume = costume;
|
|
37
35
|
this.wardrobe = path.dirname(path.dirname(costume));
|
|
36
|
+
this.log = path.dirname(this.wardrobe) + "/wardrobe.log";
|
|
38
37
|
this.category = category;
|
|
39
38
|
}
|
|
40
39
|
/**
|
|
41
40
|
*
|
|
42
|
-
* @param packages
|
|
43
|
-
* @param verbose
|
|
44
|
-
* @param section
|
|
45
|
-
* @returns
|
|
46
41
|
*/
|
|
47
|
-
async
|
|
48
|
-
const packages_we_want = '/tmp/packages_we_want';
|
|
49
|
-
const packages_not_exists = '/tmp/packages_not_exists';
|
|
50
|
-
const packages_exists = '/tmp/packages_exists';
|
|
51
|
-
await exec(`rm -f ${packages_we_want}`);
|
|
52
|
-
await exec(`rm -f ${packages_not_exists}`);
|
|
53
|
-
await exec(`rm -f ${packages_exists}`);
|
|
54
|
-
/**
|
|
55
|
-
* packages_we_want
|
|
56
|
-
*/
|
|
57
|
-
let content = '';
|
|
58
|
-
packages.sort();
|
|
59
|
-
for (const elem of packages) {
|
|
60
|
-
if (!Pacman.packageIsInstalled(elem)) {
|
|
61
|
-
content += elem + '\n';
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
fs.writeFileSync(packages_we_want, content, 'utf-8');
|
|
65
|
-
/**
|
|
66
|
-
* packages_exists
|
|
67
|
-
*/
|
|
68
|
-
const distro = new Distro();
|
|
69
|
-
await (distro.familyId === 'debian' ? exec(`apt-cache --no-generate pkgnames | sort | comm -12 - ${packages_we_want} > ${packages_exists}`) : exec(`pacman -S --list | awk '{print $2}' | sort | comm -12 - ${packages_we_want} > ${packages_exists}`));
|
|
70
|
-
/**
|
|
71
|
-
* packages_not_exists
|
|
72
|
-
*/
|
|
42
|
+
async prepare(verbose = true, no_accessories = false, no_firmwares = false) {
|
|
73
43
|
if (verbose) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (not_exist_packages.length > 1) {
|
|
77
|
-
// Una riga c'è sempre
|
|
78
|
-
let content = '';
|
|
79
|
-
// for (const elem of not_exist_packages) {
|
|
80
|
-
for (let i = 0; i < not_exist_packages.length - 1; i++) {
|
|
81
|
-
content += `- ${not_exist_packages[i]}\n`;
|
|
82
|
-
}
|
|
83
|
-
this.titles('tailor');
|
|
84
|
-
console.log('Following packages from ' + chalk.cyan(this.materials.name) + ' section: ' + chalk.cyan(section) + ', was not found:');
|
|
85
|
-
console.log(content);
|
|
86
|
-
Utils.pressKeyToExit('Press a key to continue...');
|
|
87
|
-
}
|
|
44
|
+
this.verbose = true;
|
|
45
|
+
this.toNull = '';
|
|
88
46
|
}
|
|
89
|
-
return fs.readFileSync(packages_exists, 'utf8').split('\n');
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* - check if every package if installed
|
|
93
|
-
* - if find any packages to install, install it
|
|
94
|
-
*/
|
|
95
|
-
async helperInstall(packages, comment = 'packages', cmd = 'apt-get install -yqq ') {
|
|
96
|
-
if (packages[0] !== null) {
|
|
97
|
-
const elements = [];
|
|
98
|
-
let strElements = '';
|
|
99
|
-
for (const elem of packages) {
|
|
100
|
-
elements.push(elem);
|
|
101
|
-
cmd += ` ${elem}`;
|
|
102
|
-
strElements += `, ${elem}`;
|
|
103
|
-
}
|
|
104
|
-
if (elements.length > 0) {
|
|
105
|
-
let step = `installing ${comment}: `;
|
|
106
|
-
if (!this.verbose) {
|
|
107
|
-
step += strElements.slice(2);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* prova 3 volte
|
|
111
|
-
*/
|
|
112
|
-
const limit = 3;
|
|
113
|
-
for (let tempts = 1; tempts < limit; tempts++) {
|
|
114
|
-
this.titles(step);
|
|
115
|
-
Utils.warning(`tempts ${tempts} of ${limit}`);
|
|
116
|
-
if (await tryCheckSuccess(cmd, this.echo)) {
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
*/
|
|
126
|
-
async prepare(verbose = true, no_accessories = false, no_firmwares = false) {
|
|
127
|
-
this.verbose = verbose;
|
|
128
47
|
this.echo = Utils.setEcho(verbose);
|
|
129
48
|
Utils.warning(`preparing ${this.costume}`);
|
|
49
|
+
if (!fs.existsSync(this.log)) {
|
|
50
|
+
fs.writeFileSync(this.log, "# eggs wardrobe wear\n\n");
|
|
51
|
+
}
|
|
52
|
+
fs.appendFileSync(this.log, `## ${this.costume}\n`);
|
|
53
|
+
fs.appendFileSync(this.log, `Packages not found:\n`);
|
|
130
54
|
/**
|
|
131
55
|
* check curl presence
|
|
132
56
|
*/
|
|
@@ -204,15 +128,28 @@ export default class Tailor {
|
|
|
204
128
|
}
|
|
205
129
|
break;
|
|
206
130
|
}
|
|
207
|
-
|
|
208
|
-
|
|
131
|
+
case 'Fedora': {
|
|
132
|
+
tailorList = `${this.costume}/fedora.yml`;
|
|
133
|
+
if (!fs.existsSync(tailorList)) {
|
|
134
|
+
tailorList = `${this.costume}/debian.yml`;
|
|
135
|
+
if (!fs.existsSync(tailorList)) {
|
|
136
|
+
console.log(`no costume definition found compatible Fedora`);
|
|
137
|
+
process.exit();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
} // end analyze
|
|
143
|
+
/**
|
|
144
|
+
* find materials
|
|
145
|
+
*/
|
|
209
146
|
if (fs.existsSync(tailorList)) {
|
|
210
147
|
this.materials = yaml.load(fs.readFileSync(tailorList, 'utf8'));
|
|
211
148
|
}
|
|
212
|
-
else
|
|
149
|
+
else {
|
|
213
150
|
switch (this.category) {
|
|
214
151
|
case 'costume': {
|
|
215
|
-
|
|
152
|
+
Utils.titles(`${this.category}: ${this.costume}`);
|
|
216
153
|
console.log("Tailor's list " + chalk.cyan(tailorList) + ' is not found \non your wardrobe ' + chalk.cyan(this.wardrobe) + '.\n');
|
|
217
154
|
console.log('Costume will not be installed, operations will abort.\n');
|
|
218
155
|
Utils.pressKeyToExit();
|
|
@@ -220,53 +157,22 @@ export default class Tailor {
|
|
|
220
157
|
break;
|
|
221
158
|
}
|
|
222
159
|
case 'accessory': {
|
|
223
|
-
|
|
160
|
+
Utils.titles(`${this.category}: ${this.costume}`);
|
|
224
161
|
console.log("Tailor's list " + chalk.cyan(tailorList) + ' is not found \non your wardrobe ' + chalk.cyan(this.wardrobe) + '.\n');
|
|
225
|
-
console.log('
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
162
|
+
console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv');
|
|
163
|
+
console.log('Accessory will not be installed,');
|
|
164
|
+
console.log('operations will continue.');
|
|
165
|
+
console.log('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^');
|
|
166
|
+
sleep(3000);
|
|
230
167
|
return;
|
|
231
168
|
}
|
|
232
|
-
// No default
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* distro e sources_list
|
|
236
|
-
* vengono definite qua perchè servono a tutti
|
|
237
|
-
*/
|
|
238
|
-
const sources_list = new SourcesList();
|
|
239
|
-
let step = '';
|
|
240
|
-
if (this.materials.distributions !== undefined) {
|
|
241
|
-
step = 'analyzing distribution';
|
|
242
|
-
Utils.warning(step);
|
|
243
|
-
if (!(await sources_list.distribution(this.materials.distributions))) {
|
|
244
|
-
switch (this.category) {
|
|
245
|
-
case 'costume': {
|
|
246
|
-
this.titles('step');
|
|
247
|
-
console.log('Costume ' + chalk.cyan(this.materials.name) + ' is not compatible \nwith your ' + chalk.cyan(distro.distroId + '/' + distro.codenameId) + ' system.\n');
|
|
248
|
-
console.log('Costume will not be installed, operations will abort.\n');
|
|
249
|
-
Utils.pressKeyToExit();
|
|
250
|
-
process.exit();
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
case 'accessory': {
|
|
254
|
-
this.titles('step');
|
|
255
|
-
console.log('Accessory ' + chalk.cyan(this.materials.name) + ' is not compatible \nwith your ' + chalk.cyan(distro.distroId + '/' + distro.codenameId) + ' system.\n');
|
|
256
|
-
console.log('Accessory will not be installed, operations will continue.\n');
|
|
257
|
-
Utils.pressKeyToExit();
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
case 'try_accessory': {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
// No default
|
|
264
|
-
}
|
|
265
169
|
}
|
|
266
170
|
}
|
|
267
171
|
/**
|
|
268
172
|
* sequence
|
|
269
173
|
*/
|
|
174
|
+
const sources_list = new SourcesList();
|
|
175
|
+
let step = '';
|
|
270
176
|
if (this.materials.sequence !== undefined) {
|
|
271
177
|
step = 'analyzing sequence';
|
|
272
178
|
Utils.warning(step);
|
|
@@ -329,10 +235,12 @@ export default class Tailor {
|
|
|
329
235
|
}
|
|
330
236
|
case 'alpine': {
|
|
331
237
|
await exec('apk update', Utils.setEcho(false));
|
|
332
|
-
Utils.pressKeyToExit();
|
|
333
238
|
break;
|
|
334
239
|
}
|
|
335
|
-
|
|
240
|
+
case 'fedora': {
|
|
241
|
+
await exec('dnf update', Utils.setEcho(false));
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
336
244
|
}
|
|
337
245
|
}
|
|
338
246
|
/**
|
|
@@ -355,24 +263,27 @@ export default class Tailor {
|
|
|
355
263
|
await exec('apk upgrade', Utils.setEcho(false));
|
|
356
264
|
break;
|
|
357
265
|
}
|
|
358
|
-
|
|
266
|
+
case 'fedora': {
|
|
267
|
+
await exec('dnf upgrade', Utils.setEcho(false));
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
359
270
|
}
|
|
360
271
|
} // upgrade true
|
|
361
272
|
} // undefined upgrade
|
|
362
273
|
} // end sequence/repositories
|
|
363
274
|
/**
|
|
364
|
-
* sequence/
|
|
275
|
+
* sequence/cmds
|
|
365
276
|
*/
|
|
366
|
-
if (this.materials.sequence.
|
|
367
|
-
step = '
|
|
277
|
+
if (this.materials.sequence.cmds !== undefined && Array.isArray(this.materials.sequence.cmds)) {
|
|
278
|
+
step = 'sequence commands';
|
|
368
279
|
Utils.warning(step);
|
|
369
|
-
for (const
|
|
370
|
-
if (fs.existsSync(`${this.costume}/${
|
|
371
|
-
await exec(`${this.costume}/${
|
|
280
|
+
for (const cmd of this.materials.sequence.cmds) {
|
|
281
|
+
if (fs.existsSync(`${this.costume}/${cmd}`)) {
|
|
282
|
+
await exec(`${this.costume}/${cmd} ${this.materials.name}`, Utils.setEcho(true));
|
|
372
283
|
}
|
|
373
284
|
else {
|
|
374
|
-
// exec
|
|
375
|
-
await exec(`${
|
|
285
|
+
// exec cmd real env
|
|
286
|
+
await exec(`${cmd} ${this.materials.name}`, Utils.setEcho(true));
|
|
376
287
|
}
|
|
377
288
|
}
|
|
378
289
|
}
|
|
@@ -380,66 +291,25 @@ export default class Tailor {
|
|
|
380
291
|
* install packages
|
|
381
292
|
*/
|
|
382
293
|
if (this.materials.sequence.packages !== undefined) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
await this.
|
|
294
|
+
const packages = await this.packagesExists(this.materials.sequence.packages);
|
|
295
|
+
if (packages.length > 1) {
|
|
296
|
+
switch (distro.familyId) {
|
|
297
|
+
case 'debian': {
|
|
298
|
+
await this.packagesInstall(packages);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
case 'archlinux': {
|
|
302
|
+
await this.packagesInstall(this.materials.sequence.packages, 'packages', `pacman -Sy --noconfirm`);
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
case 'alpine': {
|
|
306
|
+
await this.packagesInstall(this.materials.sequence.packages, 'packages', `apk add`);
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
case 'fedora': {
|
|
310
|
+
await this.packagesInstall(this.materials.sequence.packages, 'packages', `dnf install -y`);
|
|
311
|
+
break;
|
|
388
312
|
}
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
case 'archlinux': {
|
|
392
|
-
await this.helperInstall(this.materials.sequence.packages, 'packages', `pacman -Sy --noconfirm`);
|
|
393
|
-
break;
|
|
394
|
-
}
|
|
395
|
-
case 'alpine': {
|
|
396
|
-
await this.helperInstall(this.materials.sequence.packages, 'packages', `apk add`);
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
399
|
-
// No default
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (distro.familyId === 'debian') {
|
|
403
|
-
/**
|
|
404
|
-
* sequence/packages_no_install_recommends
|
|
405
|
-
*/
|
|
406
|
-
if (this.materials.sequence.packages_no_install_recommends !== undefined) {
|
|
407
|
-
const packages_no_install_recommends = await this.helperExists(this.materials.sequence.packages_no_install_recommends, true, 'packages_no_install_recommends');
|
|
408
|
-
if (packages_no_install_recommends.length > 1) {
|
|
409
|
-
await this.helperInstall(packages_no_install_recommends, 'packages without recommends and suggests', 'apt-get install --no-install-recommends --no-install-suggests -yq ');
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* sequence/try_packages
|
|
414
|
-
*/
|
|
415
|
-
if (this.materials.sequence.try_packages !== undefined) {
|
|
416
|
-
const try_packages = await this.helperExists(this.materials.sequence.try_packages, false);
|
|
417
|
-
if (try_packages.length > 1) {
|
|
418
|
-
await this.helperInstall(try_packages, 'try packages ');
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* sequence/try_packages_no_install_recommends
|
|
423
|
-
*/
|
|
424
|
-
if (this.materials.sequence.try_packages_no_install_recommends !== undefined) {
|
|
425
|
-
const try_packages_no_install_recommends = await this.helperExists(this.materials.sequence.try_packages_no_install_recommends, false);
|
|
426
|
-
if (try_packages_no_install_recommends.length > 1) {
|
|
427
|
-
await this.helperInstall(try_packages_no_install_recommends, 'try packages without recommends and suggests', 'apt-get install --no-install-recommends --no-install-suggests -yq ');
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* sequence/debs
|
|
432
|
-
*/
|
|
433
|
-
if (this.materials.sequence.debs !== undefined && this.materials.sequence.debs) {
|
|
434
|
-
step = 'installing local packages';
|
|
435
|
-
Utils.warning(step);
|
|
436
|
-
let pathDebs = `${this.costume}/debs/${distro.codenameLikeId}`;
|
|
437
|
-
if (!fs.existsSync(pathDebs)) {
|
|
438
|
-
pathDebs = `${this.costume}/debs`;
|
|
439
|
-
}
|
|
440
|
-
// if exists pathDebs
|
|
441
|
-
if (fs.existsSync(pathDebs)) {
|
|
442
|
-
await exec(`dpkg -i ${pathDebs}/*.deb`);
|
|
443
313
|
}
|
|
444
314
|
}
|
|
445
315
|
}
|
|
@@ -461,7 +331,6 @@ export default class Tailor {
|
|
|
461
331
|
* sequence/accessories
|
|
462
332
|
*/
|
|
463
333
|
if (!no_accessories) {
|
|
464
|
-
// accessories
|
|
465
334
|
if (this.materials.sequence.accessories !== undefined && Array.isArray(this.materials.sequence.accessories)) {
|
|
466
335
|
step = 'wearing accessories';
|
|
467
336
|
for (const elem of this.materials.sequence.accessories) {
|
|
@@ -469,80 +338,67 @@ export default class Tailor {
|
|
|
469
338
|
continue;
|
|
470
339
|
}
|
|
471
340
|
if (elem.slice(0, 2) === './') {
|
|
341
|
+
// local accessory
|
|
472
342
|
const tailor = new Tailor(`${this.costume}/${elem.slice(2)}`, 'accessory');
|
|
473
343
|
await tailor.prepare(verbose);
|
|
474
344
|
}
|
|
475
345
|
else {
|
|
346
|
+
// global accessory
|
|
476
347
|
const tailor = new Tailor(`${this.wardrobe}/accessories/${elem}`, 'accessory');
|
|
477
348
|
await tailor.prepare(verbose);
|
|
478
349
|
}
|
|
479
350
|
}
|
|
480
351
|
}
|
|
481
|
-
if (distro.familyId === 'debian' && // try_accessories
|
|
482
|
-
this.materials.sequence.try_accessories !== undefined &&
|
|
483
|
-
Array.isArray(this.materials.sequence.try_accessories)) {
|
|
484
|
-
step = 'wearing try_accessories';
|
|
485
|
-
for (const elem of this.materials.sequence.try_accessories) {
|
|
486
|
-
if ((elem === 'firmwares' || elem === './firmwares') && no_firmwares) {
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
if (elem.slice(0, 2) === './') {
|
|
490
|
-
const tailor = new Tailor(`${this.costume}/${elem.slice(2)}`, 'try_accessory');
|
|
491
|
-
await tailor.prepare(verbose);
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
const tailor = new Tailor(`${this.wardrobe}/accessories/${elem}`, 'try_accessory');
|
|
495
|
-
await tailor.prepare(verbose);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
352
|
} // no-accessories
|
|
500
353
|
} // end sequence
|
|
501
354
|
/**
|
|
502
355
|
* customize
|
|
503
356
|
*/
|
|
504
|
-
if (this.materials.
|
|
357
|
+
if (this.materials.finalize !== undefined) {
|
|
505
358
|
/**
|
|
506
|
-
* customize
|
|
359
|
+
* finalize/customize
|
|
507
360
|
*/
|
|
508
|
-
if (this.materials.customize
|
|
509
|
-
step =
|
|
361
|
+
if (this.materials.finalize.customize && fs.existsSync(`/${this.costume}/sysroot`)) {
|
|
362
|
+
step = `finalize/customize: copying ${this.costume}/sysroot/ to /`;
|
|
510
363
|
Utils.warning(step);
|
|
511
|
-
let cmd = `rsync -avx ${this.costume}/
|
|
364
|
+
let cmd = `rsync -avx ${this.costume}/sysroot/* / ${this.toNull}`;
|
|
512
365
|
await exec(cmd, this.echo);
|
|
513
|
-
// chown
|
|
514
|
-
cmd =
|
|
366
|
+
// chown
|
|
367
|
+
cmd = `chown root:root /etc/sudoers.d /etc/skel -R`;
|
|
515
368
|
await exec(cmd, this.echo);
|
|
516
369
|
/**
|
|
517
370
|
* Copyng skel in /home/user
|
|
518
371
|
*/
|
|
519
|
-
if (fs.existsSync(`${this.costume}/
|
|
372
|
+
if (fs.existsSync(`${this.costume}/sysroot/etc/skel`)) {
|
|
520
373
|
const user = await Utils.getPrimaryUser();
|
|
521
|
-
step = `copying skel in /home/${user}/`;
|
|
374
|
+
step = `finalize/customize: copying skel in /home/${user}/`;
|
|
522
375
|
Utils.warning(step);
|
|
523
|
-
cmd = `rsync -avx ${this.costume}/
|
|
376
|
+
cmd = `rsync -avx ${this.costume}/sysroot/etc/skel/.config /home/${user}/ ${this.toNull}`;
|
|
524
377
|
await exec(cmd, this.echo);
|
|
525
378
|
await exec(`chown ${user}:${user} /home/${user}/ -R`);
|
|
526
379
|
}
|
|
527
380
|
}
|
|
528
381
|
/**
|
|
529
|
-
*
|
|
382
|
+
* finalize/cmds
|
|
530
383
|
*/
|
|
531
|
-
if (this.materials.
|
|
532
|
-
step = '
|
|
384
|
+
if (this.materials.finalize.cmds !== undefined && Array.isArray(this.materials.finalize.cmds)) {
|
|
385
|
+
step = 'finalize/commands';
|
|
533
386
|
Utils.warning(step);
|
|
534
|
-
for (const
|
|
535
|
-
if (fs.existsSync(`${this.costume}/${
|
|
536
|
-
|
|
537
|
-
await exec(`${this.costume}/${script} ${this.materials.name}`, Utils.setEcho(true));
|
|
387
|
+
for (const cmd of this.materials.finalize.cmds) {
|
|
388
|
+
if (fs.existsSync(`${this.costume}/${cmd}`)) {
|
|
389
|
+
await exec(`${this.costume}/${cmd} ${this.materials.name}`, Utils.setEcho(true));
|
|
538
390
|
}
|
|
539
391
|
else {
|
|
540
|
-
// exec
|
|
541
|
-
await exec(`${
|
|
392
|
+
// exec cmd real env
|
|
393
|
+
await exec(`${cmd}`, Utils.setEcho(true));
|
|
542
394
|
}
|
|
543
395
|
}
|
|
544
396
|
}
|
|
545
397
|
}
|
|
398
|
+
// show log
|
|
399
|
+
if (fs.existsSync(this.log)) {
|
|
400
|
+
await exec(`cat ${this.log}`);
|
|
401
|
+
}
|
|
546
402
|
/**
|
|
547
403
|
* reboot
|
|
548
404
|
*/
|
|
@@ -557,15 +413,86 @@ export default class Tailor {
|
|
|
557
413
|
}
|
|
558
414
|
/**
|
|
559
415
|
*
|
|
560
|
-
* @param
|
|
416
|
+
* @param packages
|
|
417
|
+
* @param verbose
|
|
418
|
+
* @param section
|
|
419
|
+
* @returns
|
|
561
420
|
*/
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
421
|
+
async packagesExists(wanted) {
|
|
422
|
+
Utils.warning(`checking packages exists ${this.costume}`);
|
|
423
|
+
wanted.sort();
|
|
424
|
+
const distro = new Distro();
|
|
425
|
+
let cmd = "";
|
|
426
|
+
if (distro.familyId === "debian") {
|
|
427
|
+
cmd = `apt-cache --no-generate pkgnames`;
|
|
428
|
+
}
|
|
429
|
+
else if (distro.familyId === "archlinux") {
|
|
430
|
+
cmd = `pacman -S --list | awk '{print $2}'`;
|
|
431
|
+
}
|
|
432
|
+
else if (distro.familyId === "alpine") {
|
|
433
|
+
cmd = `apk search | awk -F'-[0-9]' '{print $1}' | sort -u`;
|
|
434
|
+
}
|
|
435
|
+
else if (distro.familyId === 'fedora') {
|
|
436
|
+
cmd = `dnf list available | awk '{print $1}' | sed 's/\.[^.]*$//'`;
|
|
437
|
+
}
|
|
438
|
+
//available = (await exec(cmd, { capture: true, echo: false, ignore: false })).data.split('\n')
|
|
439
|
+
let available = [];
|
|
440
|
+
available = (await exec(cmd, { capture: true, echo: false, ignore: false })).data.split('\n');
|
|
441
|
+
available.sort();
|
|
442
|
+
let exists = [];
|
|
443
|
+
let not_exists = [];
|
|
444
|
+
for (const elem of wanted) {
|
|
445
|
+
if (available.includes(elem)) {
|
|
446
|
+
exists.push(elem);
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
not_exists.push(elem);
|
|
450
|
+
fs.appendFileSync(this.log, `- ${elem}\n`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (not_exists.length > 0) {
|
|
454
|
+
console.log(`${this.materials.name}, ${not_exists.length} following packages was not found:`);
|
|
455
|
+
for (const elem of not_exists) {
|
|
456
|
+
console.log(`-${elem}`);
|
|
457
|
+
}
|
|
458
|
+
console.log();
|
|
459
|
+
console.log("Wait 3 seconds");
|
|
460
|
+
await sleep(3000);
|
|
461
|
+
}
|
|
462
|
+
return exists;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* - check if every package if installed
|
|
466
|
+
* - if find any packages to install, install it
|
|
467
|
+
*/
|
|
468
|
+
async packagesInstall(packages, comment = 'packages', cmd = 'apt-get install -yqq ') {
|
|
469
|
+
Utils.warning(`installing existing packages ${this.costume}`);
|
|
470
|
+
if (packages[0] !== null) {
|
|
471
|
+
const elements = [];
|
|
472
|
+
let strElements = '';
|
|
473
|
+
for (const elem of packages) {
|
|
474
|
+
elements.push(elem);
|
|
475
|
+
cmd += ` ${elem}`;
|
|
476
|
+
strElements += `, ${elem}`;
|
|
477
|
+
}
|
|
478
|
+
if (elements.length > 0) {
|
|
479
|
+
let step = `installing ${comment}: `;
|
|
480
|
+
if (!this.verbose) {
|
|
481
|
+
step += strElements.slice(2);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* prova 3 volte
|
|
485
|
+
*/
|
|
486
|
+
const limit = 3;
|
|
487
|
+
for (let tempts = 1; tempts < limit; tempts++) {
|
|
488
|
+
Utils.titles(step);
|
|
489
|
+
Utils.warning(`tempts ${tempts} of ${limit}`);
|
|
490
|
+
if (await tryCheckSuccess(cmd, this.echo)) {
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
569
496
|
}
|
|
570
497
|
}
|
|
571
498
|
/**
|
|
@@ -585,3 +512,13 @@ async function tryCheckSuccess(cmd, echo) {
|
|
|
585
512
|
}
|
|
586
513
|
return success;
|
|
587
514
|
}
|
|
515
|
+
/**
|
|
516
|
+
*
|
|
517
|
+
* @param ms
|
|
518
|
+
* @returns
|
|
519
|
+
*/
|
|
520
|
+
function sleep(ms = 0) {
|
|
521
|
+
return new Promise((resolve) => {
|
|
522
|
+
setTimeout(resolve, ms);
|
|
523
|
+
});
|
|
524
|
+
}
|
package/dist/classes/utils.js
CHANGED
|
@@ -205,6 +205,9 @@ export default class Utils {
|
|
|
205
205
|
separator = '-';
|
|
206
206
|
version = 'linux';
|
|
207
207
|
suffix = '.img';
|
|
208
|
+
if (distro.distroId === 'ManjaroLinux' || distro.distroId === 'BigLinux') {
|
|
209
|
+
version = vmlinuz.substring(vmlinuz.indexOf('-') + 1);
|
|
210
|
+
}
|
|
208
211
|
}
|
|
209
212
|
else if (distro.familyId === 'debian') {
|
|
210
213
|
initrd = 'initrd.img';
|
|
@@ -222,6 +225,12 @@ export default class Utils {
|
|
|
222
225
|
separator = '-';
|
|
223
226
|
version = vmlinuz.substring(vmlinuz.indexOf('-') + 1);
|
|
224
227
|
}
|
|
228
|
+
else if (distro.familyId === 'voidlinux') {
|
|
229
|
+
initrd = 'initramfs';
|
|
230
|
+
separator = '-';
|
|
231
|
+
version = vmlinuz.substring(vmlinuz.indexOf('-') + 1);
|
|
232
|
+
suffix = '.img';
|
|
233
|
+
}
|
|
225
234
|
// manjaro eredita da arch
|
|
226
235
|
if (distro.distroId === 'Manjaro') {
|
|
227
236
|
version = vmlinuz.substring(vmlinuz.indexOf('-') + 1);
|