penguins-eggs 9.0.48 → 9.1.10
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 +81 -47
- package/assets/leaves.svg +1 -0
- package/assets/live-installer/com.github.pieroproietti.penguins-eggs.policy +25 -0
- package/assets/live-installer/filesystem.packages-remove +49 -0
- package/assets/penguins-live-installer.desktop +27 -0
- package/lib/classes/daddy.js +22 -22
- package/lib/classes/distro.d.ts +1 -1
- package/lib/classes/distro.js +1 -1
- package/lib/classes/family/debian.d.ts +4 -0
- package/lib/classes/family/debian.js +7 -0
- package/lib/classes/ovary.d.ts +6 -0
- package/lib/classes/ovary.js +21 -7
- package/lib/classes/settings.js +3 -4
- package/lib/classes/sources_list.d.ts +27 -0
- package/lib/classes/sources_list.js +103 -0
- package/lib/classes/tailor.d.ts +25 -4
- package/lib/classes/tailor.js +225 -329
- package/lib/classes/utils.d.ts +10 -0
- package/lib/classes/utils.js +31 -11
- package/lib/classes/xdg.d.ts +2 -1
- package/lib/classes/xdg.js +47 -106
- package/lib/commands/config.js +4 -2
- package/lib/commands/info.js +1 -1
- package/lib/commands/update.d.ts +0 -2
- package/lib/commands/update.js +3 -52
- package/lib/commands/wardrobe/get.d.ts +17 -0
- package/lib/commands/wardrobe/get.js +43 -0
- package/lib/commands/wardrobe/ironing.d.ts +6 -5
- package/lib/commands/wardrobe/ironing.js +80 -78
- package/lib/commands/wardrobe/list.d.ts +5 -1
- package/lib/commands/wardrobe/list.js +46 -11
- package/lib/commands/wardrobe/show.d.ts +5 -1
- package/lib/commands/wardrobe/show.js +36 -20
- package/lib/commands/wardrobe/wear.d.ts +10 -1
- package/lib/commands/wardrobe/wear.js +54 -17
- package/lib/components/elements/information.js +23 -19
- package/lib/components/elements/title.js +4 -3
- package/lib/components/finished.js +1 -0
- package/lib/components/network.js +1 -0
- package/lib/components/welcome.js +2 -2
- package/lib/interfaces/i-costume.d.ts +4 -20
- package/lib/interfaces/i-materia.d.ts +32 -0
- package/lib/interfaces/i-materia.js +2 -0
- package/lib/interfaces/index.d.ts +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +17 -19
- package/scripts/_eggs +23 -19
- package/scripts/eggs.bash +7 -6
- package/scripts/mom-cli.sh +66 -0
- package/scripts/resy.sh +1 -1
- package/assets/penguins-clinstaller.desktop +0 -24
- package/assets/penguins-minstall.desktop +0 -95
- package/lib/classes/basket.d.ts +0 -22
- package/lib/classes/basket.js +0 -114
- package/wardrobe.d/external.yml +0 -7
- package/wardrobe.d/hen/control.template +0 -10
- package/wardrobe.d/hen/index.yml +0 -212
- package/wardrobe.d/kde/index.yml +0 -41
- package/wardrobe.d/lamp/index.yml +0 -35
- package/wardrobe.d/xfce4/index.yml +0 -53
package/lib/classes/tailor.js
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* penguins-eggs: tailor.ts
|
|
4
|
+
* author: Piero Proietti
|
|
5
|
+
* mail: piero.proietti@gmail.com
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
const tslib_1 = require("tslib");
|
|
4
10
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
11
|
const utils_1 = tslib_1.__importDefault(require("./utils"));
|
|
6
12
|
const utils_2 = require("../lib/utils");
|
|
7
13
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
14
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
15
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
9
16
|
const pacman_1 = tslib_1.__importDefault(require("./pacman"));
|
|
17
|
+
const sources_list_1 = tslib_1.__importDefault(require("./sources_list"));
|
|
18
|
+
const xdg_1 = tslib_1.__importDefault(require("./xdg"));
|
|
19
|
+
const pjson = require('../../package.json');
|
|
10
20
|
/**
|
|
11
21
|
*
|
|
12
22
|
*/
|
|
13
23
|
class Tailor {
|
|
14
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @param wardrobe
|
|
26
|
+
* @param costume
|
|
27
|
+
*/
|
|
28
|
+
constructor(costume) {
|
|
15
29
|
this.verbose = false;
|
|
16
30
|
this.echo = {};
|
|
17
31
|
this.costume = '';
|
|
18
32
|
this.wardrobe = '';
|
|
19
33
|
this.materials = {};
|
|
20
34
|
this.costume = costume;
|
|
21
|
-
this.wardrobe =
|
|
35
|
+
this.wardrobe = path_1.default.dirname((path_1.default.dirname(costume)));
|
|
22
36
|
}
|
|
23
37
|
/**
|
|
24
38
|
*
|
|
25
39
|
*/
|
|
26
|
-
async prepare(verbose = false) {
|
|
40
|
+
async prepare(verbose = true, no_accessories = false) {
|
|
27
41
|
this.verbose = verbose;
|
|
28
42
|
this.echo = utils_1.default.setEcho(verbose);
|
|
29
43
|
utils_1.default.warning(`preparing ${this.costume}`);
|
|
@@ -34,399 +48,243 @@ class Tailor {
|
|
|
34
48
|
utils_1.default.pressKeyToExit('In this tailoring shop we use curl. sudo apt update | apt install curl');
|
|
35
49
|
process.exit();
|
|
36
50
|
}
|
|
37
|
-
|
|
51
|
+
let tailorList = `${this.costume}/index.yml`;
|
|
38
52
|
if (fs_1.default.existsSync(tailorList)) {
|
|
39
53
|
this.materials = js_yaml_1.default.load(fs_1.default.readFileSync(tailorList, 'utf-8'));
|
|
40
54
|
}
|
|
41
|
-
else {
|
|
42
|
-
console.log('costume ' + chalk_1.default.cyan(this.costume) + ' not found in wardrobe: ' + chalk_1.default.green(this.wardrobe));
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Repositories
|
|
46
|
-
*/
|
|
47
|
-
if (this.materials.sequence.repositories === undefined) {
|
|
48
|
-
console.log('repositiories, and repositories.update MUST be defined on sequence ');
|
|
49
|
-
process.exit();
|
|
50
|
-
}
|
|
51
|
-
utils_1.default.warning(`analyzing repositories`);
|
|
52
|
-
/**
|
|
53
|
-
* sources.list
|
|
54
|
-
*/
|
|
55
|
-
if (this.materials.sequence.repositories.sourcesList !== undefined) {
|
|
56
|
-
let step = '/etc/apt/sources.list';
|
|
57
|
-
utils_1.default.warning(step);
|
|
58
|
-
let components = '';
|
|
59
|
-
if (this.materials.sequence.repositories.sourcesList.main) {
|
|
60
|
-
components += ' main';
|
|
61
|
-
}
|
|
62
|
-
if (this.materials.sequence.repositories.sourcesList.contrib) {
|
|
63
|
-
components += ' contrib';
|
|
64
|
-
}
|
|
65
|
-
if (this.materials.sequence.repositories.sourcesList.nonFree) {
|
|
66
|
-
components += ' non-free';
|
|
67
|
-
}
|
|
68
|
-
console.log(`using: ${components}`);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* sources.list.d
|
|
72
|
-
*/
|
|
73
|
-
if (this.materials.sequence.repositories.sourcesListD !== undefined) {
|
|
74
|
-
if (this.materials.sequence.repositories.sourcesListD[0] !== null) {
|
|
75
|
-
let step = `adding repositories to /etc/apt/sources.list.d`;
|
|
76
|
-
utils_1.default.warning(step);
|
|
77
|
-
for (const cmd of this.materials.sequence.repositories.sourcesListD) {
|
|
78
|
-
try {
|
|
79
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
await utils_1.default.pressKeyToExit(JSON.stringify(error));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
55
|
/**
|
|
88
|
-
*
|
|
56
|
+
* sequence
|
|
89
57
|
*/
|
|
90
|
-
if (this.materials.sequence
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (this.materials.sequence.repositories.fullUpgrade) {
|
|
106
|
-
await (0, utils_2.exec)('apt-get full-upgrade -y', utils_1.default.setEcho(false));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* checking dependencies
|
|
111
|
-
*/
|
|
112
|
-
if (this.materials.sequence.dependencies !== undefined) {
|
|
113
|
-
if (this.materials.sequence.dependencies[0] !== null) {
|
|
114
|
-
let cmd = 'apt-get install -y ';
|
|
115
|
-
let dependencies = '';
|
|
116
|
-
for (const dependence of this.materials.sequence.dependencies) {
|
|
117
|
-
cmd += ` ${dependence}`;
|
|
118
|
-
dependencies += `, ${dependence}`;
|
|
119
|
-
}
|
|
120
|
-
let step = `installing dependencies: ${dependencies.substring(2)}`;
|
|
121
|
-
utils_1.default.warning(step);
|
|
122
|
-
if (verbose) {
|
|
123
|
-
utils_1.default.titles();
|
|
124
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
125
|
-
}
|
|
126
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* apt-get install packages
|
|
131
|
-
*/
|
|
132
|
-
if (this.materials.sequence.packages !== undefined) {
|
|
133
|
-
if (this.materials.sequence.packages[0] !== null) {
|
|
134
|
-
let packages = '';
|
|
135
|
-
let cmd = 'apt-get install -y ';
|
|
136
|
-
for (const elem of this.materials.sequence.packages) {
|
|
137
|
-
cmd += ` ${elem}`;
|
|
138
|
-
packages += `, ${elem}`;
|
|
139
|
-
}
|
|
140
|
-
let step = `installing packages: ${packages.substring(2)}`;
|
|
141
|
-
utils_1.default.warning(step);
|
|
142
|
-
if (verbose) {
|
|
143
|
-
utils_1.default.titles();
|
|
144
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
145
|
-
}
|
|
146
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* apt-get install --no-install-recommends --no-install-suggests
|
|
151
|
-
*/
|
|
152
|
-
if (this.materials.sequence.noInstallRecommends !== undefined) {
|
|
153
|
-
if (this.materials.sequence.noInstallRecommends[0] !== null) {
|
|
154
|
-
let cmd = 'apt-get install --no-install-recommends --no-install-suggests -y ';
|
|
155
|
-
let noInstallRecommends = '';
|
|
156
|
-
for (const elem of this.materials.sequence.noInstallRecommends) {
|
|
157
|
-
cmd += ` ${elem}`;
|
|
158
|
-
noInstallRecommends += `, ${elem}`;
|
|
58
|
+
if (this.materials.sequence !== undefined) {
|
|
59
|
+
/**
|
|
60
|
+
* sequence/repositories
|
|
61
|
+
*/
|
|
62
|
+
if (this.materials.sequence.repositories !== undefined) {
|
|
63
|
+
utils_1.default.warning(`analyzing repositories`);
|
|
64
|
+
/**
|
|
65
|
+
* sequence/repositories/source_list_d
|
|
66
|
+
*/
|
|
67
|
+
if (this.materials.sequence.repositories.sources_list !== undefined) {
|
|
68
|
+
let step = 'analyzing /etc/apt/sources.list';
|
|
69
|
+
utils_1.default.warning(step);
|
|
70
|
+
const sources_list = new sources_list_1.default();
|
|
71
|
+
sources_list.distribution(this.materials.sequence.repositories.sources_list);
|
|
72
|
+
sources_list.components(this.materials.sequence.repositories.sources_list);
|
|
159
73
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
74
|
+
/**
|
|
75
|
+
* sequence/repositories/source_list_d
|
|
76
|
+
*/
|
|
77
|
+
if (this.materials.sequence.repositories.sources_list_d !== undefined) {
|
|
78
|
+
if (this.materials.sequence.repositories.sources_list_d[0] !== null) {
|
|
79
|
+
let step = `adding repositories to /etc/apt/sources.list.d`;
|
|
80
|
+
utils_1.default.warning(step);
|
|
81
|
+
for (const cmd of this.materials.sequence.repositories.sources_list_d) {
|
|
82
|
+
try {
|
|
83
|
+
await (0, utils_2.exec)(cmd, this.echo);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
await utils_1.default.pressKeyToExit(JSON.stringify(error));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
165
90
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (this.materials.sequence.packagesPip !== undefined) {
|
|
173
|
-
if (this.materials.sequence.packagesPip[0] !== null) {
|
|
174
|
-
let cmd = 'pip install ';
|
|
175
|
-
let pip = '';
|
|
176
|
-
for (const elem of this.materials.sequence.packagesPip) {
|
|
177
|
-
cmd += ` ${elem}`;
|
|
178
|
-
pip += `, ${elem}`;
|
|
91
|
+
/**
|
|
92
|
+
* sequence/repositories/update
|
|
93
|
+
*/
|
|
94
|
+
if (this.materials.sequence.repositories.update === undefined) {
|
|
95
|
+
console.log('repositiories, and repositories.update MUDE be defined on sequence ');
|
|
96
|
+
process.exit();
|
|
179
97
|
}
|
|
180
|
-
let step = `
|
|
98
|
+
let step = `updating repositories`;
|
|
181
99
|
utils_1.default.warning(step);
|
|
182
|
-
if (
|
|
183
|
-
utils_1.default.
|
|
184
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
100
|
+
if (this.materials.sequence.repositories.update) {
|
|
101
|
+
await (0, utils_2.exec)('apt-get update', utils_1.default.setEcho(false));
|
|
185
102
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
*/
|
|
192
|
-
if (this.materials.sequence.firmwares !== undefined) {
|
|
193
|
-
/**
|
|
194
|
-
* codecs
|
|
195
|
-
*/
|
|
196
|
-
if (this.materials.sequence.firmwares.codecs !== undefined) {
|
|
197
|
-
if (this.materials.sequence.firmwares.codecs[0] !== null) {
|
|
198
|
-
let cmd = 'apt-get install -y ';
|
|
199
|
-
let codecs = '';
|
|
200
|
-
for (const elem of this.materials.sequence.firmwares.codecs) {
|
|
201
|
-
cmd += ` ${elem}`;
|
|
202
|
-
codecs += `, ${elem}`;
|
|
203
|
-
}
|
|
204
|
-
let step = `installing packages firmware codecs ${codecs.substring(2)}`;
|
|
103
|
+
/**
|
|
104
|
+
* sequence/repositories/upgrade
|
|
105
|
+
*/
|
|
106
|
+
if (this.materials.sequence.repositories.upgrade !== undefined) {
|
|
107
|
+
let step = `apt-get full-upgrade`;
|
|
205
108
|
utils_1.default.warning(step);
|
|
206
|
-
if (
|
|
207
|
-
utils_1.default.
|
|
208
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
109
|
+
if (this.materials.sequence.repositories.upgrade) {
|
|
110
|
+
await (0, utils_2.exec)('apt-get full-upgrade -y', utils_1.default.setEcho(false));
|
|
209
111
|
}
|
|
210
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
211
112
|
}
|
|
212
113
|
}
|
|
213
114
|
/**
|
|
214
|
-
*
|
|
115
|
+
* sequence/preinst
|
|
215
116
|
*/
|
|
216
|
-
if (this.materials.sequence.
|
|
217
|
-
if (this.materials.sequence.
|
|
218
|
-
let
|
|
219
|
-
let drivers_graphics_tablet = '';
|
|
220
|
-
for (const elem of this.materials.sequence.firmwares.drivers_graphics_tablet) {
|
|
221
|
-
cmd += ` ${elem}`;
|
|
222
|
-
drivers_graphics_tablet += `, ${elem}`;
|
|
223
|
-
}
|
|
224
|
-
let step = `installing packages firmware drivers_graphics_tablet ${drivers_graphics_tablet.substring(2)}`;
|
|
117
|
+
if (this.materials.sequence.preinst !== undefined) {
|
|
118
|
+
if (Array.isArray(this.materials.sequence.preinst)) {
|
|
119
|
+
let step = `preinst scripts`;
|
|
225
120
|
utils_1.default.warning(step);
|
|
226
|
-
|
|
227
|
-
utils_1.default.
|
|
228
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
121
|
+
for (const script of this.materials.sequence.preinst) {
|
|
122
|
+
await (0, utils_2.exec)(`${this.costume}/${script}`, utils_1.default.setEcho(true));
|
|
229
123
|
}
|
|
230
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
231
124
|
}
|
|
232
125
|
}
|
|
233
126
|
/**
|
|
234
|
-
*
|
|
127
|
+
* apt-get install packages
|
|
235
128
|
*/
|
|
236
|
-
if (this.materials.sequence.
|
|
237
|
-
|
|
238
|
-
let cmd = 'apt-get install -y ';
|
|
239
|
-
let drivers_network = '';
|
|
240
|
-
for (const elem of this.materials.sequence.firmwares.drivers_network) {
|
|
241
|
-
cmd += ` ${elem}`;
|
|
242
|
-
drivers_network += `, ${elem}`;
|
|
243
|
-
}
|
|
244
|
-
let step = `installing packages firmware drivers_network ${drivers_network.substring(2)}`;
|
|
245
|
-
utils_1.default.warning(step);
|
|
246
|
-
if (verbose) {
|
|
247
|
-
utils_1.default.titles();
|
|
248
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
249
|
-
}
|
|
250
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* drivers_various
|
|
254
|
-
*/
|
|
255
|
-
if (this.materials.sequence.firmwares.drivers_various !== undefined) {
|
|
256
|
-
if (this.materials.sequence.firmwares.drivers_various[0] !== null) {
|
|
257
|
-
let cmd = 'apt-get install -y ';
|
|
258
|
-
let drivers_various = '';
|
|
259
|
-
for (const elem of this.materials.sequence.firmwares.drivers_various) {
|
|
260
|
-
cmd += ` ${elem}`;
|
|
261
|
-
drivers_various += `, ${elem}`;
|
|
262
|
-
}
|
|
263
|
-
let step = `installing packages firmware drivers_network ${drivers_various.substring(2)}`;
|
|
264
|
-
utils_1.default.warning(step);
|
|
265
|
-
if (verbose) {
|
|
266
|
-
utils_1.default.titles();
|
|
267
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
268
|
-
}
|
|
269
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
129
|
+
if (this.materials.sequence.packages !== undefined) {
|
|
130
|
+
await this.helper(this.materials.sequence.packages);
|
|
272
131
|
}
|
|
273
132
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (this.materials.sequence.
|
|
277
|
-
|
|
278
|
-
let cmd = 'apt-get install -y ';
|
|
279
|
-
let drivers_video_amd = '';
|
|
280
|
-
for (const elem of this.materials.sequence.firmwares.drivers_video_amd) {
|
|
281
|
-
cmd += ` ${elem}`;
|
|
282
|
-
drivers_video_amd += `, ${elem}`;
|
|
283
|
-
}
|
|
284
|
-
let step = `installing packages firmware drivers_network ${drivers_video_amd.substring(2)}`;
|
|
285
|
-
utils_1.default.warning(step);
|
|
286
|
-
if (verbose) {
|
|
287
|
-
utils_1.default.titles();
|
|
288
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
289
|
-
}
|
|
290
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
291
|
-
}
|
|
133
|
+
* sequence/packages_no_install_recommends
|
|
134
|
+
*/
|
|
135
|
+
if (this.materials.sequence.packages_no_install_recommends !== undefined) {
|
|
136
|
+
await this.helper(this.materials.sequence.packages_no_install_recommends, "packages without recommends and suggests", 'apt-get install --no-install-recommends --no-install-suggests -yq ');
|
|
292
137
|
}
|
|
293
138
|
/**
|
|
294
|
-
*
|
|
139
|
+
* sequence/debs
|
|
295
140
|
*/
|
|
296
|
-
if (this.materials.sequence.
|
|
297
|
-
if (this.materials.sequence.
|
|
298
|
-
let
|
|
299
|
-
let drivers_video_nvidia = '';
|
|
300
|
-
for (const elem of this.materials.sequence.firmwares.drivers_video_nvidia) {
|
|
301
|
-
cmd += ` ${elem}`;
|
|
302
|
-
drivers_video_nvidia += `, ${elem}`;
|
|
303
|
-
}
|
|
304
|
-
let step = `installing packages firmware drivers_network ${drivers_video_nvidia.substring(2)}`;
|
|
141
|
+
if (this.materials.sequence.debs !== undefined) {
|
|
142
|
+
if (this.materials.sequence.debs) {
|
|
143
|
+
let step = `installing local packages`;
|
|
305
144
|
utils_1.default.warning(step);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
309
|
-
}
|
|
310
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
145
|
+
let cmd = `dpkg -i ${this.costume}/debs/*.deb`;
|
|
146
|
+
await (0, utils_2.exec)(cmd);
|
|
311
147
|
}
|
|
312
148
|
}
|
|
313
149
|
/**
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (this.materials.sequence.
|
|
317
|
-
if (this.materials.sequence.
|
|
318
|
-
let cmd = '
|
|
319
|
-
let
|
|
320
|
-
for (const elem of this.materials.sequence.
|
|
150
|
+
* sequence/packages_python
|
|
151
|
+
*/
|
|
152
|
+
if (this.materials.sequence.packages_python !== undefined) {
|
|
153
|
+
if (Array.isArray(this.materials.sequence.packages_python)) {
|
|
154
|
+
let cmd = 'pip install ';
|
|
155
|
+
let pip = '';
|
|
156
|
+
for (const elem of this.materials.sequence.packages_python) {
|
|
321
157
|
cmd += ` ${elem}`;
|
|
322
|
-
|
|
158
|
+
pip += `, ${elem}`;
|
|
323
159
|
}
|
|
324
|
-
let step = `installing packages
|
|
160
|
+
let step = `installing python packages pip ${pip.substring(2)}`;
|
|
325
161
|
utils_1.default.warning(step);
|
|
326
|
-
if (verbose) {
|
|
327
|
-
utils_1.default.titles();
|
|
328
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
329
|
-
}
|
|
330
162
|
await (0, utils_2.exec)(cmd, this.echo);
|
|
331
163
|
}
|
|
332
164
|
}
|
|
333
165
|
/**
|
|
334
|
-
*
|
|
166
|
+
* sequence/accessories
|
|
335
167
|
*/
|
|
336
|
-
if (
|
|
337
|
-
if (this.materials.sequence.
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
168
|
+
if (!no_accessories) {
|
|
169
|
+
if (this.materials.sequence.accessories !== undefined) {
|
|
170
|
+
if (Array.isArray(this.materials.sequence.accessories)) {
|
|
171
|
+
let step = `wearing accessories`;
|
|
172
|
+
for (const elem of this.materials.sequence.accessories) {
|
|
173
|
+
if (elem.substring(0, 2) === './') {
|
|
174
|
+
const tailor = new Tailor(`${this.costume}/${elem.substring(2)}`);
|
|
175
|
+
await tailor.prepare(verbose);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const tailor = new Tailor(`${this.wardrobe}/accessories/${elem}`);
|
|
179
|
+
await tailor.prepare(verbose);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
349
182
|
}
|
|
350
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* dpkg -i *.deb
|
|
356
|
-
*/
|
|
357
|
-
if (this.materials.sequence.debs !== undefined) {
|
|
358
|
-
if (this.materials.sequence.debs) {
|
|
359
|
-
let step = `installing local packages`;
|
|
360
|
-
utils_1.default.warning(step);
|
|
361
|
-
let cmd = `dpkg -i ${this.wardrobe}\*.deb`;
|
|
362
|
-
if (verbose) {
|
|
363
|
-
utils_1.default.titles();
|
|
364
|
-
utils_1.default.pressKeyToExit(cmd, true);
|
|
365
183
|
}
|
|
366
|
-
await (0, utils_2.exec)(cmd);
|
|
367
184
|
}
|
|
368
185
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
186
|
+
// customize è sempre indefinito
|
|
187
|
+
if (this.materials.customize !== undefined) {
|
|
188
|
+
/**
|
|
189
|
+
* customize/dirs
|
|
190
|
+
*/
|
|
191
|
+
if (this.materials.customize.dirs) {
|
|
192
|
+
if (fs_1.default.existsSync(`/${this.costume}/dirs`)) {
|
|
375
193
|
let step = `copying dirs`;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
194
|
+
utils_1.default.warning(step);
|
|
195
|
+
let cmd = `rsync -avx ${this.costume}/dirs/* /`;
|
|
196
|
+
await (0, utils_2.exec)(cmd, this.echo);
|
|
197
|
+
// chown root:root /etc -R
|
|
198
|
+
cmd = "chown root:root /etc/sudoers.d /etc/skel -R";
|
|
381
199
|
await (0, utils_2.exec)(cmd, this.echo);
|
|
382
200
|
/**
|
|
383
201
|
* Copyng skel in /home/user
|
|
384
202
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
203
|
+
if (fs_1.default.existsSync(`${this.costume}/dirs/etc/skel`)) {
|
|
204
|
+
const user = utils_1.default.getPrimaryUser();
|
|
205
|
+
step = `copying skel in /home/${user}/`;
|
|
206
|
+
utils_1.default.warning(step);
|
|
207
|
+
cmd = `rsync -avx ${this.costume}/dirs/etc/skel/.config /home/${user}/`;
|
|
208
|
+
await (0, utils_2.exec)(cmd, this.echo);
|
|
209
|
+
await (0, utils_2.exec)(`chown ${user}:${user} /home/${user}/ -R`);
|
|
210
|
+
}
|
|
389
211
|
}
|
|
390
212
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (this.materials.sequence.hostname !== undefined) {
|
|
396
|
-
if (this.materials.sequence.hostname) {
|
|
213
|
+
/**
|
|
214
|
+
* customize/hostname
|
|
215
|
+
*/
|
|
216
|
+
if (this.materials.customize.hostname) {
|
|
397
217
|
utils_1.default.warning(`changing hostname = ${this.materials.name}`);
|
|
398
218
|
await this.hostname();
|
|
399
219
|
}
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* customizations
|
|
403
|
-
*/
|
|
404
|
-
if (this.materials.sequence.customizations !== undefined) {
|
|
405
220
|
/**
|
|
406
|
-
*
|
|
221
|
+
* customize/scripts
|
|
407
222
|
*/
|
|
408
|
-
if (this.materials.
|
|
409
|
-
if (this.materials.
|
|
410
|
-
let step = `
|
|
223
|
+
if (this.materials.customize.scripts !== undefined) {
|
|
224
|
+
if (Array.isArray(this.materials.customize.scripts)) {
|
|
225
|
+
let step = `customize script`;
|
|
411
226
|
utils_1.default.warning(step);
|
|
412
|
-
|
|
413
|
-
|
|
227
|
+
const user = process.env.SUDO_USER;
|
|
228
|
+
const desktop = `/home/${user}/${xdg_1.default.traduce("DESKTOP")}`;
|
|
229
|
+
for (const script of this.materials.customize.scripts) {
|
|
230
|
+
if (fs_1.default.existsSync(`${this.costume}/${script}`)) {
|
|
231
|
+
// exec script in costume
|
|
232
|
+
await (0, utils_2.exec)(`${this.costume}/${script} ${user} ${desktop}`, utils_1.default.setEcho(true));
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
// exec script real env
|
|
236
|
+
await (0, utils_2.exec)(`${script}`, utils_1.default.setEcho(true));
|
|
237
|
+
}
|
|
414
238
|
}
|
|
415
239
|
}
|
|
416
240
|
}
|
|
417
241
|
}
|
|
418
242
|
/**
|
|
419
243
|
* reboot
|
|
420
|
-
* mandatory
|
|
421
244
|
*/
|
|
422
|
-
if (this.materials.
|
|
423
|
-
this.materials.sequence.reboot = true;
|
|
424
|
-
}
|
|
425
|
-
if (this.materials.sequence.reboot) {
|
|
245
|
+
if (this.materials.reboot) {
|
|
426
246
|
utils_1.default.warning(`Reboot`);
|
|
427
247
|
await utils_1.default.pressKeyToExit('system need to reboot', true);
|
|
428
248
|
await (0, utils_2.exec)('reboot');
|
|
429
249
|
}
|
|
250
|
+
else {
|
|
251
|
+
console.log(`You look good with: ${this.materials.name}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* - check if every package if installed
|
|
256
|
+
* - if find any packages to install
|
|
257
|
+
* - install packages
|
|
258
|
+
*/
|
|
259
|
+
async helper(packages, comment = 'packages', cmd = 'apt-get install -yqq ') {
|
|
260
|
+
if (packages[0] !== null) {
|
|
261
|
+
let elements = [];
|
|
262
|
+
let strElements = '';
|
|
263
|
+
for (const elem of packages) {
|
|
264
|
+
if (!pacman_1.default.packageIsInstalled(elem)) {
|
|
265
|
+
elements.push(elem);
|
|
266
|
+
cmd += ` ${elem}`;
|
|
267
|
+
strElements += `, ${elem}`;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (elements.length > 0) {
|
|
271
|
+
let step = `installing ${comment}: `;
|
|
272
|
+
// if not verbose show strElements
|
|
273
|
+
if (!this.verbose) {
|
|
274
|
+
step += strElements.substring(2);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* prova 5 volte
|
|
278
|
+
*/
|
|
279
|
+
for (let tempts = 1; tempts < 5; tempts++) {
|
|
280
|
+
this.titles(step);
|
|
281
|
+
utils_1.default.warning(`tempts ${tempts} of 5`);
|
|
282
|
+
if (await tryCheckSuccess(cmd, this.echo)) {
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
430
288
|
}
|
|
431
289
|
/**
|
|
432
290
|
* hostname and hosts
|
|
@@ -455,6 +313,44 @@ class Tailor {
|
|
|
455
313
|
text += `ff02:: 3 ip6 - allhosts\n`;
|
|
456
314
|
await (0, utils_2.exec)(`rm ${file} `, this.echo);
|
|
457
315
|
fs_1.default.writeFileSync(file, text);
|
|
316
|
+
/**
|
|
317
|
+
* chenge config.snapshot.basename
|
|
318
|
+
*/
|
|
319
|
+
const config_file = '/etc/penguins-eggs.d/eggs.yaml';
|
|
320
|
+
let config = js_yaml_1.default.load(fs_1.default.readFileSync(config_file, 'utf-8'));
|
|
321
|
+
config.snapshot_basename = this.materials.name;
|
|
322
|
+
fs_1.default.writeFileSync(config_file, js_yaml_1.default.dump(config), 'utf-8');
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* @param command
|
|
327
|
+
*/
|
|
328
|
+
titles(command = '') {
|
|
329
|
+
console.clear();
|
|
330
|
+
console.log('');
|
|
331
|
+
console.log(' E G G S: the reproductive system of penguins');
|
|
332
|
+
console.log('');
|
|
333
|
+
console.log(chalk_1.default.bgGreen.whiteBright(' ' + pjson.name + ' ') +
|
|
334
|
+
chalk_1.default.bgWhite.blue(" Perri's Brewery edition ") +
|
|
335
|
+
chalk_1.default.bgRed.whiteBright(' ver. ' + pjson.version + ' '));
|
|
336
|
+
console.log('wearing: ' + chalk_1.default.bgBlack.cyan(this.costume) + ' ' + chalk_1.default.bgBlack.white(command) + '\n');
|
|
458
337
|
}
|
|
459
338
|
}
|
|
460
339
|
exports.default = Tailor;
|
|
340
|
+
/**
|
|
341
|
+
*
|
|
342
|
+
* @param cmd
|
|
343
|
+
* @param echo
|
|
344
|
+
* @returns
|
|
345
|
+
*/
|
|
346
|
+
async function tryCheckSuccess(cmd, echo) {
|
|
347
|
+
let success = false;
|
|
348
|
+
try {
|
|
349
|
+
await (0, utils_2.exec)(cmd, echo);
|
|
350
|
+
success = true;
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
success = false;
|
|
354
|
+
}
|
|
355
|
+
return success;
|
|
356
|
+
}
|