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:
35
main.go
35
main.go
@@ -436,11 +436,16 @@ func getFdeFiles(devinfo deviceinfo.DeviceInfo) (files []string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHookScripts() (files []string) {
|
func getHookScripts(scriptsdir string) (files []string, err error) {
|
||||||
scripts, _ := filepath.Glob("/etc/postmarketos-mkinitfs/hooks/*.sh")
|
fileInfo, err := os.ReadDir(scriptsdir)
|
||||||
files = append(files, scripts...)
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("getHookScripts: unable to read hook script dir: %w", err)
|
||||||
return
|
}
|
||||||
|
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) {
|
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") {
|
if exists("/usr/bin/osk-sdl") {
|
||||||
log.Println("- Including FDE support")
|
log.Println("- Including FDE support")
|
||||||
if fdeFiles, err := getFdeFiles(devinfo); err != nil {
|
if fdeFiles, err := getFdeFiles(devinfo); err != nil {
|
||||||
@@ -516,9 +530,14 @@ func getInitfsFiles(devinfo deviceinfo.DeviceInfo) (files []string, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("- Including hook scripts")
|
if exists("/etc/postmarketos-mkinitfs/hooks") {
|
||||||
hookScripts := getHookScripts()
|
log.Println("- Including hook scripts")
|
||||||
files = append(files, hookScripts...)
|
if hookScripts, err := getHookScripts("/etc/postmarketos-mkinitfs/hooks"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
files = append(files, hookScripts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("- Including required binaries")
|
log.Println("- Including required binaries")
|
||||||
if filelist, err := getFiles(requiredFiles, true); err != nil {
|
if filelist, err := getFiles(requiredFiles, true); err != nil {
|
||||||
|
Reference in New Issue
Block a user