summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-14 01:51:44 -0500
committerJeff Carr <[email protected]>2025-10-14 01:52:56 -0500
commitd10cf84916f9171ae4eb579cd3871e4ec198f2a0 (patch)
tree0f43c90d95688e3bcb6dff9a6c08513df39a37b1
parentf8d3817ebee3913bb8aecff6ea5de8fde6a560ec (diff)
move this to lib/debian
-rw-r--r--Makefile8
-rw-r--r--doIncoming.go2
-rw-r--r--keyGetFromPackaagePB.go134
-rw-r--r--main.go2
-rw-r--r--makePackagesFile.go92
5 files changed, 138 insertions, 100 deletions
diff --git a/Makefile b/Makefile
index 3e0bdf5..35f34fd 100644
--- a/Makefile
+++ b/Makefile
@@ -20,14 +20,6 @@ automate-everything:
wit upgrade
forge --version
-everything: build
- ./mirrors everything
- apt update
- sleep 1
- ls -l /var/lib/apt/lists/mirrors.wit.com*
- find /home/mirrors/wit/dists
- cat /var/lib/apt/lists/mirrors.wit.com_wit_dists_sid_InRelease
-
find:
find /var/lib/apt/lists/mi* /home/mirrors/wit/dists -type f |xargs ls -l
diff --git a/doIncoming.go b/doIncoming.go
index 531f99d..ed5b4a0 100644
--- a/doIncoming.go
+++ b/doIncoming.go
@@ -47,7 +47,7 @@ func doIncoming(pb *zoopb.Packages) (string, error) {
oldmd5 := md5.Sum(olddata)
newmd5 := md5.Sum(newdata)
if oldmd5 == newmd5 {
- log.Info("files are the same", md5.Sum(olddata), md5.Sum(newdata))
+ log.Printf("files are the same %x %x\n", md5.Sum(olddata), md5.Sum(newdata))
} else {
shell.RunVerbose([]string{"dpkg", "-I", path})
shell.RunVerbose([]string{"dpkg", "-I", newfilename})
diff --git a/keyGetFromPackaagePB.go b/keyGetFromPackaagePB.go
new file mode 100644
index 0000000..a97e080
--- /dev/null
+++ b/keyGetFromPackaagePB.go
@@ -0,0 +1,134 @@
+package main
+
+import (
+ "strings"
+
+ "go.wit.com/lib/debian"
+ "go.wit.com/lib/protobuf/zoopb"
+ "go.wit.com/log"
+)
+
+// make a list of the newest .deb files
+func doMakePackagesFile(all *zoopb.Packages) string {
+ var pfile string
+ for p := range all.IterAll() {
+ var controlfile string
+ parts, err := zoopb.GetDebInfoFields(p)
+ if err != nil {
+ log.Info(err)
+ }
+ for _, varname := range parts {
+ varname, varval := debian.GetKeyFromPackagePB(p, varname)
+ varval = strings.TrimSpace(varval)
+ if varval == "" {
+ continue
+ }
+ controlfile += log.Sprintf("%s: %s\n", varname, varval)
+ }
+ controlfile += log.Sprintf("\n")
+ pfile += controlfile
+ }
+ return pfile
+}
+
+/*
+func keyGetFromPackagePB(p *zoopb.Package, varname string) (string, string) {
+ switch varname {
+ case "Package":
+ return "Package", p.Package
+ case "Filename":
+ return "Filename", p.Filename
+ case "Version":
+ return "Version", p.Version
+ case "Architecture":
+ return "Architecture", p.Architecture
+ case "Maintainer":
+ return "Maintainer", p.DebInfo.Maintainer
+ // return "Maintainer", p.Author
+ case "Source":
+ if argv.Verbose {
+ log.Info("skipping from controlfile", varname)
+ // return "Source", p.DebInfo.Source
+ }
+ return "Source", ""
+ case "Conflicts":
+ return "Conflicts", p.DebInfo.Conflicts
+ case "Packager":
+ return "Packager", p.DebInfo.Packager
+ // 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", 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", 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 "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", "" // 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)
+ }
+ 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()")
+}
+*/
diff --git a/main.go b/main.go
index fc14458..c5fa528 100644
--- a/main.go
+++ b/main.go
@@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
+ "go.wit.com/lib/debian"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/zoopb"
@@ -93,6 +94,7 @@ func main() {
}
if argv.Verify != nil {
+ debian.InitMachine()
s, err = doVerify()
}
diff --git a/makePackagesFile.go b/makePackagesFile.go
index 0a70c3f..dd109dc 100644
--- a/makePackagesFile.go
+++ b/makePackagesFile.go
@@ -188,6 +188,7 @@ func populateDebInfo(p *zoopb.Package) error {
return nil
}
+/*
func makeDebianControlFile(p *zoopb.Package, varname string) (string, string) {
switch varname {
case "Package":
@@ -280,95 +281,4 @@ func makeDebianControlFile(p *zoopb.Package, varname string) (string, string) {
}
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
- for p := range all.IterAll() {
- var controlfile string
- parts, err := zoopb.GetDebInfoFields(p)
- if err != nil {
- log.Info(err)
- }
- for _, varname := range parts {
- varname, varval := makeDebianControlFile(p, varname)
- varval = strings.TrimSpace(varval)
- if varval == "" {
- continue
- }
- controlfile += log.Sprintf("%s: %s\n", varname, varval)
- }
- controlfile += log.Sprintf("\n")
- pfile += controlfile
- }
- return pfile
-}
-
-/*
- log.Printf("Scanning for .deb files in %s\n", poolDir)
- 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)
- }
-
- var counter int
- 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
- newdeb.DebInfo.SHA256 = deb.SHA256Sum
-
- // log.Info("len(CONTROLDATA)", len(deb.ControlData))
- // log.Sprintf("VAR='%s' VAL='%s'\n", varname, varvalue)
- // log.Info("%v", deb.ControlData)
- for varname, varvalue := range deb.ControlData {
- switch varname {
- case "Package":
- newdeb.Package = varvalue
- case "Version":
- newdeb.Version = varvalue
- case "Architecture":
- newdeb.Architecture = varvalue
- case "Git-Tag-Date":
- if argv.Verbose {
- log.Info("CONVERT THIS TO TIME", varname, varvalue)
- }
- case "Depends":
- newdeb.DebInfo.Depends = varvalue
- case "Build-Depends":
- newdeb.DebInfo.BuildDepends = varvalue
- case "Packager":
- newdeb.DebInfo.Packager = varvalue
- case "Package-Build-Date":
- 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 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 (unknwon var): VAR='%-30s' VAL='%s' err=%v\n", varname, varvalue, err)
- }
- // todo: add to protomap
- }
- }
*/