Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c9de619f98 | ||
|
a519769979 | ||
|
128a48dd24 | ||
|
499136e83a | ||
|
78f8fa32fb | ||
|
d03257981f | ||
|
307fb1889f | ||
|
fa3d3268d7 | ||
|
8b67848d5c | ||
|
31ab72edbc |
@@ -47,6 +47,8 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Default().SetFlags(log.Lmicroseconds)
|
||||||
|
|
||||||
deviceinfoFile := "/etc/deviceinfo"
|
deviceinfoFile := "/etc/deviceinfo"
|
||||||
if exists, err := misc.Exists(deviceinfoFile); !exists {
|
if exists, err := misc.Exists(deviceinfoFile); !exists {
|
||||||
log.Printf("NOTE: %q not found, this file is required by mkinitfs.\n", deviceinfoFile)
|
log.Printf("NOTE: %q not found, this file is required by mkinitfs.\n", deviceinfoFile)
|
||||||
@@ -63,10 +65,6 @@ func main() {
|
|||||||
return
|
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")
|
defer misc.TimeFunc(time.Now(), "mkinitfs")
|
||||||
|
|
||||||
kernVer, err := osutil.GetKernelVersion()
|
kernVer, err := osutil.GetKernelVersion()
|
||||||
@@ -95,13 +93,15 @@ func main() {
|
|||||||
log.Print("Generating for kernel version: ", kernVer)
|
log.Print("Generating for kernel version: ", kernVer)
|
||||||
log.Print("Output directory: ", *outDir)
|
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{
|
if err := generateArchive("initramfs", compressionFormat, compressionLevel, workDir, []filelist.FileLister{
|
||||||
hookdirs.New("/usr/share/mkinitfs/dirs"),
|
hookdirs.New("/usr/share/mkinitfs/dirs"),
|
||||||
hookdirs.New("/etc/mkinitfs/dirs"),
|
hookdirs.New("/etc/mkinitfs/dirs"),
|
||||||
hookfiles.New("/usr/share/mkinitfs/files"),
|
hookfiles.New("/usr/share/mkinitfs/files"),
|
||||||
hookfiles.New("/etc/mkinitfs/files"),
|
hookfiles.New("/etc/mkinitfs/files"),
|
||||||
hookscripts.New("/usr/share/mkinitfs/hooks"),
|
hookscripts.New("/usr/share/mkinitfs/hooks", "/hooks"),
|
||||||
hookscripts.New("/etc/mkinitfs/hooks"),
|
hookscripts.New("/etc/mkinitfs/hooks", "/hooks"),
|
||||||
modules.New(strings.Fields(devinfo.ModulesInitfs), "/usr/share/mkinitfs/modules"),
|
modules.New(strings.Fields(devinfo.ModulesInitfs), "/usr/share/mkinitfs/modules"),
|
||||||
modules.New([]string{}, "/etc/mkinitfs/modules"),
|
modules.New([]string{}, "/etc/mkinitfs/modules"),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@@ -111,14 +111,13 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: compression disabled for initramfs-extra, since it slows down boot
|
// deviceinfo.InitfsExtraCompression needs a little more post-processing
|
||||||
// and can add more requirements to the initramfs (e.g. need to add support
|
compressionFormat, compressionLevel = archive.ExtractFormatLevel(devinfo.InitfsExtraCompression)
|
||||||
// for extracting zstd)
|
if err := generateArchive("initramfs-extra", compressionFormat, compressionLevel, workDir, []filelist.FileLister{
|
||||||
if err := generateArchive("initramfs-extra", archive.FormatNone, archive.LevelDefault, workDir, []filelist.FileLister{
|
|
||||||
hookfiles.New("/usr/share/mkinitfs/files-extra"),
|
hookfiles.New("/usr/share/mkinitfs/files-extra"),
|
||||||
hookfiles.New("/etc/mkinitfs/files-extra"),
|
hookfiles.New("/etc/mkinitfs/files-extra"),
|
||||||
hookscripts.New("/usr/share/mkinitfs/hooks-extra"),
|
hookscripts.New("/usr/share/mkinitfs/hooks-extra", "/hooks-extra"),
|
||||||
hookscripts.New("/etc/mkinitfs/hooks-extra"),
|
hookscripts.New("/etc/mkinitfs/hooks-extra", "/hooks-extra"),
|
||||||
modules.New([]string{}, "/usr/share/mkinitfs/modules-extra"),
|
modules.New([]string{}, "/usr/share/mkinitfs/modules-extra"),
|
||||||
modules.New([]string{}, "/etc/mkinitfs/modules-extra"),
|
modules.New([]string{}, "/etc/mkinitfs/modules-extra"),
|
||||||
osksdl.New(devinfo.MesaDriver),
|
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 {
|
func generateArchive(name string, format archive.CompressFormat, level archive.CompressLevel, path string, features []filelist.FileLister) error {
|
||||||
log.Printf("== Generating %s ==\n", name)
|
log.Printf("== Generating %s ==\n", name)
|
||||||
|
log.Printf("- Using compression format %s with level %q\n", format, level)
|
||||||
|
|
||||||
defer misc.TimeFunc(time.Now(), name)
|
defer misc.TimeFunc(time.Now(), name)
|
||||||
a, err := archive.New(format, level)
|
a, err := archive.New(format, level)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -33,6 +33,7 @@ mkinitfs reads deviceinfo values from */etc/deviceinfo*. The following variables
|
|||||||
are *required* by mkinitfs:
|
are *required* by mkinitfs:
|
||||||
|
|
||||||
- deviceinfo_initfs_compression
|
- deviceinfo_initfs_compression
|
||||||
|
- deviceinfo_initfs_extra_compression
|
||||||
- deviceinfo_mesa_driver
|
- deviceinfo_mesa_driver
|
||||||
- deviceinfo_modules_initfs
|
- deviceinfo_modules_initfs
|
||||||
- deviceinfo_uboot_boardname
|
- 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
|
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.
|
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
|
# DIRECTORIES
|
||||||
|
|
||||||
The following directories are used by mkinitfs to generate the initramfs and
|
The following directories are used by mkinitfs to generate the initramfs and
|
||||||
|
@@ -2,10 +2,12 @@ package bootdeploy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -68,7 +70,8 @@ func bootDeploy(workDir string, outDir string) error {
|
|||||||
}
|
}
|
||||||
defer kernFd.Close()
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -76,12 +79,14 @@ func bootDeploy(workDir string, outDir string) error {
|
|||||||
if _, err = io.Copy(kernFileCopy, kernFd); err != nil {
|
if _, err = io.Copy(kernFileCopy, kernFd); err != nil {
|
||||||
return err
|
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
|
// boot-deploy -i initramfs -k vmlinuz-postmarketos-rockchip -d /tmp/cpio -o /tmp/foo initramfs-extra
|
||||||
cmd := exec.Command("boot-deploy",
|
cmd := exec.Command("boot-deploy",
|
||||||
"-i", "initramfs",
|
"-i", "initramfs",
|
||||||
"-k", "vmlinuz",
|
"-k", kernFilename,
|
||||||
"-d", workDir,
|
"-d", workDir,
|
||||||
"-o", outDir,
|
"-o", outDir,
|
||||||
"initramfs-extra")
|
"initramfs-extra")
|
||||||
|
@@ -23,7 +23,7 @@ func New(path string) *HookDirs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *HookDirs) List() (*filelist.FileList, error) {
|
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()
|
files := filelist.NewFileList()
|
||||||
fileInfo, err := os.ReadDir(h.path)
|
fileInfo, err := os.ReadDir(h.path)
|
||||||
|
@@ -26,7 +26,7 @@ func New(filePath string) *HookFiles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *HookFiles) List() (*filelist.FileList, error) {
|
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()
|
files := filelist.NewFileList()
|
||||||
fileInfo, err := os.ReadDir(h.filePath)
|
fileInfo, err := os.ReadDir(h.filePath)
|
||||||
|
@@ -9,19 +9,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type HookScripts struct {
|
type HookScripts struct {
|
||||||
|
destPath string
|
||||||
scriptsDir string
|
scriptsDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new HookScripts that will use the given path to provide a list
|
// New returns a new HookScripts that will use the given path to provide a list
|
||||||
// of script files.
|
// of script files. The destination for each script it set to destPath, using
|
||||||
func New(scriptsDir string) *HookScripts {
|
// the original file name.
|
||||||
|
func New(scriptsDir string, destPath string) *HookScripts {
|
||||||
return &HookScripts{
|
return &HookScripts{
|
||||||
|
destPath: destPath,
|
||||||
scriptsDir: scriptsDir,
|
scriptsDir: scriptsDir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HookScripts) List() (*filelist.FileList, error) {
|
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()
|
files := filelist.NewFileList()
|
||||||
|
|
||||||
@@ -32,7 +35,8 @@ func (h *HookScripts) List() (*filelist.FileList, error) {
|
|||||||
}
|
}
|
||||||
for _, file := range fileInfo {
|
for _, file := range fileInfo {
|
||||||
path := filepath.Join(h.scriptsDir, file.Name())
|
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
|
return files, nil
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ func New(modulesList []string, modulesListPath string) *Modules {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Modules) List() (*filelist.FileList, error) {
|
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()
|
kernVer, err := osutil.GetKernelVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -14,10 +14,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DeviceInfo struct {
|
type DeviceInfo struct {
|
||||||
InitfsCompression string
|
InitfsCompression string
|
||||||
MesaDriver string
|
InitfsExtraCompression string
|
||||||
ModulesInitfs string
|
MesaDriver string
|
||||||
UbootBoardname string
|
ModulesInitfs string
|
||||||
|
UbootBoardname string
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadDeviceinfo(file string) (DeviceInfo, error) {
|
func ReadDeviceinfo(file string) (DeviceInfo, error) {
|
||||||
|
@@ -21,6 +21,7 @@ func TestNameToField(t *testing.T) {
|
|||||||
{"deviceinfo_modules_initfs", "ModulesInitfs"},
|
{"deviceinfo_modules_initfs", "ModulesInitfs"},
|
||||||
{"modules_initfs", "ModulesInitfs"},
|
{"modules_initfs", "ModulesInitfs"},
|
||||||
{"deviceinfo_modules_initfs___", "ModulesInitfs"},
|
{"deviceinfo_modules_initfs___", "ModulesInitfs"},
|
||||||
|
{"deviceinfo_initfs_extra_compression", "InitfsExtraCompression"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, table := range tables {
|
for _, table := range tables {
|
||||||
|
Reference in New Issue
Block a user