Skip to content

Commit

Permalink
Added logging of sha1 hashes for patched files (closes #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaskin committed Jul 17, 2019
1 parent 186ad9c commit c6b3c1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ require (
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
gopkg.in/yaml.v2 v2.2.2
)

10 changes: 10 additions & 0 deletions kobopatch/kobopatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"archive/zip"
"bytes"
"compress/gzip"
"crypto/sha1"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -59,6 +60,7 @@ func main() {
Debugf: func(format string, a ...interface{}) {
fmt.Fprintf(logfile, format+"\n", a...)
},
sums: map[string]string{},
}

patchfile.Log = func(format string, a ...interface{}) {
Expand Down Expand Up @@ -194,6 +196,7 @@ type KoboPatch struct {
outTar *tar.Writer
outGZ *gzip.Writer
outTarExpectedSize int64
sums map[string]string

Logf func(format string, a ...interface{}) // displayed to user
Errorf func(format string, a ...interface{}) // displayed to user
Expand Down Expand Up @@ -274,6 +277,11 @@ func (k *KoboPatch) WriteOutput() error {
return fmt.Errorf("size mismatch: expected %d, got %d (please report this)", k.outTarExpectedSize, sum)
}

k.d("\nsha1 checksums:")
for f, s := range k.sums {
k.d(" %s %s", s, f)
}

return nil
}

Expand Down Expand Up @@ -432,6 +440,8 @@ func (k *KoboPatch) ApplyPatches() error {
k.d(" --> error writing new file to patched KoboRoot.tgz")
return errors.New("error writing new file to patched KoboRoot.tgz")
}

k.sums[h.Name] = fmt.Sprintf("%x", sha1.Sum(fbuf))
}

return nil
Expand Down

0 comments on commit c6b3c1d

Please sign in to comment.