"use strict";
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"));
async function bootloaderConfigDebian() {
    let cmd = '';
    try {
        cmd = `chroot ${this.installTarget} apt-get update -y ${this.toNull}`;
        await (0, utils_1.exec)(cmd, this.echo);
    }
    catch (error) {
        console.log(error);
        await utils_2.default.pressKeyToExit(cmd, true);
    }
    try {
        cmd = `chroot ${this.installTarget} sleep 1 ${this.toNull}`;
        await (0, utils_1.exec)(cmd, this.echo);
    }
    catch (error) {
        console.log(error);
        await utils_2.default.pressKeyToExit(cmd, true);
    }
    const aptInstallOptions = ' apt install -y --no-upgrade --allow-unauthenticated -o Acquire::gpgv::Options::=--ignore-time-conflict ';
    if (this.efi) {
        try {
            cmd = `chroot ${this.installTarget} ${aptInstallOptions} grub-efi-${utils_2.default.uefiArch()} --allow-unauthenticated ${this.toNull}`;
            await (0, utils_1.exec)(cmd, this.echo);
        }
        catch (error) {
            console.log(error);
            await utils_2.default.pressKeyToExit(cmd, true);
        }
    }
    else {
        try {
            cmd = `chroot ${this.installTarget} ${aptInstallOptions} grub-pc ${this.toNull}`;
            await (0, utils_1.exec)(cmd, this.echo);
        }
        catch (error) {
            console.log(error);
            await utils_2.default.pressKeyToExit(cmd, true);
        }
    }
}
exports.default = bootloaderConfigDebian;
