getInitfsExtraFiles: add scripts from hooks-extra (MR 27)
Put scripts from /etc/postmarketos-mkinitfs/hooks-extra into the extra initramfs instead of the regular one, similar to how it is possible with files listed in /etc/postmarketos-mkinitfs/files-extra. This way we will be able to launch hooks not only very early in the initramfs as it's currently the case. But also later on after the initramfs-extra was extracted, and more files are available. ondev2 will make use of this feature.
This commit is contained in:
31
main.go
31
main.go
@@ -436,11 +436,16 @@ func getFdeFiles(devinfo deviceinfo.DeviceInfo) (files []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func getHookScripts() (files []string) {
|
||||
scripts, _ := filepath.Glob("/etc/postmarketos-mkinitfs/hooks/*.sh")
|
||||
files = append(files, scripts...)
|
||||
|
||||
return
|
||||
func getHookScripts(scriptsdir string) (files []string, err error) {
|
||||
fileInfo, err := os.ReadDir(scriptsdir)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getHookScripts: unable to read hook script dir: %w", err)
|
||||
}
|
||||
for _, file := range fileInfo {
|
||||
path := filepath.Join(scriptsdir, file.Name())
|
||||
files = append(files, path)
|
||||
}
|
||||
return files, nil
|
||||
}
|
||||
|
||||
func getInitfsExtraFiles(devinfo deviceinfo.DeviceInfo) (files []string, err error) {
|
||||
@@ -476,6 +481,15 @@ func getInitfsExtraFiles(devinfo deviceinfo.DeviceInfo) (files []string, err err
|
||||
}
|
||||
}
|
||||
|
||||
if exists("/etc/postmarketos-mkinitfs/hooks-extra") {
|
||||
log.Println("- Including extra hook scripts")
|
||||
if hookScripts, err := getHookScripts("/etc/postmarketos-mkinitfs/hooks-extra"); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
files = append(files, hookScripts...)
|
||||
}
|
||||
}
|
||||
|
||||
if exists("/usr/bin/osk-sdl") {
|
||||
log.Println("- Including FDE support")
|
||||
if fdeFiles, err := getFdeFiles(devinfo); err != nil {
|
||||
@@ -516,9 +530,14 @@ func getInitfsFiles(devinfo deviceinfo.DeviceInfo) (files []string, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if exists("/etc/postmarketos-mkinitfs/hooks") {
|
||||
log.Println("- Including hook scripts")
|
||||
hookScripts := getHookScripts()
|
||||
if hookScripts, err := getHookScripts("/etc/postmarketos-mkinitfs/hooks"); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
files = append(files, hookScripts...)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("- Including required binaries")
|
||||
if filelist, err := getFiles(requiredFiles, true); err != nil {
|
||||
|
Reference in New Issue
Block a user