mirror of
https://github.com/mudler/luet.git
synced 2025-09-02 15:54:39 +00:00
Drop CompressedPath, or we don't have a way to compare checksums
Refers to #33
This commit is contained in:
@@ -69,14 +69,13 @@ func (i ArtifactIndex) CleanPath() ArtifactIndex {
|
|||||||
// which will consist in just of an repository.yaml which is just the repository structure with the list of package artifact.
|
// which will consist in just of an repository.yaml which is just the repository structure with the list of package artifact.
|
||||||
// In this way a generic client can fetch the packages and, after unpacking the tree, performing queries to install packages.
|
// In this way a generic client can fetch the packages and, after unpacking the tree, performing queries to install packages.
|
||||||
type PackageArtifact struct {
|
type PackageArtifact struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
CompressedPath string `json:"compressedpath"`
|
|
||||||
|
|
||||||
Dependencies []*PackageArtifact `json:"dependencies"`
|
Dependencies []*PackageArtifact `json:"dependencies"`
|
||||||
CompileSpec *LuetCompilationSpec `json:"compilationspec"`
|
CompileSpec *LuetCompilationSpec `json:"compilationspec"`
|
||||||
Checksums Checksums `json:"checksums"`
|
Checksums Checksums `json:"checksums"`
|
||||||
SourceAssertion solver.PackagesAssertions `json:"-"`
|
SourceAssertion solver.PackagesAssertions `json:"-"`
|
||||||
CompressionType CompressionImplementation `json:"compression"`
|
CompressionType CompressionImplementation `json:"compressiontype"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPackageArtifact(path string) Artifact {
|
func NewPackageArtifact(path string) Artifact {
|
||||||
@@ -233,7 +232,8 @@ func (a *PackageArtifact) Compress(src string, concurrency int) error {
|
|||||||
}
|
}
|
||||||
w.Close()
|
w.Close()
|
||||||
os.RemoveAll(a.Path) // Remove original
|
os.RemoveAll(a.Path) // Remove original
|
||||||
a.CompressedPath = gzipfile
|
// a.CompressedPath = gzipfile
|
||||||
|
a.Path = gzipfile
|
||||||
return nil
|
return nil
|
||||||
//a.Path = gzipfile
|
//a.Path = gzipfile
|
||||||
}
|
}
|
||||||
@@ -248,15 +248,16 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
|
|||||||
|
|
||||||
case GZip:
|
case GZip:
|
||||||
// Create the uncompressed archive
|
// Create the uncompressed archive
|
||||||
archive, err := os.Create(a.GetPath())
|
archive, err := os.Create(a.GetPath() + ".uncompressed")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(a.GetPath())
|
defer os.RemoveAll(a.GetPath() + ".uncompressed")
|
||||||
|
defer archive.Close()
|
||||||
|
|
||||||
original, err := os.Open(a.CompressedPath)
|
original, err := os.Open(a.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Wrap(err, "Cannot open "+a.Path)
|
||||||
}
|
}
|
||||||
defer original.Close()
|
defer original.Close()
|
||||||
|
|
||||||
@@ -269,10 +270,10 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
|
|||||||
|
|
||||||
_, err = io.Copy(archive, r)
|
_, err = io.Copy(archive, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Wrap(err, "Cannot copy to "+a.GetPath()+".uncompressed")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = helpers.Untar(a.GetPath(), dst, keepPerms)
|
err = helpers.Untar(a.GetPath()+".uncompressed", dst, keepPerms)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -283,13 +284,41 @@ func (a *PackageArtifact) Unpack(dst string, keepPerms bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *PackageArtifact) FileList() ([]string, error) {
|
func (a *PackageArtifact) FileList() ([]string, error) {
|
||||||
|
var tr *tar.Reader
|
||||||
|
switch a.CompressionType {
|
||||||
|
case None:
|
||||||
|
|
||||||
|
tarFile, err := os.Open(a.GetPath())
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, errors.Wrap(err, "Could not open package archive")
|
||||||
|
}
|
||||||
|
defer tarFile.Close()
|
||||||
|
tr = tar.NewReader(tarFile)
|
||||||
|
|
||||||
|
case GZip:
|
||||||
|
// Create the uncompressed archive
|
||||||
|
archive, err := os.Create(a.GetPath() + ".uncompressed")
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(a.GetPath() + ".uncompressed")
|
||||||
|
defer archive.Close()
|
||||||
|
|
||||||
|
original, err := os.Open(a.Path)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, errors.Wrap(err, "Cannot open "+a.Path)
|
||||||
|
}
|
||||||
|
defer original.Close()
|
||||||
|
|
||||||
|
bufferedReader := bufio.NewReader(original)
|
||||||
|
r, err := gzip.NewReader(bufferedReader)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, err
|
||||||
|
}
|
||||||
|
defer r.Close()
|
||||||
|
tr = tar.NewReader(r)
|
||||||
|
|
||||||
tarFile, err := os.Open(a.GetPath())
|
|
||||||
if err != nil {
|
|
||||||
return []string{}, errors.Wrap(err, "Could not open package archive")
|
|
||||||
}
|
}
|
||||||
defer tarFile.Close()
|
|
||||||
tr := tar.NewReader(tarFile)
|
|
||||||
|
|
||||||
var files []string
|
var files []string
|
||||||
// untar each segment
|
// untar each segment
|
||||||
|
Reference in New Issue
Block a user