mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 17:26:28 +00:00
Do not use filepath.Join if constructing LinuxKit paths
This will do the wrong thing on Windows, and construct paths with \. fix #142 Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
parent
7a549fda07
commit
4da3c09e19
@ -10,7 +10,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -132,7 +131,7 @@ func outputImage(image Image, section string, prefix string, m Moby, idMap map[s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to create config for %s: %v", image.Image, err)
|
return fmt.Errorf("Failed to create config for %s: %v", image.Image, err)
|
||||||
}
|
}
|
||||||
path := filepath.Join("containers", section, prefix+image.Name)
|
path := path.Join("containers", section, prefix+image.Name)
|
||||||
readonly := oci.Root.Readonly
|
readonly := oci.Root.Readonly
|
||||||
err = ImageBundle(path, image.Image, config, iw, useTrust, pull, readonly)
|
err = ImageBundle(path, image.Image, config, iw, useTrust, pull, readonly)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
@ -189,8 +189,8 @@ func ImageTar(image, prefix string, tw tarWriter, trust bool, pull bool, resolv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ImageBundle produces an OCI bundle at the given path in a tarball, given an image and a config.json
|
// ImageBundle produces an OCI bundle at the given path in a tarball, given an image and a config.json
|
||||||
func ImageBundle(path string, image string, config []byte, tw tarWriter, trust bool, pull bool, readonly bool) error {
|
func ImageBundle(prefix string, image string, config []byte, tw tarWriter, trust bool, pull bool, readonly bool) error {
|
||||||
log.Debugf("image bundle: %s %s cfg: %s", path, image, string(config))
|
log.Debugf("image bundle: %s %s cfg: %s", prefix, image, string(config))
|
||||||
|
|
||||||
// if read only, just unpack in rootfs/ but otherwise set up for overlay
|
// if read only, just unpack in rootfs/ but otherwise set up for overlay
|
||||||
rootfs := "rootfs"
|
rootfs := "rootfs"
|
||||||
@ -198,11 +198,11 @@ func ImageBundle(path string, image string, config []byte, tw tarWriter, trust b
|
|||||||
rootfs = "lower"
|
rootfs = "lower"
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ImageTar(image, filepath.Join(path, rootfs)+"/", tw, trust, pull, ""); err != nil {
|
if err := ImageTar(image, path.Join(prefix, rootfs)+"/", tw, trust, pull, ""); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hdr := &tar.Header{
|
hdr := &tar.Header{
|
||||||
Name: filepath.Join(path, "config.json"),
|
Name: path.Join(prefix, "config.json"),
|
||||||
Mode: 0644,
|
Mode: 0644,
|
||||||
Size: int64(len(config)),
|
Size: int64(len(config)),
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ func ImageBundle(path string, image string, config []byte, tw tarWriter, trust b
|
|||||||
if !readonly {
|
if !readonly {
|
||||||
// add a tmp directory to be used as a mount point for tmpfs for upper, work
|
// add a tmp directory to be used as a mount point for tmpfs for upper, work
|
||||||
hdr = &tar.Header{
|
hdr = &tar.Header{
|
||||||
Name: filepath.Join(path, "tmp"),
|
Name: path.Join(prefix, "tmp"),
|
||||||
Mode: 0755,
|
Mode: 0755,
|
||||||
Typeflag: tar.TypeDir,
|
Typeflag: tar.TypeDir,
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ func ImageBundle(path string, image string, config []byte, tw tarWriter, trust b
|
|||||||
}
|
}
|
||||||
// add rootfs as merged mount point
|
// add rootfs as merged mount point
|
||||||
hdr = &tar.Header{
|
hdr = &tar.Header{
|
||||||
Name: filepath.Join(path, "rootfs"),
|
Name: path.Join(prefix, "rootfs"),
|
||||||
Mode: 0755,
|
Mode: 0755,
|
||||||
Typeflag: tar.TypeDir,
|
Typeflag: tar.TypeDir,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user