summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makePackagesFile.go123
1 files changed, 2 insertions, 121 deletions
diff --git a/makePackagesFile.go b/makePackagesFile.go
index 72f9bbf..a2d1173 100644
--- a/makePackagesFile.go
+++ b/makePackagesFile.go
@@ -1,7 +1,6 @@
package main
import (
- "bufio"
"crypto/md5"
"crypto/sha256"
"errors"
@@ -11,10 +10,9 @@ import (
"path/filepath"
"strings"
- "go.wit.com/lib/cobol"
+ "go.wit.com/lib/debian"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/zoopb"
- "go.wit.com/log"
"google.golang.org/protobuf/types/known/timestamppb"
)
@@ -66,124 +64,7 @@ func populateDebInfo(p *zoopb.Package) error {
p.Ctime = timestamppb.New(stat.ModTime())
// PARSE "dpkg -I <p.Filename>", then exit as we are done
- starting := true
all := strings.Join(r.Stdout, "\n")
- scanner := bufio.NewScanner(strings.NewReader(all))
- for scanner.Scan() {
- line := scanner.Text()
- parts := strings.Fields(line)
- if starting {
- if parts[0] == "new" {
- if argv.Verbose {
- log.Printf("new: %v\n", parts)
- }
- // skip the first dpkg -I line
- continue
- }
- if parts[0] == "size" {
- if argv.Verbose {
- log.Printf("size: %v\n", parts)
- }
- // todo: make this correct
- p.DebInfo.Size = parts[1]
- p.DebInfo.InstalledSize = parts[1]
- // scan all the entries from size
- for scanner.Scan() {
- line = scanner.Text()
- parts = strings.Fields(line)
- if strings.HasPrefix(line, " ") {
- if argv.Verbose {
- log.Printf("sizeline: %v\n", parts)
- }
- continue
- }
- starting = false
- break
- }
- }
- if starting {
- if argv.Verbose {
- log.Printf("parts: %v\n", parts)
- }
- continue
- }
- }
- varname := strings.TrimSuffix(parts[0], ":")
- varval := strings.Join(parts[1:], " ")
- // log.Printf("varname:%s varval:%s\n", varname, varval)
- switch varname {
- case "Package":
- p.Package = varval
- case "Filename":
- log.Printf("Filename: varname:%s varval:%s\n", varname, varval)
- // p.Package = varval
- case "Version":
- p.Version = varval
- case "Architecture":
- p.Architecture = varval
- case "GoPath":
- p.Namespace = varval
- case "Maintainer":
- p.DebInfo.Maintainer = varval
- case "Packager":
- p.DebInfo.Packager = varval
- case "Depends":
- p.DebInfo.Depends = varval
- case "Source":
- p.DebInfo.Source = varval
- case "URL":
- p.DebInfo.URL = varval
- case "Build-Depends":
- p.DebInfo.BuildDepends = varval
- case "Installed-Size:":
- case "Installed-Size":
- p.DebInfo.InstalledSize = varval
- case "Homepage":
- p.DebInfo.URL = varval
- case "Conflicts":
- p.DebInfo.Conflicts = varval
- case "Source-Date":
- t, err := cobol.GetTime(varval)
- if err == nil {
- p.GitDate = timestamppb.New(t)
- } else {
- if argv.Verbose {
- log.Info("FIXME: Package-Build-Date", varval, err)
- }
- }
- case "Build-Date":
- case "Package-Build-Date":
- t, err := cobol.GetTime(varval)
- if err == nil {
- p.BuildDate = timestamppb.New(t)
- } else {
- if argv.Verbose {
- log.Info("FIXME: Package-Build-Date", varval, err)
- }
- }
- case "Git-Tag-Date":
- if argv.Verbose {
- log.Info("FIXME: Git-Tag-Date", varval)
- }
- case "Description":
- description := varval
- for scanner.Scan() {
- line := scanner.Text()
- if strings.HasPrefix(line, " ") {
- line = strings.TrimSpace(line)
- description += line + "\n"
- continue
- }
- break
- }
- p.DebInfo.Description = description
- default:
- // This forces me(it could be you!) to fix this parser
- varname2 := strings.TrimSuffix(varname, ":")
- log.Printf("UNKNOWN: varname:%s varval:%s varname2=%s\n", varname, varval, varname2)
- panic("fix mirrors populateDebInfo()")
- }
- }
- // pb.DebInfo should be correctly populated. You can verify these with "mirrors --verify"
+ debian.ParseDpkgOutputIntoPB(p, all)
return nil
}