Changeset 3028 for trunk/packages/invirt-dev/python
- Timestamp:
- Jul 5, 2010, 2:01:45 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-dev/python/invirt/builder.py
r2834 r3028 29 29 return os.path.join(_REPO_DIR, 'invirt/packages', '%s.git' % package) 30 30 31 def ensureValidRepo(package): 32 """Perform some basic sanity checks that the requested repo is in a 33 subdirectory of _REPO_DIR/invirt/packages. This prevents weirdness 34 such as submitting a package like '../prod/...git'. Also ensures that 35 the repo exists.""" 36 # TODO: this might be easier just to regex 37 repo = os.path.abspath(getRepo(package)) 38 parent_dir = os.path.dirname(repo) 39 prefix = os.path.join(_REPO_DIR, 'invirt/packages') 40 if not parent_dir.startswith(prefix): 41 raise InvalidBuild('Invalid package name %s' % package) 42 elif not os.path.exists(repo): 43 raise InvalidBuild('Nonexisting package %s' % package) 31 44 32 45 def pocketToGit(pocket): … … 43 56 """Return the contents of a path from a git ref in a package.""" 44 57 return c.captureOutput(['git', 'cat-file', 'blob', '%s:%s' % (ref, path)], 45 cwd=getRepo(package))58 cwd=getRepo(package)) 46 59 47 60 … … 86 99 it returns True. 87 100 """ 101 ensureValidRepo(package) 88 102 package_repo = getRepo(package) 89 103 new_version = getVersion(package, commit) … … 97 111 b = pocketToGit(p) 98 112 current_commit = c.captureOutput(['git', 'rev-parse', b], 99 cwd=package_repo)113 cwd=package_repo).strip() 100 114 current_version = getVersion(package, b) 101 115 … … 104 118 ret = p 105 119 else: 106 raise InvalidBuild('Version %s of %s already available i n '120 raise InvalidBuild('Version %s of %s already available is in ' 107 121 'pocket %s from commit %s' % 108 122 (new_version, package, p, current_commit)) 109 123 110 if config.build.pockets[pocket].get('allow_backtracking', False):124 if not config.build.pockets[pocket].get('allow_backtracking', False): 111 125 branch = pocketToGit(pocket) 112 126 current_version = getVersion(package, branch)
Note: See TracChangeset
for help on using the changeset viewer.