Skip to content

Commit be415a8

Browse files
authored
Merge pull request #1326 from elezar/unconditional-ldcache
Always update the ldcache in the container
2 parents b179712 + 31e6830 commit be415a8

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

internal/ldconfig/ldconfig.go

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,11 @@ func (l *Ldconfig) UpdateLDCache(directories ...string) error {
8080
// Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
8181
// be configured to use a different config file by default.
8282
"-f", "/etc/ld.so.conf",
83+
"-C", "/etc/ld.so.cache",
8384
}
8485

85-
if l.ldcacheExists() {
86-
args = append(args, "-C", "/etc/ld.so.cache")
87-
} else {
88-
args = append(args, "-N")
89-
}
90-
91-
// If the ld.so.conf.d directory exists, we create a config file there
92-
// containing the required directories, otherwise we add the specified
93-
// directories to the ldconfig command directly.
94-
if l.ldsoconfdDirectoryExists() {
95-
err := createLdsoconfdFile(ldsoconfdFilenamePattern, directories...)
96-
if err != nil {
97-
return fmt.Errorf("failed to update ld.so.conf.d: %w", err)
98-
}
99-
} else {
100-
args = append(args, directories...)
86+
if err := createLdsoconfdFile(ldsoconfdFilenamePattern, directories...); err != nil {
87+
return fmt.Errorf("failed to update ld.so.conf.d: %w", err)
10188
}
10289

10390
return SafeExec(ldconfigPath, args, nil)
@@ -126,21 +113,6 @@ func (l *Ldconfig) prepareRoot() (string, error) {
126113
return ldconfigPath, nil
127114
}
128115

129-
func (l *Ldconfig) ldcacheExists() bool {
130-
if _, err := os.Stat("/etc/ld.so.cache"); err != nil && os.IsNotExist(err) {
131-
return false
132-
}
133-
return true
134-
}
135-
136-
func (l *Ldconfig) ldsoconfdDirectoryExists() bool {
137-
info, err := os.Stat("/etc/ld.so.conf.d")
138-
if os.IsNotExist(err) {
139-
return false
140-
}
141-
return info.IsDir()
142-
}
143-
144116
// createLdsoconfdFile creates a file at /etc/ld.so.conf.d/.
145117
// The file is created at /etc/ld.so.conf.d/{{ .pattern }} using `CreateTemp` and
146118
// contains the specified directories on each line.

0 commit comments

Comments
 (0)