diff options
| -rw-r--r-- | argv.go | 10 | ||||
| -rw-r--r-- | doWalk.go | 42 |
2 files changed, 39 insertions, 13 deletions
@@ -18,8 +18,8 @@ var argv args type args struct { List *EmptyCmd `arg:"subcommand:list" help:"show the packages"` - Walk *EmptyCmd `arg:"subcommand:walk" help:"walk the filesystem for new .deb files"` - Update *EmptyCmd `arg:"subcommand:update" help:"update the apt repo"` + Walk *WalkCmd `arg:"subcommand:walk" help:"walk the filesystem for new .deb files"` + Update *EmptyCmd `arg:"subcommand:oldway" help:"the old code to update the apt repo"` Incoming *EmptyCmd `arg:"subcommand:incoming" help:"handle the incoming directory"` MakeDists *EmptyCmd `arg:"subcommand:makedists" help:"make debian mirrors/dists files for 'apt update'"` DryRun bool `arg:"--dry-run" help:"only show what would be packaged"` @@ -30,6 +30,10 @@ type args struct { type EmptyCmd struct { } +type WalkCmd struct { + Verbose bool `arg:"--verbose" help:"be loud about it"` +} + func (args) Buildtime() (string, string) { return BUILDTIME, VERSION } @@ -43,7 +47,7 @@ func (args) Appname() string { } func (a args) DoAutoComplete(pb *prep.Auto) { - base := []string{"--version", "update", "--dry-run", "--force", "incoming", "walk", "list"} + base := []string{"--version", "oldway", "--dry-run", "--force", "incoming", "walk", "list"} if pb.Cmd == "" { pb.Autocomplete3(base) @@ -2,12 +2,15 @@ package main import ( "os" + "strings" + "time" "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/encoding/prototext" + "google.golang.org/protobuf/types/known/timestamppb" ) func doWalk() (string, error) { @@ -15,7 +18,7 @@ func doWalk() (string, error) { // 2. Scan pool directory for .deb files and gather info log.Printf("Scanning for .deb files in %s\n", poolDir) - debInfos, err := scanDebs(poolDir, 35) + debInfos, err := scanDebs(poolDir, 200) if err != nil { log.Printf("Failed to scan .deb files: %v\n", err) me.sh.BadExit("scan pool scan dir", err) @@ -25,6 +28,7 @@ func doWalk() (string, error) { for _, deb := range debInfos { newdeb := new(zoopb.Package) newdeb.DebInfo = new(zoopb.DebInfo) + newdeb.Filename = deb.Filename newdeb.DebInfo.Filename = deb.Filename newdeb.DebInfo.MD5SUM = deb.MD5Sum newdeb.DebInfo.SHA1 = deb.SHA1Sum @@ -42,7 +46,9 @@ func doWalk() (string, error) { case "Architecture": newdeb.Architecture = varvalue case "Git-Tag-Date": - log.Info("CONVERT THIS TO TIME", varname, varvalue) + if argv.Verbose { + log.Info("CONVERT THIS TO TIME", varname, varvalue) + } case "Depends": newdeb.DebInfo.Depends = varvalue case "Build-Depends": @@ -50,23 +56,39 @@ func doWalk() (string, error) { case "Packager": newdeb.DebInfo.Packager = varvalue case "Package-Build-Date": - varvalue = "PackageBuildDate" - log.Info("CONVERT THIS TO TIME", varname, varvalue) + varname = "PackageBuildDate" + const layout = "2006/01/02 15:04:05 MST" + parsedTime, err := time.Parse(layout, varvalue) + if err != nil { + log.Info("CONVERT TO TIME failed", varname, varvalue, err) + } + newdeb.BuildDate = timestamppb.New(parsedTime) case "URL": newdeb.DebInfo.Homepage = varvalue default: - if ok, err := debian.SetString(newdeb, varname, varvalue); ok { - continue - } else if err != nil { - log.Printf("%v VAR='%s' VAL='%s'\n", err, varname, varvalue) + if err := debian.SetDebInfoString(newdeb, varname, varvalue); err == nil { + if argv.Verbose { + log.Printf("Searching for Sugarman WORKED: VAR='%-30s' VAL='%s'\n", varname, varvalue) + } + } else { + log.Printf("Searching for Sugarman FAILED: VAR='%-30s' VAL='%s' err=%v\n", varname, varvalue, err) } // todo: add to protomap } } counter += 1 me.pb.AppendByFilename(newdeb) - shell.RunVerbose([]string{"dpkg", "-I", newdeb.Filename}) - log.Info(prototext.Format(newdeb)) + if newdeb.Filename == "" { + log.Info(deb) + log.Info("file=", deb.Filename) + panic("newdeb.Filename = ''") + } + if argv.Verbose { + shell.RunVerbose([]string{"dpkg", "-I", newdeb.Filename}) + log.Info("\nNEW PB START") + log.Info(strings.TrimSpace(prototext.Format(newdeb))) + log.Info("NEW PB END\n") + } // arch := deb.ControlData["Architecture"] } |
