summaryrefslogtreecommitdiff
path: root/stuff.go
diff options
context:
space:
mode:
Diffstat (limited to 'stuff.go')
-rw-r--r--stuff.go128
1 files changed, 64 insertions, 64 deletions
diff --git a/stuff.go b/stuff.go
index ca3a618..0458b05 100644
--- a/stuff.go
+++ b/stuff.go
@@ -18,62 +18,14 @@ import (
"go.wit.com/log"
)
-// scanDebs finds all .deb files and extracts their metadata.
-func scanDebs(root string, count int) ([]DebInfo, error) {
- var debs []DebInfo
- var counter int
- err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
- if err != nil {
- return err
- }
- if !info.IsDir() && strings.HasSuffix(info.Name(), ".deb") {
- found := me.pb.FindByFilename(path)
- if found != nil {
- // log.Info("already processed", path)
- return nil
- }
- if count == -1 {
- return nil
- }
- counter += 1
- if counter > count {
- return nil
- }
- log.Printf(" -> Processing %s\n", path)
-
- // Get control info
- cmd := exec.Command("dpkg-deb", "-I", path)
- var out bytes.Buffer
- cmd.Stdout = &out
- if err := cmd.Run(); err != nil {
- return fmt.Errorf("failed to run dpkg-deb on %s: %v", path, err)
- }
-
- controlData := parseControlData(out.String())
-
- // Get checksums
- md5sum, sha1sum, sha256sum, err := getChecksums(path)
- if err != nil {
- return err
- }
-
- relativePath, err := filepath.Rel(".", path)
- if err != nil {
- return err
- }
-
- debs = append(debs, DebInfo{
- ControlData: controlData,
- Filename: relativePath,
- Size: info.Size(),
- MD5Sum: md5sum,
- SHA1Sum: sha1sum,
- SHA256Sum: sha256sum,
- })
- }
- return nil
- })
- return debs, err
+func runCommand(cmd *exec.Cmd) error {
+ var stderr bytes.Buffer
+ cmd.Stderr = &stderr
+ err := cmd.Run()
+ if err != nil {
+ return fmt.Errorf("command '%s' failed: %v\nStderr: %s", cmd.String(), err, stderr.String())
+ }
+ return nil
}
// parseControlData converts the text output of dpkg-deb into a map.
@@ -229,12 +181,60 @@ func generateAndSignReleaseFile(distPath string) error {
return nil
}
-func runCommand(cmd *exec.Cmd) error {
- var stderr bytes.Buffer
- cmd.Stderr = &stderr
- err := cmd.Run()
- if err != nil {
- return fmt.Errorf("command '%s' failed: %v\nStderr: %s", cmd.String(), err, stderr.String())
- }
- return nil
+// scanDebs finds all .deb files and extracts their metadata.
+func scanDebs(root string, count int) ([]DebInfo, error) {
+ var debs []DebInfo
+ var counter int
+ err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
+ if err != nil {
+ return err
+ }
+ if !info.IsDir() && strings.HasSuffix(info.Name(), ".deb") {
+ found := me.pb.FindByFilename(path)
+ if found != nil {
+ // log.Info("already processed", path)
+ return nil
+ }
+ if count == -1 {
+ return nil
+ }
+ counter += 1
+ if counter > count {
+ return nil
+ }
+ log.Printf(" -> Processing %s\n", path)
+
+ // Get control info
+ cmd := exec.Command("dpkg-deb", "-I", path)
+ var out bytes.Buffer
+ cmd.Stdout = &out
+ if err := cmd.Run(); err != nil {
+ return fmt.Errorf("failed to run dpkg-deb on %s: %v", path, err)
+ }
+
+ controlData := parseControlData(out.String())
+
+ // Get checksums
+ md5sum, sha1sum, sha256sum, err := getChecksums(path)
+ if err != nil {
+ return err
+ }
+
+ relativePath, err := filepath.Rel(".", path)
+ if err != nil {
+ return err
+ }
+
+ debs = append(debs, DebInfo{
+ ControlData: controlData,
+ Filename: relativePath,
+ Size: info.Size(),
+ MD5Sum: md5sum,
+ SHA1Sum: sha1sum,
+ SHA256Sum: sha256sum,
+ })
+ }
+ return nil
+ })
+ return debs, err
}