Skip to content

Aptly cannot use deb packages which have control.tar #632

@rlguarino

Description

@rlguarino

Detailed Description

Aptly cannot handle packages which have control.tar control files instead of control.tar.gz.

Context

Most gzip implementations are non-deterministic. Since control.tar is supported buy dpkg it should also be supported by aptly.

Possible Implementation

diff --git a/deb/deb.go b/deb/deb.go
index 26db3a1..f5f0c40 100644
--- a/deb/deb.go
+++ b/deb/deb.go
@@ -44,12 +44,16 @@ func GetControlFileFromDeb(packageFile string) (Stanza, error) {
                        return nil, fmt.Errorf("unable to read .deb archive %s: %s", packageFile, err)
                }
 
-               if header.Name == "control.tar.gz" {
-                       ungzip, err := gzip.NewReader(library)
-                       if err != nil {
-                               return nil, fmt.Errorf("unable to ungzip control file from %s. Error: %s", packageFile, err)
+               if strings.HasPrefix(header.Name, "control.tar") {
+                       if strings.HasSuffix(header.Name, ".gz") {
+                               ungzip, err := gzip.NewReader(library)
+                               if err != nil {
+                                       return nil, fmt.Errorf("unable to ungzip control file from %s. Error: %s", packageFile, err)
+                               }
+                               defer ungzip.Close()
+                       } else {
+                               ungzip := library
                        }
-                       defer ungzip.Close()
 
                        untar := tar.NewReader(ungzip)
                        for {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions