diff --git a/builder/kojid b/builder/kojid index 05f806d3..ff344150 100755 --- a/builder/kojid +++ b/builder/kojid @@ -1081,7 +1081,9 @@ class MavenTask(MultiPlatformTask): if spec_url: rpm_results = self.buildWrapperRPM(spec_url, self.build_task_id, build_tag, build_info, repo_id) - if not self.opts.get('scratch'): + if self.opts.get('scratch'): + self.session.host.moveMavenBuildToScratch(self.id, maven_results, rpm_results) + else: self.session.host.completeMavenBuild(self.id, self.build_id, maven_results, rpm_results) except (SystemExit, ServerExit, KeyboardInterrupt): # we do not trap these diff --git a/hub/kojihub.py b/hub/kojihub.py index d6d2b785..5a61bc9e 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -8843,8 +8843,40 @@ class HostExports(object): os.rename(fn,dest) os.symlink(dest,fn) + def moveMavenBuildToScratch(self, task_id, results, rpm_results): + "Move a completed Maven scratch build into place (not imported)" + if not context.opts.get('EnableMaven'): + raise koji.GenericError, 'Maven support not enabled' + host = Host() + host.verify() + task = Task(task_id) + task.assertHost(host.id) + scratchdir = koji.pathinfo.scratch() + username = get_user(task.getOwner())['name'] + destdir = os.path.join(scratchdir, username, 'task_%s' % task_id) + for reldir, files in results['files'].items() + [('', results['logs'])]: + for filename in files: + if reldir: + relpath = os.path.join(reldir, filename) + else: + relpath = filename + src = os.path.join(koji.pathinfo.task(results['task_id']), relpath) + dest = os.path.join(destdir, relpath) + koji.ensuredir(os.path.dirname(dest)) + os.rename(src, dest) + os.symlink(dest, src) + if rpm_results: + for relpath in [rpm_results['srpm']] + rpm_results['rpms'] + \ + rpm_results['logs']: + src = os.path.join(koji.pathinfo.task(rpm_results['task_id']), + relpath) + dest = os.path.join(destdir, 'rpms', relpath) + koji.ensuredir(os.path.dirname(dest)) + os.rename(src, dest) + os.symlink(dest, src) + def moveWinBuildToScratch(self, task_id, results, rpm_results): - "Move a completed scratch build into place (not imported)" + "Move a completed Windows scratch build into place (not imported)" if not context.opts.get('EnableWin'): raise koji.GenericError, 'Windows support not enabled' host = Host()