Compare commits
7 Commits
2.1.1
...
recurse-ho
Author | SHA1 | Date | |
---|---|---|---|
|
b54044a605 | ||
|
f0544999db | ||
|
8fac3004a6 | ||
|
a15a3ad781 | ||
|
1e8580a0a1 | ||
|
e6ee43826d | ||
|
7bdd68800d |
@@ -152,10 +152,7 @@ func generateArchive(name string, format archive.CompressFormat, level archive.C
|
|||||||
log.Printf("- Using compression format %s with level %q\n", format, level)
|
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 := archive.New(format, level)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
fs := initramfs.New(features)
|
fs := initramfs.New(features)
|
||||||
if err := a.AddItems(fs); err != nil {
|
if err := a.AddItems(fs); err != nil {
|
||||||
|
@@ -24,6 +24,15 @@ is purely to generate the archive(s). mkinitfs does call *boot-deploy* after
|
|||||||
creating the archive(s), in order to install/deploy them and any other relevant
|
creating the archive(s), in order to install/deploy them and any other relevant
|
||||||
boot-related items onto the system.
|
boot-related items onto the system.
|
||||||
|
|
||||||
|
Design goals of this project are:
|
||||||
|
|
||||||
|
- Support as many distros as possible
|
||||||
|
- Simplify configuration, while still giving multiple opportunities to set or override defaults
|
||||||
|
- Execute an external app to do any boot install/setup finalization
|
||||||
|
- One such app is here: https://gitlab.com/postmarketOS/boot-deploy
|
||||||
|
- But implementation can be anything, see the section on *BOOT-DEPLOY*
|
||||||
|
for more info
|
||||||
|
|
||||||
# DEVICEINFO
|
# DEVICEINFO
|
||||||
|
|
||||||
The canonical deviceinfo "specification" is at
|
The canonical deviceinfo "specification" is at
|
||||||
@@ -117,6 +126,30 @@ create/manage. mkinitfs reads configuration from */usr/share/mkinitfs* first, an
|
|||||||
directories to create within the initramfs. There is no *-extra* variant,
|
directories to create within the initramfs. There is no *-extra* variant,
|
||||||
since directories are of negligible size.
|
since directories are of negligible size.
|
||||||
|
|
||||||
|
# BOOT-DEPLOY
|
||||||
|
|
||||||
|
After generating archives, mkinitfs will execute *boot-deploy*, using *$PATH* to
|
||||||
|
search for the app. The following commandline options are passed to it:
|
||||||
|
|
||||||
|
*-i* <initramfs filename>
|
||||||
|
|
||||||
|
Currently this is hardcoded to be "initramfs"
|
||||||
|
|
||||||
|
*-k* <kernel filename>
|
||||||
|
|
||||||
|
*-d* <work directory>
|
||||||
|
|
||||||
|
Path to the directory containing the build artifacts from mkinitfs.
|
||||||
|
|
||||||
|
*-o* <destination directory>
|
||||||
|
|
||||||
|
Path to the directory that boot-deploy should use as its root when
|
||||||
|
installing files.
|
||||||
|
|
||||||
|
*initramfs-extra*
|
||||||
|
|
||||||
|
This string is the filename of the initramfs-extra archive.
|
||||||
|
|
||||||
# AUTHORS
|
# AUTHORS
|
||||||
|
|
||||||
*Clayton Craft* <clayton@craftyguy.net>
|
*Clayton Craft* <clayton@craftyguy.net>
|
||||||
|
@@ -51,7 +51,7 @@ type Archive struct {
|
|||||||
items archiveItems
|
items archiveItems
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(format CompressFormat, level CompressLevel) (*Archive, error) {
|
func New(format CompressFormat, level CompressLevel) *Archive {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
archive := &Archive{
|
archive := &Archive{
|
||||||
cpioWriter: cpio.NewWriter(buf),
|
cpioWriter: cpio.NewWriter(buf),
|
||||||
@@ -60,7 +60,7 @@ func New(format CompressFormat, level CompressLevel) (*Archive, error) {
|
|||||||
compress_level: level,
|
compress_level: level,
|
||||||
}
|
}
|
||||||
|
|
||||||
return archive, nil
|
return archive
|
||||||
}
|
}
|
||||||
|
|
||||||
type archiveItem struct {
|
type archiveItem struct {
|
||||||
@@ -184,10 +184,11 @@ func (archive *Archive) Write(path string, mode os.FileMode) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds the given items in the map to the archive. The map format is {source path:dest path}.
|
// AddItems adds the given items in the map to the archive. The map format is
|
||||||
// Internally this just calls AddItem on each key,value pair in the map.
|
// {source path:dest path}. Internally this just calls AddItem on each
|
||||||
func (archive *Archive) AddItems(f filelist.FileLister) error {
|
// key,value pair in the map.
|
||||||
list, err := f.List()
|
func (archive *Archive) AddItems(flister filelist.FileLister) error {
|
||||||
|
list, err := flister.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,12 @@
|
|||||||
package filelist
|
package filelist
|
||||||
|
|
||||||
import "sync"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/misc"
|
||||||
|
)
|
||||||
|
|
||||||
type FileLister interface {
|
type FileLister interface {
|
||||||
List() (*FileList, error)
|
List() (*FileList, error)
|
||||||
@@ -45,6 +51,26 @@ func (f *FileList) Import(src *FileList) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FileList) AddGlobbed(src string, dest string) error {
|
||||||
|
fFiles, err := misc.GetFiles([]string{src}, true)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to add %q: %w", src, err)
|
||||||
|
}
|
||||||
|
// loop over all returned files from GetFile
|
||||||
|
for _, file := range fFiles {
|
||||||
|
if len(fFiles) > 1 {
|
||||||
|
// Glob with arbitrary subdirectories, so we need to
|
||||||
|
// remove the src path and prepend the dest path
|
||||||
|
f.Add(file, filepath.Join(dest, file[len(src):]))
|
||||||
|
} else {
|
||||||
|
// dest path specified, and only 1 file
|
||||||
|
f.Add(file, dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// iterate through the list and and send each one as a new File over the
|
// iterate through the list and and send each one as a new File over the
|
||||||
// returned channel
|
// returned channel
|
||||||
func (f *FileList) IterItems() <-chan File {
|
func (f *FileList) IterItems() <-chan File {
|
||||||
|
@@ -10,7 +10,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/filelist"
|
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/filelist"
|
||||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/misc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type HookFiles struct {
|
type HookFiles struct {
|
||||||
@@ -60,22 +59,13 @@ func slurpFiles(fd io.Reader) (*filelist.FileList, error) {
|
|||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
src, dest, has_dest := strings.Cut(s.Text(), ":")
|
src, dest, has_dest := strings.Cut(s.Text(), ":")
|
||||||
|
|
||||||
fFiles, err := misc.GetFiles([]string{src}, true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("unable to add %q: %w", src, err)
|
|
||||||
}
|
|
||||||
// loop over all returned files from GetFile
|
|
||||||
for _, file := range fFiles {
|
|
||||||
if !has_dest {
|
if !has_dest {
|
||||||
files.Add(file, file)
|
dest = src
|
||||||
} else if len(fFiles) > 1 {
|
|
||||||
// Don't support specifying dest if src was a glob
|
|
||||||
// NOTE: this could support this later...
|
|
||||||
files.Add(file, file)
|
|
||||||
} else {
|
|
||||||
// dest path specified, and only 1 file
|
|
||||||
files.Add(file, dest)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err := files.AddGlobbed(src, dest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,8 +35,13 @@ 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())
|
||||||
|
if file.IsDir() {
|
||||||
|
log.Printf("-- Including dir %s\n", path)
|
||||||
|
files.AddGlobbed(filepath.Join(path, "*"), filepath.Join(h.destPath, file.Name()))
|
||||||
|
} else {
|
||||||
log.Printf("-- Including script: %s\n", path)
|
log.Printf("-- Including script: %s\n", path)
|
||||||
files.Add(path, filepath.Join(h.destPath, file.Name()))
|
files.Add(path, filepath.Join(h.destPath, file.Name()))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return files, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
|
@@ -70,7 +70,6 @@ func (m *Modules) List() (*filelist.FileList, error) {
|
|||||||
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)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("-- Unable to find dir, skipping...")
|
|
||||||
return files, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
for _, file := range fileInfo {
|
for _, file := range fileInfo {
|
||||||
|
Reference in New Issue
Block a user