Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
80098d29c6 | ||
|
67f1839ddc | ||
|
baf76ed614 | ||
|
27e271b904 | ||
|
1ac85b12fe | ||
|
f7f42bc2d4 | ||
|
c62a1f9ddb |
@@ -44,11 +44,11 @@ const (
|
||||
)
|
||||
|
||||
type Archive struct {
|
||||
items archiveItems
|
||||
cpioWriter *cpio.Writer
|
||||
buf *bytes.Buffer
|
||||
compress_format CompressFormat
|
||||
compress_level CompressLevel
|
||||
items archiveItems
|
||||
}
|
||||
|
||||
func New(format CompressFormat, level CompressLevel) (*Archive, error) {
|
||||
@@ -64,8 +64,8 @@ func New(format CompressFormat, level CompressLevel) (*Archive, error) {
|
||||
}
|
||||
|
||||
type archiveItem struct {
|
||||
sourcePath string
|
||||
header *cpio.Header
|
||||
sourcePath string
|
||||
}
|
||||
|
||||
type archiveItems struct {
|
||||
|
@@ -16,8 +16,8 @@ import (
|
||||
)
|
||||
|
||||
type Modules struct {
|
||||
modulesList []string
|
||||
modulesListPath string
|
||||
modulesList []string
|
||||
}
|
||||
|
||||
// New returns a new Modules that will use the given moduleto provide a list
|
||||
@@ -30,8 +30,6 @@ func New(modulesList []string, modulesListPath string) *Modules {
|
||||
}
|
||||
|
||||
func (m *Modules) List() (*filelist.FileList, error) {
|
||||
log.Printf("- Searching for kernel modules from %s", m.modulesListPath)
|
||||
|
||||
kernVer, err := osutil.GetKernelVersion()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -55,17 +53,21 @@ func (m *Modules) List() (*filelist.FileList, error) {
|
||||
}
|
||||
|
||||
// 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("getInitfsModules: unable to get modules from deviceinfo: %w", err)
|
||||
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
|
||||
log.Printf("- Searching for kernel modules from %s", m.modulesListPath)
|
||||
fileInfo, err := os.ReadDir(m.modulesListPath)
|
||||
if err != nil {
|
||||
log.Println("-- Unable to find dir, skipping...")
|
||||
@@ -126,7 +128,11 @@ func slurpModules(fd io.Reader, modDir string) (*filelist.FileList, error) {
|
||||
}
|
||||
|
||||
func getModulesInDir(modPath string) (files []string, err error) {
|
||||
err = filepath.Walk(modPath, func(path string, f os.FileInfo, err error) error {
|
||||
err = filepath.Walk(modPath, func(path string, _ os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
// Unable to walk path
|
||||
return err
|
||||
}
|
||||
if filepath.Ext(path) != ".ko" && filepath.Ext(path) != ".xz" {
|
||||
return nil
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ func RemoveDuplicates(in []string) (out []string) {
|
||||
// defer misc.TimeFunc(time.Now(), "foo")
|
||||
func TimeFunc(start time.Time, name string) {
|
||||
elapsed := time.Since(start)
|
||||
log.Printf("%s completed in: %s", name, elapsed)
|
||||
log.Printf("%s completed in: %.2fs", name, elapsed.Seconds())
|
||||
}
|
||||
|
||||
// Exists tests if the given file/dir exists or not. Returns any errors related
|
||||
|
Reference in New Issue
Block a user