Fix config struct exports

This commit is contained in:
HikariKnight 2023-04-09 17:59:10 +02:00
parent c64da46cce
commit 8a2ddeb261
2 changed files with 26 additions and 29 deletions

View file

@ -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)
}
}

View file

@ -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)