Ejemplo n.º 1
0
//TODO: this is commented out because it's an unfinished proof-of-concept.
func NoTestUnAr(t *testing.T) {
	goroot := runtime.GOROOT()
	goos := "linux"
	arch := "arm"
	platPkgFileRuntime := filepath.Join(goroot, "pkg", goos+"_"+arch, "runtime.a")
	nr, err := os.Open(platPkgFileRuntime)
	if err != nil {
		t.Fatalf("failed: %v", err)
	}
	tr, err := NewReader(nr)
	if err != nil {
		t.Fatalf("failed: %v", err)
	}
	for {
		h, err := tr.Next()
		if err != nil {
			t.Fatalf("failed: %v", err)
		}
		log.Printf("Header: %+v", h)
		if h.Name == "__.PKGDEF" {
			firstLine := make([]byte, 50)
			if _, tr.err = io.ReadFull(tr.r, firstLine); tr.err != nil {
				t.Fatalf("failed: %v", err)
			}
			tr.nb -= 50
			log.Printf("pkgdef first part: '%s'", string(firstLine))
			expectedPrefix := "go object " + goos + " " + arch + " "
			if !strings.HasPrefix(string(firstLine), expectedPrefix) {
				t.Fatalf("failed: does not match '%s'", expectedPrefix)
			}
			parts := strings.Split(string(firstLine), " ")
			compiledVersion := parts[4]
			log.Printf("Compiled version: %s", compiledVersion)
			runtimeVersion := runtime.Version()
			log.Printf("Runtime version: %s", runtimeVersion)
			cmd := exec.Command("go")
			args := []string{"version"}
			err = executils.PrepareCmd(cmd, ".", args, []string{}, false)
			out, err := cmd.Output()
			if err != nil {
				log.Printf("`go version` failed: %v", err)
			}
			log.Printf("output: %s", string(out))
			goParts := strings.Split(string(out), " ")
			goVersion := goParts[2]
			log.Printf("Go version: %s", goVersion)
			if compiledVersion != goVersion {
				t.Fatalf("Package version does NOT match!")
			}
		}
	}
}
Ejemplo n.º 2
0
Archivo: tag.go Proyecto: yl10/goxc
func tag(tp TaskParams) error {
	vcs := tp.Settings.GetTaskSettingString(TASK_TAG, "vcs")
	prefix := tp.Settings.GetTaskSettingString(TASK_TAG, "prefix")

	if vcs == "git" {
		version := tp.Settings.GetFullVersionName()
		cmd := exec.Command("git")
		args := []string{"tag", prefix + version}
		err := executils.PrepareCmd(cmd, tp.WorkingDirectory, args, []string{}, tp.Settings.IsVerbose())
		if err != nil {
			return err
		}
		return executils.StartAndWait(cmd)
	} else {
		return errors.New("Only 'git' is supported at this stage")
	}

}
Ejemplo n.º 3
0
func validatePlatToolchainPackageVersion(dest platforms.Platform, goroot string, verbose bool) error {
	platPkgFileRuntime := filepath.Join(goroot, "pkg", dest.Os+"_"+dest.Arch, "runtime.a")
	nr, err := os.Open(platPkgFileRuntime)
	if err != nil {
		log.Printf("Could not validate toolchain version: %v", err)
	}
	tr, err := ar.NewReader(nr)
	if err != nil {
		log.Printf("Could not validate toolchain version: %v", err)
	}
	for {
		h, err := tr.Next()
		if err != nil {
			if err == io.EOF {
				log.Printf("Could not validate toolchain version: %v", err)
				return nil
			}
			log.Printf("Could not validate toolchain version: %v", err)
			return err
		}
		//log.Printf("Header: %+v", h)
		if h.Name == "__.PKGDEF" {
			firstLine, err := tr.NextString(50)
			if err != nil {
				log.Printf("failed to read first line of PKGDEF: %v", err)
				return nil
			}
			//log.Printf("pkgdef first part: '%s'", firstLine)
			expectedPrefix := "go object " + dest.Os + " " + dest.Arch + " "
			if !strings.HasPrefix(firstLine, expectedPrefix) {
				log.Printf("first line of __.PKGDEF does not match expected pattern: %v", expectedPrefix)
				return nil
			}
			parts := strings.Split(firstLine, " ")
			compiledVersion := parts[4]
			//runtimeVersion := runtime.Version()
			//log.Printf("Runtime version: %s", runtimeVersion)
			cmdPath := filepath.Join(goroot, "bin", "go")
			cmd := exec.Command(cmdPath)
			args := []string{"version"}
			err = executils.PrepareCmd(cmd, ".", args, []string{}, false)
			if err != nil {
				log.Printf("`go version` failed: %v", err)
				return nil
			}
			goVersionOutput, err := cmd.Output()
			if err != nil {
				log.Printf("`go version` failed: %v", err)
				return nil
			}
			//log.Printf("output: %s", string(out))
			goVersionOutputParts := strings.Split(string(goVersionOutput), " ")
			goVersion := goVersionOutputParts[2]
			if compiledVersion != goVersion {
				return errors.New("static library version '" + compiledVersion + "' does NOT match `go version` '" + goVersion + "'!")
			}
			if verbose {
				log.Printf("Toolchain version '%s' verified against 'go %s' for %v", compiledVersion, goVersion, dest)
			}
			return nil
		}
	}
}