Merge pull request #320 from paul-krohn/master

add diagnostic output
This commit is contained in:
Andrey Smirnov
2015-12-03 12:11:25 +03:00
2 changed files with 12 additions and 12 deletions
+11 -11
View File
@@ -26,16 +26,16 @@ func GetControlFileFromDeb(packageFile string) (Stanza, error) {
for { for {
header, err := library.Next() header, err := library.Next()
if err == io.EOF { if err == io.EOF {
return nil, fmt.Errorf("unable to find control.tar.gz part") return nil, fmt.Errorf("unable to find control.tar.gz part in package %s", packageFile)
} }
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read .deb archive: %s", err) return nil, fmt.Errorf("unable to read .deb archive %s: %s", packageFile, err)
} }
if header.Name == "control.tar.gz" { if header.Name == "control.tar.gz" {
ungzip, err := gzip.NewReader(library) ungzip, err := gzip.NewReader(library)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to ungzip: %s", err) return nil, fmt.Errorf("unable to ungzip control file from %s. Error: %s", packageFile, err)
} }
defer ungzip.Close() defer ungzip.Close()
@@ -43,10 +43,10 @@ func GetControlFileFromDeb(packageFile string) (Stanza, error) {
for { for {
tarHeader, err := untar.Next() tarHeader, err := untar.Next()
if err == io.EOF { if err == io.EOF {
return nil, fmt.Errorf("unable to find control file") return nil, fmt.Errorf("unable to find control file in %s", packageFile)
} }
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read .tar archive: %s", err) return nil, fmt.Errorf("unable to read .tar archive from %s. Error: %s", packageFile, err)
} }
if tarHeader.Name == "./control" || tarHeader.Name == "control" { if tarHeader.Name == "./control" || tarHeader.Name == "control" {
@@ -112,10 +112,10 @@ func GetContentsFromDeb(packageFile string) ([]string, error) {
for { for {
header, err := library.Next() header, err := library.Next()
if err == io.EOF { if err == io.EOF {
return nil, fmt.Errorf("unable to find data.tar.* part") return nil, fmt.Errorf("unable to find data.tar.* part in %s", packageFile)
} }
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read .deb archive: %s", err) return nil, fmt.Errorf("unable to read .deb archive from %s: %s", packageFile, err)
} }
if strings.HasPrefix(header.Name, "data.tar") { if strings.HasPrefix(header.Name, "data.tar") {
@@ -127,7 +127,7 @@ func GetContentsFromDeb(packageFile string) ([]string, error) {
case "data.tar.gz": case "data.tar.gz":
ungzip, err := gzip.NewReader(library) ungzip, err := gzip.NewReader(library)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to ungzip: %s", err) return nil, fmt.Errorf("unable to ungzip data.tar.gz from %s: %s", packageFile,err)
} }
defer ungzip.Close() defer ungzip.Close()
tarInput = ungzip tarInput = ungzip
@@ -136,7 +136,7 @@ func GetContentsFromDeb(packageFile string) ([]string, error) {
case "data.tar.xz": case "data.tar.xz":
unxz, err := xz.NewReader(library) unxz, err := xz.NewReader(library)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to unxz: %s", err) return nil, fmt.Errorf("unable to unxz data.tar.xz from %s: %s", packageFile, err)
} }
defer unxz.Close() defer unxz.Close()
tarInput = unxz tarInput = unxz
@@ -145,7 +145,7 @@ func GetContentsFromDeb(packageFile string) ([]string, error) {
defer unlzma.Close() defer unlzma.Close()
tarInput = unlzma tarInput = unlzma
default: default:
return nil, fmt.Errorf("unsupported tar compression: %s", header.Name) return nil, fmt.Errorf("unsupported tar compression in %s: %s", packageFile, header.Name)
} }
untar := tar.NewReader(tarInput) untar := tar.NewReader(tarInput)
@@ -156,7 +156,7 @@ func GetContentsFromDeb(packageFile string) ([]string, error) {
return results, nil return results, nil
} }
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read .tar archive: %s", err) return nil, fmt.Errorf("unable to read .tar archive from %s: %s", packageFile, err)
} }
if tarHeader.Typeflag == tar.TypeDir { if tarHeader.Typeflag == tar.TypeDir {
+1 -1
View File
@@ -28,7 +28,7 @@ func (s *DebSuite) TestGetControlFileFromDeb(c *C) {
_, _File, _, _ := runtime.Caller(0) _, _File, _, _ := runtime.Caller(0)
_, err = GetControlFileFromDeb(_File) _, err = GetControlFileFromDeb(_File)
c.Check(err, ErrorMatches, "unable to read .deb archive: ar: missing global header") c.Check(err, ErrorMatches, "^.+ar: missing global header")
st, err := GetControlFileFromDeb(s.debFile) st, err := GetControlFileFromDeb(s.debFile)
c.Check(err, IsNil) c.Check(err, IsNil)