mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-04-02 12:00:18 +00:00
Move resolution of host LDConfig to config package
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
4088430fc1
commit
15645e6cd5
@ -20,7 +20,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
@ -115,7 +114,7 @@ func (m command) run(c *cli.Context, cfg *options) error {
|
||||
return fmt.Errorf("failed to determined container root: %v", err)
|
||||
}
|
||||
|
||||
ldconfigPath := m.resolveLDConfigPath(cfg.ldconfigPath)
|
||||
ldconfigPath := config.ResolveLDConfigPathOnHost(cfg.ldconfigPath)
|
||||
args := []string{
|
||||
filepath.Base(ldconfigPath),
|
||||
// Run ldconfig in the container root directory on the host.
|
||||
@ -146,10 +145,3 @@ func (m command) run(c *cli.Context, cfg *options) error {
|
||||
|
||||
return m.Exec(ldconfigPath, args, nil)
|
||||
}
|
||||
|
||||
// resolveLDConfigPath determines the LDConfig path to use for the system.
|
||||
// On systems such as Ubuntu where `/sbin/ldconfig` is a wrapper around
|
||||
// /sbin/ldconfig.real, the latter is returned.
|
||||
func (m command) resolveLDConfigPath(path string) string {
|
||||
return strings.TrimPrefix(config.NormalizeLDConfigPath("@"+path), "@")
|
||||
}
|
||||
|
@ -94,3 +94,10 @@ func (p ldconfigPath) normalize() ldconfigPath {
|
||||
func NormalizeLDConfigPath(path string) string {
|
||||
return string(ldconfigPath(path).normalize())
|
||||
}
|
||||
|
||||
// ResolveLDConfigPathOnHost determines the LDConfig path to use for the system.
|
||||
// The ldconfig path is normalized (i.e. /sbin/ldconfig or /sbin/ldconfig.real is used as required)
|
||||
// and is guaranteed to resolve on the host.
|
||||
func ResolveLDConfigPathOnHost(path string) string {
|
||||
return strings.TrimPrefix(NormalizeLDConfigPath("@"+path), "@")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user