only update for newer versions

This commit is contained in:
ferrreo 2023-09-05 21:47:10 +01:00
parent 45634ba02d
commit d93765e41e
4 changed files with 12 additions and 3 deletions

BIN
ppp

Binary file not shown.

View File

@ -5,3 +5,5 @@ go 1.21.0
require github.com/ulikunitz/xz v0.5.11
require github.com/klauspost/compress v1.16.7
require pault.ag/go/debian v0.15.0 // indirect

View File

@ -2,3 +2,5 @@ github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGC
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
pault.ag/go/debian v0.15.0 h1:x2VLkGx/nTvGdgW0+FzFSgQZKt7zo9zSVYkikRjNTns=
pault.ag/go/debian v0.15.0/go.mod h1:JFl0XWRCv9hWBrB5MDDZjA5GSEs1X3zcFK/9kCNIUmE=

View File

@ -14,6 +14,7 @@ import (
"github.com/klauspost/compress/gzip"
"github.com/ulikunitz/xz"
"pault.ag/go/debian/version"
)
func main() {
@ -101,9 +102,13 @@ func processFile(url string) map[string]packageInfo {
}
} else {
if strings.HasPrefix(line, "Version: ") {
ver, err := version.Parse(strings.TrimPrefix(line, "Version: "))
if err != nil {
panic(err)
}
packages[currentPackage] = packageInfo{
Name: currentPackage,
Version: strings.TrimPrefix(line, "Version: "),
Version: ver,
}
}
if strings.HasPrefix(line, "Filename: ") {
@ -122,7 +127,7 @@ func compare(basePackages map[string]packageInfo, targetPackages map[string]pack
output := make(map[string]packageInfo)
for pack, info := range targetPackages {
if baseVersion, ok := basePackages[pack]; ok {
if baseVersion.Version != info.Version && (!is32bit || !strings.HasSuffix(info.FilePath, "all.deb")) {
if version.Compare(info.Version, baseVersion.Version) > 0 && (!is32bit || !strings.HasSuffix(info.FilePath, "all.deb")) {
output[pack] = info
if !download {
os.Stdout.WriteString(pack)
@ -298,7 +303,7 @@ type config struct {
type packageInfo struct {
Name string
Version string
Version version.Version
FilePath string
}