コード例 #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)
}