mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 23:18:49 +00:00
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.
This commit is contained in:
parent
b58b632be9
commit
19bfaff943
14
CHANGELOG.md
14
CHANGELOG.md
@ -13,6 +13,20 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
|||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
### Fixed
|
### 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
|
## [0.67.5] - 2025-11-11
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
2
Makefile
2
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
|
.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)
|
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||||
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
||||||
|
|||||||
@ -285,13 +285,30 @@ func (bi *BinaryInstaller) InstallDeBrosBinaries(branch string, debrosHome strin
|
|||||||
os.MkdirAll(srcDir, 0755)
|
os.MkdirAll(srcDir, 0755)
|
||||||
os.MkdirAll(binDir, 0755)
|
os.MkdirAll(binDir, 0755)
|
||||||
|
|
||||||
// Clone repository if not present
|
// Check if git repository is already initialized
|
||||||
if _, err := os.Stat(filepath.Join(srcDir, "Makefile")); os.IsNotExist(err) {
|
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")
|
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)
|
cmd := exec.Command("git", "clone", "--branch", branch, "--depth", "1", "https://github.com/DeBrosOfficial/network.git", srcDir)
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return fmt.Errorf("failed to clone repository: %w", err)
|
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
|
// Build binaries
|
||||||
@ -386,6 +403,32 @@ func (bi *BinaryInstaller) InitializeIPFSRepo(nodeType, ipfsRepoPath string, swa
|
|||||||
if output, err := cmd.CombinedOutput(); err != nil {
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("failed to disable AutoConf: %v\n%s", err, string(output))
|
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
|
// Fix ownership
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user