This commit is contained in:
ferrreo 2023-09-06 23:35:37 +01:00
parent bc609ee9e2
commit dcfd766e59
2 changed files with 32 additions and 34 deletions

BIN
ppp

Binary file not shown.

View File

@ -63,45 +63,44 @@ func processFile(url string) map[string]packageInfo {
packages := make(map[string]packageInfo) packages := make(map[string]packageInfo)
var currentPackage string var currentPackage string
scanner := bufio.NewScanner(rdr) scanner := bufio.NewScanner(rdr)
const maxCapacity = 4096 * 4096
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
if strings.HasPrefix(line, "Package: ") {
pkName := strings.TrimPrefix(line, "Package: ") + " "
_, broken := brokenPackages[pkName]
if !broken {
currentPackage = pkName
packages[currentPackage] = packageInfo{
Name: pkName,
}
} else {
currentPackage = ""
}
} else if strings.HasPrefix(line, "Version: ") && currentPackage != "" {
ver, err := version.Parse(strings.TrimPrefix(line, "Version: "))
if err != nil {
panic(err)
}
packages[currentPackage] = packageInfo{
Name: currentPackage,
Version: ver,
}
} else if strings.HasPrefix(line, "Filename: ") && currentPackage != "" {
packages[currentPackage] = packageInfo{
Name: currentPackage,
Version: packages[currentPackage].Version,
FilePath: strings.TrimPrefix(line, "Filename: "),
}
}
if line == "" { if line == "" {
currentPackage = "" currentPackage = ""
} }
if currentPackage == "" {
if strings.HasPrefix(line, "Package: ") {
pkName := strings.TrimPrefix(line, "Package: ") + " "
_, broken := brokenPackages[pkName]
if !broken {
currentPackage = pkName
packages[currentPackage] = packageInfo{
Name: pkName,
}
} else {
currentPackage = ""
}
}
} 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: ver,
}
}
if strings.HasPrefix(line, "Filename: ") {
packages[currentPackage] = packageInfo{
Name: currentPackage,
Version: packages[currentPackage].Version,
FilePath: strings.TrimPrefix(line, "Filename: "),
}
}
}
} }
return packages return packages
} }
@ -110,7 +109,7 @@ func compare(basePackages map[string]packageInfo, targetPackages map[string]pack
output := make(map[string]packageInfo) output := make(map[string]packageInfo)
for pack, info := range targetPackages { for pack, info := range targetPackages {
if baseVersion, ok := basePackages[pack]; ok { if baseVersion, ok := basePackages[pack]; ok {
if version.Compare(info.Version, baseVersion.Version) > 0 { if version.Compare(info.Version, baseVersion.Version) != 0 {
output[pack] = info output[pack] = info
if !download { if !download {
os.Stdout.WriteString(pack) os.Stdout.WriteString(pack)
@ -232,5 +231,4 @@ var brokenPackages = map[string]bool{
"libnvidia-common-390 ": true, "libnvidia-common-390 ": true,
"libnvidia-common-530 ": true, "libnvidia-common-530 ": true,
"midisport-firmware ": true, "midisport-firmware ": true,
"librust-winapi-dev ": true,
} }