예제 #1
0
파일: repository.go 프로젝트: Andals/gpm
func parseRepositoryConf(repStr string) (*RepositoryConf, *exception.Exception) {
	repConf := new(RepositoryConf)
	repoRune := []rune(repStr)

	schemePos := strings.Index(repStr, SEP_SCHEME)
	if schemePos == -1 {
		return nil, exception.New(errno.E_CONF_REPOSITORY_STR_ERROR, "invalid repository str: don't have scheme pos")
	}
	repConf.scheme = string(repoRune[0:schemePos])

	url := ""
	tagPos := strings.LastIndex(repStr, SEP_TAG)
	if tagPos != -1 {
		repConf.tag = string(repoRune[tagPos+1:])
		url = string(repoRune[schemePos+len(SEP_SCHEME) : tagPos])
	} else {
		url = string(repoRune[schemePos+2:])
	}

	switch repConf.scheme {
	case "git+ssh:":
		repConf.url = url
	case "git+https:":
		repConf.url = "https://" + url
	case "git+http:":
		repConf.url = "http://" + url
	case "git:":
		repConf.url = "git://" + url
	default:
		return nil, exception.New(errno.E_CONF_REPOSITORY_STR_ERROR, "invalid repository str: undefined scheme")
	}

	return repConf, nil
}
예제 #2
0
파일: package.go 프로젝트: Andals/gpm
func ParsePackageConf(prjHome string) (*PackageConf, *exception.Exception) {
	confPath := getPackageJsonPath(prjHome)
	if !misc.FileExist(confPath) {
		return nil, exception.New(errno.E_CONF_PACKAGE_JSON_NOT_EXISTS, "There is no "+PACKAGE_JSON+" in "+prjHome)
	}

	var pkgJson packageJson

	jsonStr, _ := ioutil.ReadFile(confPath)
	err := json.Unmarshal(jsonStr, &pkgJson)
	if nil != err {
		return nil, exception.New(errno.E_CONF_PACKAGE_JSON_PARSE_ERROR, "Parse "+PACKAGE_JSON+" error")
	}

	return parseByJson(prjHome, &pkgJson)
}
예제 #3
0
파일: base.go 프로젝트: Andals/gpm
func GetCommand(name string) (ICommand, *exception.Exception) {
	switch name {
	case COMMAND_NAME_INSTALL:
		return new(installCommand), nil
	default:
		return nil, exception.New(errno.E_COMMAND_INVALID_NAME, "invalid command name")
	}
}
예제 #4
0
파일: package.go 프로젝트: Andals/gpm
func parseByJson(prjHome string, pkgJson *packageJson) (*PackageConf, *exception.Exception) {
	pkgConf := new(PackageConf)

	if pkgJson.Name == "" {
		return nil, exception.New(errno.E_CONF_PACKAGE_NAME_ERROR, "Parse package name error")
	}

	pkgConf.name = pkgJson.Name

	pkgConf.dependencies = make(map[string]*DependConf, len(pkgJson.Dependencies))
	for name, repStr := range pkgJson.Dependencies {
		depConf, err := parseDependConf(prjHome, name, repStr)
		if err != nil {
			fmt.Println("Parse depend conf error:" + err.Error())
			continue
		}
		pkgConf.dependencies[name] = depConf
	}

	return pkgConf, nil
}
예제 #5
0
파일: value.go 프로젝트: Andals/gpm
func (this *baseValue) Error() *exception.Exception {
	return exception.New(this.errno, this.msg)
}