Skip to content

Commit

Permalink
Merge branch 'master' into nextyb
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridai Govinda Pombo committed Jul 13, 2020
2 parents cbaa501 + 2520ea1 commit 813f3e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions buildpacks/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (bt GolangBuildTool) Install(ctx context.Context) (string, error) {

log.Infof("Downloading from URL %s ...", downloadURL)
localFile, err := t.DownloadFile(ctx, downloadURL)
if err != nil {
log.Errorf("Error downloading file: %v", err)
return "", err
}

err = t.Unarchive(ctx, localFile, installDir)
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions buildpacks/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (bt RustBuildTool) Setup(ctx context.Context, rustDir string) error {
return nil
}

func (bt RustBuildTool) ArchiveFile() string {
func (bt RustBuildTool) installerFile() string {
extension := ""
return fmt.Sprintf("rustup-init%s", extension)
}
Expand All @@ -49,7 +49,7 @@ func (bt RustBuildTool) DownloadURL(ctx context.Context) (string, error) {
arch := "x86_64"
operatingSystem := "unknown-linux-gnu"

return fmt.Sprintf("%s/%s-%s/%s", rustDistMirrorTemplate, arch, operatingSystem, bt.ArchiveFile()), nil
return fmt.Sprintf("%s/%s-%s/%s", rustDistMirrorTemplate, arch, operatingSystem, bt.installerFile()), nil
}

func (bt RustBuildTool) Install(ctx context.Context) (string, error) {
Expand All @@ -71,7 +71,7 @@ func (bt RustBuildTool) Install(ctx context.Context) (string, error) {
}

downloadDir := t.ToolsDir(ctx)
localFile := filepath.Join(downloadDir, bt.ArchiveFile())
localFile := filepath.Join(downloadDir, bt.installerFile())
log.Infof("Downloading from URL %s to local file %s", downloadURL, localFile)
localFile, err = t.DownloadFile(ctx, downloadURL)
if err != nil {
Expand All @@ -82,10 +82,15 @@ func (bt RustBuildTool) Install(ctx context.Context) (string, error) {
t.SetEnv("CARGO_HOME", rustDir)
t.SetEnv("RUSTUP_HOME", rustDir)

_, newName := filepath.Split(localFile)
renamedFilePath := filepath.Join(downloadDir, newName)

for _, cmd := range []string{
"chmod +x " + localFile,
localFile + " -y",
"mv " + localFile + " " + renamedFilePath,
"./" + newName + " -y",
} {
log.Infof("Running %v", cmd)
p := runtime.Process{
Command: cmd,
Directory: downloadDir,
Expand Down

0 comments on commit 813f3e8

Please sign in to comment.