Skip to content

Commit

Permalink
patch: give clear message after init; auto-reload when apt in use
Browse files Browse the repository at this point in the history
  • Loading branch information
rockavoldy committed Nov 9, 2023
1 parent 004207f commit 081cb81
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
path: ${{ github.workspace }}/publish

- name: Get Commits since last Release
id: changes
id: changelog
uses: simbo/changes-since-last-release-action@v1
with:
line-prefix: "* "
Expand All @@ -152,5 +152,5 @@ jobs:
tag: "${{ needs.build.outputs.bump_tag }}"
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Changes since ${{ steps.changes.outputs.last-tag }}:
${{ steps.changes.outputs.log }}
Changes since ${{ steps.changelog.outputs.last-tag }}:
${{ steps.changelog.outputs.log }}
31 changes: 24 additions & 7 deletions cmd/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"strings"
"time"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -54,18 +55,34 @@ func CheckRequirement() {
}

fmt.Println("Update apt repositories, please wait...")
err = exec.Command("sudo", "apt-get", "update").Run()
if err != nil {
Logger.Fatalln("Failed to update repositories: ", err)
doneProcess := false
for !doneProcess {
err = exec.Command("sudo", "apt-get", "update").Run()
if err != nil {
if !strings.Contains(err.Error(), "exit status 100") {
doneProcess = true
Logger.Fatalln("Failed to update repositories: ", err)
}
Logger.Println("Update repositories: ", err)
time.Sleep(500 * time.Millisecond)
}
}

fmt.Println("Installing dependencies, please wait...")
cmdAptInstall := []string{"apt-get", "install", "-y"}
cmdAptInstall := []string{"apt-get", "install", "-y", "--no-install-recommends"}
cmdAptInstall = utils.PrependCommand(notInstalledDeps, cmdAptInstall)

err = exec.Command("sudo", cmdAptInstall...).Run()
if err != nil {
Logger.Fatalln("Install dependencies: ", err)
doneProcess = false
for !doneProcess {
err = exec.Command("sudo", cmdAptInstall...).Run()
if err != nil {
if !strings.Contains(err.Error(), "exit status 100") {
doneProcess = true
Logger.Fatalln("Failed to install dependencies: ", err)
}
Logger.Println("Install dependencies: ", err)
time.Sleep(500 * time.Millisecond)
}
}

fmt.Println("Dependencies installed")
Expand Down
21 changes: 13 additions & 8 deletions utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,21 @@ addons_path = ./addons, ./odoo/addons`, dbUser, dbPass, dbName)
}

func PyenvInfoBash() {
rcfile := "~/.bashrc"
if strings.Contains(os.Getenv("SHELL"), "zsh") {
rcfile = "~/.zshrc"
}
fmt.Println()
fmt.Println("One more thing you need to do, please add this line to your ~/.bashrc file:")
fmt.Printf("One more thing you need to do, please add this line to your %s file:\n", rcfile)
fmt.Println("(Just copy and paste to your terminal line per line)")
fmt.Println()
fmt.Println(`echo 'PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc`)
fmt.Println(`echo 'PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc`)
fmt.Println(`echo 'eval "$(pyenv init -)"' >> ~/.bashrc`)
fmt.Println(`echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc`)
fmt.Printf(`echo 'PYENV_ROOT="$HOME/.pyenv"' >> %s\n`, rcfile)
fmt.Printf(`echo 'PATH="$PYENV_ROOT/bin:$PATH"' >> %s\n`, rcfile)
fmt.Printf(`echo 'eval "$(pyenv init -)"' >> %s\n`, rcfile)
fmt.Printf(`echo 'eval "$(pyenv virtualenv-init -)"' >> %s\n`, rcfile)
fmt.Println()
fmt.Println("Then run this command to reload your bashrc file")
fmt.Println("source ~/.bashrc")
fmt.Printf("\n\nIf you have zsh as your shell, changes '~/.bashrc' here with '~/.zshrc'\n\n")
fmt.Println("Then run this command to reload your shell")
fmt.Printf("source %s\n", rcfile)
}

func IsPyenvConfigured() bool {
Expand Down Expand Up @@ -170,6 +173,8 @@ func ValidateOdooVer(odooVer string) bool {
return true
case "16.0":
return true
case "17.0":
return true
default:
return false
}
Expand Down

0 comments on commit 081cb81

Please sign in to comment.