penguins-eggs 9.3.26 → 9.3.28
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/conf/derivatives.yaml +7 -0
- package/dist/classes/bleach.js +26 -24
- package/dist/classes/compressors.js +7 -5
- package/dist/classes/daddy.js +38 -36
- package/dist/classes/distro.js +30 -27
- package/dist/classes/family/archlinux.js +21 -19
- package/dist/classes/family/debian.js +33 -31
- package/dist/classes/family/fedora.js +19 -17
- package/dist/classes/family/suse.js +19 -17
- package/dist/classes/incubation/branding.js +8 -6
- package/dist/classes/incubation/distros/bionic.js +5 -3
- package/dist/classes/incubation/distros/buster.js +5 -3
- package/dist/classes/incubation/distros/focal.js +5 -3
- package/dist/classes/incubation/distros/jessie.js +6 -4
- package/dist/classes/incubation/distros/rolling.js +9 -7
- package/dist/classes/incubation/fisherman-helper/displaymanager.js +5 -3
- package/dist/classes/incubation/fisherman-helper/packages.js +17 -15
- package/dist/classes/incubation/fisherman.js +19 -19
- package/dist/classes/incubation/incubator.js +37 -35
- package/dist/classes/incubation/installer.js +8 -6
- package/dist/classes/initrd.js +5 -3
- package/dist/classes/keyboards.js +25 -23
- package/dist/classes/locales.js +19 -17
- package/dist/classes/n8.js +4 -2
- package/dist/classes/network.js +9 -9
- package/dist/classes/ovary.js +280 -281
- package/dist/classes/pacman.js +128 -128
- package/dist/classes/pve-live.js +7 -5
- package/dist/classes/pxe.js +141 -138
- package/dist/classes/settings.js +34 -32
- package/dist/classes/sources_list.js +31 -31
- package/dist/classes/systemctl.js +16 -14
- package/dist/classes/tailor.js +255 -262
- package/dist/classes/tools.js +7 -5
- package/dist/classes/users.js +30 -28
- package/dist/classes/utils.js +22 -20
- package/dist/classes/xdg.js +60 -58
- package/dist/classes/yolk.js +33 -33
- package/dist/commands/adapt.js +14 -12
- package/dist/commands/analyze.js +48 -15
- package/dist/commands/calamares.js +28 -26
- package/dist/commands/config.js +77 -79
- package/dist/commands/cuckoo.js +19 -17
- package/dist/commands/dad.js +16 -14
- package/dist/commands/export/deb.js +19 -17
- package/dist/commands/export/iso.js +17 -15
- package/dist/commands/install.js +31 -29
- package/dist/commands/kill.js +17 -15
- package/dist/commands/mom.js +11 -9
- package/dist/commands/produce.js +30 -28
- package/dist/commands/status.js +7 -5
- package/dist/commands/syncfrom.js +41 -41
- package/dist/commands/syncto.js +77 -80
- package/dist/commands/tools/clean.js +13 -11
- package/dist/commands/tools/ppa.js +26 -24
- package/dist/commands/tools/skel.js +18 -16
- package/dist/commands/tools/stat.js +12 -10
- package/dist/commands/tools/yolk.js +13 -11
- package/dist/commands/update.js +29 -27
- package/dist/commands/wardrobe/get.js +14 -12
- package/dist/commands/wardrobe/list.js +25 -23
- package/dist/commands/wardrobe/show.js +25 -23
- package/dist/commands/wardrobe/wear.js +24 -22
- package/dist/components/elements/information.js +21 -19
- package/dist/components/elements/steps.js +4 -2
- package/dist/components/elements/title.js +4 -2
- package/dist/components/finished.js +10 -8
- package/dist/components/install.js +10 -8
- package/dist/components/keyboard.js +10 -8
- package/dist/components/location.js +10 -8
- package/dist/components/network.js +10 -8
- package/dist/components/partitions.js +10 -8
- package/dist/components/summary.js +10 -8
- package/dist/components/users.js +33 -8
- package/dist/components/welcome.js +10 -8
- package/dist/interfaces/i-packages.js +1 -1
- package/dist/interfaces/i-pxe.js +39 -0
- package/dist/krill/krill-prepare.js +92 -90
- package/dist/krill/krill-sequence.js +148 -145
- package/dist/krill/modules/add-user.js +11 -9
- package/dist/krill/modules/bootloader-config-ubuntu.js +25 -23
- package/dist/krill/modules/bootloader.js +11 -9
- package/dist/krill/modules/change-password.js +2 -2
- package/dist/krill/modules/del-live-user.js +8 -6
- package/dist/krill/modules/fstab.js +35 -33
- package/dist/krill/modules/grubcfg.js +8 -6
- package/dist/krill/modules/hostname.js +19 -17
- package/dist/krill/modules/initramfs-cfg.js +6 -4
- package/dist/krill/modules/initramfs.js +17 -15
- package/dist/krill/modules/locale-cfg.js +12 -10
- package/dist/krill/modules/locale.js +13 -11
- package/dist/krill/modules/m-keyboard.js +33 -31
- package/dist/krill/modules/m-timezone.js +7 -5
- package/dist/krill/modules/machine-id.js +8 -6
- package/dist/krill/modules/mkfs.js +7 -7
- package/dist/krill/modules/mount-fs.js +22 -22
- package/dist/krill/modules/mount-vfs.js +12 -12
- package/dist/krill/modules/network-cfg.js +21 -21
- package/dist/krill/modules/packages.js +20 -18
- package/dist/krill/modules/partition.js +148 -139
- package/dist/krill/modules/remove-installer-link.js +5 -3
- package/dist/krill/modules/umount.js +9 -7
- package/dist/krill/modules/unpackfs.js +8 -6
- package/dist/lib/cli-autologin.js +163 -163
- package/dist/lib/dependencies.js +10 -10
- package/dist/lib/get_address.js +6 -4
- package/dist/lib/get_dns.js +6 -4
- package/dist/lib/get_domain.js +6 -4
- package/dist/lib/get_gateway.js +6 -4
- package/dist/lib/get_hostname.js +6 -4
- package/dist/lib/get_netmask.js +6 -4
- package/dist/lib/get_password.js +8 -6
- package/dist/lib/get_root_password.js +7 -5
- package/dist/lib/get_userfullname.js +6 -4
- package/dist/lib/get_username.js +6 -4
- package/dist/lib/select_address_type.js +6 -4
- package/dist/lib/select_filesystem_type.js +8 -6
- package/dist/lib/select_installation_device.js +7 -5
- package/dist/lib/select_installation_mode.js +6 -4
- package/dist/lib/select_interface.js +6 -4
- package/dist/lib/select_keyboard_layout.js +10 -8
- package/dist/lib/select_keyboard_model.js +10 -8
- package/dist/lib/select_keyboard_option.js +10 -8
- package/dist/lib/select_keyboard_variant.js +10 -8
- package/dist/lib/select_languages.js +9 -7
- package/dist/lib/select_regions.js +6 -4
- package/dist/lib/select_user_swap_choice.js +8 -6
- package/dist/lib/select_zones.js +12 -10
- package/dist/lib/utils.js +3 -3
- package/package.json +12 -5
- package/dist/dhcpd/dhcpd.js +0 -222
- package/dist/dhcpd/index.js +0 -7
- package/dist/dhcpd/packet/converters.js +0 -377
- package/dist/dhcpd/packet/options.js +0 -2
- package/dist/dhcpd/packet/types.js +0 -2
- package/dist/dhcpd/packet.js +0 -251
- package/dist/dhcpd/proxy.js +0 -152
- package/dist/dhcpd/server.js +0 -152
- package/dist/dhcpd/sprintf.js +0 -170
- package/dist/dhcpd/utils.js +0 -190
- package/dist/interfaces/i-pxe-options.js +0 -2
package/dist/classes/tailor.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
6
|
/**
|
|
5
7
|
* penguins-eggs: tailor.ts
|
|
6
8
|
* author: Piero Proietti
|
|
7
9
|
* mail: piero.proietti@gmail.com
|
|
8
10
|
*
|
|
9
11
|
*/
|
|
10
|
-
const chalk_1 =
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const fs_1 =
|
|
14
|
-
const path_1 =
|
|
15
|
-
const js_yaml_1 =
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const utils_js_1 = __importDefault(require("./utils.js"));
|
|
14
|
+
const utils_js_2 = require("../lib/utils.js");
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
18
|
+
const pacman_js_1 = __importDefault(require("./pacman.js"));
|
|
19
|
+
const distro_js_1 = __importDefault(require("./distro.js"));
|
|
20
|
+
const sources_list_js_1 = __importDefault(require("./sources_list.js"));
|
|
19
21
|
const pjson = require('../../package.json');
|
|
20
22
|
/**
|
|
21
23
|
*
|
|
@@ -41,167 +43,170 @@ class Tailor {
|
|
|
41
43
|
*/
|
|
42
44
|
async prepare(verbose = true, no_accessories = false, no_firmwares = false) {
|
|
43
45
|
this.verbose = verbose;
|
|
44
|
-
this.echo =
|
|
45
|
-
|
|
46
|
+
this.echo = utils_js_1.default.setEcho(verbose);
|
|
47
|
+
utils_js_1.default.warning(`preparing ${this.costume}`);
|
|
46
48
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!
|
|
50
|
-
|
|
49
|
+
* check curl presence
|
|
50
|
+
*/
|
|
51
|
+
if (!pacman_js_1.default.packageIsInstalled('curl')) {
|
|
52
|
+
utils_js_1.default.pressKeyToExit('In this tailoring shop we use curl. sudo apt update | apt install curl');
|
|
51
53
|
process.exit();
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
const tailorList = `${this.costume}/index.yml`;
|
|
54
56
|
if (fs_1.default.existsSync(tailorList)) {
|
|
55
57
|
this.materials = js_yaml_1.default.load(fs_1.default.readFileSync(tailorList, 'utf-8'));
|
|
56
58
|
}
|
|
57
|
-
else
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
utils_1.default.pressKeyToExit();
|
|
63
|
-
process.exit();
|
|
64
|
-
}
|
|
65
|
-
else if (this.category === 'accessory') {
|
|
66
|
-
this.titles(`${this.category}: ${this.costume}`);
|
|
67
|
-
console.log('Tailor\'s list ' + chalk_1.default.cyan(tailorList) + ' is not found \non your wardrobe ' + chalk_1.default.cyan(this.wardrobe) + '.\n');
|
|
68
|
-
console.log('Accessory will not be installed, operations will continue.\n');
|
|
69
|
-
utils_1.default.pressKeyToExit();
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
else if (this.category === 'try_accessory') {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* distro e sources_list
|
|
78
|
-
* vengono definite qua perchè servono a tutti
|
|
79
|
-
*/
|
|
80
|
-
const distro = new distro_1.default();
|
|
81
|
-
const sources_list = new sources_list_1.default();
|
|
82
|
-
let step = '';
|
|
83
|
-
if (this.materials.distributions !== undefined) {
|
|
84
|
-
step = 'analyzing distribution';
|
|
85
|
-
utils_1.default.warning(step);
|
|
86
|
-
if (!await sources_list.distribution(this.materials.distributions)) {
|
|
87
|
-
if (this.category === 'costume') {
|
|
88
|
-
this.titles('step');
|
|
89
|
-
console.log('Costume ' + chalk_1.default.cyan(this.materials.name) + ' is not compatible \nwith your ' + chalk_1.default.cyan(distro.distroId + '/' + distro.codenameId) + ' system.\n');
|
|
59
|
+
else
|
|
60
|
+
switch (this.category) {
|
|
61
|
+
case 'costume': {
|
|
62
|
+
this.titles(`${this.category}: ${this.costume}`);
|
|
63
|
+
console.log('Tailor\'s list ' + chalk_1.default.cyan(tailorList) + ' is not found \non your wardrobe ' + chalk_1.default.cyan(this.wardrobe) + '.\n');
|
|
90
64
|
console.log('Costume will not be installed, operations will abort.\n');
|
|
91
|
-
|
|
65
|
+
utils_js_1.default.pressKeyToExit();
|
|
92
66
|
process.exit();
|
|
67
|
+
break;
|
|
93
68
|
}
|
|
94
|
-
|
|
95
|
-
this.titles(
|
|
96
|
-
console.log('
|
|
69
|
+
case 'accessory': {
|
|
70
|
+
this.titles(`${this.category}: ${this.costume}`);
|
|
71
|
+
console.log('Tailor\'s list ' + chalk_1.default.cyan(tailorList) + ' is not found \non your wardrobe ' + chalk_1.default.cyan(this.wardrobe) + '.\n');
|
|
97
72
|
console.log('Accessory will not be installed, operations will continue.\n');
|
|
98
|
-
|
|
73
|
+
utils_js_1.default.pressKeyToExit();
|
|
99
74
|
return;
|
|
100
75
|
}
|
|
101
|
-
|
|
76
|
+
case 'try_accessory': {
|
|
102
77
|
return;
|
|
103
78
|
}
|
|
79
|
+
// No default
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* distro e sources_list
|
|
83
|
+
* vengono definite qua perchè servono a tutti
|
|
84
|
+
*/
|
|
85
|
+
const distro = new distro_js_1.default();
|
|
86
|
+
const sources_list = new sources_list_js_1.default();
|
|
87
|
+
let step = '';
|
|
88
|
+
if (this.materials.distributions !== undefined) {
|
|
89
|
+
step = 'analyzing distribution';
|
|
90
|
+
utils_js_1.default.warning(step);
|
|
91
|
+
if (!await sources_list.distribution(this.materials.distributions)) {
|
|
92
|
+
switch (this.category) {
|
|
93
|
+
case 'costume': {
|
|
94
|
+
this.titles('step');
|
|
95
|
+
console.log('Costume ' + chalk_1.default.cyan(this.materials.name) + ' is not compatible \nwith your ' + chalk_1.default.cyan(distro.distroId + '/' + distro.codenameId) + ' system.\n');
|
|
96
|
+
console.log('Costume will not be installed, operations will abort.\n');
|
|
97
|
+
utils_js_1.default.pressKeyToExit();
|
|
98
|
+
process.exit();
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'accessory': {
|
|
102
|
+
this.titles('step');
|
|
103
|
+
console.log('Accessory ' + chalk_1.default.cyan(this.materials.name) + ' is not compatible \nwith your ' + chalk_1.default.cyan(distro.distroId + '/' + distro.codenameId) + ' system.\n');
|
|
104
|
+
console.log('Accessory will not be installed, operations will continue.\n');
|
|
105
|
+
utils_js_1.default.pressKeyToExit();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
case 'try_accessory': {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// No default
|
|
112
|
+
}
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
* sequence
|
|
117
|
+
*/
|
|
109
118
|
if (this.materials.sequence !== undefined) {
|
|
110
119
|
step = 'analyzing sequence';
|
|
111
|
-
|
|
120
|
+
utils_js_1.default.warning(step);
|
|
112
121
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
* sequence/repositories
|
|
123
|
+
*/
|
|
115
124
|
if (this.materials.sequence.repositories !== undefined) {
|
|
116
125
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
* sequence/repositories/sources_list
|
|
127
|
+
*/
|
|
119
128
|
// evito di fallire se sources_list non è presente
|
|
120
129
|
if (this.materials.sequence.repositories.sources_list !== undefined) {
|
|
121
130
|
step = 'analyzing sources_list';
|
|
122
|
-
|
|
131
|
+
utils_js_1.default.warning(step);
|
|
123
132
|
// controllo i componenti solo se Debian/Devuab
|
|
124
133
|
if (distro.distroId === 'Debian' || distro.distroId === 'Devuan') {
|
|
125
134
|
await sources_list.components(this.materials.sequence.repositories.sources_list);
|
|
126
135
|
}
|
|
127
136
|
}
|
|
128
137
|
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (this.materials.sequence.repositories.sources_list_d !== undefined) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
138
|
+
* sequence/repositories/sources_list_d
|
|
139
|
+
*/
|
|
140
|
+
if (this.materials.sequence.repositories.sources_list_d !== undefined && this.materials.sequence.repositories.sources_list_d[0] !== null) {
|
|
141
|
+
step = 'adding repositories to /etc/apt/sources_list_d';
|
|
142
|
+
utils_js_1.default.warning(step);
|
|
143
|
+
for (const cmd of this.materials.sequence.repositories.sources_list_d) {
|
|
144
|
+
try {
|
|
145
|
+
// repeat 3 times if fail curl or others commands
|
|
146
|
+
for (let i = 0; i < 2; i++) {
|
|
147
|
+
const result = await (0, utils_js_2.exec)(cmd, this.echo);
|
|
148
|
+
if (result.code === 0) {
|
|
149
|
+
break;
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
await utils_js_1.default.pressKeyToExit(JSON.stringify(error));
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
158
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
* sequence/repositories/update
|
|
160
|
+
*/
|
|
154
161
|
if (this.materials.sequence.repositories.update === undefined) {
|
|
155
162
|
console.log('repositiories, and repositories.update MUST be defined on sequence ');
|
|
156
163
|
process.exit();
|
|
157
164
|
}
|
|
158
|
-
step =
|
|
159
|
-
|
|
165
|
+
step = 'updating repositories';
|
|
166
|
+
utils_js_1.default.warning(step);
|
|
160
167
|
if (this.materials.sequence.repositories.update) {
|
|
161
|
-
await (0,
|
|
168
|
+
await (0, utils_js_2.exec)('apt-get update', utils_js_1.default.setEcho(false));
|
|
162
169
|
}
|
|
163
170
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
* sequence/repositories/upgrade
|
|
172
|
+
*/
|
|
166
173
|
if (this.materials.sequence.repositories.upgrade !== undefined) {
|
|
167
|
-
step =
|
|
168
|
-
|
|
174
|
+
step = 'apt-get full-upgrade';
|
|
175
|
+
utils_js_1.default.warning(step);
|
|
169
176
|
if (this.materials.sequence.repositories.upgrade) {
|
|
170
|
-
await (0,
|
|
177
|
+
await (0, utils_js_2.exec)('apt-get full-upgrade -y', utils_js_1.default.setEcho(false));
|
|
171
178
|
}
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
} // fine repositories
|
|
175
182
|
/**
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (this.materials.sequence.preinst !== undefined) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
await (0, utils_2.exec)(`${script}`, utils_1.default.setEcho(true));
|
|
189
|
-
}
|
|
183
|
+
* sequence/preinst
|
|
184
|
+
*/
|
|
185
|
+
if (this.materials.sequence.preinst !== undefined && Array.isArray(this.materials.sequence.preinst)) {
|
|
186
|
+
step = 'preinst scripts';
|
|
187
|
+
utils_js_1.default.warning(step);
|
|
188
|
+
for (const script of this.materials.sequence.preinst) {
|
|
189
|
+
if (fs_1.default.existsSync(`${this.costume}/${script}`)) {
|
|
190
|
+
await (0, utils_js_2.exec)(`${this.costume}/${script}`, utils_js_1.default.setEcho(true));
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
// exec script real env
|
|
194
|
+
await (0, utils_js_2.exec)(`${script}`, utils_js_1.default.setEcho(true));
|
|
190
195
|
}
|
|
191
196
|
}
|
|
192
197
|
}
|
|
193
198
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
199
|
+
* apt-get install dependencies
|
|
200
|
+
*/
|
|
196
201
|
if (this.materials.sequence.dependencies !== undefined) {
|
|
197
202
|
const dependencies = await this.helperExists(this.materials.sequence.dependencies);
|
|
198
203
|
if (dependencies.length > 1) {
|
|
199
|
-
await this.helperInstall(dependencies,
|
|
204
|
+
await this.helperInstall(dependencies, 'dependencies');
|
|
200
205
|
}
|
|
201
206
|
}
|
|
202
207
|
/**
|
|
203
|
-
|
|
204
|
-
|
|
208
|
+
* apt-get install packages
|
|
209
|
+
*/
|
|
205
210
|
if (this.materials.sequence.packages !== undefined) {
|
|
206
211
|
const packages = await this.helperExists(this.materials.sequence.packages, true, 'packages');
|
|
207
212
|
if (packages.length > 1) {
|
|
@@ -209,17 +214,17 @@ class Tailor {
|
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
216
|
/**
|
|
212
|
-
|
|
213
|
-
|
|
217
|
+
* sequence/packages_no_install_recommends
|
|
218
|
+
*/
|
|
214
219
|
if (this.materials.sequence.packages_no_install_recommends !== undefined) {
|
|
215
220
|
const packages_no_install_recommends = await this.helperExists(this.materials.sequence.packages_no_install_recommends, true, 'packages_no_install_recommends');
|
|
216
221
|
if (packages_no_install_recommends.length > 1) {
|
|
217
|
-
await this.helperInstall(packages_no_install_recommends,
|
|
222
|
+
await this.helperInstall(packages_no_install_recommends, 'packages without recommends and suggests', 'apt-get install --no-install-recommends --no-install-suggests -yq ');
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
/**
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
* apt-get TRY install packages
|
|
227
|
+
*/
|
|
223
228
|
if (this.materials.sequence.try_packages !== undefined) {
|
|
224
229
|
const try_packages = await this.helperExists(this.materials.sequence.try_packages, false);
|
|
225
230
|
if (try_packages.length > 1) {
|
|
@@ -227,153 +232,141 @@ class Tailor {
|
|
|
227
232
|
}
|
|
228
233
|
}
|
|
229
234
|
/**
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
* apt-get TRY packages_no_install_recommends
|
|
236
|
+
*/
|
|
232
237
|
if (this.materials.sequence.try_packages_no_install_recommends !== undefined) {
|
|
233
238
|
const try_packages_no_install_recommends = await this.helperExists(this.materials.sequence.try_packages_no_install_recommends, false);
|
|
234
239
|
if (try_packages_no_install_recommends.length > 1) {
|
|
235
|
-
await this.helperInstall(try_packages_no_install_recommends,
|
|
240
|
+
await this.helperInstall(try_packages_no_install_recommends, 'try packages without recommends and suggests', 'apt-get install --no-install-recommends --no-install-suggests -yq ');
|
|
236
241
|
}
|
|
237
242
|
}
|
|
238
243
|
/**
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (this.materials.sequence.debs !== undefined) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
await (0, utils_2.exec)(`dpkg -i ${pathDebs}/*.deb`);
|
|
252
|
-
}
|
|
244
|
+
* sequence/debs
|
|
245
|
+
*/
|
|
246
|
+
if (this.materials.sequence.debs !== undefined && this.materials.sequence.debs) {
|
|
247
|
+
step = 'installing local packages';
|
|
248
|
+
utils_js_1.default.warning(step);
|
|
249
|
+
let pathDebs = `${this.costume}/debs/${distro.codenameLikeId}`;
|
|
250
|
+
if (!fs_1.default.existsSync(pathDebs)) {
|
|
251
|
+
pathDebs = `${this.costume}/debs`;
|
|
252
|
+
}
|
|
253
|
+
// if exists pathDebs
|
|
254
|
+
if (fs_1.default.existsSync(pathDebs)) {
|
|
255
|
+
await (0, utils_js_2.exec)(`dpkg -i ${pathDebs}/*.deb`);
|
|
253
256
|
}
|
|
254
257
|
}
|
|
255
258
|
/**
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (this.materials.sequence.packages_python !== undefined) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
pip += `, ${elem}`;
|
|
265
|
-
}
|
|
266
|
-
step = `installing python packages pip ${pip.substring(2)}`;
|
|
267
|
-
utils_1.default.warning(step);
|
|
268
|
-
await (0, utils_2.exec)(cmd, this.echo);
|
|
259
|
+
* sequence/packages_python
|
|
260
|
+
*/
|
|
261
|
+
if (this.materials.sequence.packages_python !== undefined && Array.isArray(this.materials.sequence.packages_python)) {
|
|
262
|
+
let cmd = 'pip install ';
|
|
263
|
+
let pip = '';
|
|
264
|
+
for (const elem of this.materials.sequence.packages_python) {
|
|
265
|
+
cmd += ` ${elem}`;
|
|
266
|
+
pip += `, ${elem}`;
|
|
269
267
|
}
|
|
268
|
+
step = `installing python packages pip ${pip.slice(2)}`;
|
|
269
|
+
utils_js_1.default.warning(step);
|
|
270
|
+
await (0, utils_js_2.exec)(cmd, this.echo);
|
|
270
271
|
}
|
|
271
272
|
/**
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
* sequence/accessories
|
|
274
|
+
*/
|
|
274
275
|
if (!no_accessories) {
|
|
275
276
|
// accessories
|
|
276
|
-
if (this.materials.sequence.accessories !== undefined) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
await tailor.prepare(verbose);
|
|
290
|
-
}
|
|
277
|
+
if (this.materials.sequence.accessories !== undefined && Array.isArray(this.materials.sequence.accessories)) {
|
|
278
|
+
step = 'wearing accessories';
|
|
279
|
+
for (const elem of this.materials.sequence.accessories) {
|
|
280
|
+
if ((elem === 'firmwares' || elem === './firmwares') && no_firmwares) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (elem.slice(0, 2) === './') {
|
|
284
|
+
const tailor = new Tailor(`${this.costume}/${elem.slice(2)}`, 'accessory');
|
|
285
|
+
await tailor.prepare(verbose);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
const tailor = new Tailor(`${this.wardrobe}/accessories/${elem}`, 'accessory');
|
|
289
|
+
await tailor.prepare(verbose);
|
|
291
290
|
}
|
|
292
291
|
}
|
|
293
292
|
}
|
|
294
293
|
// try_accessories
|
|
295
|
-
if (this.materials.sequence.try_accessories !== undefined) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
await tailor.prepare(verbose);
|
|
309
|
-
}
|
|
294
|
+
if (this.materials.sequence.try_accessories !== undefined && Array.isArray(this.materials.sequence.try_accessories)) {
|
|
295
|
+
step = 'wearing try_accessories';
|
|
296
|
+
for (const elem of this.materials.sequence.try_accessories) {
|
|
297
|
+
if ((elem === 'firmwares' || elem === './firmwares') && no_firmwares) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (elem.slice(0, 2) === './') {
|
|
301
|
+
const tailor = new Tailor(`${this.costume}/${elem.slice(2)}`, 'try_accessory');
|
|
302
|
+
await tailor.prepare(verbose);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
const tailor = new Tailor(`${this.wardrobe}/accessories/${elem}`, 'try_accessory');
|
|
306
|
+
await tailor.prepare(verbose);
|
|
310
307
|
}
|
|
311
308
|
}
|
|
312
309
|
}
|
|
313
310
|
} // no-accessories
|
|
314
311
|
/**
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
* customize
|
|
313
|
+
*/
|
|
317
314
|
if (this.materials.customize !== undefined) {
|
|
318
315
|
/**
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (this.materials.customize.dirs) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
await (0, utils_2.exec)(`chown ${user}:${user} /home/${user}/ -R`);
|
|
340
|
-
}
|
|
316
|
+
* customize/dirs
|
|
317
|
+
*/
|
|
318
|
+
if (this.materials.customize.dirs && fs_1.default.existsSync(`/${this.costume}/dirs`)) {
|
|
319
|
+
step = 'copying dirs';
|
|
320
|
+
utils_js_1.default.warning(step);
|
|
321
|
+
let cmd = `rsync -avx ${this.costume}/dirs/* /`;
|
|
322
|
+
await (0, utils_js_2.exec)(cmd, this.echo);
|
|
323
|
+
// chown root:root /etc -R
|
|
324
|
+
cmd = 'chown root:root /etc/sudoers.d /etc/skel -R';
|
|
325
|
+
await (0, utils_js_2.exec)(cmd, this.echo);
|
|
326
|
+
/**
|
|
327
|
+
* Copyng skel in /home/user
|
|
328
|
+
*/
|
|
329
|
+
if (fs_1.default.existsSync(`${this.costume}/dirs/etc/skel`)) {
|
|
330
|
+
const user = await utils_js_1.default.getPrimaryUser();
|
|
331
|
+
step = `copying skel in /home/${user}/`;
|
|
332
|
+
utils_js_1.default.warning(step);
|
|
333
|
+
cmd = `rsync -avx ${this.costume}/dirs/etc/skel/.config /home/${user}/`;
|
|
334
|
+
await (0, utils_js_2.exec)(cmd, this.echo);
|
|
335
|
+
await (0, utils_js_2.exec)(`chown ${user}:${user} /home/${user}/ -R`);
|
|
341
336
|
}
|
|
342
337
|
}
|
|
343
338
|
/**
|
|
344
|
-
|
|
345
|
-
|
|
339
|
+
* customize/hostname
|
|
340
|
+
*/
|
|
346
341
|
if (this.materials.customize.hostname) {
|
|
347
|
-
|
|
342
|
+
utils_js_1.default.warning(`changing hostname = ${this.materials.name}`);
|
|
348
343
|
await this.hostname();
|
|
349
344
|
}
|
|
350
345
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (this.materials.customize.scripts !== undefined) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
await (0, utils_2.exec)(`${script}`, utils_1.default.setEcho(true));
|
|
365
|
-
}
|
|
346
|
+
* customize/scripts
|
|
347
|
+
*/
|
|
348
|
+
if (this.materials.customize.scripts !== undefined && Array.isArray(this.materials.customize.scripts)) {
|
|
349
|
+
step = 'customize script';
|
|
350
|
+
utils_js_1.default.warning(step);
|
|
351
|
+
for (const script of this.materials.customize.scripts) {
|
|
352
|
+
if (fs_1.default.existsSync(`${this.costume}/${script}`)) {
|
|
353
|
+
// exec script in costume passing costume-name
|
|
354
|
+
await (0, utils_js_2.exec)(`${this.costume}/${script} ${this.materials.name}`, utils_js_1.default.setEcho(true));
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
// exec script real env
|
|
358
|
+
await (0, utils_js_2.exec)(`${script}`, utils_js_1.default.setEcho(true));
|
|
366
359
|
}
|
|
367
360
|
}
|
|
368
361
|
}
|
|
369
362
|
}
|
|
370
363
|
/**
|
|
371
|
-
|
|
372
|
-
|
|
364
|
+
* reboot
|
|
365
|
+
*/
|
|
373
366
|
if (this.materials.reboot) {
|
|
374
|
-
|
|
375
|
-
await
|
|
376
|
-
await (0,
|
|
367
|
+
utils_js_1.default.warning('Reboot');
|
|
368
|
+
await utils_js_1.default.pressKeyToExit('system need to reboot', true);
|
|
369
|
+
await (0, utils_js_2.exec)('reboot');
|
|
377
370
|
}
|
|
378
371
|
else {
|
|
379
372
|
console.log(`You look good with: ${this.materials.name}`);
|
|
@@ -390,29 +383,29 @@ class Tailor {
|
|
|
390
383
|
const packages_we_want = '/tmp/packages_we_want';
|
|
391
384
|
const packages_not_exists = '/tmp/packages_not_exists';
|
|
392
385
|
const packages_exists = '/tmp/packages_exists';
|
|
393
|
-
await (0,
|
|
394
|
-
await (0,
|
|
395
|
-
await (0,
|
|
386
|
+
await (0, utils_js_2.exec)(`rm -f ${packages_we_want}`);
|
|
387
|
+
await (0, utils_js_2.exec)(`rm -f ${packages_not_exists}`);
|
|
388
|
+
await (0, utils_js_2.exec)(`rm -f ${packages_exists}`);
|
|
396
389
|
/**
|
|
397
|
-
|
|
398
|
-
|
|
390
|
+
* packages_we_want
|
|
391
|
+
*/
|
|
399
392
|
let content = '';
|
|
400
393
|
packages.sort();
|
|
401
394
|
for (const elem of packages) {
|
|
402
|
-
if (!
|
|
395
|
+
if (!pacman_js_1.default.packageIsInstalled(elem)) {
|
|
403
396
|
content += elem + '\n';
|
|
404
397
|
}
|
|
405
398
|
}
|
|
406
399
|
fs_1.default.writeFileSync(packages_we_want, content, 'utf-8');
|
|
407
400
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
await (0,
|
|
401
|
+
* packages_exists
|
|
402
|
+
*/
|
|
403
|
+
await (0, utils_js_2.exec)(`apt-cache --no-generate pkgnames | sort | comm -12 - ${packages_we_want} > ${packages_exists}`);
|
|
411
404
|
/**
|
|
412
|
-
|
|
413
|
-
|
|
405
|
+
* packages_not_exists
|
|
406
|
+
*/
|
|
414
407
|
if (verbose) {
|
|
415
|
-
await (0,
|
|
408
|
+
await (0, utils_js_2.exec)(`apt-cache --no-generate pkgnames | sort | comm -13 - ${packages_we_want} > ${packages_not_exists}`);
|
|
416
409
|
const not_exist_packages = fs_1.default.readFileSync(packages_not_exists, 'utf-8').split('\n');
|
|
417
410
|
if (not_exist_packages.length > 1) { // Una riga c'è sempre
|
|
418
411
|
let content = '';
|
|
@@ -421,9 +414,9 @@ class Tailor {
|
|
|
421
414
|
content += `- ${not_exist_packages[i]}\n`;
|
|
422
415
|
}
|
|
423
416
|
this.titles('tailor');
|
|
424
|
-
console.log(
|
|
417
|
+
console.log('Following packages from ' + chalk_1.default.cyan(this.materials.name) + ' section: ' + chalk_1.default.cyan(section) + ', was not found:');
|
|
425
418
|
console.log(content);
|
|
426
|
-
|
|
419
|
+
utils_js_1.default.pressKeyToExit('Press a key to continue...');
|
|
427
420
|
}
|
|
428
421
|
}
|
|
429
422
|
return fs_1.default.readFileSync(packages_exists, 'utf-8').split('\n');
|
|
@@ -434,7 +427,7 @@ class Tailor {
|
|
|
434
427
|
*/
|
|
435
428
|
async helperInstall(packages, comment = 'packages', cmd = 'apt-get install -yqq ') {
|
|
436
429
|
if (packages[0] !== null) {
|
|
437
|
-
|
|
430
|
+
const elements = [];
|
|
438
431
|
let strElements = '';
|
|
439
432
|
for (const elem of packages) {
|
|
440
433
|
elements.push(elem);
|
|
@@ -445,15 +438,15 @@ class Tailor {
|
|
|
445
438
|
let step = `installing ${comment}: `;
|
|
446
439
|
// if not verbose show strElements
|
|
447
440
|
if (!this.verbose) {
|
|
448
|
-
step += strElements.
|
|
441
|
+
step += strElements.slice(2);
|
|
449
442
|
}
|
|
450
443
|
/**
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
444
|
+
* prova 3 volte
|
|
445
|
+
*/
|
|
446
|
+
const limit = 3;
|
|
454
447
|
for (let tempts = 1; tempts < limit; tempts++) {
|
|
455
448
|
this.titles(step);
|
|
456
|
-
|
|
449
|
+
utils_js_1.default.warning(`tempts ${tempts} of ${limit}`);
|
|
457
450
|
if (await tryCheckSuccess(cmd, this.echo)) {
|
|
458
451
|
break;
|
|
459
452
|
}
|
|
@@ -466,33 +459,33 @@ class Tailor {
|
|
|
466
459
|
*/
|
|
467
460
|
async hostname() {
|
|
468
461
|
/**
|
|
469
|
-
|
|
470
|
-
|
|
462
|
+
* hostname
|
|
463
|
+
*/
|
|
471
464
|
let file = '/etc/hostname';
|
|
472
465
|
let text = this.materials.name;
|
|
473
|
-
await (0,
|
|
466
|
+
await (0, utils_js_2.exec)(`rm ${file} `, this.echo);
|
|
474
467
|
fs_1.default.writeFileSync(file, text);
|
|
475
468
|
/**
|
|
476
|
-
|
|
477
|
-
|
|
469
|
+
* hosts
|
|
470
|
+
*/
|
|
478
471
|
file = '/etc/hosts';
|
|
479
472
|
text = '';
|
|
480
473
|
text += '127.0.0.1 localhost localhost.localdomain\n';
|
|
481
474
|
text += `127.0.1.1 ${this.materials.name} \n`;
|
|
482
|
-
text +=
|
|
483
|
-
text +=
|
|
484
|
-
text +=
|
|
485
|
-
text +=
|
|
486
|
-
text +=
|
|
487
|
-
text +=
|
|
488
|
-
text +=
|
|
489
|
-
await (0,
|
|
475
|
+
text += '# The following lines are desirable for IPv6 capable hosts\n';
|
|
476
|
+
text += ':: 1 ip6 - localhost ip6 - loopback\n';
|
|
477
|
+
text += 'fe00:: 0 ip6 - localnet\n';
|
|
478
|
+
text += 'ff00:: 0 ip6 - mcastprefix\n';
|
|
479
|
+
text += 'ff02:: 1 ip6 - allnodes\n';
|
|
480
|
+
text += 'ff02:: 2 ip6 - allrouters\n';
|
|
481
|
+
text += 'ff02:: 3 ip6 - allhosts\n';
|
|
482
|
+
await (0, utils_js_2.exec)(`rm ${file} `, this.echo);
|
|
490
483
|
fs_1.default.writeFileSync(file, text);
|
|
491
484
|
/**
|
|
492
|
-
|
|
493
|
-
|
|
485
|
+
* chenge config.snapshot.basename
|
|
486
|
+
*/
|
|
494
487
|
const config_file = '/etc/penguins-eggs.d/eggs.yaml';
|
|
495
|
-
|
|
488
|
+
const config = js_yaml_1.default.load(fs_1.default.readFileSync(config_file, 'utf-8'));
|
|
496
489
|
config.snapshot_basename = this.materials.name;
|
|
497
490
|
fs_1.default.writeFileSync(config_file, js_yaml_1.default.dump(config), 'utf-8');
|
|
498
491
|
}
|
|
@@ -521,10 +514,10 @@ exports.default = Tailor;
|
|
|
521
514
|
async function tryCheckSuccess(cmd, echo) {
|
|
522
515
|
let success = false;
|
|
523
516
|
try {
|
|
524
|
-
await (0,
|
|
517
|
+
await (0, utils_js_2.exec)(cmd, echo);
|
|
525
518
|
success = true;
|
|
526
519
|
}
|
|
527
|
-
catch
|
|
520
|
+
catch {
|
|
528
521
|
success = false;
|
|
529
522
|
}
|
|
530
523
|
return success;
|