fix issue where entries for different systems override each other
This commit is contained in:
parent
3bbc65268d
commit
e69fec95c8
2 changed files with 19 additions and 21 deletions
18
.gitignore
vendored
18
.gitignore
vendored
|
@ -1,11 +1,7 @@
|
||||||
/mozilla-central
|
mozilla-central
|
||||||
/mozilla-release
|
mozilla-release
|
||||||
/.vscode
|
.vscode
|
||||||
/patches
|
patches
|
||||||
/packages.json
|
APPINDEX
|
||||||
/packages_temp.json
|
browser-amd64-*
|
||||||
/APKINDEX
|
sourceforge_config.json
|
||||||
/APPINDEX
|
|
||||||
/browser-amd64-nightly-linux.tar.gz
|
|
||||||
/browser-amd64-nightly-windows.tar.gz
|
|
||||||
/sourceforge_config.json
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ func PackageAPPINDEX(
|
||||||
// For demo, we call `calcChecksum` with a mock package name.
|
// For demo, we call `calcChecksum` with a mock package name.
|
||||||
checksum := calcChecksum(fileName)
|
checksum := calcChecksum(fileName)
|
||||||
|
|
||||||
// Remove existing entry based on P, R, A, o (if you want to deduplicate).
|
// Remove existing entry based on P, R, A, o, and p:
|
||||||
removeExistingEntry(name, release, arch, origin)
|
removeExistingEntry(name, release, arch, origin, platform)
|
||||||
|
|
||||||
// Use current Unix timestamp
|
// Use current Unix timestamp
|
||||||
timestamp := time.Now().Unix()
|
timestamp := time.Now().Unix()
|
||||||
|
@ -100,8 +100,8 @@ func calcChecksum(input string) string {
|
||||||
return fmt.Sprintf("%x", h.Sum(nil))
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// removeExistingEntry removes an existing entry from APPINDEX if it matches P, R, A, and o fields.
|
// removeExistingEntry removes an existing entry from APPINDEX if it matches P, R, A, o, and p fields.
|
||||||
func removeExistingEntry(name, release, arch, origin string) {
|
func removeExistingEntry(name, release, arch, origin, platform string) {
|
||||||
// Read file contents
|
// Read file contents
|
||||||
content, err := os.ReadFile("./APPINDEX")
|
content, err := os.ReadFile("./APPINDEX")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -118,8 +118,8 @@ func removeExistingEntry(name, release, arch, origin string) {
|
||||||
|
|
||||||
inEntry := false // true when we're reading lines for a single entry
|
inEntry := false // true when we're reading lines for a single entry
|
||||||
|
|
||||||
// Use these to store the P, R, A, o values within the current entry
|
// We'll store the P, R, A, o, p values within the current entry
|
||||||
var pVal, rVal, aVal, oVal string
|
var pVal, rVal, aVal, oVal, plVal string
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
trimmed := strings.TrimSpace(line)
|
trimmed := strings.TrimSpace(line)
|
||||||
|
@ -129,7 +129,7 @@ func removeExistingEntry(name, release, arch, origin string) {
|
||||||
// If we were in an entry previously, check if it should be removed or kept
|
// If we were in an entry previously, check if it should be removed or kept
|
||||||
if inEntry && len(currentEntry) > 0 {
|
if inEntry && len(currentEntry) > 0 {
|
||||||
// Decide whether to keep the previous entry
|
// Decide whether to keep the previous entry
|
||||||
if !(pVal == name && rVal == release && aVal == arch && oVal == origin) {
|
if !(pVal == name && rVal == release && aVal == arch && oVal == origin && plVal == platform) {
|
||||||
newLines = append(newLines, currentEntry...)
|
newLines = append(newLines, currentEntry...)
|
||||||
newLines = append(newLines, "") // Blank line to separate entries
|
newLines = append(newLines, "") // Blank line to separate entries
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ func removeExistingEntry(name, release, arch, origin string) {
|
||||||
inEntry = true
|
inEntry = true
|
||||||
|
|
||||||
// Reset these values for the new entry
|
// Reset these values for the new entry
|
||||||
pVal, rVal, aVal, oVal = "", "", "", ""
|
pVal, rVal, aVal, oVal, plVal = "", "", "", "", ""
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ func removeExistingEntry(name, release, arch, origin string) {
|
||||||
// Collect lines for this entry
|
// Collect lines for this entry
|
||||||
currentEntry = append(currentEntry, trimmed)
|
currentEntry = append(currentEntry, trimmed)
|
||||||
|
|
||||||
// Extract P, R, A, o for matching later
|
// Extract fields for matching later
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(trimmed, "P:"):
|
case strings.HasPrefix(trimmed, "P:"):
|
||||||
pVal = strings.TrimPrefix(trimmed, "P:")
|
pVal = strings.TrimPrefix(trimmed, "P:")
|
||||||
|
@ -158,6 +158,8 @@ func removeExistingEntry(name, release, arch, origin string) {
|
||||||
aVal = strings.TrimPrefix(trimmed, "A:")
|
aVal = strings.TrimPrefix(trimmed, "A:")
|
||||||
case strings.HasPrefix(trimmed, "o:"):
|
case strings.HasPrefix(trimmed, "o:"):
|
||||||
oVal = strings.TrimPrefix(trimmed, "o:")
|
oVal = strings.TrimPrefix(trimmed, "o:")
|
||||||
|
case strings.HasPrefix(trimmed, "p:"):
|
||||||
|
plVal = strings.TrimPrefix(trimmed, "p:")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Lines outside of entries just get appended directly
|
// Lines outside of entries just get appended directly
|
||||||
|
@ -171,7 +173,7 @@ func removeExistingEntry(name, release, arch, origin string) {
|
||||||
// Handle the last entry if we ended inEntry
|
// Handle the last entry if we ended inEntry
|
||||||
if inEntry && len(currentEntry) > 0 {
|
if inEntry && len(currentEntry) > 0 {
|
||||||
// Decide whether to keep the final entry
|
// Decide whether to keep the final entry
|
||||||
if !(pVal == name && rVal == release && aVal == arch && oVal == origin) {
|
if !(pVal == name && rVal == release && aVal == arch && oVal == origin && plVal == platform) {
|
||||||
newLines = append(newLines, currentEntry...)
|
newLines = append(newLines, currentEntry...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue