diff options
| author | Jeff Carr <[email protected]> | 2025-10-11 11:07:56 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-11 11:09:24 -0500 |
| commit | 3eb1215f1105d98901bdb2a696f8ec14b7cf2efb (patch) | |
| tree | d0dc399fc3101dc0408a8f9a6e65aeea1ade27b6 /doVerify.go | |
| parent | 2677081b8e9514d689049af9f1450197df57ad08 (diff) | |
more removing of edge cases
Diffstat (limited to 'doVerify.go')
| -rw-r--r-- | doVerify.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/doVerify.go b/doVerify.go index b936f24..09c8c74 100644 --- a/doVerify.go +++ b/doVerify.go @@ -6,6 +6,7 @@ import ( "path/filepath" "strings" + "go.wit.com/lib/cobol" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" @@ -66,6 +67,35 @@ func doVerify() (string, error) { counter += 1 continue } + if p.Architecture == "" { + log.Printf("%-16.16s %-130.130s\n", "arch is blank", pdump) + counter += 1 + continue + } + if p.Architecture != "amd64" { + log.Printf("%-16.16s %-130.130s\n", "arch is not x64", pdump) + continue + } + if p.DebInfo.Architecture != "" { + if p.Architecture != p.DebInfo.Architecture { + log.Printf("%-16.16s %-130.130s\n", "arch mismatch", p.Architecture, p.DebInfo.Architecture) + counter += 1 + continue + } + } + if p.Version == "" { + log.Printf("%-16.16s %-130.130s\n", "version is blank", pdump) + counter += 1 + continue + } + // verify constructed filename + constructedFilename := p.Package + "_" + p.Version + "_" + p.Architecture + ".deb" + _, fname := filepath.Split(p.Filename) + if constructedFilename != fname { + log.Info("filename mismatch", constructedFilename, fname, cobol.Since(p.Ctime)) + return moveToBroken(p) + } + // log.Info("Package", p.Package) if p.Ctime == nil { log.Printf("ctime is nil %-130.130s\n", fullname) @@ -87,3 +117,20 @@ func doVerify() (string, error) { return "verified ok", nil } + +func moveToBroken(p *zoopb.Package) (string, error) { + if err := os.Chdir(me.pb.BaseDir); err != nil { + return "no '" + me.pb.BaseDir + "' directory", err + } + brokendir := filepath.Join(me.pb.BaseDir, "broken") + if err := os.MkdirAll(brokendir, 0755); err != nil { + return "mkdir " + brokendir, err + } + _, fname := filepath.Split(p.Filename) + newname := filepath.Join(brokendir, fname) + if err := os.Rename(p.Filename, newname); err != nil { + return "rename failed " + newname, err + } + // panic("rename worked?") + return "rename worked " + newname, nil +} |
