getBinaryDeps: search in /usr/lib/expect* (MR 28)

Instead of only searching for shared libraries in /usr/lib and /lib,
also search in /usr/lib/expect* (currently the expect binary links
against /usr/lib/expect5.45.4/libexpect5.45.4.so).

I've also considered searching /usr/lib recursively, but that would be a
major performance hit.

Expect gets added to the initramfs-extra in a script that runs the
ondev2 testsuite inside qemu.
This commit is contained in:
Oliver Smith
2023-01-11 20:26:08 +01:00
committed by Clayton Craft
parent 112b572dc2
commit d52cc16c88

14
main.go
View File

@@ -218,9 +218,18 @@ func getBinaryDeps(file string) (files []string, err error) {
return files, err
}
libdirs := []string{"/usr/lib", "/lib"}
// we don't recursively search these paths for performance reasons
libdirGlobs := []string{
"/usr/lib",
"/lib",
"/usr/lib/expect*",
}
for _, lib := range libs {
found := false
findDepLoop:
for _, libdirGlob := range libdirGlobs {
libdirs, _ := filepath.Glob(libdirGlob)
for _, libdir := range libdirs {
path := filepath.Join(libdir, lib)
if _, err := os.Stat(path); err == nil {
@@ -231,7 +240,8 @@ func getBinaryDeps(file string) (files []string, err error) {
files = append(files, binaryDepFiles...)
files = append(files, path)
found = true
break
break findDepLoop
}
}
}
if !found {