From 8a2ddeb2613e0152c07eaa991f686c9c1b1dd554 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Sun, 9 Apr 2023 17:59:10 +0200 Subject: [PATCH] Fix config struct exports --- internal/configs/config_bootloaders.go | 16 +++++------ internal/configs/configs.go | 39 ++++++++++++-------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/internal/configs/config_bootloaders.go b/internal/configs/config_bootloaders.go index d970586..5f038ff 100644 --- a/internal/configs/config_bootloaders.go +++ b/internal/configs/config_bootloaders.go @@ -14,20 +14,20 @@ func getBootloader(config *Config) { _, err := command.Run("which", "grub-mkconfig") if err == nil { // Mark bootloader as grub2 - config.bootloader = "grub2" + config.Bootloader = "grub2" } // Check for grubby (used by fedora) _, err = command.Run("which", "grubby") if err == nil { // Mark it as unknown as i do not support it yet - config.bootloader = "unknown" + config.Bootloader = "unknown" } // Check for kernelstub (used by pop os) _, err = command.Run("which", "kernelstub") if err == nil { - config.bootloader = "kernelstub" + config.Bootloader = "kernelstub" } } @@ -42,19 +42,19 @@ func set_Cmdline() { config := GetConfig() // Write the file containing our kernel arguments to feed the bootloader - fileio.AppendContent("iommu=pt", config.path.CMDLINE) + fileio.AppendContent("iommu=pt", config.Path.CMDLINE) // Write the argument based on which cpu the user got switch cpuinfo.VendorString { case "AuthenticAMD": - fileio.AppendContent(" amd_iommu=on", config.path.CMDLINE) + fileio.AppendContent(" amd_iommu=on", config.Path.CMDLINE) case "GenuineIntel": - fileio.AppendContent(" intel_iommu=on", config.path.CMDLINE) + fileio.AppendContent(" intel_iommu=on", config.Path.CMDLINE) } // If the config folder for dracut exists in our configs - if fileio.FileExist(config.path.DRACUT) { + if fileio.FileExist(config.Path.DRACUT) { // Add an extra kernel argument needed for dracut users - fileio.AppendContent(" rd.driver.pre=vfio_pci", config.path.CMDLINE) + fileio.AppendContent(" rd.driver.pre=vfio_pci", config.Path.CMDLINE) } } diff --git a/internal/configs/configs.go b/internal/configs/configs.go index 338efcb..b1eb384 100644 --- a/internal/configs/configs.go +++ b/internal/configs/configs.go @@ -22,9 +22,9 @@ type Path struct { } type Config struct { - bootloader string - cpuvendor string - path *Path + Bootloader string + Cpuvendor string + Path *Path } func GetConfigPaths() *Path { @@ -43,18 +43,15 @@ func GetConfigPaths() *Path { } func GetConfig() *Config { - config := &Config{} - config.path = GetConfigPaths() - - // Set default value for bootloader - config.bootloader = "unknown" + config := &Config{ + Bootloader: "unknown", + Cpuvendor: cpuid.CPU.VendorString, + Path: GetConfigPaths(), + } // Detect the bootloader we are using getBootloader(config) - // Detect the cpu vendor - config.cpuvendor = cpuid.CPU.VendorString - return config } @@ -63,10 +60,10 @@ func InitConfigs() { // Add all directories we need into a stringlist dirs := []string{ - config.path.MODPROBE, - config.path.INITRAMFS, - config.path.DEFAULT, - config.path.DRACUT, + config.Path.MODPROBE, + config.Path.INITRAMFS, + config.Path.DEFAULT, + config.Path.DRACUT, } // Remove old config @@ -93,10 +90,10 @@ func InitConfigs() { // Add all files we need to a stringlist files := []string{ - config.path.ETCMODULES, - config.path.MKINITCPIO, - fmt.Sprintf("%s/modules", config.path.INITRAMFS), - fmt.Sprintf("%s/grub", config.path.DEFAULT), + config.Path.ETCMODULES, + config.Path.MKINITCPIO, + fmt.Sprintf("%s/modules", config.Path.INITRAMFS), + fmt.Sprintf("%s/grub", config.Path.DEFAULT), } for _, conffile := range files { @@ -115,14 +112,14 @@ func InitConfigs() { // If we now have a config that exists if fileio.FileExist(conffile) { switch conffile { - case config.path.ETCMODULES: + case config.Path.ETCMODULES: // Read the header header := initramfs_readHeader(4, sysfile) fileio.AppendContent(header, conffile) // Add the modules to the config file initramfs_addModules(conffile) - case fmt.Sprintf("%s/modules", config.path.INITRAMFS): + case fmt.Sprintf("%s/modules", config.Path.INITRAMFS): // Read the header header := initramfs_readHeader(11, sysfile) fileio.AppendContent(header, conffile)