Allow create-repo to source trees from remote repositories

This makes possible to create the repositorie from external ones,
It also required to address #26.

Fixes #26
This commit is contained in:
Ettore Di Giacinto
2021-04-15 12:25:34 +02:00
parent 9202bcbbbe
commit c27d4d258e
8 changed files with 218 additions and 34 deletions

View File

@@ -156,14 +156,20 @@ COPY . /`
// CreateArtifactForFile creates a new artifact from the given file
func CreateArtifactForFile(s string, opts ...func(*PackageArtifact)) (*PackageArtifact, error) {
if _, err := os.Stat(s); os.IsNotExist(err) {
return nil, errors.Wrap(err, "artifact path doesn't exist")
}
fileName := path.Base(s)
archive, err := LuetCfg.GetSystem().TempDir("archive")
if err != nil {
return nil, errors.Wrap(err, "error met while creating tempdir for "+s)
}
defer os.RemoveAll(archive) // clean up
helpers.CopyFile(s, filepath.Join(archive, fileName))
dst := filepath.Join(archive, fileName)
if err := helpers.CopyFile(s, dst); err != nil {
return nil, errors.Wrapf(err, "error while copying %s to %s", s, dst)
}
artifact, err := LuetCfg.GetSystem().TempDir("artifact")
if err != nil {
return nil, errors.Wrap(err, "error met while creating tempdir for "+s)