Changeset 3028
- Timestamp:
- Jul 5, 2010, 2:01:45 AM (14 years ago)
- Location:
- trunk/packages/invirt-dev
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-dev/README
r1322 r3028 6 6 The public key should then be in the apt keyring of systems using 7 7 the packages. 8 9 - Packages should be located at 10 /srv/git/invirt/packages/${packagename}.git -
trunk/packages/invirt-dev/debian/changelog
r3011 r3028 1 invirt-dev (0.1.1) unstable; urgency=low 2 3 * Added missing imports 4 * Other minor functional changes 5 6 -- Greg Brockman <gdb@mit.edu> Mon, 05 Jul 2010 01:43:45 -0400 7 1 8 invirt-dev (0.1.0) unstable; urgency=low 2 9 -
trunk/packages/invirt-dev/debian/control
r2819 r3028 8 8 Package: invirt-dev 9 9 Architecture: all 10 Depends: ${shlibs:Depends}, ${misc:Depends}, dpkg-dev-el, emacs21, reprepro, apache2, postfix, screen, dh-make, fakeroot, quilt, patchutils, config-package-dev, pbuilder, equivs, invirt-base, invirt-database, remctl-server, update-inetd, openbsd-inetd | inet-superserver, python-pyinotify10 Depends: ${shlibs:Depends}, ${misc:Depends}, dpkg-dev-el, emacs21, reprepro, apache2, postfix, screen, dh-make, fakeroot, quilt, patchutils, config-package-dev, sbuild, equivs, invirt-base, invirt-database, remctl-server, update-inetd, openbsd-inetd | inet-superserver, python-pyinotify, python-debian, git-core (>= 1.6.4) 11 11 Description: Invirt build and apt server 12 12 This packages the build scripts and apt-repository configuration for Invirt. -
trunk/packages/invirt-dev/invirt-submit-build
r2639 r3028 19 19 20 20 import datetime 21 import optparse 21 22 import os 22 23 import sys … … 28 29 29 30 def main(): 30 pocket, package, commit = sys.argv[1:4] 31 parser = optparse.OptionParser('Usage: %prog pocket package commit') 32 opts, args = parser.parse_args() 33 if len(args) != 3: 34 parser.print_help() 35 return 1 36 pocket, package, commit = args 31 37 principal = os.environ['REMOTE_USER'] 32 38 request_time = datetime.datetime.utcnow() … … 47 53 q = os.fdopen(q_fd, 'r+') 48 54 print >>q, "%s %s %s %s" % (pocket, package, commit, principal) 55 q.close() 49 56 os.rename(q_name, q_path) 50 57 -
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) -
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.