Browse Source

refactoring e controllo su public/private/static

pull/36/head
Piero Proietti 4 months ago
parent
commit
88ad8612f4
31 changed files with 2692 additions and 3272 deletions
  1. +1
    -1
      .prettierrc
  2. +53
    -37
      src/classes/bleach.ts
  3. +12
    -37
      src/classes/distro.ts
  4. +55
    -243
      src/classes/hatching.ts
  5. +495
    -466
      src/classes/incubation/beowulf.ts
  6. +602
    -579
      src/classes/incubation/bionic.ts
  7. +1
    -9
      src/classes/incubation/branding.ts
  8. +503
    -473
      src/classes/incubation/buster.ts
  9. +11
    -16
      src/classes/incubation/calamares-config.ts
  10. +17
    -18
      src/classes/incubation/calamares-modules/conf/automirror.ts
  11. +136
    -136
      src/classes/incubation/calamares-modules/scripts/automirror.ts
  12. +586
    -558
      src/classes/incubation/focal.ts
  13. +2
    -3
      src/classes/n8.ts
  14. +46
    -180
      src/classes/ovary.ts
  15. +16
    -66
      src/classes/pacman.ts
  16. +23
    -55
      src/classes/settings.ts
  17. +14
    -59
      src/classes/utils.ts
  18. +95
    -278
      src/classes/xdg.ts
  19. +3
    -7
      src/commands/calamares.ts
  20. +1
    -1
      src/commands/clean.ts
  21. +1
    -5
      src/commands/howto/configuration.ts
  22. +2
    -3
      src/commands/info.ts
  23. +2
    -5
      src/commands/prerequisites.ts
  24. +4
    -9
      src/commands/produce.ts
  25. +1
    -1
      src/commands/sterilize.ts
  26. +2
    -5
      src/commands/update.ts
  27. +5
    -6
      src/interfaces/i-addons.ts
  28. +1
    -1
      src/interfaces/i-app.ts
  29. +0
    -10
      src/interfaces/i-ovary.ts
  30. +1
    -1
      src/interfaces/index.ts
  31. +1
    -4
      src/lib/utils.ts

+ 1
- 1
.prettierrc View File

@@ -2,5 +2,5 @@
"semi": false,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 80
"printWidth": 300
}

+ 53
- 37
src/classes/bleach.ts View File

@@ -12,43 +12,17 @@ import Utils from './utils'
// libraries
const exec = require('../lib/utils').exec

/**
*
* @param dest
*/
async function rm(dest = '', verbose = false) {
let echo = { echo: false, ignore: true, capture: false }
if (verbose) {
echo = { echo: true, ignore: true, capture: false }
}

if (fs.existsSync(dest)) {
await exec(`rm ${dest} -rf`, echo)
} else {
console.log(`non esiste ${dest}`)
}
}

async function rmdir(dest = '', verbose = false) {
let echo = { echo: false, ignore: true, capture: false }
if (verbose) {
echo = { echo: true, ignore: true, capture: false }
}
const result: string[] = fs.readdirSync(dest)
if (result.length > 0) {
await exec(`rm ${dest} -rf`, echo)
}
}

/**
* Bleach:
*/
export default class Ovary {
export default class Bleach {

/**
*
* @param verbose
* clean
* @param verbose
*/
static async clean(verbose = false) {
async clean(verbose = false) {
await this.cleanApt(verbose)
await this.cleanHistory(verbose)
await this.cleanJournal(verbose)
@@ -56,10 +30,10 @@ export default class Ovary {
}

/**
* PULITORI
* cleanApt
* @param verbose
*/

static async cleanApt(verbose = false) {
private async cleanApt(verbose = false) {
let echo = { echo: false, ignore: true, capture: false }
if (verbose) {
echo = { echo: true, ignore: true, capture: false }
@@ -71,7 +45,11 @@ export default class Ovary {
rmdir(dest, verbose)
}

static async cleanHistory(verbose = false) {
/**
* cleanHistory
* @param verbose
*/
private async cleanHistory(verbose = false) {
if (verbose) {
Utils.warning('cleaning bash history')
}
@@ -81,7 +59,11 @@ export default class Ovary {
}
}

static async cleanJournal(verbose = false) {
/**
* cleanJournal
* @param verbose
*/
private async cleanJournal(verbose = false) {
let echo = { echo: false, ignore: true, capture: false }
if (verbose) {
echo = { echo: true, ignore: true, capture: false }
@@ -92,7 +74,11 @@ export default class Ovary {
await exec('journalctl --vacuum-time=1s', echo)
}

static async cleanSystemCache(verbose = false) {
/**
* cleanSystemCache
* @param verbose
*/
private async cleanSystemCache(verbose = false) {
let echo = { echo: false, ignore: true, capture: false }
if (verbose) {
echo = { echo: true, ignore: true, capture: false }
@@ -109,6 +95,35 @@ export default class Ovary {
}
}


/**
*
* @param dest
*/
async function rm(dest = '', verbose = false) {
let echo = { echo: false, ignore: true, capture: false }
if (verbose) {
echo = { echo: true, ignore: true, capture: false }
}

if (fs.existsSync(dest)) {
await exec(`rm ${dest} -rf`, echo)
} else {
console.log(`non esiste ${dest}`)
}
}

async function rmdir(dest = '', verbose = false) {
let echo = { echo: false, ignore: true, capture: false }
if (verbose) {
echo = { echo: true, ignore: true, capture: false }
}
const result: string[] = fs.readdirSync(dest)
if (result.length > 0) {
await exec(`rm ${dest} -rf`, echo)
}
}

/**
* Elenco pulitori bleachbit
* Solo quelli pertinenti root
@@ -153,3 +168,4 @@ x11.debug_logs
yum.clean_all
yum.vacuum
*/


+ 12
- 37
src/classes/distro.ts View File

@@ -10,10 +10,10 @@
* Debian 10 (buster) โ€” l'attuale versione stable
* Debian 9 (stretch) โ€” l'attuale versione oldstable
* Debian 8 (jessie) โ€” l'attuale versione oldoldstable
*
*
* Devuan ASCII
* Devuan beowlf
* Devuan Chimaera
* Devuan beowlf
* Devuan Chimaera
*
* Ubuntu 16.04 (xenial) LTS active
* Ubuntu 18.04 (bionic) LTS active
@@ -84,43 +84,29 @@ class Distro implements IDistro {
os[info.BUG_REPORT_URL] = 'BUG_REPORT_URL='
for (const temp in data) {
if (!data[temp].search(os[info.HOME_URL])) {
this.homeUrl = data[temp]
.substring(os[info.HOME_URL].length)
.replace(/"/g, '')
this.homeUrl = data[temp].substring(os[info.HOME_URL].length).replace(/"/g, '')
}

if (!data[temp].search(os[info.SUPPORT_URL])) {
this.supportUrl = data[temp]
.substring(os[info.SUPPORT_URL].length)
.replace(/"/g, '')
this.supportUrl = data[temp].substring(os[info.SUPPORT_URL].length).replace(/"/g, '')
}

if (!data[temp].search(os[info.BUG_REPORT_URL])) {
this.bugReportUrl = data[temp]
.substring(os[info.BUG_REPORT_URL].length)
.replace(/"/g, '')
this.bugReportUrl = data[temp].substring(os[info.BUG_REPORT_URL].length).replace(/"/g, '')
}
}

/**
* lsb_release -c -s
*/
this.versionId = shell
.exec('lsb_release -c -s', { silent: true })
.stdout.toString()
.trim()
this.versionId = shell.exec('lsb_release -c -s', { silent: true }).stdout.toString().trim()

/**
* LINUX MINT dall 19 in poi
*/

// LinuxMint 19 tara, 19.1 tessa, 19.2 Tina, 19.3 Tricia
if (
this.versionId === 'tara' ||
this.versionId === 'tessa' ||
this.versionId === 'tina' ||
this.versionId === 'tricia'
) {
// LinuxMint 19 tara, 19.1 tessa, 19.2 Tina, 19.3 Tricia
if (this.versionId === 'tara' || this.versionId === 'tessa' || this.versionId === 'tina' || this.versionId === 'tricia') {
this.distroId = 'Linux Mint'
this.distroLike = 'Ubuntu'
this.versionLike = 'bionic'
@@ -162,7 +148,6 @@ class Distro implements IDistro {
this.distroId = 'Debian'
this.distroLike = 'Debian'
this.versionLike = 'stretch'

} // Deepin 20
else if (this.versionId === 'n/a') {
this.distroId = 'Deepin'
@@ -173,13 +158,11 @@ class Distro implements IDistro {
/**
* DEVUAN
*/

} else if (this.versionId === 'beowulf') {
this.distroId = 'Devuan'
this.versionId = 'beowulf'
this.distroLike = 'Devuan'
this.versionLike = 'beowulf'

/**
* UBUNTU
@@ -202,9 +185,7 @@ class Distro implements IDistro {
this.distroLike = 'Ubuntu'
this.versionLike = 'bionic'
} else {
console.log(
"Sorry, this distro is not supported, I'll try Debian Buster mode!"
)
console.log("Sorry, this distro is not supported, I'll try Debian Buster mode!")
this.distroId = 'custom'
this.distroLike = 'Debian'
this.versionLike = 'buster'
@@ -213,14 +194,8 @@ class Distro implements IDistro {
/**
* Selezione il mountpoint per squashfs
*/
if (
this.versionLike === 'jessie' ||
this.versionLike === 'stretch' ||
this.versionLike === 'bionic' ||
this.versionLike === 'xenial'
) {
this.mountpointSquashFs =
'/lib/live/mount/medium/live/filesystem.squashfs'
if (this.versionLike === 'jessie' || this.versionLike === 'stretch' || this.versionLike === 'bionic' || this.versionLike === 'xenial') {
this.mountpointSquashFs = '/lib/live/mount/medium/live/filesystem.squashfs'
} else {
this.mountpointSquashFs = '/run/live/medium/live/filesystem.squashfs'
}


+ 55
- 243
src/classes/hatching.ts View File

@@ -48,10 +48,8 @@ export default class Hatching {
Utils.warning('hatching: questions')
}

const msg1 =
'\nThe process of installation will format your disk and destroy all datas on it.\n Did You are sure?\n'
const msg2 =
'\nWe need to be absolutely sure, did You saved your data before to proced?\n'
const msg1 = '\nThe process of installation will format your disk and destroy all datas on it.\n Did You are sure?\n'
const msg2 = '\nWe need to be absolutely sure, did You saved your data before to proced?\n'
const msg3 = '\nConfirm, again you want to continue?\n'

if (await Utils.customConfirm(msg1)) {
@@ -88,31 +86,11 @@ export default class Hatching {

Utils.titles(`install`)
Utils.warning('get options users')
console.log(
`- ` +
chalk.bgGreen.black(`username: `) +
chalk.bgGreen.whiteBright(users.username)
)
console.log(
`- ` +
chalk.bgGreen.black(`userfullname: `) +
chalk.bgGreen.whiteBright(users.userfullname)
)
console.log(
`- ` +
chalk.bgGreen.black(`user password: `) +
chalk.bgGreen.whiteBright(users.userpassword)
)
console.log(
`- ` +
chalk.bgGreen.black(`autologin: `) +
chalk.bgGreen.whiteBright(users.autologin)
)
console.log(
`- ` +
chalk.bgGreen.black(`root password: `) +
chalk.bgGreen.whiteBright(users.rootpassword)
)
console.log(`- ` + chalk.bgGreen.black(`username: `) + chalk.bgGreen.whiteBright(users.username))
console.log(`- ` + chalk.bgGreen.black(`userfullname: `) + chalk.bgGreen.whiteBright(users.userfullname))
console.log(`- ` + chalk.bgGreen.black(`user password: `) + chalk.bgGreen.whiteBright(users.userpassword))
console.log(`- ` + chalk.bgGreen.black(`autologin: `) + chalk.bgGreen.whiteBright(users.autologin))
console.log(`- ` + chalk.bgGreen.black(`root password: `) + chalk.bgGreen.whiteBright(users.rootpassword))
console.log()

const result = JSON.parse(await Utils.customConfirmAbort())
@@ -135,16 +113,8 @@ export default class Hatching {

Utils.titles(`install`)
Utils.warning('get options host')
console.log(
`- ` +
chalk.bgGreen.black(`hostname: `) +
chalk.bgGreen.whiteBright(host.hostname)
)
console.log(
`- ` +
chalk.bgGreen.black(`domain: `) +
chalk.bgGreen.whiteBright(host.domain)
)
console.log(`- ` + chalk.bgGreen.black(`hostname: `) + chalk.bgGreen.whiteBright(host.hostname))
console.log(`- ` + chalk.bgGreen.black(`domain: `) + chalk.bgGreen.whiteBright(host.domain))
console.log()

const result = JSON.parse(await Utils.customConfirmAbort())
@@ -167,31 +137,11 @@ export default class Hatching {

Utils.titles(`install`)
Utils.warning('get options net')
console.log(
`- ` +
chalk.bgGreen.black(`net Interface: `) +
chalk.bgGreen.whiteBright(net.netInterface)
)
console.log(
`- ` +
chalk.bgGreen.black(`net address type: `) +
chalk.bgGreen.whiteBright(net.netAddressType)
)
console.log(
`- ` +
chalk.bgGreen.black(`net address: `) +
chalk.bgGreen.whiteBright(net.netAddress)
)
console.log(
`- ` +
chalk.bgGreen.black(`net mask: `) +
chalk.bgGreen.whiteBright(net.netMask)
)
console.log(
`- ` +
chalk.bgGreen.black(`net gateway: `) +
chalk.bgGreen.whiteBright(net.netGateway)
)
console.log(`- ` + chalk.bgGreen.black(`net Interface: `) + chalk.bgGreen.whiteBright(net.netInterface))
console.log(`- ` + chalk.bgGreen.black(`net address type: `) + chalk.bgGreen.whiteBright(net.netAddressType))
console.log(`- ` + chalk.bgGreen.black(`net address: `) + chalk.bgGreen.whiteBright(net.netAddress))
console.log(`- ` + chalk.bgGreen.black(`net mask: `) + chalk.bgGreen.whiteBright(net.netMask))
console.log(`- ` + chalk.bgGreen.black(`net gateway: `) + chalk.bgGreen.whiteBright(net.netGateway))
console.log()
const result = JSON.parse(await Utils.customConfirmAbort())
if (result.confirm === 'Yes') {
@@ -215,28 +165,12 @@ export default class Hatching {
Utils.titles(`install`)
Utils.warning('get options disk and partition type')

const optionsDisk: any = await this.getOptionsDisk(
aDrives,
partitionTypes,
verbose
)
const optionsDisk: any = await this.getOptionsDisk(aDrives, partitionTypes, verbose)
disk = JSON.parse(optionsDisk)

console.log(
`- ` +
chalk.bgGreen.black(`installation device: `) +
chalk.bgGreen.whiteBright(disk.installationDevice)
)
console.log(
`- ` +
chalk.bgGreen.black(`partition type: `) +
chalk.bgGreen.whiteBright(disk.partionType)
)
console.log(
`- ` +
chalk.bgGreen.black(`fs type: `) +
chalk.bgGreen.whiteBright(disk.fsType)
)
console.log(`- ` + chalk.bgGreen.black(`installation device: `) + chalk.bgGreen.whiteBright(disk.installationDevice))
console.log(`- ` + chalk.bgGreen.black(`partition type: `) + chalk.bgGreen.whiteBright(disk.partionType))
console.log(`- ` + chalk.bgGreen.black(`fs type: `) + chalk.bgGreen.whiteBright(disk.fsType))
console.log()
const result = JSON.parse(await Utils.customConfirmAbort())
if (result.confirm === 'Yes') {
@@ -252,9 +186,7 @@ export default class Hatching {
*/
Utils.titles(`install`)
console.log()
console.log(
`You choose to install the system with the following parameters:`
)
console.log(`You choose to install the system with the following parameters:`)
console.log()
console.log(`- username: ` + chalk.cyanBright(users.username))
console.log(`- userfullname: ` + chalk.cyanBright(users.userfullname))
@@ -266,26 +198,17 @@ export default class Hatching {
console.log(`- domain: ` + chalk.cyanBright(host.domain))

console.log(`- net Interface: ` + chalk.cyanBright(net.netInterface))
console.log(
`- net address type: ` + chalk.cyanBright(net.netAddressType)
)
console.log(`- net address type: ` + chalk.cyanBright(net.netAddressType))
if (net.netAddressType !== 'dhcp') {
console.log(`- net address: ` + chalk.cyanBright(net.netAddress))
console.log(`- net mask: ` + chalk.cyanBright(net.netMask))
console.log(`- net gateway: ` + chalk.cyanBright(net.netGateway))
}
console.log(
`- installation device: ` +
chalk.cyanBright(disk.installationDevice)
)
console.log(`- installation device: ` + chalk.cyanBright(disk.installationDevice))
console.log(`- partition type: ` + chalk.cyanBright(disk.partionType))
console.log(`- fs type: ` + chalk.cyanBright(disk.fsType))
console.log()
console.log(
chalk.bgRed.white(
`This is the last opportunity to abort, the follow operation will destroy the data on the disk`
)
)
console.log(chalk.bgRed.white(`This is the last opportunity to abort, the follow operation will destroy the data on the disk`))
console.log()
const result = JSON.parse(await Utils.customConfirmAbort())
if (result.confirm === 'Yes') {
@@ -319,11 +242,7 @@ export default class Hatching {
}
}

const isDiskPrepared: boolean = await this.diskPartition(
disk.installationDevice,
disk.partionType,
verbose
)
const isDiskPrepared: boolean = await this.diskPartition(disk.installationDevice, disk.partionType, verbose)
if (isDiskPrepared) {
try {
await this.mkfs(verbose)
@@ -404,15 +323,7 @@ export default class Hatching {
}

try {
await this.addUser(
users.username,
users.userpassword,
users.fullName,
'',
'',
'',
verbose
)
await this.addUser(users.username, users.userpassword, users.fullName, '', '', '', verbose)
} catch (error) {
console.log(`addUser: ${error}`)
}
@@ -474,12 +385,7 @@ export default class Hatching {
}
const oldUser = Utils.getPrimaryUser()
if (Pacman.packageIsInstalled('lightdm')) {
shx.sed(
'-i',
`autologin-user=${oldUser}`,
`autologin-user=${newUser}`,
`${this.target}/etc/lightdm/lightdm.conf`
)
shx.sed('-i', `autologin-user=${oldUser}`, `autologin-user=${newUser}`, `${this.target}/etc/lightdm/lightdm.conf`)
}
}

@@ -492,15 +398,7 @@ export default class Hatching {
* @param workPhone
* @param homePhone
*/
async addUser(
username = 'live',
password = 'evolution',
fullName = '',
roomNumber = '',
workPhone = '',
homePhone = '',
verbose = false
): Promise <void> {
async addUser(username = 'live', password = 'evolution', fullName = '', roomNumber = '', workPhone = '', homePhone = '', verbose = false): Promise<void> {
const echo = Utils.setEcho(verbose)
if (verbose) {
Utils.warning('hatching: addUser')
@@ -515,10 +413,7 @@ adduser ${username} \

await exec(cmd, echo)

await exec(
`echo ${username}:${password} | chroot ${this.target} chpasswd `,
echo
)
await exec(`echo ${username}:${password} | chroot ${this.target} chpasswd `, echo)

await exec(`chroot ${this.target} usermod -aG sudo ${username}`, echo)
}
@@ -528,11 +423,7 @@ adduser ${username} \
* @param username
* @param newPassword
*/
async changePassword(
username = 'live',
newPassword = 'evolution',
verbose = false
) {
async changePassword(username = 'live', newPassword = 'evolution', verbose = false) {
const echo = Utils.setEcho(verbose)
if (verbose) {
Utils.warning('hatching: changePassword')
@@ -573,10 +464,7 @@ adduser ${username} \
} else {
await exec(`chroot ${this.target} apt install grub-pc --yes`)
}
await exec(
`chroot ${this.target} grub-install ${options.installationDevice}`,
echo
)
await exec(`chroot ${this.target} grub-install ${options.installationDevice}`, echo)
await exec(`chroot ${this.target} update-grub`, echo)
await exec('sleep 1', echo)
}
@@ -590,10 +478,7 @@ adduser ${username} \
Utils.warning('hatching: updateInitramfs')
}

await exec(
`chroot ${this.target} update-initramfs -u -k $(uname -r)`,
echo
)
await exec(`chroot ${this.target} update-initramfs -u -k $(uname -r)`, echo)
}

/**
@@ -688,34 +573,24 @@ adduser ${username} \
let text = ''

text += `# ${this.devices.root.name} ${this.devices.root.mountPoint} ${this.devices.root.fsType} ${mountOptsRoot}\n`
text += `UUID=${Utils.uuid(this.devices.root.name)} ${
this.devices.root.mountPoint
} ${this.devices.root.fsType} ${mountOptsRoot}\n`
text += `UUID=${Utils.uuid(this.devices.root.name)} ${this.devices.root.mountPoint} ${this.devices.root.fsType} ${mountOptsRoot}\n`

if (this.devices.boot.name !== `none`) {
text += `# ${this.devices.boot.name} ${this.devices.boot.mountPoint} ${this.devices.boot.fsType} ${mountOptsBoot}\n`
text += `UUID=${Utils.uuid(this.devices.boot.name)} ${
this.devices.boot.mountPoint
} ${this.devices.root.fsType} ${mountOptsBoot}\n`
text += `UUID=${Utils.uuid(this.devices.boot.name)} ${this.devices.boot.mountPoint} ${this.devices.root.fsType} ${mountOptsBoot}\n`
}

if (this.devices.data.name !== `none`) {
text += `# ${this.devices.data.name} ${this.devices.data.mountPoint} ${this.devices.data.fsType} ${mountOptsData}\n`
text += `UUID=${Utils.uuid(this.devices.data.name)} ${
this.devices.data.mountPoint
} ${this.devices.data.fsType} ${mountOptsData}\n`
text += `UUID=${Utils.uuid(this.devices.data.name)} ${this.devices.data.mountPoint} ${this.devices.data.fsType} ${mountOptsData}\n`
}

if (this.efi) {
text += `# ${this.devices.efi.name} ${this.devices.efi.mountPoint} vfat ${mountOptsEfi}\n`
text += `UUID=${Utils.uuid(this.devices.efi.name)} ${
this.devices.efi.mountPoint
} vfat ${mountOptsEfi}\n`
text += `UUID=${Utils.uuid(this.devices.efi.name)} ${this.devices.efi.mountPoint} vfat ${mountOptsEfi}\n`
}
text += `# ${this.devices.swap.name} ${this.devices.swap.mountPoint} ${this.devices.swap.fsType} ${mountOptsSwap}\n`
text += `UUID=${Utils.uuid(this.devices.swap.name)} ${
this.devices.swap.mountPoint
} ${this.devices.swap.fsType} ${mountOptsSwap}\n`
text += `UUID=${Utils.uuid(this.devices.swap.name)} ${this.devices.swap.mountPoint} ${this.devices.swap.fsType} ${mountOptsSwap}\n`
Utils.write(file, text)
}

@@ -909,29 +784,18 @@ adduser ${username} \
this.devices.boot.fsType = `ext2`
this.devices.boot.mountPoint = '/boot'
}
Utils.warning(
`Formatting ${this.devices.boot.name} as ${this.devices.boot.fsType}`
)
await exec(
`mkfs -t ${this.devices.boot.fsType} ${this.devices.boot.name}`,
echo
)
Utils.warning(`Formatting ${this.devices.boot.name} as ${this.devices.boot.fsType}`)
await exec(`mkfs -t ${this.devices.boot.fsType} ${this.devices.boot.name}`, echo)
}

if (this.devices.root.name !== 'none') {
Utils.warning(`Formatting ${this.devices.root.name}`)
await exec(
`mkfs -t ${this.devices.root.fsType} ${this.devices.root.name}`,
echo
)
await exec(`mkfs -t ${this.devices.root.fsType} ${this.devices.root.name}`, echo)
}

if (this.devices.data.name !== 'none') {
Utils.warning(`Formatting ${this.devices.data.name}`)
await exec(
`mkfs -t ${this.devices.data.fsType} ${this.devices.data.name}`,
echo
)
await exec(`mkfs -t ${this.devices.data.fsType} ${this.devices.data.name}`, echo)
}

if (this.devices.swap.name !== 'none') {
@@ -956,43 +820,28 @@ adduser ${username} \
}

// Monto la root
await exec(
`mount ${this.devices.root.name} ${this.target}${this.devices.root.mountPoint}`,
echo
)
await exec(`mount ${this.devices.root.name} ${this.target}${this.devices.root.mountPoint}`, echo)
await exec(`tune2fs -c 0 -i 0 ${this.devices.root.name}`, echo)
await exec(`rm -rf ${this.target}/lost+found`, echo)

// boot
if (this.devices.boot.name !== `none`) {
await exec(`mkdir ${this.target}/boot -p`)
await exec(
`mount ${this.devices.boot.name} ${this.target}${this.devices.boot.mountPoint}`,
echo
)
await exec(`mount ${this.devices.boot.name} ${this.target}${this.devices.boot.mountPoint}`, echo)
await exec(`tune2fs -c 0 -i 0 ${this.devices.boot.name}`, echo)
}

// data
if (this.devices.data.name !== `none`) {
await exec(`mkdir ${this.target}${this.devices.data.mountPoint} -p`)
await exec(
`mount ${this.devices.data.name} ${this.target}${this.devices.data.mountPoint}`,
echo
)
await exec(`mount ${this.devices.data.name} ${this.target}${this.devices.data.mountPoint}`, echo)
await exec(`tune2fs -c 0 -i 0 ${this.devices.data.name}`, echo)
}

if (this.efi) {
if (!fs.existsSync(this.target + this.devices.efi.mountPoint)) {
await exec(
`mkdir ${this.target}${this.devices.efi.mountPoint} -p`,
echo
)
await exec(
`mount ${this.devices.efi.name} ${this.target}${this.devices.efi.mountPoint}`,
echo
)
await exec(`mkdir ${this.target}${this.devices.efi.mountPoint} -p`, echo)
await exec(`mount ${this.devices.efi.name} ${this.target}${this.devices.efi.mountPoint}`, echo)
}
}
return true
@@ -1033,11 +882,7 @@ adduser ${username} \
* @param partitionType
* @param verbose
*/
async diskPartition(
device: string,
partitionType: string,
verbose = false
): Promise<boolean> {
async diskPartition(device: string, partitionType: string, verbose = false): Promise<boolean> {
let retVal = false
const echo = Utils.setEcho(verbose)
if (verbose) {
@@ -1045,10 +890,7 @@ adduser ${username} \
}

if (partitionType === 'simple' && this.efi) {
await exec(
`parted --script ${device} mklabel gpt mkpart primary 0% 1% mkpart primary 1% 95% mkpart primary 95% 100%`,
echo
)
await exec(`parted --script ${device} mklabel gpt mkpart primary 0% 1% mkpart primary 1% 95% mkpart primary 95% 100%`, echo)
await exec(`parted --script ${device} set 1 boot on`, echo)
await exec(`parted --script ${device} set 1 esp on`, echo)

@@ -1070,15 +912,9 @@ adduser ${username} \
retVal = true
} else if (partitionType === 'simple' && !this.efi) {
await exec(`parted --script ${device} mklabel msdos`, echo)
await exec(
`parted --script --align optimal ${device} mkpart primary 1MiB 95%`,
echo
)
await exec(`parted --script --align optimal ${device} mkpart primary 1MiB 95%`, echo)
await exec(`parted --script ${device} set 1 boot on`, echo)
await exec(
`parted --script --align optimal ${device} mkpart primary 95% 100%`,
echo
)
await exec(`parted --script --align optimal ${device} mkpart primary 95% 100%`, echo)

this.devices.efi.name = `none`

@@ -1104,22 +940,12 @@ adduser ${username} \
// Creo partizioni
await exec(`parted --script ${device} mkpart primary ext2 1 512`)
await exec(`parted --script --align optimal ${device} set 1 boot on`)
await exec(
`parted --script --align optimal ${device} mkpart primary ext2 512 100%`
)
await exec(`parted --script --align optimal ${device} mkpart primary ext2 512 100%`)
await exec(`parted --script ${device} set 2 lvm on`)

// Partizione LVM
const lvmPartname = shx
.exec(`fdisk $1 -l | grep 8e | awk '{print $1}' | cut -d "/" -f3`)
.stdout.trim()
const lvmByteSize = Number(
shx
.exec(
`cat /proc/partitions | grep ${lvmPartname}| awk '{print $3}' | grep "[0-9]"`
)
.stdout.trim()
)
const lvmPartname = shx.exec(`fdisk $1 -l | grep 8e | awk '{print $1}' | cut -d "/" -f3`).stdout.trim()
const lvmByteSize = Number(shx.exec(`cat /proc/partitions | grep ${lvmPartname}| awk '{print $3}' | grep "[0-9]"`).stdout.trim())
const lvmSize = lvmByteSize / 1024

// La partizione di root viene posta ad 1/4 della partizione LVM.
@@ -1191,9 +1017,7 @@ adduser ${username} \
let response: any
let retVal = false

response = shx
.exec(`cat /sys/block/${device}/queue/rotational`, { silent: verbose })
.stdout.trim()
response = shx.exec(`cat /sys/block/${device}/queue/rotational`, { silent: verbose }).stdout.trim()
if (response === '1') {
retVal = true
}
@@ -1376,11 +1200,7 @@ adduser ${username} \
* @param partitionTypes
* @param verbose
*/
async getOptionsDisk(
driveList: string[],
partitionTypes: string[],
verbose = false
): Promise<any> {
async getOptionsDisk(driveList: string[], partitionTypes: string[], verbose = false): Promise<any> {
const echo = Utils.setEcho(verbose)
if (verbose) {
Utils.warning('hatching: getOptions')
@@ -1421,19 +1241,11 @@ adduser ${username} \
finished(installationDevice: string, hostname: string, username: string) {
Utils.titles()
Utils.warning(`installation is finished.`)
console.log(
'Your system was installed on ' +
chalk.cyanBright(installationDevice) +
'.'
)
console.log('Your system was installed on ' + chalk.cyanBright(installationDevice) + '.')
console.log('Host name was set as ' + chalk.cyanBright(hostname) + '.')
console.log('The user name is ' + chalk.cyanBright(username) + '.')
console.log('Enjoy Your new penguin!')
console.log(
`Note: it is recommended to run the command ` +
chalk.cyanBright(`sudo update-initramfs -u`) +
` after next reboot.`
)
console.log(`Note: it is recommended to run the command ` + chalk.cyanBright(`sudo update-initramfs -u`) + ` after next reboot.`)
console.log('Press any key to exit')
require('child_process').spawnSync('read _ ', {
shell: true,


+ 495
- 466
src/classes/incubation/beowulf.ts View File

@@ -12,483 +12,512 @@ import { IRemix, IDistro } from '../../interfaces'
const exec = require('../../lib/utils').exec

/**
*
*
*/
export class Beowulf {
verbose = false

remix: IRemix

distro: IDistro
verbose = false

displaymanager = false
remix: IRemix

user_opt: string
distro: IDistro

dirGlobalModules = '/usr/lib/x86_64-linux-gnu/calamares/modules/'
displaymanager = false

user_opt: string

/**
* @param remix
* @param distro
* @param displaymanager
* @param verbose
*/
constructor(remix: IRemix, distro: IDistro, displaymanager: boolean, user_opt: string, verbose = false) {
this.remix = remix
this.distro = distro
this.user_opt = user_opt
this.verbose = verbose
this.displaymanager = displaymanager
if (process.arch === 'ia32') {
this.dirGlobalModules = '/usr/lib/calamares/modules/'
}
dirGlobalModules = '/usr/lib/x86_64-linux-gnu/calamares/modules/'

}
/**
* @param remix
* @param distro
* @param displaymanager
* @param verbose
*/
constructor(remix: IRemix, distro: IDistro, displaymanager: boolean, user_opt: string, verbose = false) {
this.remix = remix
this.distro = distro
this.user_opt = user_opt
this.verbose = verbose
this.displaymanager = displaymanager
if (process.arch === 'ia32') {
this.dirGlobalModules = '/usr/lib/calamares/modules/'
}
}

/**
* write setting
*/
settings() {
const dir = '/etc/calamares/'
const file = dir + 'settings.conf'
write(file, this.getSettings(), this.verbose)
}

/**
*
*/
private getSettings(): string {
// path di ricerca dei moduli
const modulesSearch = ['local', '/usr/lib/calamares/modules']

// moduli da mostrare a video
const show = ['welcome', 'locale', 'keyboard', 'partition', 'users', 'summary']

// moduli da eseguire
let exec: string[] = []
exec.push('partition')
exec.push('mount')
exec.push('unpackfs')
exec.push('sources-trusted')
//exec.push('machineid')
exec.push('fstab')
exec.push('locale')
exec.push('keyboard')
exec.push('localecfg')
exec.push('users')
if (this.displaymanager) {
exec.push('displaymanager')
}
exec.push('networkcfg')
exec.push('hwclock')
exec.push('services-systemd')
exec.push('create-tmp')
exec.push('bootloader-config')
exec.push('grubcfg')
exec.push('bootloader')
exec.push('luksbootkeyfile')
exec.push('plymouthcfg')
exec.push('initramfscfg')
exec.push('initramfs')
exec.push('removeuser')
exec.push('sources-trusted-unmount')
exec.push('sources-final')
exec.push('umount')

const settings = {
'modules-search': modulesSearch,
sequence: [{ show: show }, { exec: exec }, { show: ['finished'] }],
branding: this.remix.branding,
'prompt-install': false,
'dont-chroot': false
}
let title = `# calamares settings, id: ${this.distro.distroId}/${this.distro.versionId} like: ${this.distro.distroLike}/${this.distro.versionLike}\n`
return title + yaml.safeDump(settings)
}

/**
*
*/
modules() {
this.modulePartition()
this.moduleMount()
this.moduleUnpackfs()
this.moduleSourcesTrusted()
//this.moduleMachineid()
this.moduleFstab()
this.moduleLocale()
this.moduleKeyboard()
this.moduleLocalecfg()
this.moduleUsers()
if (this.displaymanager) {
this.moduleDisplaymanager()
}
this.moduleNetworkcfg()
this.moduleHwclock()
this.moduleServicesSystemd()
this.moduleCreateTmp()
this.moduleBootloaderConfig()
this.moduleGrubcfg()
this.moduleBootloader()
this.modulePackages()
this.moduleLuksbootkeyfile()
this.moduleLuksopenswaphookcfg()
this.modulePlymouthcfg()
this.moduleInitramfscfg()
this.moduleInitramfs()
this.moduleRemoveuser()
this.moduleSourcesTrustedUnmount()
this.moduleSourcesFinal()
this.moduleUmount()
}

/**
* ========================================================================
* module = name + '.conf'
* shellprocess = 'shellprocess_' + name + '.conf'
* contextualprocess = name + '_context.conf'
*
* module_calamares
* dir = '/usr/lib/calamares/modules/' + name
* name = module.desc
* script =
* ========================================================================
*/

/**
* write setting
*/
public settings() {
const dir = '/etc/calamares/'
const file = dir + 'settings.conf'
write(file, this.getSettings(), this.verbose)
}
/**
* write module
* @param name
* @param content
*/
private module(name: string, content: string) {
const dir = `/etc/calamares/modules/`
const file = dir + name + '.conf'
write(file, content, this.verbose)
}

/**
* write shellprocess
* @param name
*/
private shellprocess(name: string) {
let content = ''
const dir = `/etc/calamares/modules/`
let file = dir + 'shellprocess_' + name + '.conf'
write(file, content, this.verbose)
}

/**
* write contextualprocess
* @param process
*/
private contextualprocess(name: string) {
let content = ''
const dir = `/etc/calamares/modules/`
let file = dir + name + '_context' + '.conf'
write(file, content, this.verbose)
}

/**
* ====================================================================================
* M O D U L E S
* ====================================================================================
*/

/**
*
/**
*
*/
getSettings(): string {
// path di ricerca dei moduli
const modulesSearch = ['local', '/usr/lib/calamares/modules']

// moduli da mostrare a video
const show = ['welcome', 'locale', 'keyboard', 'partition', 'users', 'summary']

// moduli da eseguire
let exec: string[] = []
exec.push('partition')
exec.push('mount')
exec.push('unpackfs')
exec.push('sources-trusted')
//exec.push('machineid')
exec.push('fstab')
exec.push('locale')
exec.push('keyboard')
exec.push('localecfg')
exec.push('users')
if (this.displaymanager) {
exec.push('displaymanager')
}
exec.push('networkcfg')
exec.push('hwclock')
exec.push('services-systemd')
exec.push('create-tmp')
exec.push('bootloader-config')
exec.push('grubcfg')
exec.push('bootloader')
exec.push('luksbootkeyfile')
exec.push('plymouthcfg')
exec.push('initramfscfg')
exec.push('initramfs')
exec.push('removeuser')
exec.push('sources-trusted-unmount')
exec.push('sources-final')
exec.push('umount')

const settings = {
'modules-search': modulesSearch,
sequence: [{ show: show }, { exec: exec }, { show: ['finished'] }],
branding: this.remix.branding,
'prompt-install': false,
'dont-chroot': false
}
let title = `# calamares settings, id: ${this.distro.distroId}/${this.distro.versionId} like: ${this.distro.distroLike}/${this.distro.versionLike}\n`
return title + yaml.safeDump(settings)
}

/**
*
private modulePartition() {
if (this.verbose) {
console.log(`calamares: module partition. Nothing to do!`)
}
}

/**
*
*/
public modules() {
this.modulePartition()
this.moduleMount()
this.moduleUnpackfs()
this.moduleSourcesTrusted()
//this.moduleMachineid()
this.moduleFstab()
this.moduleLocale()
this.moduleKeyboard()
this.moduleLocalecfg()
this.moduleUsers()
if (this.displaymanager) {
this.moduleDisplaymanager()
}
this.moduleNetworkcfg()
this.moduleHwclock()
this.moduleServicesSystemd()
this.moduleCreateTmp()
this.moduleBootloaderConfig()
this.moduleGrubcfg()
this.moduleBootloader()
this.modulePackages()
this.moduleLuksbootkeyfile()
this.moduleLuksopenswaphookcfg()
this.modulePlymouthcfg()
this.moduleInitramfscfg()
this.moduleInitramfs()
this.moduleRemoveuser()
this.moduleSourcesTrustedUnmount()
this.moduleSourcesFinal()
this.moduleUmount()
}


/**
* ========================================================================
* module = name + '.conf'
* shellprocess = 'shellprocess_' + name + '.conf'
* contextualprocess = name + '_context.conf'
*
* module_calamares
* dir = '/usr/lib/calamares/modules/' + name
* name = module.desc
* script =
* ========================================================================
*/

/**
* write module
* @param name
* @param content
*/
module(name: string, content: string) {
const dir = `/etc/calamares/modules/`
const file = dir + name + '.conf'
write(file, content, this.verbose)
}

/**
* write shellprocess
* @param name
*/
shellprocess(name: string) {
let content = ''
const dir = `/etc/calamares/modules/`
let file = dir + 'shellprocess_' + name + '.conf'
write(file, content, this.verbose)
}

/**
* write contextualprocess
* @param process
*/
contextualprocess(name: string) {
let content = ''
const dir = `/etc/calamares/modules/`
let file = dir + name + '_context' + '.conf'
write(file, content, this.verbose)
}


/**
* ====================================================================================
* M O D U L E S
* ====================================================================================
*/

/**
*
*/
modulePartition() {
if (this.verbose) {
console.log(`calamares: module partition. Nothing to do!`)
}
}

/**
*
*/
moduleMount() {
const mount = yaml.safeDump({
extraMounts: [{
device: "proc",
fs: "proc",
mountPoint: "/proc"
}, {
device: "sys",
fs: "sysfs",
mountPoint: "/sys"
}, {
device: "/dev",
mountPoint: "/dev",
options: "bind"
}, {
device: "/dev/pts",
fs: "devpts",
mountPoint: "/dev/pts"
}, {
device: "tmpfs",
fs: "tmpfs",
mountPoint: "/run"
}, {
device: "/run/udev",
mountPoint: "/run/udev",
options: "bind"
}],
extraMountsEfi: [{
device: "efivarfs",
fs: "tmpefivarfsfs",
mountPoint: "/sys/firmware/efi/efivars"
}]
})

this.module('mount', mount)
}

/**
*
*/
moduleUnpackfs() {
const unpack = yaml.safeDump({
unpack: [{
source: this.distro.mountpointSquashFs,
sourcefs: "squashfs",
destination: ""
}]
})
this.module('unpackfs', unpack)
}

/**
*
*/
moduleMachineid() {
const machineid = yaml.safeDump({
systemd: true,
dbus: true,
symlink: true
})
this.module('machineid', machineid)
}

/**
*
*/
moduleFstab() {
const fstab = yaml.safeDump({
mountOptions: {
default: "defaults,noatime",
btrfs: "defaults,noatime,space_cache,autodefrag"
private moduleMount() {
const mount = yaml.safeDump({
extraMounts: [
{
device: 'proc',
fs: 'proc',
mountPoint: '/proc'
},
{
device: 'sys',
fs: 'sysfs',
mountPoint: '/sys'
},
{
device: '/dev',
mountPoint: '/dev',
options: 'bind'
},
{
device: '/dev/pts',
fs: 'devpts',
mountPoint: '/dev/pts'
},
ssdExtraMountOptions: {
ext4: "discard",
jfs: "discard",
xfs: "discard",
swap: "discard",
btrfs: "discard,compress=lzo"
{
device: 'tmpfs',
fs: 'tmpfs',
mountPoint: '/run'
},
crypttabOptions: "luks,keyscript=/bin/cat"
})

this.module('fstab', fstab)
}

moduleLocale() { if (this.verbose) console.log(`calamares: module locale. Nothing to do!`) }

moduleKeyboard() { if (this.verbose) console.log(`calamares: module keyboard. Nothing to do!`) }

moduleLocalecfg() { if (this.verbose) console.log(`calamares: module localecfg. Nothing to do!`) }


/**
*
*/
moduleUsers() {
const users = yaml.safeDump({
userGroup: "users",
defaultGroups: [
"cdrom", "floppy", "sudo", "audio", "dip", "video", "plugdev", "netdev", "lpadmin", "scanner", "bluetooth"
],
autologinGroup: "autologin",
sudoersGroup: "sudo",
setRootPassword: false
})
this.module('users', users)
}

/**
*
*/
moduleDisplaymanager() {
const displaymanager = require('./modules/displaymanager').displaymanager
this.module('displaymanager', displaymanager())
}

moduleNetworkcfg() { if (this.verbose) console.log(`calamares: module networkcfg. Nothing to do!`) }

moduleHwclock() { if (this.verbose) console.log(`calamares: module hwclock. Nothing to do!`) }

moduleServicesSystemd() { if (this.verbose) console.log(`calamares: module servives-systemd. Nothing to do!`) }

moduleGrubcfg() { if (this.verbose) console.log(`calamares: module grubcfg. Nothing to do!`) }

/**
*
*/
moduleBootloader() {
const bootloader = yaml.safeDump({
efiBootLoader: "grub",
kernel: "/vmlinuz-linux",
img: "/initramfs-linux.img",
fallback: "/initramfs-linux-fallback.img",
timeout: 10,
grubInstall: "grub-install",
grubMkconfig: "grub-mkconfig",
grubCfg: "/boot/grub/grub.cfg",
grubProbe: "grub-probe",
efiBootMgr: "efibootmgr",
installEFIFallback: false
})
this.module('bootloader', bootloader)
}

/**
* create module packages.conf
*/
modulePackages() {
const packages = require('./modules/packages').packages
this.module('packages', packages())
}

/**
*
*/
moduleLuksbootkeyfile() { if (this.verbose) console.log(`calamares: module luksbootkeyfile. Nothing to do!`) }
/**
*
*/
moduleLuksopenswaphookcfg() {
const lksopenswaphookcfg = yaml.safeDump({
configFilePath: "/etc/openswap.conf"
})
this.module('lksopenswaphookcfg', lksopenswaphookcfg)
}

modulePlymouthcfg() { if (this.verbose) console.log(`calamares: module plymouthcfg. Nothing to do!`) }

moduleInitramfscfg() { if (this.verbose) console.log(`calamares: module initramfscfg. Nothing to do!`) }

/**
*
*/
moduleRemoveuser() {
const removeuser = yaml.safeDump({ username: this.user_opt })
this.module('removeuser', removeuser)
}

moduleInitramfs() { if (this.verbose) console.log(`calamares: module initramfs. Nothing to do!`) }

moduleUmount() { if (this.verbose) console.log(`calamares: module unmount. Nothing to do!`) }

/**
* ====================================================================================
* M O D U L E S C A L A M A R E S
* ====================================================================================
*/

/**
*
*/
async moduleSourcesTrusted() {
const name = 'sources-trusted'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descSourcesTrusted = require(`./calamares-modules/desc/${name}`).sourcesTrusted
write(dir + 'module.desc', descSourcesTrusted(), this.verbose)

const bashSourcesTrusted = require(`./calamares-modules/scripts/${name}`).sourcesTrusted
const bashFile = `/usr/sbin/${name}`
write(bashFile, bashSourcesTrusted(), this.verbose)
await exec(`chmod +x ${bashFile}`)
}

/**
*
*/
async moduleCreateTmp() {
const name = 'create-tmp'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descCreateTmp = require(`./calamares-modules/desc/${name}`).createTmp
write(dir + 'module.desc', descCreateTmp(), this.verbose)

const bashCreateTmp = require(`./calamares-modules/scripts/${name}`).createTmp
const scriptFile = `/usr/sbin/${name}`
write(scriptFile, bashCreateTmp(), this.verbose)
await exec(`chmod +x ${scriptFile}`)
}

/**
*
*/
async moduleBootloaderConfig() {
const name = 'bootloader-config'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descBootloaderConfig = require('./calamares-modules/desc/bootloader-config').bootloaderConfig
write(dir + 'module.desc', descBootloaderConfig(), this.verbose)

const bashBootloaderConfig = require(`./calamares-modules/scripts/${name}`).bootloaderConfig
const scriptFile = `/usr/sbin/${name}`
write(scriptFile, bashBootloaderConfig(), this.verbose)
await exec(`chmod +x ${scriptFile}`)
}

/**
*
*/
moduleSourcesTrustedUnmount() {
const name = 'sources-trusted-unmount'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descSourcesTrustedUnmount = require(`./calamares-modules/desc/${name}`).sourcesTrustedUnmount
write(dir + 'module.desc', descSourcesTrustedUnmount(), this.verbose)

if (this.verbose) { console.log(`calamares: module ${name} use the same script of source-trusted`) }
}

/**
*
*/
async moduleSourcesFinal() {
const name = 'sources-final'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descSourcesFinal = require(`./calamares-modules/desc/${name}`).sourcesFinal
write(dir + 'module.desc', descSourcesFinal(), this.verbose)

const bashSourcesFinal = require(`./calamares-modules/scripts/${name}`).sourcesFinal
const bashFile = `/usr/sbin/${name}`
write(bashFile, bashSourcesFinal(), this.verbose)
await exec(`chmod +x ${bashFile}`)
}
{
device: '/run/udev',
mountPoint: '/run/udev',
options: 'bind'
}
],
extraMountsEfi: [
{
device: 'efivarfs',
fs: 'tmpefivarfsfs',
mountPoint: '/sys/firmware/efi/efivars'
}
]
})

this.module('mount', mount)
}

/**
*
*/
private moduleUnpackfs() {
const unpack = yaml.safeDump({
unpack: [
{
source: this.distro.mountpointSquashFs,
sourcefs: 'squashfs',
destination: ''
}
]
})
this.module('unpackfs', unpack)
}

/**
*
*/
private moduleMachineid() {
const machineid = yaml.safeDump({
systemd: true,
dbus: true,
symlink: true
})
this.module('machineid', machineid)
}

/**
*
*/
private moduleFstab() {
const fstab = yaml.safeDump({
mountOptions: {
default: 'defaults,noatime',
btrfs: 'defaults,noatime,space_cache,autodefrag'
},
ssdExtraMountOptions: {
ext4: 'discard',
jfs: 'discard',
xfs: 'discard',
swap: 'discard',
btrfs: 'discard,compress=lzo'
},
crypttabOptions: 'luks,keyscript=/bin/cat'
})

this.module('fstab', fstab)
}

private moduleLocale() {
if (this.verbose) console.log(`calamares: module locale. Nothing to do!`)
}

private moduleKeyboard() {
if (this.verbose) console.log(`calamares: module keyboard. Nothing to do!`)
}

private moduleLocalecfg() {
if (this.verbose) console.log(`calamares: module localecfg. Nothing to do!`)
}

/**
*
*/
private moduleUsers() {
const users = yaml.safeDump({
userGroup: 'users',
defaultGroups: ['cdrom', 'floppy', 'sudo', 'audio', 'dip', 'video', 'plugdev', 'netdev', 'lpadmin', 'scanner', 'bluetooth'],
autologinGroup: 'autologin',
sudoersGroup: 'sudo',
setRootPassword: false
})
this.module('users', users)
}

/**
*
*/
private moduleDisplaymanager() {
const displaymanager = require('./modules/displaymanager').displaymanager
this.module('displaymanager', displaymanager())
}

private moduleNetworkcfg() {
if (this.verbose) console.log(`calamares: module networkcfg. Nothing to do!`)
}

private moduleHwclock() {
if (this.verbose) console.log(`calamares: module hwclock. Nothing to do!`)
}

private moduleServicesSystemd() {
if (this.verbose) console.log(`calamares: module servives-systemd. Nothing to do!`)
}

private moduleGrubcfg() {
if (this.verbose) console.log(`calamares: module grubcfg. Nothing to do!`)
}

/**
*
*/
private moduleBootloader() {
const bootloader = yaml.safeDump({
efiBootLoader: 'grub',
kernel: '/vmlinuz-linux',
img: '/initramfs-linux.img',
fallback: '/initramfs-linux-fallback.img',
timeout: 10,
grubInstall: 'grub-install',
grubMkconfig: 'grub-mkconfig',
grubCfg: '/boot/grub/grub.cfg',
grubProbe: 'grub-probe',
efiBootMgr: 'efibootmgr',
installEFIFallback: false
})
this.module('bootloader', bootloader)
}

/**
* create module packages.conf
*/
private modulePackages() {
const packages = require('./modules/packages').packages
this.module('packages', packages())
}

/**
*
*/
private moduleLuksbootkeyfile() {
if (this.verbose) console.log(`calamares: module luksbootkeyfile. Nothing to do!`)
}
/**
*
*/
private moduleLuksopenswaphookcfg() {
const lksopenswaphookcfg = yaml.safeDump({
configFilePath: '/etc/openswap.conf'
})
this.module('lksopenswaphookcfg', lksopenswaphookcfg)
}

private modulePlymouthcfg() {
if (this.verbose) console.log(`calamares: module plymouthcfg. Nothing to do!`)
}

private moduleInitramfscfg() {
if (this.verbose) console.log(`calamares: module initramfscfg. Nothing to do!`)
}

/**
*
*/
private moduleRemoveuser() {
const removeuser = yaml.safeDump({ username: this.user_opt })
this.module('removeuser', removeuser)
}

private moduleInitramfs() {
if (this.verbose) console.log(`calamares: module initramfs. Nothing to do!`)
}

private moduleUmount() {
if (this.verbose) console.log(`calamares: module unmount. Nothing to do!`)
}

/**
* ====================================================================================
* M O D U L E S C A L A M A R E S
* ====================================================================================
*/

/**
*
*/
private async moduleSourcesTrusted() {
const name = 'sources-trusted'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descSourcesTrusted = require(`./calamares-modules/desc/${name}`).sourcesTrusted
write(dir + 'module.desc', descSourcesTrusted(), this.verbose)

const bashSourcesTrusted = require(`./calamares-modules/scripts/${name}`).sourcesTrusted
const bashFile = `/usr/sbin/${name}`
write(bashFile, bashSourcesTrusted(), this.verbose)
await exec(`chmod +x ${bashFile}`)
}

/**
*
*/
private async moduleCreateTmp() {
const name = 'create-tmp'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descCreateTmp = require(`./calamares-modules/desc/${name}`).createTmp
write(dir + 'module.desc', descCreateTmp(), this.verbose)

const bashCreateTmp = require(`./calamares-modules/scripts/${name}`).createTmp
const scriptFile = `/usr/sbin/${name}`
write(scriptFile, bashCreateTmp(), this.verbose)
await exec(`chmod +x ${scriptFile}`)
}

/**
*
*/
private async moduleBootloaderConfig() {
const name = 'bootloader-config'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descBootloaderConfig = require('./calamares-modules/desc/bootloader-config').bootloaderConfig
write(dir + 'module.desc', descBootloaderConfig(), this.verbose)

const bashBootloaderConfig = require(`./calamares-modules/scripts/${name}`).bootloaderConfig
const scriptFile = `/usr/sbin/${name}`
write(scriptFile, bashBootloaderConfig(), this.verbose)
await exec(`chmod +x ${scriptFile}`)
}

/**
*
*/
private moduleSourcesTrustedUnmount() {
const name = 'sources-trusted-unmount'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descSourcesTrustedUnmount = require(`./calamares-modules/desc/${name}`).sourcesTrustedUnmount
write(dir + 'module.desc', descSourcesTrustedUnmount(), this.verbose)

if (this.verbose) {
console.log(`calamares: module ${name} use the same script of source-trusted`)
}
}

/**
*
*/
private async moduleSourcesFinal() {
const name = 'sources-final'
const dir = this.dirGlobalModules + name + `/`
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir)
}

const descSourcesFinal = require(`./calamares-modules/desc/${name}`).sourcesFinal
write(dir + 'module.desc', descSourcesFinal(), this.verbose)

const bashSourcesFinal = require(`./calamares-modules/scripts/${name}`).sourcesFinal
const bashFile = `/usr/sbin/${name}`
write(bashFile, bashSourcesFinal(), this.verbose)
await exec(`chmod +x ${bashFile}`)
}
}

/**
@@ -498,8 +527,8 @@ export class Beowulf {
* @param verbose
*/
function write(file: string, content: string, verbose = false) {
if (verbose) {
console.log(`calamares: create ${file}`)
}
fs.writeFileSync(file, content, 'utf8')
if (verbose) {
console.log(`calamares: create ${file}`)
}
fs.writeFileSync(file, content, 'utf8')
}

+ 602
- 579
src/classes/incubation/bionic.ts
File diff suppressed because it is too large
View File


+ 1
- 9
src/classes/incubation/branding.ts View File

@@ -14,12 +14,7 @@ import Ovary from '../ovary'
* @param oses
* @param verbose
*/
export function branding(
remix: IRemix,
distro: IDistro,
brand = '',
verbose = false
): string {
export function branding(remix: IRemix, distro: IDistro, brand = '', verbose = false): string {
const versionLike: string = distro.versionLike
const homeUrl: string = distro.homeUrl
const supportUrl: string = distro.supportUrl
@@ -70,6 +65,3 @@ export function branding(
//console.log(branding)
return yaml.safeDump(branding)
}




+ 503
- 473
src/classes/incubation/buster.ts View File

@@ -11,481 +11,511 @@ import { IRemix, IDistro } from '../../interfaces'
const exec = require('../../lib/utils').exec

/**
*
*
*/
export class Buster {
verbose = false

remix: IRemix

distro: IDistro

displaymanager = false

user_opt: string

dirGlobalModules = '/usr/lib/x86_64-linux-gnu/calamares/modules/'


/**
* @param remix
* @param distro
* @param displaymanager
* @param verbose
*/
constructor(remix: IRemix, distro: IDistro, displaymanager: boolean, user_opt: string, verbose = false) {
this.remix = remix
this.distro = distro
this.user_opt = user_opt
this.verbose = verbose
this.displaymanager = displaymanager
if (process.arch === 'ia32') {
this.dirGlobalModules = '/usr/lib/calamares/modules/'
}
}

/**
* write setting
*/
public settings() {
const dir = '/etc/calamares/'
const file = dir + 'settings.conf'
write(file, this.getSettings(), this.verbose)
}

/**
*
verbose = false

remix: IRemix

distro: IDistro

displaymanager = false

user_opt: string

dirGlobalModules = '/usr/lib/x86_64-linux-gnu/calamares/modules/'

/**
* @param remix
* @param distro
* @param displaymanager
* @param verbose
*/
constructor(remix: IRemix, distro: IDistro, displaymanager: boolean, user_opt: string, verbose = false) {
this.remix = remix
this.distro = distro
this.user_opt = user_opt
this.verbose = verbose
this.displaymanager = displaymanager
if (process.arch === 'ia32') {
this.dirGlobalModules = '/usr/lib/calamares/modules/'
}
}

/**
* write setting
*/
settings() {
const dir = '/etc/calamares/'
const file = dir + 'settings.conf'
write(file, this.getSettings(), this.verbose)
}

/**
*
*/
private getSettings(): string {
// path di ricerca dei moduli
const modulesSearch = ['local', '/usr/lib/calamares/modules']

// moduli da mostrare a video
const show = ['welcome', 'locale', 'keyboard', 'partition', 'users', 'summary']

// moduli da eseguire
let exec: string[] = []
exec.push('partition')
exec.push('mount')
exec.push('unpackfs')
exec.push('sources-trusted')
exec.push('machineid')
exec.push('fstab')
exec.push('locale')
exec.push('keyboard')
exec.push('localecfg')
exec.push('users')
if (this.displaymanager) {
exec.push('displaymanager')
}
exec.push('networkcfg')
exec.push('hwclock')
exec.push('services-systemd')
exec.push('create-tmp')
exec.push('bootloader-config')
exec.push('grubcfg')
exec.push('bootloader')
exec.push('luksbootkeyfile')
exec.push('plymouthcfg')
exec.push('initramfscfg')
exec.push('initramfs')
exec.push('removeuser')
exec.push('sources-trusted-unmount')
exec.push('sources-final')
exec.push('umount')

const settings = {
'modules-search': modulesSearch,
sequence: [{ show: show }, { exec: exec }, { show: ['finished'] }],
branding: this.remix.branding,
'prompt-install': false,
'dont-chroot': false
}
return yaml.safeDump(settings)
}

/**
*
*/
async modules() {
this.modulePartition()
this.moduleMount()
this.moduleUnpackfs()
this.moduleSourcesTrusted()
this.moduleMachineid()
this.moduleFstab()
this.moduleLocale()
this.moduleKeyboard()
this.moduleLocalecfg()
this.moduleUsers()
if (this.displaymanager) {
this.moduleDisplaymanager()
}
this.moduleNetworkcfg()
this.moduleHwclock()
this.moduleServicesSystemd()
this.moduleCreateTmp()
this.moduleBootloaderConfig()
this.moduleGrubcfg()
this.moduleBootloader()
this.modulePackages()
this.moduleLuksbootkeyfile()
this.moduleLuksopenswaphookcfg()
this.modulePlymouthcfg()
this.moduleInitramfscfg()
this.moduleInitramfs()
this.moduleRemoveuser()
this.moduleSourcesTrustedUnmount()
this.moduleSourcesFinal()
this.moduleUmount()
}

/**
* ========================================================================
* module = name + '.conf0
* shellprocess = 'shellprocess_' + name + '.conf'
* contextualprocess = name + '_context.conf'
*
* module_calamares
* dir = '/usr/lib/calamares/modules/' + name
* name = module.desc
* script =
* ========================================================================
*/
getSettings(): string {
// path di ricerca dei moduli
const modulesSearch = ['local', '/usr/lib/calamares/modules']

// moduli da mostrare a video
const show = ['welcome', 'locale', 'keyboard', 'partition', 'users', 'summary']

// moduli da eseguire
let exec: string[] = []
exec.push('partition')
exec.push('mount')
exec.push('unpackfs')
exec.push('sources-trusted')
exec.push('machineid')
exec.push('fstab')
exec.push('locale')
exec.push('keyboard')
exec.push('localecfg')
exec.push('users')
if (this.displaymanager) {
exec.push('displaymanager')
}
exec.push('networkcfg')
exec.push('hwclock')
exec.push('services-systemd')
exec.push('create-tmp')
exec.push('bootloader-config')
exec.push('grubcfg')
exec.push('bootloader')
exec.push('luksbootkeyfile')
exec.push('plymouthcfg')
exec.push('initramfscfg')
exec.push('initramfs')
exec.push('removeuser')
exec.push('sources-trusted-unmount')
exec.push('sources-final')
exec.push('umount')

const settings = {
'modules-search': modulesSearch,
sequence: [{ show: show }, { exec: exec }, { show: ['finished'] }],
branding: this.remix.branding,
'prompt-install': false,
'dont-chroot': false
}
return yaml.safeDump(settings)
}

/**
*

/**
* write module
* @param name