Changeset 3028 for trunk/packages/invirt-dev/invirtibuilder
- Timestamp:
- Jul 5, 2010, 2:01:45 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-dev/invirtibuilder
r2838 r3028 30 30 31 31 import contextlib 32 import glob 32 33 import os 33 34 import re 34 35 import shutil 35 36 import subprocess 37 import tempfile 38 import traceback 36 39 37 40 import pyinotify 38 41 42 from debian_bundle import deb822 43 39 44 import invirt.builder as b 45 import invirt.common as c 40 46 from invirt import database 47 from invirt.config import structs as config 41 48 42 49 … … 52 59 """ 53 60 return deb822.Deb822.iter_paragraphs( 54 getGitFile(package, ref, 'debian/control').split('\n'))61 b.getGitFile(package, ref, 'debian/control').split('\n')) 55 62 56 63 … … 72 79 def getDscName(package, ref): 73 80 """Return the .dsc file that will be generated for this package.""" 74 v = getVersion(package, ref)81 v = b.getVersion(package, ref) 75 82 if v.debian_version: 76 83 v_str = '%s-%s' % (v.upstream_version, … … 96 103 97 104 98 def aptCopy(package s, dst_pocket, src_pocket):105 def aptCopy(package, commit, dst_pocket, src_pocket): 99 106 """Copy a package from one pocket to another.""" 100 107 binaries = getBinaries(package, commit) 101 c patureOutput(['reprepro-env', 'copy',102 b.pocketToApt(dst_pocket),103 b.pocketToApt(src_pocket),104 package] + binaries)108 c.captureOutput(['reprepro-env', 'copy', 109 b.pocketToApt(dst_pocket), 110 b.pocketToApt(src_pocket), 111 package] + binaries) 105 112 106 113 … … 123 130 124 131 125 def tagSubmodule(pocket, package, ref, principal):132 def tagSubmodule(pocket, package, principal, version, env): 126 133 """Tag a new version of a submodule. 127 134 … … 139 146 """ 140 147 if not config.build.pockets[pocket].get('allow_backtracking', False): 141 env = dict(os.environ)142 148 branch = b.pocketToGit(pocket) 143 version = b.getVersion(package, ref)144 145 env['GIT_COMMITTER_NAME'] = config.build.tagger.name146 env['GIT_COMMITTER_EMAIL'] = config.build.tagger.email147 149 tag_msg = ('Tag %s of %s\n\n' 148 150 'Requested by %s' % (version.full_version, … … 160 162 branch = b.pocketToGit(pocket) 161 163 c.captureOutput( 162 ['git', 'update-ref', 'refs/heads/%s' % branch, ref] )164 ['git', 'update-ref', 'refs/heads/%s' % branch, ref], cwd=b.getRepo(package)) 163 165 164 166 … … 168 170 for changes in glob.glob(os.path.join(workdir, '*.changes')): 169 171 c.captureOutput(['reprepro-env', 172 '--ignore=wrongdistribution', 170 173 'include', 171 '--ignore=wrongdistribution',172 174 apt, 173 175 changes]) 174 176 175 177 176 def updateSuperproject(pocket, package, commit, principal ):178 def updateSuperproject(pocket, package, commit, principal, version, env): 177 179 """Update the superproject. 178 180 … … 186 188 branch = b.pocketToGit(pocket) 187 189 tree = c.captureOutput(['git', 'ls-tree', branch], 188 cwd=superproject)190 cwd=superproject).strip() 189 191 190 192 new_tree = re.compile( 191 193 r'^(160000 commit )[0-9a-f]*(\t%s)$' % package, re.M).sub( 192 r'\ 1%s\2' % commit,194 r'\g<1>%s\g<2>' % commit, 193 195 tree) 194 196 195 new_tree_id = c.captureOutput(['git', 'mktree' ],196 cwd=superproject,197 stdin_str=new_tree)197 new_tree_id = c.captureOutput(['git', 'mktree', '--missing'], 198 cwd=superproject, 199 stdin_str=new_tree).strip() 198 200 199 201 commit_msg = ('Update %s to version %s\n\n' … … 202 204 principal)) 203 205 new_commit = c.captureOutput( 204 ['git', 'commit-tree', new_tree_ hash, '-p', branch],206 ['git', 'commit-tree', new_tree_id, '-p', branch], 205 207 cwd=superproject, 206 208 env=env, 207 stdin_str=commit_msg) 209 stdin_str=commit_msg).strip() 208 210 209 211 c.captureOutput( … … 211 213 cwd=superproject) 212 214 215 216 def makeReadable(workdir): 217 os.chmod(workdir, 0755) 213 218 214 219 @contextlib.contextmanager … … 228 233 ['git', 'archive', 229 234 '--remote=file://%s' % b.getRepo(package), 230 '--prefix=%s ' % package,235 '--prefix=%s/' % package, 231 236 commit, 232 237 ], … … 278 283 db.principal = principal 279 284 database.session.save_or_update(db) 280 database. commit()281 282 database. begin()285 database.session.commit() 286 287 database.session.begin() 283 288 284 289 try: 285 290 db.failed_stage = 'validating job' 286 src = validateBuild(pocket, package, commit) 291 src = b.validateBuild(pocket, package, commit) 292 # Don't expand the commit in the DB until we're sure the user 293 # isn't trying to be tricky. 294 db.commit = commit = c.captureOutput(['git', 'rev-parse', commit], 295 cwd=b.getRepo(package)).strip() 287 296 288 297 db.version = str(b.getVersion(package, commit)) … … 295 304 if src != True: 296 305 db.failed_stage = 'copying package from another pocket' 297 aptCopy(package s, pocket, src)306 aptCopy(package, commit, pocket, src) 298 307 # If we can't copy the package from somewhere, but 299 308 # validateBuild didn't raise an exception, then we need to … … 320 329 sbuildAll(package, commit, workdir) 321 330 finally: 322 logdir = os.path.join(b._LOG_DIR, db.build_id)331 logdir = os.path.join(b._LOG_DIR, str(db.build_id)) 323 332 if not os.path.exists(logdir): 324 333 os.makedirs(logdir) … … 326 335 for log in glob.glob(os.path.join(workdir, '*.build')): 327 336 os.copy2(log, logdir) 337 338 db.failed_stage = 'processing metadata' 339 env = dict(os.environ) 340 env['GIT_COMMITTER_NAME'] = config.build.tagger.name 341 env['GIT_COMMITTER_EMAIL'] = config.build.tagger.email 342 version = b.getVersion(package, commit) 343 328 344 db.failed_stage = 'tagging submodule' 329 tagSubmodule(pocket, package, commit, principal)345 tagSubmodule(pocket, package, principal, version, env) 330 346 db.failed_stage = 'updating submodule branches' 331 347 updateSubmoduleBranch(pocket, package, commit) 332 348 db.failed_stage = 'updating superproject' 333 updateSuperproject(pocket, package, commit, principal) 349 updateSuperproject(pocket, package, commit, principal, version, env) 350 db.failed_stage = 'relaxing permissions on workdir' 351 makeReadable(workdir) 334 352 db.failed_stage = 'uploading packages to apt repo' 335 353 uploadBuild(pocket, workdir)
Note: See TracChangeset
for help on using the changeset viewer.