diff --git a/CHANGELOG.md b/CHANGELOG.md index cd42ef03..4e814081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## v1.13.1 -* Bump version to 1.13.1 +* Update `update-ldcache` hook to only update ldcache if it exists. +* Update `update-ldcache` hook to create `/etc/ld.so.conf.d` folder if it doesn't exist. ## v1.13.0 diff --git a/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go b/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go index f94cd513..4ced4f89 100644 --- a/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go +++ b/cmd/nvidia-ctk/hook/update-ldcache/update-ldcache.go @@ -84,6 +84,12 @@ func (m command) run(c *cli.Context, cfg *config) error { return fmt.Errorf("failed to determined container root: %v", err) } + _, err = os.Stat(filepath.Join(containerRoot, "/etc/ld.so.cache")) + if err != nil && os.IsNotExist(err) { + m.logger.Debugf("No ld.so.cache found, skipping update") + return nil + } + err = m.createConfig(containerRoot, cfg.folders.Value()) if err != nil { return fmt.Errorf("failed to update ld.so.conf: %v", err) @@ -105,6 +111,10 @@ func (m command) createConfig(root string, folders []string) error { return nil } + if err := os.MkdirAll(filepath.Join(root, "/etc/ld.so.conf.d"), 0755); err != nil { + return fmt.Errorf("failed to create ld.so.conf.d: %v", err) + } + configFile, err := os.CreateTemp(filepath.Join(root, "/etc/ld.so.conf.d"), "nvcr-*.conf") if err != nil { return fmt.Errorf("failed to create config file: %v", err)