Compare commits
No commits in common. "cad3f9a27f3787dd25a46a58bb3c30360df1e858" and "e080c9114dc1e8e43f99809b49028758a18001a8" have entirely different histories.
cad3f9a27f
...
e080c9114d
2 changed files with 21 additions and 19 deletions
18
.gitignore
vendored
18
.gitignore
vendored
|
@ -1,7 +1,11 @@
|
||||||
mozilla-central
|
/mozilla-central
|
||||||
mozilla-release
|
/mozilla-release
|
||||||
.vscode
|
/.vscode
|
||||||
patches
|
/patches
|
||||||
APPINDEX
|
/packages.json
|
||||||
browser-amd64-*
|
/packages_temp.json
|
||||||
sourceforge_config.json
|
/APKINDEX
|
||||||
|
/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, and p:
|
// Remove existing entry based on P, R, A, o (if you want to deduplicate).
|
||||||
removeExistingEntry(name, release, arch, origin, platform)
|
removeExistingEntry(name, release, arch, origin)
|
||||||
|
|
||||||
// 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, o, and p fields.
|
// removeExistingEntry removes an existing entry from APPINDEX if it matches P, R, A, and o fields.
|
||||||
func removeExistingEntry(name, release, arch, origin, platform string) {
|
func removeExistingEntry(name, release, arch, origin 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, platform 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
|
||||||
|
|
||||||
// We'll store the P, R, A, o, p values within the current entry
|
// Use these to store the P, R, A, o values within the current entry
|
||||||
var pVal, rVal, aVal, oVal, plVal string
|
var pVal, rVal, aVal, oVal 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, platform 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 && plVal == platform) {
|
if !(pVal == name && rVal == release && aVal == arch && oVal == origin) {
|
||||||
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, platform string) {
|
||||||
inEntry = true
|
inEntry = true
|
||||||
|
|
||||||
// Reset these values for the new entry
|
// Reset these values for the new entry
|
||||||
pVal, rVal, aVal, oVal, plVal = "", "", "", "", ""
|
pVal, rVal, aVal, oVal = "", "", "", ""
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ func removeExistingEntry(name, release, arch, origin, platform string) {
|
||||||
// Collect lines for this entry
|
// Collect lines for this entry
|
||||||
currentEntry = append(currentEntry, trimmed)
|
currentEntry = append(currentEntry, trimmed)
|
||||||
|
|
||||||
// Extract fields for matching later
|
// Extract P, R, A, o 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,8 +158,6 @@ func removeExistingEntry(name, release, arch, origin, platform 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
|
||||||
|
@ -173,7 +171,7 @@ func removeExistingEntry(name, release, arch, origin, platform 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 && plVal == platform) {
|
if !(pVal == name && rVal == release && aVal == arch && oVal == origin) {
|
||||||
newLines = append(newLines, currentEntry...)
|
newLines = append(newLines, currentEntry...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue