summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-14 02:13:17 -0500
committerJeff Carr <[email protected]>2025-10-14 02:24:58 -0500
commitcde244af8f9fc4062213d170ce23be730656b416 (patch)
tree0b9112f9dc44f1106272c3098f2b2d46529b8c96
parentbfe7463f38670b75e6d3a0753d53d0762ddeeed7 (diff)
finally remove old cruft
-rw-r--r--mirrorsSupport.go.off162
1 files changed, 0 insertions, 162 deletions
diff --git a/mirrorsSupport.go.off b/mirrorsSupport.go.off
deleted file mode 100644
index d60cd2d..0000000
--- a/mirrorsSupport.go.off
+++ /dev/null
@@ -1,162 +0,0 @@
-package main
-
-// makes dists/ directores for 'apt update'
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "os"
- "path"
- "path/filepath"
- "strings"
-
- "go.wit.com/lib/gui/shell"
- "go.wit.com/log"
- "google.golang.org/protobuf/encoding/prototext"
-)
-
-var verbose bool
-
-// remove and return the pb varname
-func (pb *Package) DeleteString(varname string) string {
- return "todo"
-}
-
-func (pb *Package) Print() {
- shell.RunVerbose([]string{"dpkg", "-I", pb.Filename})
- log.Info("\nNEW PB START")
- log.Info(strings.TrimSpace(prototext.Format(pb)))
- log.Info("NEW PB END\n")
-
- log.Info("Attempt to walk pb.DebInfo")
- if err := printDebInfoStrings(pb, true); err != nil {
- log.Info("pb.walk error:", err)
- }
-
-}
-
-// makes /home/mirrors/debian/dists/ for use by 'apt update'
-func (pb *Packages) MakeDists() (string, error) {
- log.Printf("Attempting to make dists/ in %s with %d .deb files\n", pb.BaseDir, pb.Len())
- os.Chdir(pb.BaseDir)
-
- var s string
- var err error
- var archpb *Packages
- archpb, s, err = pb.doNormalArch("all")
- log.Printf("arch all found %5d packages. %s err=(%v)\n", archpb.Len(), filepath.Join(pb.BaseDir, s), err)
- archpb, s, err = pb.doNormalArch("riscv64")
- log.Printf("arch riscv64 found %5d packages. %s err=(%v)\n", archpb.Len(), filepath.Join(pb.BaseDir, s), err)
-
- // archpb, s, err = pb.doNormalArch("amd64")
- // log.Printf("arch amd64 found %5d packages. %s err=(%v)\n", archpb.Len(), filepath.Join(pb.BaseDir, s), err)
-
- // archpb, s, err = pb.doNormalArch("arm64")
- // log.Printf("arch arm64 found %5d not as cool as riscv packages. msg='%s' err=(%v)\n", archpb.Len(), s, err)
-
- return s, nil
-}
-
-func (pb *Packages) doNormalArch(arch string) (*Packages, string, error) {
- packageDir := filepath.Join("dists", "sid", "main", "binary-"+arch)
- archpb, s, err := pb.MakePackageFile(packageDir, arch)
- if err != nil {
- log.Info("MakePackageFile() failed", s, err)
- } else {
- if verbose {
- log.Info("MakePackageFile() for", arch, "worked")
- }
- }
-
- /*
- // 5. Generate and sign the Release file
- log.Println("Generating and signing Release file...")
- if err := generateAndSignReleaseFile(distPath); err != nil {
- log.Printf("Failed to generate or sign Release file: %v\n", err)
- return err
- }
- */
- return archpb, filepath.Join(packageDir, "Packages"), err
-}
-
-// similar to "dpkg -I moonbuggy.deb"
-// destroys the pb so send a copy
-func (pb *Package) writeDebInfo(w io.Writer) {
- fmt.Fprintf(w, "Package: %s\n", pb.Package)
- fmt.Fprintf(w, "Filename: %s\n", pb.Filename)
- fmt.Fprintf(w, "MD5sum: %s\n", pb.DeleteString("md5sum"))
- fmt.Fprintf(w, "SHA1: %s\n", pb.DeleteString("SHA1"))
- fmt.Fprintf(w, "SHA256: %s\n", pb.DeleteString("sha256"))
-}
-
-// makes the file "dists/sid/main/binary-riscv64/Packages"
-// then compresses it as .gz & .bz2 files
-func (pb *Packages) MakePackageFile(packageDir string, arch string) (*Packages, string, error) {
- if verbose {
- log.Printf("Attempting to make Package file for arch=%s\n", arch)
- }
- if err := os.Chdir(pb.BaseDir); err != nil {
- return nil, "", err
- }
-
- fullpath := path.Join(pb.BaseDir, packageDir)
- if err := os.MkdirAll(fullpath, 0755); err != nil {
- return nil, "", err
- }
-
- // made a new PB in memory of just the matching riscv64.deb files
- matcharch := NewPackages()
-
- // goes through each .deb file and writes out the entry in the Packages file
- for debPB := range pb.IterAll() {
- if verbose {
- log.Info("Adding package", debPB.Architecture, debPB.Filename)
- }
- if debPB.Architecture != arch {
- continue
- }
- matcharch.Append(debPB)
- }
-
- if matcharch.Len() == 0 {
- return matcharch, "found no files", errors.New("no " + arch + " files found")
- }
-
- var data bytes.Buffer
- for debPB := range matcharch.IterByFilename() {
- if verbose {
- log.Info("Adding package", debPB.Filename)
- }
- debPB.writeDebInfo(&data)
- fmt.Fprintf(&data, "\n")
- }
-
- // write out the "Packages" file
- filename := filepath.Join(packageDir, "Package")
- fullname := filepath.Join(pb.BaseDir, filename)
- if len(data.String()) == 0 {
- return matcharch, fullname, errors.New("something is wrong. Package file would be empty")
- }
- log.Info("Going to write file", fullname, "with string length", len(data.String()))
- if err := os.WriteFile(fullname, []byte(data.String()), 0644); err != nil {
- return matcharch, fullname, err
- }
-
- log.Info(data.String())
-
- /*
- // Create "Packages.gz"
- if err := compressFile(filepath.Join(fullfile, "Package.gz"); err != nil {
- return err
- }
-
- // Create "Packages.gz"
- if err := compressFile(filepath.Join(fullfile, "Package.bz2"); err != nil {
- return err
- }
- */
- s := log.Sprintf("Created %s", fullname)
- return matcharch, s, nil
-}