From 19bfaff943572147529a29262560240451655674 Mon Sep 17 00:00:00 2001 From: anonpenguin23 Date: Tue, 11 Nov 2025 08:35:40 +0200 Subject: [PATCH] feat: enhance binary installation and IPFS configuration management - Improved the binary installation process by checking if the git repository is already initialized, allowing for updates instead of re-cloning. - Added error handling for fetching and resetting the repository to ensure the latest changes are applied. - Enhanced IPFS configuration management by clearing AutoConf placeholders to prevent startup errors, with detailed logging for each cleanup step. --- CHANGELOG.md | 14 +++++++ Makefile | 2 +- pkg/environments/production/installers.go | 47 ++++++++++++++++++++++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 846d701..c8ff78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,20 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant ### Deprecated ### Fixed +## [0.67.6] - 2025-11-11 + +### Added +\n +### Changed +- The binary installer now updates the source repository if it already exists, instead of only cloning it if missing. + +### Deprecated + +### Removed + +### Fixed +- Resolved an issue where disabling AutoConf in the IPFS repository could leave 'auto' placeholders in the config, causing startup errors. + ## [0.67.5] - 2025-11-11 ### Added diff --git a/Makefile b/Makefile index 2fdbb53..41f653b 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test-e2e: .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill -VERSION := 0.67.5 +VERSION := 0.67.6 COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' diff --git a/pkg/environments/production/installers.go b/pkg/environments/production/installers.go index d4683fa..a14f374 100644 --- a/pkg/environments/production/installers.go +++ b/pkg/environments/production/installers.go @@ -285,13 +285,30 @@ func (bi *BinaryInstaller) InstallDeBrosBinaries(branch string, debrosHome strin os.MkdirAll(srcDir, 0755) os.MkdirAll(binDir, 0755) - // Clone repository if not present - if _, err := os.Stat(filepath.Join(srcDir, "Makefile")); os.IsNotExist(err) { + // Check if git repository is already initialized + repoInitialized := false + if _, err := os.Stat(filepath.Join(srcDir, ".git")); err == nil { + repoInitialized = true + } + + // Clone repository if not present, otherwise update it + if !repoInitialized { fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Cloning repository...\n") cmd := exec.Command("git", "clone", "--branch", branch, "--depth", "1", "https://github.com/DeBrosOfficial/network.git", srcDir) if err := cmd.Run(); err != nil { return fmt.Errorf("failed to clone repository: %w", err) } + } else { + fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Updating repository to latest changes...\n") + if output, err := exec.Command("git", "-C", srcDir, "fetch", "origin", branch).CombinedOutput(); err != nil { + return fmt.Errorf("failed to fetch repository updates: %v\n%s", err, string(output)) + } + if output, err := exec.Command("git", "-C", srcDir, "reset", "--hard", "origin/"+branch).CombinedOutput(); err != nil { + return fmt.Errorf("failed to reset repository: %v\n%s", err, string(output)) + } + if output, err := exec.Command("git", "-C", srcDir, "clean", "-fd").CombinedOutput(); err != nil { + return fmt.Errorf("failed to clean repository: %v\n%s", err, string(output)) + } } // Build binaries @@ -386,6 +403,32 @@ func (bi *BinaryInstaller) InitializeIPFSRepo(nodeType, ipfsRepoPath string, swa if output, err := cmd.CombinedOutput(); err != nil { return fmt.Errorf("failed to disable AutoConf: %v\n%s", err, string(output)) } + + // Clear AutoConf placeholders from config to prevent Kubo startup errors + // When AutoConf is disabled, 'auto' placeholders must be replaced with explicit values or empty + fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " Clearing AutoConf placeholders from IPFS config...\n") + + type configCommand struct { + desc string + args []string + } + + // List of config replacements to clear 'auto' placeholders + cleanup := []configCommand{ + {"clearing Bootstrap peers", []string{"config", "Bootstrap", "--json", "[]"}}, + {"clearing Routing.DelegatedRouters", []string{"config", "Routing.DelegatedRouters", "--json", "[]"}}, + {"clearing Ipns.DelegatedPublishers", []string{"config", "Ipns.DelegatedPublishers", "--json", "[]"}}, + {"clearing DNS.Resolvers", []string{"config", "DNS.Resolvers", "--json", "{}"}}, + } + + for _, step := range cleanup { + fmt.Fprintf(bi.logWriter.(interface{ Write([]byte) (int, error) }), " %s...\n", step.desc) + cmd := exec.Command(ipfsBinary, step.args...) + cmd.Env = append(os.Environ(), "IPFS_PATH="+ipfsRepoPath) + if output, err := cmd.CombinedOutput(); err != nil { + return fmt.Errorf("failed while %s: %v\n%s", step.desc, err, string(output)) + } + } } // Fix ownership