Do not support loading modules from "deviceinfo_modules_initfs" (MR 38)
This variable will dissappear from the deviceinfo at some point: https://gitlab.com/postmarketOS/pmaports/-/merge_requests/4169 so after it does, it would not make much sense to keep its use around
This commit is contained in:
committed by
Clayton Craft
parent
d77e1cd11d
commit
2b467eb77f
@@ -9,7 +9,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/archive"
|
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/archive"
|
||||||
@@ -105,8 +104,8 @@ func main() {
|
|||||||
hookfiles.New("/etc/mkinitfs/files"),
|
hookfiles.New("/etc/mkinitfs/files"),
|
||||||
hookscripts.New("/usr/share/mkinitfs/hooks", "/hooks"),
|
hookscripts.New("/usr/share/mkinitfs/hooks", "/hooks"),
|
||||||
hookscripts.New("/etc/mkinitfs/hooks", "/hooks"),
|
hookscripts.New("/etc/mkinitfs/hooks", "/hooks"),
|
||||||
modules.New(strings.Fields(devinfo.ModulesInitfs), "/usr/share/mkinitfs/modules"),
|
modules.New("/usr/share/mkinitfs/modules"),
|
||||||
modules.New([]string{}, "/etc/mkinitfs/modules"),
|
modules.New("/etc/mkinitfs/modules"),
|
||||||
})
|
})
|
||||||
if err := initramfsAr.AddItems(initfs); err != nil {
|
if err := initramfsAr.AddItems(initfs); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@@ -137,8 +136,8 @@ func main() {
|
|||||||
hookfiles.New("/etc/mkinitfs/files-extra"),
|
hookfiles.New("/etc/mkinitfs/files-extra"),
|
||||||
hookscripts.New("/usr/share/mkinitfs/hooks-extra", "/hooks-extra"),
|
hookscripts.New("/usr/share/mkinitfs/hooks-extra", "/hooks-extra"),
|
||||||
hookscripts.New("/etc/mkinitfs/hooks-extra", "/hooks-extra"),
|
hookscripts.New("/etc/mkinitfs/hooks-extra", "/hooks-extra"),
|
||||||
modules.New([]string{}, "/usr/share/mkinitfs/modules-extra"),
|
modules.New("/usr/share/mkinitfs/modules-extra"),
|
||||||
modules.New([]string{}, "/etc/mkinitfs/modules-extra"),
|
modules.New("/etc/mkinitfs/modules-extra"),
|
||||||
osksdl.New(devinfo.MesaDriver),
|
osksdl.New(devinfo.MesaDriver),
|
||||||
})
|
})
|
||||||
if err := initramfsExtraAr.AddItemsExclude(initfsExtra, initfs); err != nil {
|
if err := initramfsExtraAr.AddItemsExclude(initfsExtra, initfs); err != nil {
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ are *required* by mkinitfs:
|
|||||||
- deviceinfo_initfs_compression
|
- deviceinfo_initfs_compression
|
||||||
- deviceinfo_initfs_extra_compression
|
- deviceinfo_initfs_extra_compression
|
||||||
- deviceinfo_mesa_driver
|
- deviceinfo_mesa_driver
|
||||||
- deviceinfo_modules_initfs
|
|
||||||
- deviceinfo_uboot_boardname
|
- deviceinfo_uboot_boardname
|
||||||
|
|
||||||
It is a design goal to keep the number of required variables from deviceinfo to
|
It is a design goal to keep the number of required variables from deviceinfo to
|
||||||
|
|||||||
@@ -17,14 +17,11 @@ import (
|
|||||||
|
|
||||||
type Modules struct {
|
type Modules struct {
|
||||||
modulesListPath string
|
modulesListPath string
|
||||||
modulesList []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new Modules that will use the given moduleto provide a list
|
// New returns a new Modules that will read in lists of kernel modules in the given path.
|
||||||
// of script files.
|
func New(modulesListPath string) *Modules {
|
||||||
func New(modulesList []string, modulesListPath string) *Modules {
|
|
||||||
return &Modules{
|
return &Modules{
|
||||||
modulesList: modulesList,
|
|
||||||
modulesListPath: modulesListPath,
|
modulesListPath: modulesListPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,20 +49,6 @@ func (m *Modules) List() (*filelist.FileList, error) {
|
|||||||
files.Add(file, file)
|
files.Add(file, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// slurp up given list of modules
|
|
||||||
if len(m.modulesList) > 0 {
|
|
||||||
log.Printf("-- Including kernel modules from deviceinfo")
|
|
||||||
for _, module := range m.modulesList {
|
|
||||||
if modFilelist, err := getModule(module, modDir); err != nil {
|
|
||||||
return nil, fmt.Errorf("unable to get modules from deviceinfo: %w", err)
|
|
||||||
} else {
|
|
||||||
for _, file := range modFilelist {
|
|
||||||
files.Add(file, file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// slurp up modules from lists in modulesListPath
|
// slurp up modules from lists in modulesListPath
|
||||||
log.Printf("- Searching for kernel modules from %s", m.modulesListPath)
|
log.Printf("- Searching for kernel modules from %s", m.modulesListPath)
|
||||||
fileInfo, err := os.ReadDir(m.modulesListPath)
|
fileInfo, err := os.ReadDir(m.modulesListPath)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ type DeviceInfo struct {
|
|||||||
InitfsCompression string
|
InitfsCompression string
|
||||||
InitfsExtraCompression string
|
InitfsExtraCompression string
|
||||||
MesaDriver string
|
MesaDriver string
|
||||||
ModulesInitfs string
|
|
||||||
UbootBoardname string
|
UbootBoardname string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
// Test ReadDeviceinfo and the logic of reading from multiple files
|
// Test ReadDeviceinfo and the logic of reading from multiple files
|
||||||
func TestReadDeviceinfo(t *testing.T) {
|
func TestReadDeviceinfo(t *testing.T) {
|
||||||
modules_expected := "panfrost foo bar bazz"
|
compression_expected := "gz -9"
|
||||||
mesa_expected := "msm"
|
mesa_expected := "msm"
|
||||||
|
|
||||||
var devinfo DeviceInfo
|
var devinfo DeviceInfo
|
||||||
@@ -28,8 +28,8 @@ func TestReadDeviceinfo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("received an unexpected err: %s", err)
|
t.Errorf("received an unexpected err: %s", err)
|
||||||
}
|
}
|
||||||
if devinfo.ModulesInitfs != modules_expected {
|
if devinfo.InitfsCompression != compression_expected {
|
||||||
t.Errorf("expected %q, got: %q", modules_expected, devinfo.ModulesInitfs)
|
t.Errorf("expected %q, got: %q", compression_expected, devinfo.InitfsCompression)
|
||||||
}
|
}
|
||||||
if devinfo.MesaDriver != mesa_expected {
|
if devinfo.MesaDriver != mesa_expected {
|
||||||
t.Errorf("expected %q, got: %q", mesa_expected, devinfo.MesaDriver)
|
t.Errorf("expected %q, got: %q", mesa_expected, devinfo.MesaDriver)
|
||||||
@@ -44,9 +44,9 @@ func TestNameToField(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{"deviceinfo_dtb", "Dtb"},
|
{"deviceinfo_dtb", "Dtb"},
|
||||||
{"dtb", "Dtb"},
|
{"dtb", "Dtb"},
|
||||||
{"deviceinfo_modules_initfs", "ModulesInitfs"},
|
{"deviceinfo_initfs_compression", "InitfsCompression"},
|
||||||
{"modules_initfs", "ModulesInitfs"},
|
{"modules_initfs", "ModulesInitfs"},
|
||||||
{"deviceinfo_modules_initfs___", "ModulesInitfs"},
|
{"deviceinfo_initfs_compression___", "InitfsCompression"},
|
||||||
{"deviceinfo_initfs_extra_compression", "InitfsExtraCompression"},
|
{"deviceinfo_initfs_extra_compression", "InitfsExtraCompression"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +67,11 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
in string
|
in string
|
||||||
expected string
|
expected string
|
||||||
}{
|
}{
|
||||||
{"ModulesInitfs", "deviceinfo_modules_initfs=\"panfrost foo bar bazz\"\n", "panfrost foo bar bazz"},
|
{"InitfsCompression", "deviceinfo_initfs_compression=\"gzip:-9\"\n", "gzip:-9"},
|
||||||
{"ModulesInitfs", "deviceinfo_modules_initfs=\"panfrost foo bar bazz\"", "panfrost foo bar bazz"},
|
|
||||||
// line with multiple '='
|
// line with multiple '='
|
||||||
{"InitfsCompression", "deviceinfo_initfs_compression=zstd:--foo=1 -T0 --bar=bazz", "zstd:--foo=1 -T0 --bar=bazz"},
|
{"InitfsCompression", "deviceinfo_initfs_compression=zstd:--foo=1 -T0 --bar=bazz", "zstd:--foo=1 -T0 --bar=bazz"},
|
||||||
// empty option
|
// empty option
|
||||||
{"ModulesInitfs", "deviceinfo_modules_initfs=\"\"\n", ""},
|
{"InitfsCompression", "deviceinfo_initfs_compression=\"\"\n", ""},
|
||||||
// line with comment at the end
|
// line with comment at the end
|
||||||
{"MesaDriver", "deviceinfo_mesa_driver=\"panfrost\" # this is a nice driver", "panfrost"},
|
{"MesaDriver", "deviceinfo_mesa_driver=\"panfrost\" # this is a nice driver", "panfrost"},
|
||||||
{"", "# this is a comment!\n", ""},
|
{"", "# this is a comment!\n", ""},
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
deviceinfo_modules_initfs="panfrost foo bar bazz"
|
deviceinfo_initfs_compression="gz -9"
|
||||||
deviceinfo_mesa_driver="panfrost"
|
deviceinfo_mesa_driver="panfrost"
|
||||||
|
|||||||
Reference in New Issue
Block a user