summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go6
-rw-r--r--doMake.go61
-rw-r--r--doRelease.go1
-rw-r--r--doVerify.go3
-rw-r--r--main.go3
5 files changed, 6 insertions, 68 deletions
diff --git a/argv.go b/argv.go
index f84b26b..966356a 100644
--- a/argv.go
+++ b/argv.go
@@ -17,14 +17,14 @@ import (
var argv args
type args struct {
+ Incoming *IncomingCmd `arg:"subcommand:incoming" help:"handle the incoming directory"`
List *EmptyCmd `arg:"subcommand:list" help:"show the packages"`
- Walk *WalkCmd `arg:"subcommand:walk" help:"walk the filesystem for new .deb files"`
Verify *EmptyCmd `arg:"subcommand:verify" help:"verify the pb is accurate and doesn't have errors"`
- Incoming *IncomingCmd `arg:"subcommand:incoming" help:"handle the incoming directory"`
MakeDists *EmptyCmd `arg:"subcommand:makedists" help:"make debian mirrors/dists files for 'apt update'"`
+ Newest *EmptyCmd `arg:"subcommand:newest" help:"make a list of the newest .deb packages"`
SignRelease *EmptyCmd `arg:"subcommand:release" help:"make & GPG sign the Release files"`
Everything *EmptyCmd `arg:"subcommand:everything" help:"do the whole thing needed. nothing more. just everything."`
- Newest *EmptyCmd `arg:"subcommand:newest" help:"make a list of the newest .deb packages"`
+ Walk *WalkCmd `arg:"subcommand:walk" help:"walk the filesystem for new .deb files"`
DryRun bool `arg:"--dry-run" help:"only show what would be packaged"`
Verbose bool `arg:"--verbose" help:"be loud about it"`
Force bool `arg:"--force" help:"rebuild everything"`
diff --git a/doMake.go b/doMake.go
index cc4c963..76ba16e 100644
--- a/doMake.go
+++ b/doMake.go
@@ -1,20 +1,12 @@
package main
import (
- "crypto/md5"
- "crypto/sha256"
- "errors"
- "fmt"
- "io"
"os"
- "path/filepath"
"strings"
"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"
)
// os.Chdir(me.mirrorsDir)
@@ -56,56 +48,3 @@ func doMakePackagesFile(all *zoopb.Packages) string {
}
return pfile
}
-
-func populateDebInfo(p *zoopb.Package) error {
- // SIMPLE SANITY CHECKS
- if p.DebInfo != nil {
- // already added p.DebInfo
- return nil
- }
- fullname := filepath.Join(me.pb.BaseDir, p.Filename)
- cmd := []string{"dpkg", "-I", fullname}
- r := shell.Run(cmd)
- if r.Error != nil {
- return r.Error
- }
- if r.Exit != 0 {
- return errors.New("dpkg returned -1")
- }
- stat, err := os.Stat(fullname)
- if err != nil {
- return err
- }
- filedata, err := os.Open(fullname)
- if err != nil {
- return err
- }
- defer filedata.Close()
- // SIMPLE SANITY CHECKS END
-
- // SHA256 HASH
- p.DebInfo = new(zoopb.DebInfo)
-
- hSHA256 := sha256.New()
- hMD5 := md5.New() // probably deprecate, but love md5sum too much
- // hSHA1 := sha1.New() // deprecated
-
- // TeeReader allows writing to multiple hashers at once
- // multiWriter := io.MultiWriter(hMD5, hSHA1, hSHA256)
- multiWriter := io.MultiWriter(hSHA256, hMD5)
- if _, err := io.Copy(multiWriter, filedata); err != nil {
- return err
- }
- p.DebInfo.SHA256 = fmt.Sprintf("%x", hSHA256.Sum(nil)) // should be the standard now
- p.DebInfo.MD5SUM = fmt.Sprintf("%x", hMD5.Sum(nil)) // probably deprecate
- // p.DebInfo.SHA1 = fmt.Sprintf("%x", hSHA1.Sum(nil)) // deprecated
- // SHA256 HASH END
-
- // set file create time
- p.Ctime = timestamppb.New(stat.ModTime())
-
- // PARSE "dpkg -I <p.Filename>", then exit as we are done
- all := strings.Join(r.Stdout, "\n")
- debian.ParseDpkgOutputIntoPB(p, all)
- return nil
-}
diff --git a/doRelease.go b/doRelease.go
index 91908d1..dee1baf 100644
--- a/doRelease.go
+++ b/doRelease.go
@@ -108,7 +108,6 @@ func doRelease() (string, error) {
// Sign the file
log.Println("Signing with GPG key:", gpgKeyID)
- // distPath := "/home/mirrors/wit/dists/sid"
distPath := config.GetPanic("distPath")
// Create InRelease
cmdClearSign := exec.Command("gpg", "--default-key", gpgKeyID, "--clearsign", "-o", filepath.Join(distPath, "InRelease"), releasePath)
diff --git a/doVerify.go b/doVerify.go
index 99175f0..86690d6 100644
--- a/doVerify.go
+++ b/doVerify.go
@@ -6,6 +6,7 @@ import (
"path/filepath"
"strings"
+ "go.wit.com/lib/debian"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
@@ -36,7 +37,7 @@ func doVerify() (string, error) {
if p.DebInfo == nil {
fullname := filepath.Join(me.pb.BaseDir, p.Filename)
log.Printf("Running: dpkg -I %s\n", fullname)
- populateDebInfo(p)
+ debian.RunDpkg(p, fullname)
counter += 1
// if counter > 10 {
// break
diff --git a/main.go b/main.go
index 6a0aa8f..7f86b60 100644
--- a/main.go
+++ b/main.go
@@ -18,7 +18,7 @@ var VERSION string
var BUILDTIME string
// used for shell auto completion
-var ARGNAME string = "mirrors" // todo: get this from $0 ?
+var ARGNAME string = "mirrors" // todo: get this from $0
//go:embed resources/*
var resources embed.FS
@@ -32,7 +32,6 @@ func main() {
me.pb.Filename = config.GetPanic("mirrors.pb")
if err := me.pb.Load(); err != nil {
if argv.Create {
- // me.pb.BaseDir = "/home/mirrors/wit"
me.pb.BaseDir = config.GetPanic("BaseDir")
me.pb.Save()
me.sh.GoodExit("created new pb file: " + me.pb.Filename)