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

32
main.go
View File

@@ -218,20 +218,30 @@ func getBinaryDeps(file string) (files []string, err error) {
return files, err 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 { for _, lib := range libs {
found := false found := false
for _, libdir := range libdirs { findDepLoop:
path := filepath.Join(libdir, lib) for _, libdirGlob := range libdirGlobs {
if _, err := os.Stat(path); err == nil { libdirs, _ := filepath.Glob(libdirGlob)
binaryDepFiles, err := getBinaryDeps(path) for _, libdir := range libdirs {
if err != nil { path := filepath.Join(libdir, lib)
return files, err if _, err := os.Stat(path); err == nil {
binaryDepFiles, err := getBinaryDeps(path)
if err != nil {
return files, err
}
files = append(files, binaryDepFiles...)
files = append(files, path)
found = true
break findDepLoop
} }
files = append(files, binaryDepFiles...)
files = append(files, path)
found = true
break
} }
} }
if !found { if !found {