fixed not being able to resolve homedir key path
This commit is contained in:
parent
c4693c4b14
commit
3bbc65268d
4 changed files with 15 additions and 5 deletions
2
go.mod
2
go.mod
|
@ -1,3 +1,5 @@
|
||||||
module spitfire-builder
|
module spitfire-builder
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
|
require github.com/mitchellh/go-homedir v1.1.0
|
||||||
|
|
2
go.sum
Normal file
2
go.sum
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
4
main.go
4
main.go
|
@ -69,7 +69,7 @@ func init() {
|
||||||
func printHelp() {
|
func printHelp() {
|
||||||
fmt.Println("Usage: go run . -p=<path-to-build> -t=<target> [-c|--compress] [-v|--version=<version>] [-component=<component>] [-arch=<architecture>] [-release=<release>] [-platform=<platform>]")
|
fmt.Println("Usage: go run . -p=<path-to-build> -t=<target> [-c|--compress] [-v|--version=<version>] [-component=<component>] [-arch=<architecture>] [-release=<release>] [-platform=<platform>]")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
fmt.Println("Example: go run . --upload -c --upload-path=./mozilla-release/obj-x86_64-pc-linux-gnu/dist/bin -a")
|
fmt.Println("Example: go run . --upload -c -a")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ func PackageAndUploadProcess(buildDir string) {
|
||||||
fmt.Printf("Compression efficiency: %.2f%%\n", efficiency)
|
fmt.Printf("Compression efficiency: %.2f%%\n", efficiency)
|
||||||
|
|
||||||
// Display compressed directory path
|
// Display compressed directory path
|
||||||
fmt.Printf("Compressed dir: %s", pathToUse)
|
fmt.Printf("Compressed dir: %s\n", pathToUse)
|
||||||
|
|
||||||
// If not uploading, we're done
|
// If not uploading, we're done
|
||||||
if !upload {
|
if !upload {
|
||||||
|
|
|
@ -12,6 +12,8 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config struct to hold SourceForge configurations
|
// Config struct to hold SourceForge configurations
|
||||||
|
@ -24,7 +26,7 @@ type Config struct {
|
||||||
|
|
||||||
// Load the SourceForge configuration from a file
|
// Load the SourceForge configuration from a file
|
||||||
func LoadConfig() (*Config, error) {
|
func LoadConfig() (*Config, error) {
|
||||||
file, err := os.Open("sourceforge_config.json") // Assuming a JSON config file
|
file, err := os.Open("sourceforge_config.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to open config file: %v", err)
|
return nil, fmt.Errorf("failed to open config file: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -35,8 +37,12 @@ func LoadConfig() (*Config, error) {
|
||||||
return nil, fmt.Errorf("failed to decode config file: %v", err)
|
return nil, fmt.Errorf("failed to decode config file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize the SSH key path for the current OS
|
// Expand tilde manually
|
||||||
config.SFKeyPath = filepath.Clean(config.SFKeyPath)
|
expandedPath, err := homedir.Expand(config.SFKeyPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed expanding key path: %v", err)
|
||||||
|
}
|
||||||
|
config.SFKeyPath = filepath.Clean(expandedPath)
|
||||||
|
|
||||||
// Validate that the key file exists
|
// Validate that the key file exists
|
||||||
if _, err := os.Stat(config.SFKeyPath); os.IsNotExist(err) {
|
if _, err := os.Stat(config.SFKeyPath); os.IsNotExist(err) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue