Skip to content

Commit

Permalink
Merge pull request #14 from dpastoor/rhel7
Browse files Browse the repository at this point in the history
feat: add conditional logic for rhel7
  • Loading branch information
dpastoor authored Jan 14, 2023
2 parents 735fbd6 + 56b14bd commit 5c34787
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
21 changes: 20 additions & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"runtime"
"strings"
"sync"

"github.com/AlecAivazis/survey/v2"
Expand Down Expand Up @@ -82,7 +83,25 @@ func newInstall(installOpts installOpts, release string) (error, string) {
return nil, release
}
log.Info("attempting to install quarto version: ", release)
res, err := pipeline.DownloadReleaseVersion(release, runtime.GOOS, installOpts.progress)
osType := runtime.GOOS

// quarto has a specific custom version for rhel7/centos7 because
// of the old version of glibc so if on linux we need to also check
// what version to pull
if osType == "linux" {
// check if rhel7 system
if _, err := os.Stat("/etc/redhat-release"); err == nil {
releaseVersion, err := os.ReadFile("/etc/redhat-release")
if err != nil {
return err, ""
}
if strings.Contains(string(releaseVersion), "release 7") {
osType = "rhel7"
}
}
}

res, err := pipeline.DownloadReleaseVersion(release, osType, installOpts.progress)
if err != nil {
return err, ""
}
Expand Down
9 changes: 7 additions & 2 deletions internal/gh/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func getOsAssetSuffix(os string) osAssetSuffix {
return macos
case "windows":
return win
case "rhel7":
return rhel7
default:
return unknown
}
Expand All @@ -35,6 +37,7 @@ const (
linuxamd64
macos
win
rhel7
)

func (o osAssetSuffix) String() string {
Expand All @@ -45,6 +48,8 @@ func (o osAssetSuffix) String() string {
return "macos.tar.gz"
case win:
return "win.zip"
case rhel7:
return "linux-rhel7-amd64.tar.gz"
default:
return "unknown"
}
Expand Down Expand Up @@ -78,10 +83,10 @@ func (wc *WriteCounter) Write(p []byte) (int, error) {
// targetOs should be "windows", "darwin", "linux"
func DownloadReleaseAsset(client *github.Client, tag string, targetOs string, progress bool) (string, error) {
switch targetOs {
case "windows", "darwin", "linux":
case "windows", "darwin", "linux", "rhel7":
break
default:
return "", fmt.Errorf("invalid target os: %s, must be one of linux,darwin,windows", targetOs)
return "", fmt.Errorf("invalid target os: %s, must be one of linux,darwin,windows,rhel7", targetOs)
}
release, err := GetRelease(client, tag)
if err != nil {
Expand Down

0 comments on commit 5c34787

Please sign in to comment.