10 Commits
2.0 ... 2.1

Author SHA1 Message Date
Clayton Craft
c9de619f98 filelist/hookscripts: use the correct path for scripts 2023-03-10 23:23:53 -08:00
Clayton Craft
a519769979 filelist/*: use "searching" instead of "including" in top-level msg
When this is printed, it's about to search the given path for stuff to
slurp up, but it hasn't actually included anything yet. Using
"Including" here was kinda confusing, so this changes it to use
"Searching for." Hopefully that's better!
2023-03-10 22:33:32 -08:00
Clayton Craft
128a48dd24 cmd/mkinitfs: re-add support for setting initramfs-extra compression 2023-03-10 22:22:51 -08:00
Clayton Craft
499136e83a cmd/mkinitfs: move printing compression info to generateArchive 2023-03-10 22:22:51 -08:00
Clayton Craft
78f8fa32fb deviceinfo: add initfs_extra_compression
For configuring the archive compression parameters for the
initramfs-extra archive.
2023-03-10 22:22:50 -08:00
Clayton Craft
d03257981f bootdeploy: add context to kernel copy fd close error (MR 33) 2023-03-06 22:20:11 -08:00
Clayton Craft
307fb1889f bootdeploy: use original kernel filename when calling boot-deploy (MR 33)
fixes #21
2023-03-06 22:20:07 -08:00
Clayton Craft
fa3d3268d7 bootdeploy: catch any errors when closing kernel file copy fd 2023-03-05 23:56:58 -08:00
Clayton Craft
8b67848d5c filelist/modules: print search path for modules
By doing so, it adds more useful context to this:

         - Including kernel modules
         -- Unable to find dir, skipping...
         - Including kernel modules
         -- Unable to find dir, skipping...
2023-03-05 23:54:15 -08:00
Clayton Craft
31ab72edbc cmd/mkinitfs: configure log to print milliseconds
Useful for timing each step of generating the initramfs without having
to add a bunch of calls to the "time func" function
2023-03-01 22:57:53 -08:00
9 changed files with 43 additions and 26 deletions

View File

@@ -47,6 +47,8 @@ func main() {
return
}
log.Default().SetFlags(log.Lmicroseconds)
deviceinfoFile := "/etc/deviceinfo"
if exists, err := misc.Exists(deviceinfoFile); !exists {
log.Printf("NOTE: %q not found, this file is required by mkinitfs.\n", deviceinfoFile)
@@ -63,10 +65,6 @@ func main() {
return
}
// deviceinfo.InitfsCompression needs a little more post-processing
compressionFormat, compressionLevel := archive.ExtractFormatLevel(devinfo.InitfsCompression)
log.Printf("Using compression format %s with level %q\n", compressionFormat, compressionLevel)
defer misc.TimeFunc(time.Now(), "mkinitfs")
kernVer, err := osutil.GetKernelVersion()
@@ -95,13 +93,15 @@ func main() {
log.Print("Generating for kernel version: ", kernVer)
log.Print("Output directory: ", *outDir)
// deviceinfo.InitfsCompression needs a little more post-processing
compressionFormat, compressionLevel := archive.ExtractFormatLevel(devinfo.InitfsCompression)
if err := generateArchive("initramfs", compressionFormat, compressionLevel, workDir, []filelist.FileLister{
hookdirs.New("/usr/share/mkinitfs/dirs"),
hookdirs.New("/etc/mkinitfs/dirs"),
hookfiles.New("/usr/share/mkinitfs/files"),
hookfiles.New("/etc/mkinitfs/files"),
hookscripts.New("/usr/share/mkinitfs/hooks"),
hookscripts.New("/etc/mkinitfs/hooks"),
hookscripts.New("/usr/share/mkinitfs/hooks", "/hooks"),
hookscripts.New("/etc/mkinitfs/hooks", "/hooks"),
modules.New(strings.Fields(devinfo.ModulesInitfs), "/usr/share/mkinitfs/modules"),
modules.New([]string{}, "/etc/mkinitfs/modules"),
}); err != nil {
@@ -111,14 +111,13 @@ func main() {
return
}
// Note: compression disabled for initramfs-extra, since it slows down boot
// and can add more requirements to the initramfs (e.g. need to add support
// for extracting zstd)
if err := generateArchive("initramfs-extra", archive.FormatNone, archive.LevelDefault, workDir, []filelist.FileLister{
// deviceinfo.InitfsExtraCompression needs a little more post-processing
compressionFormat, compressionLevel = archive.ExtractFormatLevel(devinfo.InitfsExtraCompression)
if err := generateArchive("initramfs-extra", compressionFormat, compressionLevel, workDir, []filelist.FileLister{
hookfiles.New("/usr/share/mkinitfs/files-extra"),
hookfiles.New("/etc/mkinitfs/files-extra"),
hookscripts.New("/usr/share/mkinitfs/hooks-extra"),
hookscripts.New("/etc/mkinitfs/hooks-extra"),
hookscripts.New("/usr/share/mkinitfs/hooks-extra", "/hooks-extra"),
hookscripts.New("/etc/mkinitfs/hooks-extra", "/hooks-extra"),
modules.New([]string{}, "/usr/share/mkinitfs/modules-extra"),
modules.New([]string{}, "/etc/mkinitfs/modules-extra"),
osksdl.New(devinfo.MesaDriver),
@@ -150,6 +149,8 @@ func bootDeploy(workDir, outDir, ubootBoardname string) error {
func generateArchive(name string, format archive.CompressFormat, level archive.CompressLevel, path string, features []filelist.FileLister) error {
log.Printf("== Generating %s ==\n", name)
log.Printf("- Using compression format %s with level %q\n", format, level)
defer misc.TimeFunc(time.Now(), name)
a, err := archive.New(format, level)
if err != nil {

View File

@@ -33,6 +33,7 @@ mkinitfs reads deviceinfo values from */etc/deviceinfo*. The following variables
are *required* by mkinitfs:
- deviceinfo_initfs_compression
- deviceinfo_initfs_extra_compression
- deviceinfo_mesa_driver
- deviceinfo_modules_initfs
- deviceinfo_uboot_boardname
@@ -40,6 +41,10 @@ are *required* by mkinitfs:
It is a design goal to keep the number of required variables from deviceinfo to
a bare minimum, and to require only variables that don't hold lists of things.
*NOTE*: When deviceinfo_initfs_extra_compression is set, make sure that the
necessary tools to extract the configured archive format are in the initramfs
archive.
# DIRECTORIES
The following directories are used by mkinitfs to generate the initramfs and

View File

@@ -2,10 +2,12 @@ package bootdeploy
import (
"errors"
"fmt"
"io"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
)
@@ -68,7 +70,8 @@ func bootDeploy(workDir string, outDir string) error {
}
defer kernFd.Close()
kernFileCopy, err := os.Create(filepath.Join(workDir, "vmlinuz"))
kernFilename := path.Base(kernFile)
kernFileCopy, err := os.Create(filepath.Join(workDir, kernFilename))
if err != nil {
return err
}
@@ -76,12 +79,14 @@ func bootDeploy(workDir string, outDir string) error {
if _, err = io.Copy(kernFileCopy, kernFd); err != nil {
return err
}
kernFileCopy.Close()
if err := kernFileCopy.Close(); err != nil {
return fmt.Errorf("error closing %s: %w", kernFilename, err)
}
// boot-deploy -i initramfs -k vmlinuz-postmarketos-rockchip -d /tmp/cpio -o /tmp/foo initramfs-extra
cmd := exec.Command("boot-deploy",
"-i", "initramfs",
"-k", "vmlinuz",
"-k", kernFilename,
"-d", workDir,
"-o", outDir,
"initramfs-extra")

View File

@@ -23,7 +23,7 @@ func New(path string) *HookDirs {
}
func (h *HookDirs) List() (*filelist.FileList, error) {
log.Printf("- Creating directories specified in %s", h.path)
log.Printf("- Searching for directories specified in %s", h.path)
files := filelist.NewFileList()
fileInfo, err := os.ReadDir(h.path)

View File

@@ -26,7 +26,7 @@ func New(filePath string) *HookFiles {
}
func (h *HookFiles) List() (*filelist.FileList, error) {
log.Printf("- Including file lists from %s", h.filePath)
log.Printf("- Searching for file lists from %s", h.filePath)
files := filelist.NewFileList()
fileInfo, err := os.ReadDir(h.filePath)

View File

@@ -9,19 +9,22 @@ import (
)
type HookScripts struct {
destPath string
scriptsDir string
}
// New returns a new HookScripts that will use the given path to provide a list
// of script files.
func New(scriptsDir string) *HookScripts {
// of script files. The destination for each script it set to destPath, using
// the original file name.
func New(scriptsDir string, destPath string) *HookScripts {
return &HookScripts{
destPath: destPath,
scriptsDir: scriptsDir,
}
}
func (h *HookScripts) List() (*filelist.FileList, error) {
log.Printf("- Including hook scripts from %s", h.scriptsDir)
log.Printf("- Searching for hook scripts from %s", h.scriptsDir)
files := filelist.NewFileList()
@@ -32,7 +35,8 @@ func (h *HookScripts) List() (*filelist.FileList, error) {
}
for _, file := range fileInfo {
path := filepath.Join(h.scriptsDir, file.Name())
files.Add(path, path)
log.Printf("-- Including script: %s\n", path)
files.Add(path, filepath.Join(h.destPath, file.Name()))
}
return files, nil
}

View File

@@ -30,7 +30,7 @@ func New(modulesList []string, modulesListPath string) *Modules {
}
func (m *Modules) List() (*filelist.FileList, error) {
log.Println("- Including kernel modules")
log.Printf("- Searching for kernel modules from %s", m.modulesListPath)
kernVer, err := osutil.GetKernelVersion()
if err != nil {

View File

@@ -15,6 +15,7 @@ import (
type DeviceInfo struct {
InitfsCompression string
InitfsExtraCompression string
MesaDriver string
ModulesInitfs string
UbootBoardname string

View File

@@ -21,6 +21,7 @@ func TestNameToField(t *testing.T) {
{"deviceinfo_modules_initfs", "ModulesInitfs"},
{"modules_initfs", "ModulesInitfs"},
{"deviceinfo_modules_initfs___", "ModulesInitfs"},
{"deviceinfo_initfs_extra_compression", "InitfsExtraCompression"},
}
for _, table := range tables {