Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ List of contributors, in chronological order:
* Clemens Rabe (https://github.com/seeraven)
* TJ Merritt (https://github.com/tjmerritt)
* Matt Martyn (https://github.com/MMartyn)
* Ross Guario (https://github.com/rlguarino)
18 changes: 12 additions & 6 deletions deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ 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") {
var src io.Reader
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()
src = ungzip
} else {
src = library
}
defer ungzip.Close()

untar := tar.NewReader(ungzip)
untar := tar.NewReader(src)
for {
tarHeader, err := untar.Next()
if err == io.EOF {
Expand Down
9 changes: 8 additions & 1 deletion deb/deb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type DebSuite struct {
debFile, debFile2, dscFile, dscFileNoSign string
debFile, debFile2, debFile3, dscFile, dscFileNoSign string
}

var _ = Suite(&DebSuite{})
Expand All @@ -20,6 +20,7 @@ func (s *DebSuite) SetUpSuite(c *C) {
_, _File, _, _ := runtime.Caller(0)
s.debFile = filepath.Join(filepath.Dir(_File), "../system/files/libboost-program-options-dev_1.49.0.1_i386.deb")
s.debFile2 = filepath.Join(filepath.Dir(_File), "../system/changes/hardlink_0.2.1_amd64.deb")
s.debFile3 = filepath.Join(filepath.Dir(_File), "../system/files/test_tar_control.deb")
s.dscFile = filepath.Join(filepath.Dir(_File), "../system/files/pyspi_0.6.1-1.3.dsc")
s.dscFileNoSign = filepath.Join(filepath.Dir(_File), "../system/files/pyspi-0.6.1-1.3.stripped.dsc")
}
Expand All @@ -36,6 +37,12 @@ func (s *DebSuite) TestGetControlFileFromDeb(c *C) {
c.Check(err, IsNil)
c.Check(st["Version"], Equals, "1.49.0.1")
c.Check(st["Package"], Equals, "libboost-program-options-dev")

st, err = GetControlFileFromDeb(s.debFile3)
c.Check(err, IsNil)
c.Check(st["Version"], Equals, "1.2.3")
c.Check(st["Package"], Equals, "test")

}

func (s *DebSuite) TestGetControlFileFromDsc(c *C) {
Expand Down
Binary file added system/files/test_tar_control.deb
Binary file not shown.