penguins-eggs 25.11.8 → 25.11.12

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.
@@ -1,52 +0,0 @@
1
- /**
2
- * penguins-eggs
3
- * class: distro.ts
4
- * author: Piero Proietti (modified by Hossein Seilani)
5
- * license: MIT
6
- *
7
- * FINAL VERSION WITH EXPLAINED COMMENTS AND NEW CHANGE TAGS
8
- */
9
- import { IDistro } from '../interfaces/index.js';
10
- declare class Distro implements IDistro {
11
- bugReportUrl: string;
12
- codenameId: string;
13
- distroUniqueId: string;
14
- distroId: string;
15
- distroLike: string;
16
- familyId: string;
17
- homeUrl: string;
18
- isCalamaresAvailable: boolean;
19
- liveMediumPath: string;
20
- releaseId: string;
21
- squashfs: string;
22
- supportUrl: string;
23
- syslinuxPath: string;
24
- usrLibPath: string;
25
- constructor();
26
- /**
27
- * NEW CHANGE6: Modular configuration for main distro types like Alpine, Fedora-family, etc.
28
- * This simplifies the constructor and keeps distro-specific logic isolated.
29
- */
30
- private configureDistro;
31
- /**
32
- * NEW CHANGE12: Map Debian, Ubuntu, Devuan codenames to proper IDs and paths
33
- * This avoids long if/else chains and allows easier future updates.
34
- */
35
- private debianFamily;
36
- /**
37
- * NEW CHANGE15: Async derivative detection from YAML files
38
- * This allows future-proofing and easy updates for new distros.
39
- */
40
- private detectDerivatives;
41
- /**
42
- * NEW CHANGE16: Apply family-specific paths for usrLibPath, squashfs, and liveMediumPath
43
- * Handles Debian, openSUSE, Manjaro and derivatives consistently.
44
- */
45
- private applyFamilySpecificPaths;
46
- /**
47
- * NEW CHANGE17: Load custom HOME, SUPPORT, BUG_REPORT URLs from /etc/os-release
48
- * Allows overrides of default URLs for user-friendly experience.
49
- */
50
- private loadOSReleaseUrls;
51
- }
52
- export default Distro;
@@ -1,239 +0,0 @@
1
- /**
2
- * penguins-eggs
3
- * class: distro.ts
4
- * author: Piero Proietti (modified by Hossein Seilani)
5
- * license: MIT
6
- *
7
- * FINAL VERSION WITH EXPLAINED COMMENTS AND NEW CHANGE TAGS
8
- */
9
- import yaml from 'js-yaml';
10
- import fs from 'node:fs/promises';
11
- import fsSync from 'node:fs';
12
- import path from 'node:path';
13
- import shell from 'shelljs';
14
- import Utils from './utils.js';
15
- import Diversions from './diversions.js';
16
- const __dirname = path.dirname(new URL(import.meta.url).pathname);
17
- class Distro {
18
- // NEW CHANGE 1: Added default values for all main distro properties to ensure proper initialization.
19
- // This prevents undefined values in later logic and standardizes URLs and paths.
20
- bugReportUrl = 'https://github.com-pieroproietti/penguins-eggs/issue';
21
- codenameId = '';
22
- distroUniqueId = '';
23
- distroId = '';
24
- distroLike = '';
25
- familyId = 'debian';
26
- homeUrl = 'https://penguins-eggs.net';
27
- isCalamaresAvailable = true;
28
- liveMediumPath = '/run/live/medium/';
29
- releaseId = '';
30
- squashfs = 'live/filesystem.squashfs';
31
- supportUrl = 'https://penguins-eggs.net';
32
- syslinuxPath = path.resolve(__dirname, `../../syslinux`);
33
- usrLibPath = '/usr/lib';
34
- constructor() {
35
- // NEW CHANGE2: Initialize OS info using Utils.getOsRelease()
36
- // This ensures the distroId, codenameId, and releaseId are set early for proper logic.
37
- const osInfo = Utils.getOsRelease();
38
- this.distroId = osInfo.ID;
39
- this.codenameId = osInfo.VERSION_CODENAME;
40
- this.releaseId = osInfo.VERSION_ID;
41
- // NEW CHANGE3: Normalize special distro names to handle edge cases like Debian sid
42
- // or custom Biglinux/Bigcommunity derivatives to maintain consistency.
43
- if (this.distroId === 'Debian' && this.codenameId === 'sid')
44
- this.codenameId = 'trixie';
45
- if (this.distroId.includes('Biglinux'))
46
- this.distroId = 'Biglinux';
47
- if (this.distroId.includes('Bigcommunity'))
48
- this.distroId = 'Bigcommunity';
49
- // NEW CHANGE4: Modularize distro configuration for better readability and maintenance
50
- this.configureDistro();
51
- this.applyFamilySpecificPaths();
52
- // NEW CHANGE5: Load URLs from /etc/os-release to override defaults if available
53
- this.loadOSReleaseUrls();
54
- }
55
- /**
56
- * NEW CHANGE6: Modular configuration for main distro types like Alpine, Fedora-family, etc.
57
- * This simplifies the constructor and keeps distro-specific logic isolated.
58
- */
59
- configureDistro() {
60
- // NEW CHANGE7: Handle Alpine specific paths and properties
61
- if (this.distroId === 'Alpine') {
62
- this.familyId = 'alpine';
63
- this.distroLike = 'Alpine';
64
- this.codenameId = 'rolling';
65
- this.distroUniqueId = this.familyId;
66
- this.liveMediumPath = '/mnt/';
67
- return;
68
- }
69
- /**
70
- * Arch
71
- */
72
- if (this.codenameId === 'rolling' || this.codenameId === 'n/a') {
73
- this.familyId = 'archlinux';
74
- this.distroLike = 'Arch';
75
- this.codenameId = 'rolling';
76
- this.distroUniqueId = 'archlinux';
77
- this.liveMediumPath = '/run/archiso/bootmnt/';
78
- this.squashfs = `arch/x86_64/airootfs.sfs`;
79
- return;
80
- }
81
- // NEW CHANGE8: Consolidated Fedora-family detection for multiple derivatives
82
- const fedoraDistros = ['Almalinux', 'Fedora', 'Nobara', 'Rhel', 'Rocky'];
83
- if (fedoraDistros.includes(this.distroId)) {
84
- this.familyId = 'fedora';
85
- this.distroLike = 'Fedora';
86
- this.codenameId = 'rolling';
87
- this.distroUniqueId = this.familyId;
88
- this.liveMediumPath = '/run/initramfs/live/';
89
- return;
90
- }
91
- // NEW CHANGE9: Openmamba specific properties
92
- if (this.distroId === 'Openmamba') {
93
- this.familyId = 'openmamba';
94
- this.distroLike = 'Openmamba';
95
- this.codenameId = 'rolling';
96
- this.distroUniqueId = this.familyId;
97
- this.liveMediumPath = '/run/initramfs/live/';
98
- return;
99
- }
100
- // NEW CHANGE10: OpenSUSE specific properties
101
- if (this.distroId.includes('Opensuse')) {
102
- this.familyId = 'opensuse';
103
- this.distroLike = 'Opensuse';
104
- this.codenameId = 'rolling';
105
- this.distroUniqueId = this.familyId;
106
- this.liveMediumPath = '/run/initramfs/live/';
107
- return;
108
- }
109
- // NEW CHANGE11: Handle Debian/Ubuntu/Devuan and their derivatives
110
- this.debianFamily();
111
- }
112
- /**
113
- * NEW CHANGE12: Map Debian, Ubuntu, Devuan codenames to proper IDs and paths
114
- * This avoids long if/else chains and allows easier future updates.
115
- */
116
- debianFamily() {
117
- const mapping = {
118
- jessie: { distroLike: 'Debian', uniqueId: 'jessie', livePath: '/lib/live/mount/medium/', calamares: false },
119
- stretch: { distroLike: 'Debian', uniqueId: 'stretch', livePath: '/lib/live/mount/medium/', calamares: false },
120
- buster: { distroLike: 'Debian', uniqueId: 'buster' },
121
- bullseye: { distroLike: 'Debian', uniqueId: 'bullseye' },
122
- bookworm: { distroLike: 'Debian', uniqueId: 'bookworm' },
123
- trixie: { distroLike: 'Debian', uniqueId: 'trixie' },
124
- forky: { distroLike: 'Debian', uniqueId: 'forky' },
125
- beowulf: { distroLike: 'Devuan', uniqueId: 'beowulf' },
126
- chimaera: { distroLike: 'Devuan', uniqueId: 'chimaera' },
127
- daedalus: { distroLike: 'Devuan', uniqueId: 'daedalus' },
128
- excalibur: { distroLike: 'Devuan', uniqueId: 'excalibur' },
129
- bionic: { distroLike: 'Ubuntu', uniqueId: 'bionic', livePath: '/lib/live/mount/medium/' },
130
- focal: { distroLike: 'Ubuntu', uniqueId: 'focal' },
131
- jammy: { distroLike: 'Ubuntu', uniqueId: 'jammy' },
132
- noble: { distroLike: 'Ubuntu', uniqueId: 'noble' },
133
- devel: { distroLike: 'Ubuntu', uniqueId: 'devel' },
134
- };
135
- // NEW CHANGE13: Apply mapping if codename exists
136
- const cfg = mapping[this.codenameId];
137
- if (cfg) {
138
- this.familyId = "debian";
139
- this.distroLike = cfg.distroLike;
140
- this.distroUniqueId = cfg.uniqueId;
141
- if (cfg.livePath !== undefined)
142
- this.liveMediumPath = cfg.livePath;
143
- if (cfg.calamares !== undefined)
144
- this.isCalamaresAvailable = cfg.calamares;
145
- return;
146
- }
147
- // NEW CHANGE14: Detect derivatives if not in mapping
148
- this.detectDerivatives();
149
- }
150
- /**
151
- * NEW CHANGE15: Async derivative detection from YAML files
152
- * This allows future-proofing and easy updates for new distros.
153
- */
154
- async detectDerivatives() {
155
- let archDebianDerivatives = path.resolve(__dirname, '../../conf/derivatives.yaml');
156
- if (fsSync.existsSync('/etc/penguins-eggs.d/derivatives.yaml')) {
157
- archDebianDerivatives = '/etc/penguins-eggs.d/derivatives.yaml';
158
- }
159
- let found = false;
160
- if (fsSync.existsSync(archDebianDerivatives)) {
161
- const content = await fs.readFile(archDebianDerivatives, 'utf8');
162
- const distros = yaml.load(content);
163
- for (const distro of distros) {
164
- if (distro.ids !== undefined) {
165
- for (let n = 0; n < distro.ids.length; n++) {
166
- if (this.codenameId === distro.ids[n]) {
167
- found = true;
168
- this.distroLike = distro.distroLike;
169
- this.distroUniqueId = distro.id;
170
- this.familyId = distro.family;
171
- found = true;
172
- }
173
- }
174
- }
175
- }
176
- }
177
- if (!found) {
178
- let fedoraDerivatives = path.resolve(__dirname, '../../conf/derivatives_fedora.yaml');
179
- if (fsSync.existsSync('/etc/penguins-eggs.d/derivatives_fedora.yaml')) {
180
- fedoraDerivatives = '/etc/penguins-eggs.d/derivatives_fedora.yaml';
181
- }
182
- const content = fsSync.readFileSync(fedoraDerivatives, 'utf8');
183
- const elem = yaml.load(content);
184
- if (elem.includes(this.distroId)) {
185
- this.familyId = 'fedora';
186
- this.distroLike = 'Fedora';
187
- this.codenameId = 'rolling';
188
- this.distroUniqueId = this.familyId;
189
- this.liveMediumPath = '/run/initramfs/live/';
190
- found = true;
191
- }
192
- }
193
- if (!found) {
194
- console.warn(`This distro ${this.distroId}/${this.codenameId} is not yet recognized!`);
195
- console.warn('Edit derivatives.yaml and run: sudo eggs dad -d to re-configure.');
196
- process.exit(0);
197
- }
198
- }
199
- /**
200
- * NEW CHANGE16: Apply family-specific paths for usrLibPath, squashfs, and liveMediumPath
201
- * Handles Debian, openSUSE, Manjaro and derivatives consistently.
202
- */
203
- applyFamilySpecificPaths() {
204
- if (this.familyId === 'archlinux') {
205
- if (Diversions.isManjaroBased(this.distroId)) {
206
- this.liveMediumPath = '/run/miso/bootmnt/';
207
- this.squashfs = 'manjaro/x86_64/livefs.sfs';
208
- this.codenameId = shell.exec('lsb_release -cs', { silent: true }).stdout.toString().trim();
209
- this.distroUniqueId = 'manjaro';
210
- }
211
- }
212
- else if (this.familyId === 'debian') {
213
- this.usrLibPath = '/usr/lib/' + Utils.usrLibPath();
214
- }
215
- else if (this.familyId === 'opensuse') {
216
- this.usrLibPath = '/usr/lib64/';
217
- }
218
- }
219
- /**
220
- * NEW CHANGE17: Load custom HOME, SUPPORT, BUG_REPORT URLs from /etc/os-release
221
- * Allows overrides of default URLs for user-friendly experience.
222
- */
223
- loadOSReleaseUrls() {
224
- const os_release = '/etc/os-release';
225
- if (!fsSync.existsSync(os_release))
226
- return;
227
- const data = fsSync.readFileSync(os_release, 'utf8');
228
- const lines = data.split('\n');
229
- for (const line of lines) {
230
- if (line.startsWith('HOME_URL='))
231
- this.homeUrl = line.slice('HOME_URL='.length).replace(/"/g, '');
232
- if (line.startsWith('SUPPORT_URL='))
233
- this.supportUrl = line.slice('SUPPORT_URL='.length).replace(/"/g, '');
234
- if (line.startsWith('BUG_REPORT_URL='))
235
- this.bugReportUrl = line.slice('BUG_REPORT_URL='.length).replace(/"/g, '');
236
- }
237
- }
238
- }
239
- export default Distro;
@@ -1,32 +0,0 @@
1
- /**
2
- * ./src/classes/incubation/distros/bionic.ts
3
- * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- */
8
- import { IDistro, IInstaller, IRemix } from '../../../interfaces/index.js';
9
- /**
10
- *
11
- */
12
- export declare class Bionic {
13
- distro: IDistro;
14
- installer: IInstaller;
15
- isClone: boolean;
16
- release: boolean;
17
- remix: IRemix;
18
- theme: string;
19
- user_opt: string;
20
- verbose: boolean;
21
- /**
22
- * @param remix
23
- * @param distro
24
- * @param release
25
- * @param verbose
26
- */
27
- constructor(installer: IInstaller, remix: IRemix, distro: IDistro, user_opt: string, release?: boolean, theme?: string, isClone?: boolean, verbose?: boolean);
28
- /**
29
- * locale, partitions, users can come from themes
30
- */
31
- create(): Promise<void>;
32
- }
@@ -1,83 +0,0 @@
1
- /**
2
- * ./src/classes/incubation/distros/bionic.ts
3
- * penguins-eggs v.25.7.x / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
7
- */
8
- import CFS from '../../../krill/classes/cfs.js';
9
- import Fisherman from '../fisherman.js';
10
- /**
11
- *
12
- */
13
- export class Bionic {
14
- distro;
15
- installer = {};
16
- isClone;
17
- release = false;
18
- remix;
19
- theme; // theme comprende il path
20
- user_opt;
21
- verbose = false;
22
- /**
23
- * @param remix
24
- * @param distro
25
- * @param release
26
- * @param verbose
27
- */
28
- constructor(installer, remix, distro, user_opt, release = false, theme = 'eggs', isClone = false, verbose = false) {
29
- this.installer = installer;
30
- this.remix = remix;
31
- this.distro = distro;
32
- this.user_opt = user_opt;
33
- this.verbose = verbose;
34
- this.release = release;
35
- this.theme = theme;
36
- this.isClone = isClone;
37
- }
38
- /**
39
- * locale, partitions, users can come from themes
40
- */
41
- async create() {
42
- const fisherman = new Fisherman(this.distro, this.installer, this.verbose);
43
- await fisherman.createCalamaresSettings(this.theme, this.isClone);
44
- await fisherman.buildModule('welcome');
45
- await fisherman.buildModule('partition', this.remix.branding);
46
- await fisherman.buildModule('mount');
47
- await fisherman.buildModuleUnpackfs(); //
48
- await fisherman.buildModule('machineid');
49
- await fisherman.buildModule('fstab');
50
- await fisherman.buildModule('locale', this.remix.branding);
51
- await fisherman.buildModule('keyboard');
52
- await fisherman.buildModule('localecfg');
53
- await fisherman.buildModule('luksbootkeyfile');
54
- await fisherman.buildModule('users', this.remix.branding);
55
- await fisherman.buildModule('displaymanager');
56
- await fisherman.buildModule('networkcfg');
57
- await fisherman.buildModule('hwclock');
58
- await fisherman.buildCalamaresModule('sources-yolk', true);
59
- await fisherman.buildCalamaresModule('bug');
60
- await fisherman.buildModule('initramfscfg');
61
- await fisherman.buildModule('initramfs');
62
- await fisherman.buildCalamaresPy('grubcfg');
63
- await fisherman.buildModule('bootloader');
64
- await fisherman.buildCalamaresModule('after-bootloader');
65
- await fisherman.buildCalamaresModule('add386arch', false);
66
- await fisherman.buildModulePackages(this.distro, this.release); //
67
- await fisherman.buildModuleRemoveuser(this.user_opt); //
68
- await fisherman.buildCalamaresModule('sources-yolk-undo', false);
69
- await fisherman.buildCalamaresModule('cleanup', true);
70
- /**
71
- * cfs: custom final steps
72
- */
73
- const cfs = new CFS();
74
- const steps = await cfs.steps();
75
- if (steps.length > 0) {
76
- for (const step of steps) {
77
- await fisherman.buildCalamaresModule(step, true, this.theme);
78
- }
79
- }
80
- await fisherman.buildModule('umount');
81
- await fisherman.buildModule('finished');
82
- }
83
- }