diff --git a/lepton/image.go b/lepton/image.go index f31548f0..6a4f0c61 100644 --- a/lepton/image.go +++ b/lepton/image.go @@ -344,7 +344,7 @@ func BuildManifest(c *types.Config) (*fs.Manifest, error) { return nil, errors.Wrap(err, 1) } - deps, err := getSharedLibs(c.TargetRoot, c.Program) + deps, err := getSharedLibs(c.TargetRoot, c.Program, c) if err != nil { return nil, errors.Wrap(err, 1) } diff --git a/lepton/ldd_darwin.go b/lepton/ldd_darwin.go index ca3e5733..dbdaa20f 100644 --- a/lepton/ldd_darwin.go +++ b/lepton/ldd_darwin.go @@ -11,6 +11,7 @@ import ( "github.com/nanovms/ops/constants" "github.com/nanovms/ops/fs" "github.com/nanovms/ops/log" + "github.com/nanovms/ops/types" ) // GetElfFileInfo returns an object with elf information of the path program @@ -75,7 +76,7 @@ func findLib(targetRoot string, origin string, libDirs []string, path string) (s return "", "", os.ErrNotExist } -func _getSharedLibs(libs map[string]string, targetRoot string, path string) error { +func _getSharedLibs(libs map[string]string, targetRoot string, path string, c *types.Config) error { path, err := fs.LookupFile(targetRoot, path) if err != nil { return errors.WrapPrefix(err, path, 0) @@ -120,6 +121,11 @@ func _getSharedLibs(libs map[string]string, targetRoot string, path string) erro libDirs = append(libDirs, strings.Split(d, ":")...) } } + + // 3. read LD_LIBRARY_PATH from config + if configEnv, hasLibPaths := c.Env["LD_LIBRARY_PATH"]; hasLibPaths { + libDirs = append(libDirs, strings.Split(configEnv, ":")...) + } libDirs = append(libDirs, "/lib64", "/lib/x86_64-linux-gnu", "/usr/lib", "/usr/lib64", "/usr/lib/x86_64-linux-gnu") dtNeeded, err := fd.DynString(elf.DT_NEEDED) @@ -141,7 +147,7 @@ func _getSharedLibs(libs map[string]string, targetRoot string, path string) erro libs[libpath] = absLibpath // append library dependencies - err := _getSharedLibs(libs, targetRoot, absLibpath) + err := _getSharedLibs(libs, targetRoot, absLibpath, c) if err != nil { return err } @@ -166,7 +172,7 @@ func _getSharedLibs(libs map[string]string, targetRoot string, path string) erro } if _, ok := libs[ipath]; !ok { libs[ipath] = absIpath - err := _getSharedLibs(libs, targetRoot, ipath) + err := _getSharedLibs(libs, targetRoot, ipath, c) if err != nil { return err } @@ -176,9 +182,9 @@ func _getSharedLibs(libs map[string]string, targetRoot string, path string) erro return nil } -func getSharedLibs(targetRoot string, path string) (map[string]string, error) { +func getSharedLibs(targetRoot string, path string, c *types.Config) (map[string]string, error) { libs := make(map[string]string) - err := _getSharedLibs(libs, targetRoot, path) + err := _getSharedLibs(libs, targetRoot, path, c) if err != nil { return nil, err } diff --git a/lepton/ldd_freebsd.go b/lepton/ldd_freebsd.go index 60883145..e336e3c6 100644 --- a/lepton/ldd_freebsd.go +++ b/lepton/ldd_freebsd.go @@ -3,6 +3,7 @@ package lepton import ( "debug/elf" "errors" + "github.com/nanovms/ops/types" ) // GetElfFileInfo returns an object with elf information of the path program @@ -22,7 +23,7 @@ func IsDynamicLinked(efd *elf.File) bool { // works only on linux, need to // replace looking up in dynamic section in ELF -func getSharedLibs(targetRoot string, path string) (map[string]string, error) { +func getSharedLibs(targetRoot string, path string, c *types.Config) (map[string]string, error) { return nil, nil } diff --git a/lepton/ldd_linux.go b/lepton/ldd_linux.go index 5d8458ba..3f6177b8 100644 --- a/lepton/ldd_linux.go +++ b/lepton/ldd_linux.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/go-errors/errors" + "github.com/nanovms/ops/types" ) // GetElfFileInfo returns an object with elf information of the path program @@ -47,7 +48,7 @@ func IsDynamicLinked(efd *elf.File) bool { // works only on linux, need to // replace looking up in dynamic section in ELF -func getSharedLibs(targetRoot string, path string) (map[string]string, error) { +func getSharedLibs(targetRoot string, path string, c *types.Config) (map[string]string, error) { var notExistLib []string var absTargetRoot string if targetRoot != "" { diff --git a/lepton/ldd_windows.go b/lepton/ldd_windows.go index 6832031c..4851d1c5 100644 --- a/lepton/ldd_windows.go +++ b/lepton/ldd_windows.go @@ -3,6 +3,7 @@ package lepton import ( "debug/elf" "errors" + "github.com/nanovms/ops/types" ) // IsDynamicLinked stub @@ -21,7 +22,7 @@ func GetElfFileInfo(path string) (*elf.File, error) { } // stub -func getSharedLibs(targetRoot string, path string) (map[string]string, error) { +func getSharedLibs(targetRoot string, path string, c *types.Config) (map[string]string, error) { var deps = make(map[string]string) return deps, nil }