summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-13 02:39:06 -0500
committerJeff Carr <[email protected]>2025-10-13 03:41:42 -0500
commit620c99631c5bf204f82f32faa2f5c2ea3ed37ea1 (patch)
tree778ff832b1d73f33a0399fefdf237de56b84f5fe
parent889f6dfdb23334fd01266fe1069c29931574675d (diff)
more DebInfo fields
-rw-r--r--Makefile5
-rw-r--r--argv.go2
-rw-r--r--doEverything.go48
-rw-r--r--doVerify.go11
-rw-r--r--makePackagesFile.go83
5 files changed, 95 insertions, 54 deletions
diff --git a/Makefile b/Makefile
index 1addd76..d31f3e9 100644
--- a/Makefile
+++ b/Makefile
@@ -4,10 +4,11 @@ VERSION = $(shell git describe --tags)
GUIVERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%s)
-all: install
+all: reset goimports vet install
mirrors walk
mirrors incoming
mirrors verify
+ mirrors newest
everything: install
mirrors everything
@@ -27,6 +28,8 @@ build: goimports
build-verbose:
GO111MODULE=off go build -v -x \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
+reset:
+ reset
install: goimports
GO111MODULE=off go install \
diff --git a/argv.go b/argv.go
index 24e6533..4cb8843 100644
--- a/argv.go
+++ b/argv.go
@@ -55,7 +55,7 @@ func (args) Appname() string {
}
func (a args) DoAutoComplete(pb *prep.Auto) {
- base := []string{"oldway", "--dry-run", "--force", "incoming", "walk", "list", "makedists", "verify", "newest", "--create", "--verbose"}
+ base := []string{"oldway", "--dry-run", "--force", "incoming", "walk", "list", "everything", "verify", "newest", "--create", "--verbose"}
if pb.Cmd == "" {
pb.Autocomplete3(base)
diff --git a/doEverything.go b/doEverything.go
index 7418eeb..c17cb68 100644
--- a/doEverything.go
+++ b/doEverything.go
@@ -10,9 +10,7 @@ import (
"strings"
"time"
- "go.wit.com/lib/cobol"
"go.wit.com/lib/gui/shell"
- "go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
@@ -47,37 +45,13 @@ func doEverything() (string, error) {
log.Info("Processing dir", filepath.Join(me.pb.BaseDir, "pool"))
- arch := "amd64"
+ // arch := "amd64"
- newest := zoopb.NewPackages()
- for p := range me.pb.IterAll() {
- if p.Architecture != arch {
- continue
- }
- found := newest.FindByPackage(p.Package)
- if found == nil {
- // package is new
- log.Printf("%-20.20s %-20.20s %-80.80s\n", "new package", p.Package, p.Filename)
- newest.Clone(p)
- continue
- }
- curtime := p.Ctime.AsTime()
- newtime := found.Ctime.AsTime()
- durs := cobol.Since(p.Ctime) + " vs found " + cobol.Since(found.Ctime)
- if time.Since(curtime) > time.Since(newtime) {
- log.Printf("%-20.20s %-20.20s %-80.80s %s\n", "found is newer", p.Package, p.Filename, durs)
- } else {
- log.Printf("%-20.20s %-20.20s %-80.80s %s\n", "found is older", p.Package, p.Filename, durs)
- newest.Delete(found)
- newest.Clone(p)
- }
- }
-
- // sort the packages & write out the Packages file
+ newest := doGetNewest("amd64")
newest.SortPackage()
thefile := doMakePackagesFile(newest)
fullname := "/home/mirrors/wit/dists/sid/main/binary-amd64/Packages"
- if err := os.WriteFile(fullname, []byte(thefile), 0644); err != nil {
+ if err := os.WriteFile(fullname, []byte(thefile), os.ModePerm); err != nil {
return fullname, err
}
@@ -162,5 +136,19 @@ func doEverything() (string, error) {
sum = fmt.Sprintf("%x", sha256.Sum256(fileBytes))
*/
- return "doNewest", nil
+ log.Info("")
+ log.Info("Finished Everything")
+ log.Info("")
+ log.Info("Package file:", fullname)
+ log.Info("Release file:", releasePath)
+ log.Info("InRelease file:", filepath.Join(distPath, "InRelease"))
+ log.Info("Local file:", "/var/lib/apt/lists/mirrors.wit.com_wit_dists_sid_main_binary-amd64_Packages")
+ cmd := []string{"apt-get", "update"}
+ cmd = append(cmd, "-o", "Dir::Etc::sourcelist=/etc/apt/sources.list.d/wit.list")
+ cmd = append(cmd, "-o", "Dir::Etc::sourceparts=/dev/null")
+ cmd = append(cmd, "-o", "APT::Get::List-Cleanup=0")
+ log.Info("apt update :", cmd)
+ log.Info("")
+
+ return "did everything", nil
}
diff --git a/doVerify.go b/doVerify.go
index 54ebfb1..3a8029c 100644
--- a/doVerify.go
+++ b/doVerify.go
@@ -36,7 +36,7 @@ func doVerify() (string, error) {
}
if p.DebInfo == nil {
fullname := filepath.Join(me.pb.BaseDir, p.Filename)
- log.Printf("debinfo == nil. need to run dpkg -I %s\n", fullname)
+ log.Printf("Running: dpkg -I %s\n", fullname)
populateDebInfo(p)
counter += 1
// if counter > 10 {
@@ -94,7 +94,7 @@ func doVerify() (string, error) {
}
if p.DebInfo.Architecture != "" {
if p.Architecture != p.DebInfo.Architecture {
- log.Printf("%-16.16s %-130.130s\n", "arch mismatch", p.Architecture, p.DebInfo.Architecture)
+ log.Printf("%-16.16s %-130.130s %s\n", "arch mismatch", p.Architecture, p.DebInfo.Architecture)
counter += 1
continue
}
@@ -104,6 +104,13 @@ func doVerify() (string, error) {
counter += 1
continue
}
+ if p.DebInfo.Size == "" {
+ log.Printf("%-16.16s %-130.130s\n", "Size is blank", pdump)
+ // todo: fix this
+ p.DebInfo.Size = p.DebInfo.InstalledSize
+ counter += 1
+ continue
+ }
// verify constructed filename
constructedFilename := p.Package + "_" + p.Version + "_" + p.Architecture + ".deb"
_, fname := filepath.Split(p.Filename)
diff --git a/makePackagesFile.go b/makePackagesFile.go
index 0257712..0a70c3f 100644
--- a/makePackagesFile.go
+++ b/makePackagesFile.go
@@ -84,6 +84,8 @@ func populateDebInfo(p *zoopb.Package) error {
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() {
@@ -186,17 +188,7 @@ func populateDebInfo(p *zoopb.Package) error {
return nil
}
-/*
-UNKNOWN: varname:Depends varval:protobuf-compiler, protoc-gen-go | protoc-gen-go-wit
-UNKNOWN: varname:Build-Depends varval:golang
-UNKNOWN: varname:URL varval:https://go.wit.com/
-UNKNOWN: varname:Package-Build-Date varval:2025/10/05 07:40:30 UTC
-UNKNOWN: varname:Git-Tag-Date varval:todo: get from repo
-UNKNOWN: varname:Description varval:autogen protobuf marshal and sort files
-UNKNOWN: varname:this varval:is needed for go.wit.com/lib/protobuf/ GO packages
-*/
-
-func getDebianControlFile(p *zoopb.Package, varname string) (string, string) {
+func makeDebianControlFile(p *zoopb.Package, varname string) (string, string) {
switch varname {
case "Package":
return "Package", p.Package
@@ -222,29 +214,80 @@ func getDebianControlFile(p *zoopb.Package, varname string) (string, string) {
// return "Packager", p.Packager
case "Depends":
return "Depends", p.DebInfo.Depends
+ case "Namespace":
+ return "Namespace", p.Namespace
+ case "GitHash":
+ return "Last-Git-Hash", p.DebInfo.GitHash
+ case "GitDate":
+ if p.DebInfo.GitDate == "" {
+ return "Git-Hash-Date", ""
+ }
+ return "Git-Hash-Date", cobol.Time(p.DebInfo.GitDate)
case "BuildDepends":
return "Build-Depends", p.DebInfo.BuildDepends
case "InstalledSize":
- return "Installed-Size", "222222222"
- case "URL":
- return "Homepage", p.DebInfo.URL
+ return "Installed-Size", p.DebInfo.InstalledSize
+ case "Homepage":
+ return "Homepage", p.DebInfo.Homepage
+ case "PreDepends":
+ return "Pre-Depends", p.DebInfo.PreDepends
+ case "Suggests":
+ return "Suggests", p.DebInfo.Suggests
+ case "MultiArch":
+ return "Multi-Arch", p.DebInfo.MultiArch
+ case "Tag":
+ return "Tag", p.DebInfo.Tag
case "Size":
- return "Size", "22222222"
+ return "Size", p.DebInfo.Size
+ case "Section":
+ return "Section", p.DebInfo.Section
+ case "URL":
+ return "URL", p.DebInfo.URL
+ //case "Size":
+ // return "Size", p.DebInfo.Size
case "BuildDate":
+ if p.BuildDate == nil {
+ return "Build-Date", ""
+ }
return "Build-Date", cobol.Time(p.BuildDate)
- // case "SHA1":
- // return "SHA1", p.DebInfo.SHA1
+ case "DebCtime":
+ return "Deb-File-Date", cobol.Time(p.Ctime)
+ case "SHA1":
+ return "SHA1", "" // deprecated
+ // return "SHA1", p.DebInfo.SHA1
case "MD5SUM":
return "MD5Sum", p.DebInfo.MD5SUM
case "SHA256":
return "SHA256", p.DebInfo.SHA256
case "SHA512":
- return "SHA512", "" // todo: implement or totally rediculously overkill ?
+ return "SHA512", "" // totally rediculously overkill
+ case "Description":
+ var out string
+ lines := strings.Split(p.DebInfo.Description, "\n")
+ if len(lines) == 0 {
+ return "Description", out
+ }
+ out = "Description: " + strings.TrimSpace(lines[0])
+ if len(lines) == 1 {
+ return "Description", out
+ }
+ for _, line := range lines[1:] {
+ out += " " + strings.TrimSpace(line)
+ }
+ return "Description", out
+ default:
+ dieMaking(varname)
}
- log.Info("DebInfo sent a field we didn't have. fix the code above", varname)
return "", ""
}
+func dieMaking(varname string) {
+ log.Info("DebInfo sent a field we didn't have. fix the code above", varname)
+ log.Printf("UNHANDLED ABOVE DEBINFO VAR: varname:%s\n", varname)
+ // This forces me(it could be you!) to fix this parser
+ panic("fix mirrors makeDebianControlFile()")
+}
+
// make a list of the newest .deb files
func doMakePackagesFile(all *zoopb.Packages) string {
var pfile string
@@ -255,7 +298,7 @@ func doMakePackagesFile(all *zoopb.Packages) string {
log.Info(err)
}
for _, varname := range parts {
- varname, varval := getDebianControlFile(p, varname)
+ varname, varval := makeDebianControlFile(p, varname)
varval = strings.TrimSpace(varval)
if varval == "" {
continue