func GetVersions(ipfspath, dist string) ([]string, error) { rc, err := util.Fetch(ipfspath + "/" + dist + "/versions") if err != nil { return nil, err } defer rc.Close() var out []string scan := bufio.NewScanner(rc) for scan.Scan() { out = append(out, scan.Text()) } return out, nil }
func GetBinaryForVersion(distname, binnom, root, vers, out string) error { stump.Log("fetching %s version %s", distname, vers) dir, err := ioutil.TempDir("", "ipfs-update") if err != nil { return err } stump.VLog(" - using GOOS=%s and GOARCH=%s", runtime.GOOS, runtime.GOARCH) var archive string switch runtime.GOOS { case "windows": archive = "zip" default: archive = "tar.gz" } finame := fmt.Sprintf("%s_%s_%s-%s.%s", distname, vers, runtime.GOOS, runtime.GOARCH, archive) distpath := fmt.Sprintf("%s/%s/%s/%s", root, distname, vers, finame) data, err := util.Fetch(distpath) if err != nil { return err } arcpath := filepath.Join(dir, finame) fi, err := os.Create(arcpath) if err != nil { return err } stump.VLog(" - writing to", arcpath) _, err = io.Copy(fi, data) if err != nil { return err } fi.Close() return unpackArchive(distname, binnom, arcpath, out, archive) }