Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are installable packages on the interenet, with Maintainer or Description missing. #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ebikt
Copy link
Contributor

@ebikt ebikt commented May 29, 2019

Downloaded some packages from internet, and installed them to my machines and needed my software to be able to parse them (possibly with warnings.).

@paultag
Copy link
Owner

paultag commented May 29, 2019

I had a similar issue, but I wonder if a better fix would be to drop an error that can be ignored when a required field is missing. At the end of the day, dpkg will complain quite a bit, it's invalid - and i'm split on what to do. I'm going to think about this one a bit more.

Would something like the code below have been enough to work around your issue parsing invalid debs?

diff --git a/control/decode.go b/control/decode.go
index 649b48a..66cf38d 100644
--- a/control/decode.go
+++ b/control/decode.go
@@ -21,6 +21,7 @@
 package control // import "pault.ag/go/debian/control"
 
 import (
+       "errors"
        "fmt"
        "io"
        "reflect"
@@ -103,6 +104,8 @@ func (d *Decoder) Decode(into interface{}) error {
        return decode(&d.paragraphReader, reflect.ValueOf(into))
 }
 
+var MissingField = errors.New("debian: control: Required field is missing!")
+
 // Top-level decode dispatch {{{
 
 func decode(p *ParagraphReader, into reflect.Value) error {
@@ -185,10 +188,7 @@ func decodeStruct(p Paragraph, into reflect.Value) error {
                        continue
                } else {
                        if fieldType.Tag.Get("required") == "true" {
-                               return fmt.Errorf(
-                                       "Required field '%s' is missing!",
-                                       fieldType.Name,
-                               )
+                               return MissingField
                        }
                        continue
                }

@paultag
Copy link
Owner

paultag commented May 29, 2019

Actually scratch that, this still wouldn't return the control. Nevermind. I'm still going to think about it, but I may accept this or make the required something that you can opt-in to enforce or opt-out of enforcing. Hang tight on this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants