mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-05-03 11:41:35 +00:00
Move resolution of LDConfig to utils package
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
1e7a07a3e7
commit
54aee23aad
@ -20,12 +20,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/utils"
|
"github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/utils"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/config"
|
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/oci"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/oci"
|
||||||
)
|
)
|
||||||
@ -115,7 +113,7 @@ func (m command) run(c *cli.Context, cfg *options) error {
|
|||||||
return fmt.Errorf("failed to determined container root: %v", err)
|
return fmt.Errorf("failed to determined container root: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ldconfigPath := m.resolveLDConfigPath(cfg.ldconfigPath)
|
ldconfigPath := utils.ResolveHostLDConfigPath(cfg.ldconfigPath)
|
||||||
args := []string{filepath.Base(ldconfigPath)}
|
args := []string{filepath.Base(ldconfigPath)}
|
||||||
if containerRootDir != "" {
|
if containerRootDir != "" {
|
||||||
args = append(args, "-r", containerRootDir)
|
args = append(args, "-r", containerRootDir)
|
||||||
@ -146,10 +144,3 @@ func (m command) run(c *cli.Context, cfg *options) error {
|
|||||||
|
|
||||||
return m.Exec(ldconfigPath, args, nil)
|
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), "@")
|
|
||||||
}
|
|
||||||
|
30
cmd/nvidia-cdi-hook/utils/ldconfig.go
Normal file
30
cmd/nvidia-cdi-hook/utils/ldconfig.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
**/
|
||||||
|
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResolveHostLDConfigPath 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 ResolveHostLDConfigPath(path string) string {
|
||||||
|
return strings.TrimPrefix(config.NormalizeLDConfigPath("@"+path), "@")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user