penguins-eggs 25.9.3 → 25.9.7

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.
@@ -24,6 +24,10 @@ swapfile
24
24
  sys/*
25
25
  tmp/*
26
26
 
27
+ # fedora/el9/etc
28
+ boot/*rescue*
29
+
30
+
27
31
  *.cache # suggestion from blaxbox-ai
28
32
 
29
33
  ######################################################################################################
@@ -14,13 +14,21 @@ export default class Kernel {
14
14
  * @returns Path al file vmlinuz
15
15
  */
16
16
  static vmlinuz(kernel?: string): string;
17
+ /**
18
+ * cerca il path per initramfs/initrd nella directory /boot
19
+ * se fallisce, prova la convenzione Arch
20
+ *
21
+ * @param kernel - Versione del kernel (es. '6.5.0-14-generic'). Se omessa, usa il kernel in esecuzione.
22
+ * @returns Path al file initramfs.
23
+ */
24
+ static initramfs(kernel?: string): string;
17
25
  /**
18
26
  * Ricava path per initramfs/initrd
19
27
  *
20
28
  * @param kernel - Versione del kernel
21
29
  * @returns Path al file initramfs
22
30
  */
23
- static initramfs(kernel?: string): string;
31
+ static initramfsOld(kernel?: string): string;
24
32
  /**
25
33
  * ALL PRIVATE
26
34
  */
@@ -41,13 +41,98 @@ export default class Kernel {
41
41
  }
42
42
  return vmlinuz;
43
43
  }
44
+ /**
45
+ * cerca il path per initramfs/initrd nella directory /boot
46
+ * se fallisce, prova la convenzione Arch
47
+ *
48
+ * @param kernel - Versione del kernel (es. '6.5.0-14-generic'). Se omessa, usa il kernel in esecuzione.
49
+ * @returns Path al file initramfs.
50
+ */
51
+ static initramfs(kernel = '') {
52
+ let targetKernel = kernel;
53
+ // 1. Determina la versione del kernel target
54
+ if (targetKernel === '') {
55
+ if (Utils.isContainer()) {
56
+ Utils.warning("Non è possibile determinare il kernel in un container.");
57
+ process.exit(1);
58
+ }
59
+ targetKernel = execSync('uname -r').toString().trim();
60
+ }
61
+ const kernelVersionShort = targetKernel.split('.').slice(0, 2).join('.');
62
+ const bootDir = '/boot';
63
+ // 2. Leggi tutti i file nella directory /boot
64
+ let bootFiles;
65
+ try {
66
+ bootFiles = fs.readdirSync(bootDir);
67
+ }
68
+ catch (error) {
69
+ console.error(`ERRORE: Impossibile leggere la directory ${bootDir}.`);
70
+ process.exit(1);
71
+ }
72
+ // 3. Cerca il file corrispondente con un sistema di priorità
73
+ const candidates = [];
74
+ for (const filename of bootFiles) {
75
+ if ((filename.startsWith('initramfs-') ||
76
+ filename.startsWith('initrd.img-') ||
77
+ filename.startsWith('initrd-')) &&
78
+ (filename.includes(targetKernel) || filename.includes(kernelVersionShort))) {
79
+ candidates.push(filename);
80
+ }
81
+ }
82
+ // Se troviamo almeno un candidato, usiamo quello
83
+ if (candidates.length > 0) {
84
+ let foundPath = path.join(bootDir, candidates[0]);
85
+ /**
86
+ * ma, se sono più di uno, usiamo il più breve
87
+ * per evitare estensioni come -fallback.img, .old, .bak, etc
88
+ */
89
+ if (candidates.length > 1) {
90
+ // Filtra i candidati per escludere quelli di fallback se esiste un'alternativa
91
+ const nonFallbackCandidates = candidates.filter(c => !c.includes('-fallback'));
92
+ const searchArray = nonFallbackCandidates.length > 0 ? nonFallbackCandidates : candidates;
93
+ foundPath = path.join(bootDir, searchArray[0]); // Inizia con il primo
94
+ for (const candidate of searchArray) {
95
+ const current = path.join(bootDir, candidate);
96
+ if (current.length < foundPath.length) {
97
+ foundPath = current;
98
+ }
99
+ }
100
+ }
101
+ return foundPath;
102
+ }
103
+ // 4. Fallback per casi specifici (Arch e Alpine Linux)
104
+ // Questo viene eseguito solo se la ricerca dinamica fallisce.
105
+ const staticFallbacks = [
106
+ // --- Alpine Linux ---
107
+ 'initramfs-lts', // Kernel Long-Term Support
108
+ 'initramfs-virt', // Kernel per ambienti virtualizzati
109
+ 'initramfs-standard', // Kernel standard (meno comune)
110
+ 'initramfs-rpi', // Kernel per Raspberry Pi
111
+ // --- Arch Linux ---
112
+ 'initramfs-linux.img', // Arch Linux standard
113
+ 'initramfs-linux-lts.img', // Arch Linux LTS
114
+ 'initramfs-linux-zen.img', // Arch Linux Zen
115
+ 'initramfs-linux-hardened.img', // Arch Linux hardened
116
+ ];
117
+ for (const fallback of staticFallbacks) {
118
+ const fallbackPath = path.join(bootDir, fallback);
119
+ if (fs.existsSync(fallbackPath)) {
120
+ // Nota: questo potrebbe non corrispondere al 100% al kernel in esecuzione,
121
+ // ma è il comportamento atteso su questi sistemi
122
+ return fallbackPath;
123
+ }
124
+ }
125
+ // 5. Se nessuna delle strategie ha funzionato, esci con errore
126
+ Utils.warning(`Could not find an initramfs file for kernel ${targetKernel} in ${bootDir}.`);
127
+ process.exit(1);
128
+ }
44
129
  /**
45
130
  * Ricava path per initramfs/initrd
46
131
  *
47
132
  * @param kernel - Versione del kernel
48
133
  * @returns Path al file initramfs
49
134
  */
50
- static initramfs(kernel = '') {
135
+ static initramfsOld(kernel = '') {
51
136
  const distro = new Distro();
52
137
  let initramfs = '';
53
138
  if (kernel === '') {
@@ -60,7 +60,7 @@ export default class ExportPkg extends Command {
60
60
  if (process.arch === 'ia32') {
61
61
  arch = 'i386';
62
62
  }
63
- Utils.warning(`alpine apk`);
63
+ Utils.warning(`exporting Alpine APK packages`);
64
64
  localPath = `/home/${this.user}/packages/aports/${arch}`;
65
65
  remotePath = `${this.Tu.config.remotePathPackages}/alpine/${arch}`;
66
66
  filter = `penguins-eggs-*[0-9][0-9].@([0-9]|[0-1][0-9]).@([0-9]|[0-3][0-9])-*.apk`;
@@ -73,7 +73,7 @@ export default class ExportPkg extends Command {
73
73
  * Manjaro
74
74
  */
75
75
  if (Diversions.isManjaroBased(distroId)) {
76
- Utils.warning("manjaro PKGBUILD");
76
+ Utils.warning(`exporting Manjaro .pkg.tar.zst packages`);
77
77
  localPath = `/home/${this.user}/penguins-packs/manjaro/penguins-eggs`;
78
78
  remotePath = this.Tu.config.remotePathPackages + "/manjaro";
79
79
  filter = `penguins-eggs-[0-9][0-9].@([0-9]|[0-1][0-9]).@([0-9]|[0-3][0-9])-*-any.pkg.tar.*`;
@@ -82,7 +82,7 @@ export default class ExportPkg extends Command {
82
82
  */
83
83
  }
84
84
  else {
85
- Utils.warning("aur PKGBUILD");
85
+ Utils.warning(`exporting Arch .pkg.tar.zst packages`);
86
86
  localPath = `/home/${this.user}/penguins-packs/aur/penguins-eggs`;
87
87
  remotePath = this.Tu.config.remotePathPackages + "/aur";
88
88
  filter = `penguins-eggs-[0-9][0-9].@([0-9]|[0-1][0-9]).@([0-9]|[0-3][0-9])-*-any.pkg.tar.zst`;
@@ -92,7 +92,7 @@ export default class ExportPkg extends Command {
92
92
  */
93
93
  }
94
94
  else if (familyId === "debian") {
95
- Utils.warning("debian DEB");
95
+ Utils.warning(`exporting Devuan/Debian/Ubuntu DEB packages`);
96
96
  localPath = `/home/${this.user}/penguins-eggs/dist`;
97
97
  remotePath = this.Tu.config.remotePathPackages + "/debs";
98
98
  let arch = Utils.uefiArch();
@@ -105,22 +105,23 @@ export default class ExportPkg extends Command {
105
105
  */
106
106
  }
107
107
  else if (familyId === 'fedora') {
108
- Utils.warning("fedora RPM");
109
- localPath = `/home/${this.user}/rpmbuild/RPMS/x86_64`;
110
- if (distroId === 'fedora') {
111
- remotePath = this.Tu.config.remotePathPackages + "/fedora";
108
+ let repo = 'fedora';
109
+ let warning = `exporting Fedora RPM packages`;
110
+ filter = `penguins-eggs-[0-9][0-9].[0-9]*.[0-9]*-*.fc??.x86_64.rpm`;
111
+ if (distro.distroId !== 'Fedora') {
112
+ repo = 'el9';
113
+ warning = `exporting Almalinux/Rocky RPM packages`;
112
114
  filter = `penguins-eggs-[0-9][0-9].[0-9]*.[0-9]*-*.fc??.x86_64.rpm`;
113
115
  }
114
- else {
115
- remotePath = this.Tu.config.remotePathPackages + "/el9";
116
- filter = `penguins-eggs-[0-9][0-9].[0-9]*.[0-9]*-*.el?.x86_64.rpm`;
117
- }
116
+ Utils.warning(warning);
117
+ localPath = `/home/${this.user}/rpmbuild/RPMS/x86_64`;
118
+ remotePath = this.Tu.config.remotePathPackages + `/` + repo;
118
119
  /**
119
120
  * openmamba
120
121
  */
121
122
  }
122
123
  else if (familyId === 'openmamba') {
123
- Utils.warning("openmamba rpm packages");
124
+ Utils.warning(`exporting Openmamba RPM packages`);
124
125
  localPath = `/home/${this.user}/rpmbuild/RPMS/x86_64`;
125
126
  remotePath = this.Tu.config.remotePathPackages + "/openmamba";
126
127
  filter = `penguins-eggs-[0-9][0-9].@([0-9]|[0-1][0-9]).@([0-9]|[0-3][0-9])-*mamba.*.rpm`;
@@ -129,17 +130,10 @@ export default class ExportPkg extends Command {
129
130
  */
130
131
  }
131
132
  else if (familyId === 'opensuse') {
132
- Utils.warning("opensuse rpm packages");
133
+ Utils.warning(`exporting OpenSuSE RPM packages`);
133
134
  localPath = `/home/${this.user}/rpmbuild/RPMS/x86_64`;
134
135
  remotePath = this.Tu.config.remotePathPackages + "/opensuse";
135
136
  filter = `penguins-eggs-[0-9][0-9].[0-9]*.[0-9]*-*.opensuse.x86_64.rpm`;
136
- /**
137
- * voidlinux
138
- */
139
- }
140
- else if (familyId === 'voidlinux') {
141
- Utils.warning("voidlinux packages");
142
- process.exit();
143
137
  }
144
138
  let cmd = `#!/bin/bash\n`;
145
139
  cmd += `set -e\n`;
@@ -161,6 +155,7 @@ export default class ExportPkg extends Command {
161
155
  cmd += `# Export packages\n`;
162
156
  cmd += `cp ${localPath}/${filter} ${remoteMountpoint}\n`;
163
157
  cmd += 'sync\n';
158
+ cmd += `\n`;
164
159
  cmd += `# wait before to umount\n`;
165
160
  cmd += 'sleep 2s\n';
166
161
  cmd += `fusermount3 -u ${remoteMountpoint}\n`;
@@ -172,7 +167,6 @@ export default class ExportPkg extends Command {
172
167
  }
173
168
  console.log(`copy: ${localPath}/${filter} to ${this.Tu.config.remoteUser}@${this.Tu.config.remoteHost}:${remotePath}`);
174
169
  }
175
- // console.log(cmd)
176
170
  await exec(cmd, this.echo);
177
171
  }
178
172
  }
@@ -5,6 +5,12 @@
5
5
  * email: piero.proietti@gmail.com
6
6
  * license: MIT
7
7
  */
8
+ /**
9
+ * Debian 13 trixe, Ubuntu 24.04 noble usano il formato deb822
10
+ *
11
+ * esiste un comando per modernizzare le sorgenti:
12
+ * sudo apt modernize-sources
13
+ */
8
14
  import { Command } from '@oclif/core';
9
15
  /**
10
16
  *
@@ -5,13 +5,24 @@
5
5
  * email: piero.proietti@gmail.com
6
6
  * license: MIT
7
7
  */
8
+ /**
9
+ * Debian 13 trixe, Ubuntu 24.04 noble usano il formato deb822
10
+ *
11
+ * esiste un comando per modernizzare le sorgenti:
12
+ * sudo apt modernize-sources
13
+ */
8
14
  import { Command, Flags } from '@oclif/core';
9
15
  import fs from 'node:fs';
16
+ import path from 'node:path';
10
17
  import Distro from '../../classes/distro.js';
11
18
  import Utils from '../../classes/utils.js';
12
19
  import { exec } from '../../lib/utils.js';
13
- const fkey = '/etc/apt/trusted.gpg.d/penguins-eggs-key.gpg';
14
- const flist = '/etc/apt/sources.list.d/penguins-eggs-ppa.list';
20
+ import Diversions from '../../classes/diversions.js';
21
+ const ppaKey = '/usr/share/keyrings/penguins-eggs-ppa.gpg';
22
+ // '/etc/apt/trusted.gpg.d/penguins-eggs-key.gpg'
23
+ const ppaName = `/etc/apt/sources.list.d/penguins-eggs-ppa`;
24
+ const ppaList = ppaName + '.list';
25
+ const ppaSources = ppaName + '.sources';
15
26
  /**
16
27
  *
17
28
  */
@@ -43,39 +54,48 @@ export default class Ppa extends Command {
43
54
  */
44
55
  if (distro.familyId === 'debian') {
45
56
  if (flags.add) {
46
- Utils.warning(`Are you sure to add ${flist} to your repositories?`);
57
+ Utils.warning(`Are you sure to add source ${path.basename(ppaName)} to your repositories?`);
47
58
  if (nointeractive || (await Utils.customConfirm('Select yes to continue...'))) {
48
- await debianAdd();
59
+ // remove old penguins-eggs-ppa.list
60
+ debianRemove();
61
+ if (await is822()) {
62
+ debianAdd822();
63
+ }
64
+ else {
65
+ await debianAdd();
66
+ }
49
67
  }
50
68
  }
51
69
  else if (flags.remove) {
52
- Utils.warning(`Are you sure to remove ${flist} to your repositories?`);
70
+ Utils.warning(`Are you sure to remove source ${path.basename(ppaName)} to your repositories?`);
53
71
  if (nointeractive || (await Utils.customConfirm('Select yes to continue...'))) {
54
72
  await debianRemove();
55
73
  }
56
74
  }
75
+ await exec('apt-get update');
57
76
  /**
58
- * archlinux
77
+ * Arch and only Arch! no Manjaro...
59
78
  */
60
79
  }
61
- if (distro.familyId === 'archlinux') {
80
+ else if (distro.familyId === 'archlinux' && !Diversions.isManjaroBased(distro.distroId)) {
62
81
  if (flags.add) {
63
- if (distro.distroId !== 'Manjarolinux') {
64
- Utils.warning(`Are you sure to add chaotic-aur to your repositories?`);
65
- if (await Utils.customConfirm('Select yes to continue...')) {
66
- await archAdd();
67
- }
82
+ Utils.warning(`Are you sure to add Chaotic-AUR to your repositories?`);
83
+ if (await Utils.customConfirm('Select yes to continue...')) {
84
+ await archAdd();
68
85
  }
69
86
  }
70
87
  else if (flags.remove) {
71
- await archRemove();
88
+ Utils.warning(`Are you sure to remove Chaotic-AUR to your repositories?`);
89
+ if (await Utils.customConfirm('Select yes to continue...')) {
90
+ await archRemove();
91
+ }
72
92
  }
73
- }
74
- else {
75
93
  /**
76
- * Others
94
+ * Alle the others
77
95
  */
78
- Utils.warning(`Distro> ${distro.distroId}/${distro.codenameId}, cannot use this command here!`);
96
+ }
97
+ else {
98
+ Utils.warning(`Distro: ${distro.distroId}/${distro.codenameId}, cannot use penguins-eggs-ppa nor chaotic-aur!`);
79
99
  }
80
100
  }
81
101
  }
@@ -89,7 +109,7 @@ async function archAdd() {
89
109
  const mirrorlist = 'chaotic-mirrorlist.pkg.tar.zst';
90
110
  const echo = Utils.setEcho(true);
91
111
  if (fs.existsSync(path + keyring) && fs.existsSync(path + mirrorlist)) {
92
- console.log('repository chaotic-aur, already present!');
112
+ console.log('repository Chaotic-AUR, already present!');
93
113
  await archRemove();
94
114
  process.exit();
95
115
  }
@@ -118,21 +138,48 @@ async function archRemove() {
118
138
  console.log(`Include = /etc/pacman.d/chaotic-mirrorlist`);
119
139
  }
120
140
  }
141
+ /**
142
+ * debianAdd822
143
+ */
144
+ async function debianAdd822() {
145
+ await exec(`curl -sS https://pieroproietti.github.io/penguins-eggs-ppa/KEY.gpg| gpg --dearmor | sudo tee ${ppaKey} > /dev/null`);
146
+ let content = '';
147
+ content += 'Types: deb\n';
148
+ content += 'URIs: https://pieroproietti.github.io/penguins-eggs-ppa\n';
149
+ content += 'Suites: ./\n';
150
+ content += 'Signed-By: /usr/share/keyrings/penguins-eggs-ppa.gpg\n';
151
+ fs.writeFileSync(ppaSources, content);
152
+ // crea un penguins-eggs-ppa.list vuoto
153
+ await exec(`touch ${ppaList}`);
154
+ }
121
155
  /**
122
156
  * debianAdd
123
157
  */
124
158
  async function debianAdd() {
125
- await exec(`curl -sS https://pieroproietti.github.io/penguins-eggs-ppa/KEY.gpg| gpg --dearmor | sudo tee ${fkey} > /dev/null`);
126
- const content = `deb [signed-by=${fkey}] https://pieroproietti.github.io/penguins-eggs-ppa ./\n`;
127
- fs.writeFileSync(flist, content);
128
- await exec('apt-get update');
159
+ await exec(`curl -sS https://pieroproietti.github.io/penguins-eggs-ppa/KEY.gpg| gpg --dearmor | sudo tee ${ppaKey} > /dev/null`);
160
+ const content = `deb [signed-by=${ppaKey}] https://pieroproietti.github.io/penguins-eggs-ppa ./\n`;
161
+ fs.writeFileSync(ppaList, content);
162
+ }
163
+ /**
164
+ * is822 (usa lo standard deb822 per le sorgenti)
165
+ */
166
+ async function is822() {
167
+ await exec(`curl -sS https://pieroproietti.github.io/penguins-eggs-ppa/KEY.gpg| gpg --dearmor | sudo tee ${ppaKey} > /dev/null`);
168
+ let retval = false;
169
+ const test = `([ -f /etc/apt/sources.list.d/ubuntu.sources ] || [ -f /etc/apt/sources.list.d/debian.sources ]) && echo "1" || echo "0"`;
170
+ const is822 = (await exec(test, { capture: true, echo: false, ignore: false }));
171
+ if (is822.code === 0) {
172
+ if (is822.data.trim() === '1') {
173
+ retval = true;
174
+ }
175
+ }
176
+ return retval;
129
177
  }
130
178
  /**
131
179
  * debianRemove
132
180
  */
133
181
  async function debianRemove() {
134
- await exec('rm -f /etc/apt/trusted.gpg.d/penguins-eggs*');
135
- await exec('rm -f /etc/apt/sources.list.d/penguins-eggs*');
136
- await exec('rm -f /usr/share/keyrings/penguins-eggs*');
137
- await exec('apt-get update');
182
+ await exec(`rm -f ${ppaKey}`);
183
+ await exec(`rm -f ${ppaList}`);
184
+ await exec(`rm -f ${ppaSources}`);
138
185
  }
@@ -30,7 +30,7 @@ export default class Update extends Command {
30
30
  /**
31
31
  *
32
32
  */
33
- getPkgFromRepo(): Promise<void>;
33
+ getPkgFromPackageManager(): Promise<void>;
34
34
  /**
35
35
  * download da LAN
36
36
  */
@@ -38,12 +38,7 @@ export default class Update extends Command {
38
38
  /**
39
39
  *
40
40
  */
41
- getPkgFromSourceforge(): Promise<void>;
42
- /**
43
- *
44
- * @param aptVersion
45
- */
46
- getFromSources(): void;
41
+ getFromSource(): void;
47
42
  /**
48
43
  * show
49
44
  */