Add 'vercmp' subcommand for package version comparisons in scripts

This commit is contained in:
2025-12-08 16:08:55 +02:00
parent 1895fabfb0
commit 2c91a9332b
5 changed files with 29 additions and 10 deletions
+8
View File
@@ -9,6 +9,7 @@ import (
"syscall"
"time"
version "github.com/knqyf263/go-rpm-version"
"github.com/schollz/progressbar/v3"
)
@@ -132,3 +133,10 @@ func bytesToHumanReadable(b int64) string {
}
return fmt.Sprintf("%.1fYiB", bf)
}
func CompareVersions(version1, version2 string) int {
v1 := version.NewVersion(version1)
v2 := version.NewVersion(version2)
return v1.Compare(v2)
}