Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Install = cli.Command{ Name: "install", Usage: "Install/upgrade jig and its pre-req's into your PATH", Flags: []cli.Flag{ cli.StringFlag{ Name: "binpath", Usage: "Destination directory to install tools to", Value: config.RancherBinDir, Destination: &binPath, }, cli.StringFlag{ Name: "softlinkpath", Usage: "Destination directory in PATH in which to create softlinks to tools", Value: config.GlobalBinDir, Destination: &softlinkPath, }, cli.BoolFlag{ Name: "update, upgrade", Usage: "Check for updated releases", Destination: &updateFlag, }, }, Action: func(context *cli.Context) error { jigFileToInstall, _ := osext.Executable() jigTo := "jig" if runtime.GOOS == "windows" { jigTo = jigTo + ".exe" } latestVersion := context.App.Version from, _ := filepath.EvalSymlinks(jigFileToInstall) to, _ := filepath.EvalSymlinks(filepath.Join(binPath, jigTo)) log.Debugf("testing %s (%s) to %s", from, os.Args[0], to) if updateFlag || from == to { log.Infof("Checking for newer version of jig.") resp, err := http.Get("https://github.com/SvenDowideit/jig/releases/latest") if err != nil { log.Infof("Error checking for latest version \n%s", err) } else { releaseUrl := resp.Request.URL.String() latestVersion = releaseUrl[strings.LastIndex(releaseUrl, "/")+1:] log.Debugf("this version == %s, latest version == %s", context.App.Version, latestVersion) thisVer := strings.Split(context.App.Version, ",") log.Debugf("this version == %s, latest version == %s", thisVer[0], latestVersion) thisDate, _ := time.Parse("2006-01-02", thisVer[0]) latestDate, _ := time.Parse("2006-01-02", latestVersion) if !latestDate.After(thisDate) { log.Debugf("%s is already up to date (current: : %s)(latest: %s)", jigTo, thisVer[0], latestVersion) log.Infof("%s is already up to date", jigTo) } else { log.Infof("Downloading new version of jig.") jigFile := "jig" if runtime.GOOS == "darwin" { jigFile += "-osx" } if runtime.GOOS == "windows" { jigFile += ".exe" } log.Infof("Downloading newer version of 'jig': %s", latestVersion) dir, err := ioutil.TempDir("", "jig") if err != nil { log.Fatal(err) } defer os.RemoveAll(dir) jigFileToInstall := filepath.Join(dir, "jig-download-"+latestVersion) log.Debugf("os.Arg[0]: %s ~~ jigTo %s", jigFileToInstall, jigTo) if err := wget("https://github.com/SvenDowideit/jig/releases/download/"+latestVersion+"/"+jigFile, jigFileToInstall); err != nil { return err } log.Infof("Running install using newly downloaded 'jig'") logfile.StopLogging() return util.Run(jigFileToInstall, "install") } } } jigExeName := "jig-" + latestVersion if runtime.GOOS == "windows" { jigExeName = jigExeName + ".exe" } if err := install(jigFileToInstall, jigExeName, jigTo); err != nil { return err } metaData := bugsnag.MetaData{} for _, v := range config.InstallCfg[runtime.GOOS] { version, err := installApp(v.Command, v.UrlPath, v.UrlFile) if err != nil { log.Error(err) } metaData.Add("app", v.Command, version) } metaData.Add("app", "compiler", fmt.Sprintf("%s (%s)", runtime.Compiler, runtime.Version())) metaData.Add("app", "latestVersion", latestVersion) metaData.Add("device", "os", runtime.GOOS) metaData.Add("device", "arch", runtime.GOARCH) cmd := exec.Command("uname", "-a") output, err := cmd.Output() if err != nil { return err } metaData.Add("device", "uname", string(output)) bugsnag.Notify(fmt.Errorf("Successful installation"), metaData) return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.