added automatic mozilla-release download
This commit is contained in:
parent
e5c95924d5
commit
a13f43086f
6 changed files with 477 additions and 194 deletions
|
@ -27,32 +27,36 @@ func PackageAPPINDEX(
|
|||
platform, // e.g. "linux"
|
||||
remoteDir string, // e.g. "nightly/linux/amd64"
|
||||
) error {
|
||||
fmt.Println("📦 Starting APPINDEX packaging...")
|
||||
|
||||
// Construct a filename that matches what you compress & upload
|
||||
// Adjust this naming convention to match your compress step exactly!
|
||||
// Example: "spitfire-browser-nightly-amd64-linux.tar.gz"
|
||||
fileName := fmt.Sprintf("%s-%s-%s-%s.tar.gz", origin, arch, release, platform)
|
||||
fmt.Printf(" ├─ Generated filename: %s\n", fileName)
|
||||
|
||||
// If you have a real file on disk, you might call `calcChecksum(fileName)`.
|
||||
// For demo, we call `calcChecksum` with a mock package name.
|
||||
// Calculate checksum
|
||||
checksum := calcChecksum(fileName)
|
||||
fmt.Printf(" ├─ Calculated checksum: %s\n", checksum[:8]+"...") // Show partial checksum
|
||||
|
||||
// Remove existing entry based on P, R, A, o, and p:
|
||||
removeExistingEntry(name, release, arch, origin, platform)
|
||||
|
||||
// Use current Unix timestamp
|
||||
timestamp := time.Now().Unix()
|
||||
fmt.Printf(" ├─ Current timestamp: %d\n", timestamp)
|
||||
|
||||
// Open or create the APPINDEX file for appending
|
||||
file, err := os.OpenFile("./APPINDEX", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to open APPINDEX file: %v", err)
|
||||
log.Fatalf("❌ Failed to open APPINDEX file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// Build the SourceForge-based download URL:
|
||||
// https://downloads.sourceforge.net/project/spitfire-browser/<remoteDir>/<fileName>
|
||||
downloadURL := fmt.Sprintf("https://downloads.sourceforge.net/project/spitfire-browser/%s/%s", remoteDir, fileName)
|
||||
fmt.Printf(" ├─ Download URL: %s\n", downloadURL)
|
||||
|
||||
// Format the entry.
|
||||
entry := fmt.Sprintf(`
|
||||
|
@ -85,11 +89,13 @@ func PackageAPPINDEX(
|
|||
// Trim leading newline to keep it clean
|
||||
entry = strings.TrimPrefix(entry, "\n")
|
||||
|
||||
// Write entry
|
||||
fmt.Println("✏️ Writing new entry...")
|
||||
if _, err := file.WriteString(entry + "\n"); err != nil {
|
||||
log.Fatalf("Failed to write to APPINDEX file: %v", err)
|
||||
log.Fatalf("❌ Failed to write to APPINDEX file: %v", err)
|
||||
}
|
||||
|
||||
fmt.Println("APPINDEX has been updated successfully.")
|
||||
fmt.Println("🎉 APPINDEX updated successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -192,10 +198,12 @@ func removeExistingEntry(name, release, arch, origin, platform string) {
|
|||
|
||||
// CleanAppIndex cleans up any orphaned "C:" entries and collapses excessive newlines
|
||||
func CleanAppIndex() error {
|
||||
fmt.Println("🧼 Cleaning APPINDEX file...")
|
||||
|
||||
// Read file contents
|
||||
content, err := os.ReadFile("./APPINDEX")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read APPINDEX: %v", err)
|
||||
return fmt.Errorf("❌ Failed to read APPINDEX: %v", err)
|
||||
}
|
||||
|
||||
// Split the file content into lines
|
||||
|
@ -242,11 +250,12 @@ func CleanAppIndex() error {
|
|||
cleanedContent = strings.ReplaceAll(cleanedContent, "\n\n\n", "\n\n")
|
||||
|
||||
// Write the cleaned content back to the file
|
||||
fmt.Println("✏️ Writing cleaned content...")
|
||||
err = os.WriteFile("./APPINDEX", []byte(cleanedContent), 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write cleaned APPINDEX: %v", err)
|
||||
return fmt.Errorf("❌ Failed to write cleaned APPINDEX: %v", err)
|
||||
}
|
||||
|
||||
fmt.Println("APPINDEX cleaned successfully.")
|
||||
fmt.Println("✅ APPINDEX cleaned successfully")
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue