示例#1
0
func (proj *Project) checkVersionRequirements(r *repo.Repo, upgrade bool, force bool) (bool, error) {
	rdesc, err := r.GetRepoDesc()
	if err != nil {
		return false, err
	}

	rname := r.Name()

	vers := proj.projState.GetInstalledVersion(rname)
	if vers != nil {
		ok := rdesc.SatisfiesVersion(vers, r.VersionRequirements())
		if !ok && !upgrade {
			util.StatusMessage(util.VERBOSITY_QUIET, "WARNING: Installed "+
				"version %s of repository %s does not match desired "+
				"version %s in project file.  You can fix this by either upgrading"+
				" your repository, or modifying the project.yml file.\n",
				vers, rname, r.VersionRequirementsString())
			return true, err
		} else {
			if !upgrade {
				util.StatusMessage(util.VERBOSITY_VERBOSE, "%s correct version already installed\n", r.Name())
				return true, nil
			} else {
				skip, err := proj.upgradeCheck(r, vers, force)
				return skip, err
			}
		}
	} else {
		// Fallthrough and perform the installation.
		// Check to make sure that this repository contains a version
		// that can satisfy.
		_, _, ok := rdesc.Match(r)
		if !ok {
			fmt.Printf("WARNING: No matching repository version found for repository "+
				"%s specified in project.\n", r.Name())
			return true, err
		}
	}

	return false, nil
}