From d52cc16c889ec2cf24ea75ff31fb53784ec94fff Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 11 Jan 2023 20:26:08 +0100 Subject: [PATCH] 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. --- main.go | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 231be4e..05451a6 100644 --- a/main.go +++ b/main.go @@ -218,20 +218,30 @@ 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 - for _, libdir := range libdirs { - path := filepath.Join(libdir, lib) - if _, err := os.Stat(path); err == nil { - binaryDepFiles, err := getBinaryDeps(path) - if err != nil { - return files, err + 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 { + 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 {