Enable the use of common sysexts (#462)

This commit is contained in:
Itxaka 2025-04-14 15:42:20 +02:00 committed by GitHub
parent 6dedbfcc50
commit 2d238e7014
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -448,9 +448,9 @@ func (s *State) EnableSysExtensions(g *herd.Graph, opts ...herd.OpOption) error
return nil
}
// If we wanted to use a common dir for extensions used for both entries, here we would do something like:
// commonEntries, _ := os.ReadDir(s.path(fmt.Sprintf("%s/%s", cnst.SourceSysExtDir, "common")))
// entries = append(entries, commonEntries...)
// Common dir is always there for all states no matter what
commonEntries, _ := os.ReadDir(s.path(fmt.Sprintf("%s/%s", cnst.SourceSysExtDir, "common")))
entries = append(entries, commonEntries...)
for _, entry := range entries {
if !entry.IsDir() && filepath.Ext(entry.Name()) == ".raw" {
@ -465,6 +465,14 @@ func (s *State) EnableSysExtensions(g *herd.Graph, opts ...herd.OpOption) error
continue
}
}
// Check if it already exists with the same name
// This is because as we have the common dir, there could be a point in which the common dir and the
// specific boot state dir have the same file, and we dont want to fail at this point, just warn and continue
if _, err := os.Stat(filepath.Join(cnst.DestSysExtDir, entry.Name())); !os.IsNotExist(err) {
// If it exists, we can just skip it
internalUtils.Log.Warn().Str("file", filepath.Join(cnst.DestSysExtDir, entry.Name())).Msg("Skipping sysextension as its already enabled")
continue
}
// it has to link to the final dir after initramfs, so we avoid setting s.path here for the target
err = os.Symlink(filepath.Join(dir, entry.Name()), filepath.Join(cnst.DestSysExtDir, entry.Name()))
if err != nil {