feat: explicit list of source files
This commit is contained in:
		| @@ -132,11 +132,15 @@ type Patch struct { | |||||||
|  |  | ||||||
| // Artifact is for .out-of-tree.toml | // Artifact is for .out-of-tree.toml | ||||||
| type Artifact struct { | type Artifact struct { | ||||||
| 	Name       string | 	Name string | ||||||
| 	Type       ArtifactType | 	Type ArtifactType | ||||||
| 	TestFiles  []FileTransfer |  | ||||||
| 	SourcePath string | 	SourcePath  string | ||||||
| 	Targets    []Target | 	SourceFiles []string | ||||||
|  |  | ||||||
|  | 	TestFiles []FileTransfer | ||||||
|  |  | ||||||
|  | 	Targets []Target | ||||||
|  |  | ||||||
| 	Script string | 	Script string | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import ( | |||||||
| 	"math/rand" | 	"math/rand" | ||||||
| 	"os" | 	"os" | ||||||
| 	"os/exec" | 	"os/exec" | ||||||
|  | 	"path/filepath" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| @@ -112,7 +113,11 @@ func Build(flog zerolog.Logger, tmp string, ka Artifact, | |||||||
|  |  | ||||||
| 	outdir = tmp + "/source" | 	outdir = tmp + "/source" | ||||||
|  |  | ||||||
| 	err = copy.Copy(ka.SourcePath, outdir) | 	if len(ka.SourceFiles) == 0 { | ||||||
|  | 		err = copy.Copy(ka.SourcePath, outdir) | ||||||
|  | 	} else { | ||||||
|  | 		err = CopyFiles(ka.SourcePath, ka.SourceFiles, outdir) | ||||||
|  | 	} | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| @@ -226,6 +231,35 @@ type Result struct { | |||||||
| 	InternalErrorString string | 	InternalErrorString string | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func CopyFiles(path string, files []string, dest string) (err error) { | ||||||
|  | 	err = os.MkdirAll(dest, os.ModePerm) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	for _, sf := range files { | ||||||
|  | 		if sf[0] == '/' { | ||||||
|  | 			err = CopyFile(sf, filepath.Join(dest, filepath.Base(sf))) | ||||||
|  | 			if err != nil { | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 			continue | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		err = os.MkdirAll(filepath.Join(dest, filepath.Dir(sf)), os.ModePerm) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		err = CopyFile(filepath.Join(path, sf), filepath.Join(dest, sf)) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  |  | ||||||
| func CopyFile(sourcePath, destinationPath string) (err error) { | func CopyFile(sourcePath, destinationPath string) (err error) { | ||||||
| 	sourceFile, err := os.Open(sourcePath) | 	sourceFile, err := os.Open(sourcePath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user