Compare commits
5 Commits
2.3.0
...
jane400/ve
Author | SHA1 | Date | |
---|---|---|---|
|
20ba9e4131 | ||
|
e5f14d70a6 | ||
|
dd5cdeace5 | ||
|
1a99953aa2 | ||
|
e2f4e6254f |
@@ -54,6 +54,36 @@ a bare minimum, and to require only variables that don't hold lists of things.
|
||||
necessary tools to extract the configured archive format are in the initramfs
|
||||
archive.
|
||||
|
||||
# ARCHIVE COMPRESSION
|
||||
|
||||
Archive compression parameters are specified in the
|
||||
*deviceinfo_initfs_compression* and *deviceinfo_initfs_extra_compression*
|
||||
deviceinfo variables. Their values do not have to match, but special
|
||||
consideration should be taken since some formats may require additional kernel
|
||||
options or tools in the initramfs to support it.
|
||||
|
||||
Supported compression *formats* for mkinitfs are:
|
||||
|
||||
- gzip
|
||||
- lz4
|
||||
- lzma
|
||||
- none
|
||||
- zstd
|
||||
|
||||
Supported compression *levels* for mkinitfs:
|
||||
|
||||
- best
|
||||
- default
|
||||
- fast
|
||||
|
||||
The value of these variables follows this syntax: *<format>:<level>*. For
|
||||
example, *zstd* with the *fast* compression level would be:
|
||||
*deviceinfo_initfs_compression="zstd:fast"*
|
||||
|
||||
Defaults to *gzip* and *default* for both archives if format and/or level is
|
||||
unsupported or omitted.
|
||||
|
||||
|
||||
# DIRECTORIES
|
||||
|
||||
The following directories are used by mkinitfs to generate the initramfs and
|
||||
|
@@ -95,13 +95,16 @@ func (b *BootDeploy) Run() error {
|
||||
}
|
||||
|
||||
func getKernelPath(outDir string, zboot bool) ([]string, error) {
|
||||
kernFile := "vmlinuz*"
|
||||
|
||||
var kernels []string
|
||||
if zboot {
|
||||
kernFile = "linux.efi"
|
||||
kernels, _ = filepath.Glob(filepath.Join(outDir, "linux.efi"))
|
||||
if len(kernels) > 0 {
|
||||
return kernels, nil
|
||||
}
|
||||
// else fallback to vmlinuz* below
|
||||
}
|
||||
|
||||
var kernels []string
|
||||
kernFile := "vmlinuz*"
|
||||
kernels, _ = filepath.Glob(filepath.Join(outDir, kernFile))
|
||||
if len(kernels) == 0 {
|
||||
return nil, errors.New("Unable to find any kernels at " + filepath.Join(outDir, kernFile))
|
||||
|
@@ -118,7 +118,9 @@ func getModulesInDir(modPath string) (files []string, err error) {
|
||||
// Unable to walk path
|
||||
return err
|
||||
}
|
||||
if filepath.Ext(path) != ".ko" && filepath.Ext(path) != ".xz" {
|
||||
// this assumes module names are in the format <name>.ko[.format],
|
||||
// where ".format" (e.g. ".gz") is optional.
|
||||
if !strings.Contains(".ko", path) {
|
||||
return nil
|
||||
}
|
||||
files = append(files, path)
|
||||
|
@@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"log"
|
||||
|
||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/osutil"
|
||||
)
|
||||
@@ -22,29 +24,53 @@ func GetFiles(list []string, required bool) (files []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func getFile(file string, required bool) (files []string, err error) {
|
||||
// Expand glob expression
|
||||
expanded, err := filepath.Glob(file)
|
||||
// This function doesn't handle globs, use getFile() instead.
|
||||
func getFileNormalized(file string, required bool) (files []string, err error) {
|
||||
fileInfo, err := os.Stat(file)
|
||||
|
||||
// Trying some fallbacks...
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(expanded) > 0 && expanded[0] != file {
|
||||
for _, path := range expanded {
|
||||
if globFiles, err := getFile(path, required); err != nil {
|
||||
return files, err
|
||||
type triedResult struct {
|
||||
file string
|
||||
err error
|
||||
}
|
||||
|
||||
triedFiles := make([]triedResult, 0, 1)
|
||||
|
||||
// Temporary fallback until alpine/pmOS usr-merge happened
|
||||
// If a path starts with /bin or /sbin, also try /usr equivalent before giving up
|
||||
if strings.HasPrefix(file, "/bin/") || strings.HasPrefix(file, "/sbin/") {
|
||||
fileUsr := filepath.Join("/usr", file)
|
||||
_, err := os.Stat(fileUsr);
|
||||
if err == nil {
|
||||
log.Printf("getFile: failed to find %q, but found it in %q. Please adjust the path.", file, fileUsr)
|
||||
return getFileNormalized(fileUsr, required)
|
||||
} else {
|
||||
files = append(files, globFiles...)
|
||||
triedFiles = append(triedFiles, triedResult{fileUsr, err})
|
||||
}
|
||||
}
|
||||
return RemoveDuplicates(files), nil
|
||||
}
|
||||
|
||||
fileInfo, err := os.Stat(file)
|
||||
if err != nil {
|
||||
if required {
|
||||
return files, fmt.Errorf("getFile: failed to stat file %q: %w", file, err)
|
||||
{
|
||||
// Check if there is a Zstd-compressed version of the file
|
||||
fileZstd := file + ".zst" // .zst is the extension used by linux-firmware
|
||||
_, err := os.Stat(fileZstd);
|
||||
if err == nil {
|
||||
return getFileNormalized(fileZstd, required)
|
||||
} else {
|
||||
triedFiles = append(triedFiles, triedResult{fileZstd, err})
|
||||
}
|
||||
}
|
||||
|
||||
// Failed to find anything
|
||||
if required {
|
||||
failStrings := make([]string, 0, 2)
|
||||
for _, result := range triedFiles {
|
||||
failStrings = append(failStrings, fmt.Sprintf("\n - also tried %q: %v", result.file, result.err))
|
||||
}
|
||||
return files, fmt.Errorf("getFile: failed to stat file %q: %v%q", file, err, strings.Join(failStrings, ""))
|
||||
} else {
|
||||
return files, nil
|
||||
}
|
||||
return files, nil
|
||||
}
|
||||
|
||||
if fileInfo.IsDir() {
|
||||
@@ -83,6 +109,26 @@ func getFile(file string, required bool) (files []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func getFile(file string, required bool) (files []string, err error) {
|
||||
// Expand glob expression
|
||||
expanded, err := filepath.Glob(file)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(expanded) > 0 && expanded[0] != file {
|
||||
for _, path := range expanded {
|
||||
if globFiles, err := getFile(path, required); err != nil {
|
||||
return files, err
|
||||
} else {
|
||||
files = append(files, globFiles...)
|
||||
}
|
||||
}
|
||||
return RemoveDuplicates(files), nil
|
||||
}
|
||||
|
||||
return getFileNormalized(file, required)
|
||||
}
|
||||
|
||||
func getDeps(file string, parents map[string]struct{}) (files []string, err error) {
|
||||
|
||||
if _, found := parents[file]; found {
|
||||
|
Reference in New Issue
Block a user