"use strict";
/**
 * penguins-eggs
 * krill modules: initramfs.ts
 * author: Piero Proietti
 * email: piero.proietti@gmail.com
 * license: MIT
 * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
 */
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const utils_1 = require("../../lib/utils");
const utils_2 = tslib_1.__importDefault(require("../../classes/utils"));
const path_1 = tslib_1.__importDefault(require("path"));
/**
   * initramfs()
   */
async function initramfs() {
    if (this.distro.familyId === 'debian') {
        let cmd = `chroot ${this.installTarget} mkinitramfs -o ~/initrd.img-$(uname -r) ${this.toNull}`;
        try {
            await (0, utils_1.exec)(cmd, this.echo);
        }
        catch {
            await utils_2.default.pressKeyToExit(cmd);
        }
        cmd = `chroot ${this.installTarget} mv ~/initrd.img-$(uname -r) /boot ${this.toNull}`;
        try {
            await (0, utils_1.exec)(cmd, this.echo);
        }
        catch {
            await utils_2.default.pressKeyToExit(cmd);
        }
    }
    else if (this.distro.familyId === 'archlinux') {
        let initrdImg = utils_2.default.initrdImg();
        initrdImg = initrdImg.slice(Math.max(0, initrdImg.lastIndexOf('/') + 1));
        let cmd = `mkinitcpio -c ${path_1.default.resolve(__dirname, '../../../mkinitcpio/arch/mkinitcpio-install.conf')} -g ${this.installTarget}/boot/${initrdImg}`;
        if (this.distro.distroId === 'Manjaro') {
            cmd = `mkinitcpio -c ${path_1.default.resolve(__dirname, '../../../mkinitcpio/manjaro/mkinitcpio-install.conf')} -g ${this.installTarget}/boot/${initrdImg}`; // ${this.toNull}
        }
        try {
            await (0, utils_1.exec)(cmd, utils_2.default.setEcho(true));
        }
        catch {
            await utils_2.default.pressKeyToExit(cmd);
        }
    }
}
exports.default = initramfs;
