mirror of
https://github.com/containers/podman.git
synced 2025-12-06 13:56:22 +08:00
Update buildah to current master
Vendor some changes to parsing code that we need for Podman. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
29
vendor/github.com/containers/buildah/imagebuildah/executor.go
generated
vendored
29
vendor/github.com/containers/buildah/imagebuildah/executor.go
generated
vendored
@@ -42,8 +42,8 @@ var builtinAllowedBuildArgs = map[string]bool{
|
||||
}
|
||||
|
||||
// Executor is a buildah-based implementation of the imagebuilder.Executor
|
||||
// interface. It coordinates the entire build by using one StageExecutors to
|
||||
// handle each stage of the build.
|
||||
// interface. It coordinates the entire build by using one or more
|
||||
// StageExecutors to handle each stage of the build.
|
||||
type Executor struct {
|
||||
stages map[string]*StageExecutor
|
||||
store storage.Store
|
||||
@@ -248,26 +248,36 @@ func (b *Executor) getImageHistory(ctx context.Context, imageID string) ([]v1.Hi
|
||||
return oci.History, nil
|
||||
}
|
||||
|
||||
// getCreatedBy returns the command the image at node will be created by.
|
||||
func (b *Executor) getCreatedBy(node *parser.Node) string {
|
||||
// getCreatedBy returns the command the image at node will be created by. If
|
||||
// the passed-in CompositeDigester is not nil, it is assumed to have the digest
|
||||
// information for the content if the node is ADD or COPY.
|
||||
func (b *Executor) getCreatedBy(node *parser.Node, addedContentDigest string) string {
|
||||
if node == nil {
|
||||
return "/bin/sh"
|
||||
}
|
||||
if node.Value == "run" {
|
||||
switch strings.ToUpper(node.Value) {
|
||||
case "RUN":
|
||||
buildArgs := b.getBuildArgs()
|
||||
if buildArgs != "" {
|
||||
return "|" + strconv.Itoa(len(strings.Split(buildArgs, " "))) + " " + buildArgs + " /bin/sh -c " + node.Original[4:]
|
||||
}
|
||||
return "/bin/sh -c " + node.Original[4:]
|
||||
case "ADD", "COPY":
|
||||
destination := node
|
||||
for destination.Next != nil {
|
||||
destination = destination.Next
|
||||
}
|
||||
return "/bin/sh -c #(nop) " + strings.ToUpper(node.Value) + " " + addedContentDigest + " in " + destination.Value + " "
|
||||
default:
|
||||
return "/bin/sh -c #(nop) " + node.Original
|
||||
}
|
||||
return "/bin/sh -c #(nop) " + node.Original
|
||||
}
|
||||
|
||||
// historyMatches returns true if a candidate history matches the history of our
|
||||
// base image (if we have one), plus the current instruction.
|
||||
// Used to verify whether a cache of the intermediate image exists and whether
|
||||
// to run the build again.
|
||||
func (b *Executor) historyMatches(baseHistory []v1.History, child *parser.Node, history []v1.History) bool {
|
||||
func (b *Executor) historyMatches(baseHistory []v1.History, child *parser.Node, history []v1.History, addedContentDigest string) bool {
|
||||
if len(baseHistory) >= len(history) {
|
||||
return false
|
||||
}
|
||||
@@ -297,7 +307,7 @@ func (b *Executor) historyMatches(baseHistory []v1.History, child *parser.Node,
|
||||
return false
|
||||
}
|
||||
}
|
||||
return history[len(baseHistory)].CreatedBy == b.getCreatedBy(child)
|
||||
return history[len(baseHistory)].CreatedBy == b.getCreatedBy(child, addedContentDigest)
|
||||
}
|
||||
|
||||
// getBuildArgs returns a string of the build-args specified during the build process
|
||||
@@ -406,13 +416,12 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
|
||||
// arg expansion, so if the previous stage
|
||||
// was named using argument values, we might
|
||||
// not record the right value here.
|
||||
rootfs := flag[7:]
|
||||
rootfs := strings.TrimPrefix(flag, "--from=")
|
||||
b.rootfsMap[rootfs] = true
|
||||
logrus.Debugf("rootfs: %q", rootfs)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
node = node.Next // next line
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user