Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Side by Side Diff: server/git_kernel.py

Issue 3554003: Merge remote branch 'cros/upstream' into tempbranch3 (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « server/git.py ('k') | server/hosts/remote.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #
2 # Copyright 2007 IBM Corp. Released under the GPL v2
3 # Authors: Ryan Harper <ryanh@us.ibm.com>
4 #
5
6 """ 1 """
7 This module defines the GitKernel class 2 This module defines the GitKernel class
3
4 @author: Ryan Harper (ryanh@us.ibm.com)
5 @copyright: IBM 2007
8 """ 6 """
9 7
10 __author__ = """ 8 import os, logging
11 ryanh@us.ibm.com (Ryan Harper)
12 """
13
14
15 import os
16 import git, source_kernel 9 import git, source_kernel
17 10
18 11
19 class GitKernel(git.GitRepo): 12 class GitKernel(git.InstallableGitRepo):
20 """ 13 """
21 This class represents a git kernel repo. 14 This class represents an installable git kernel repo.
22 15
23 It is used to pull down a local copy of a git repo, check if the local repo 16 It is used to pull down a local copy of a git repo, check if the local repo
24 is up-to-date, if not update and then build the kernel from the git repo. 17 is up-to-date, if not update and then build the kernel from the git repo.
25
26 """ 18 """
27 def __init__(self, repodir, giturl, weburl): 19 def __init__(self, repodir, giturl, weburl):
28 git.GitRepo.__init__(self, repodir, giturl, weburl) 20 super(GitKernel, self).__init__(repodir, giturl, weburl)
29 self.__patches = [] 21 self._patches = []
30 self.__config = None 22 self._config = None
31 self.__build = None 23 self._build = None
24 self._branch = None
25 self._revision = None
32 26
33 27
34 def configure(self, config): 28 def configure(self, config):
35 self.__config = config 29 self._config = config
36 30
37 31
38 def patch(self, patch): 32 def patch(self, patch):
39 self.__patches.append(patch) 33 self._patches.append(patch)
40 34
41 35
42 def install(self, host, build=True, builddir=None): 36 def checkout(self, revision, local=None):
43 # use tmpdir if no builddir specified 37 """
44 # NB: pass a builddir to install() method if you 38 Checkout the commit id, branch, or tag.
45 # need to ensure the build remains after the completion 39
46 # of a job 40 @param revision: Name of the git remote branch, revision or tag
41 @param local: Name of the local branch, implies -b
42 """
43 logging.info('Checking out %s', revision)
44 super(GitKernel, self).checkout(revision)
45 self._revision = super(GitKernel, self).get_revision()
46 self._branch = super(GitKernel, self).get_branch()
47 logging.info('Checked out %s on branch %s', self._revision,
48 self._branch)
49
50
51 def show_branch(self):
52 """
53 Print the current local branch name.
54 """
55 self._branch = super(GitKernel, self).get_branch()
56 logging.info(self._branch)
57
58
59 def show_branches(self, all=True):
60 """
61 Print the local and remote branches.
62
63 @param all: Whether to show all branches (True) or only local branches
64 (False).
65 """
66 self._branch = super(GitKernel, self).get_branch()
67 logging.info(super(GitKernel, self).get_branch(all=all))
68
69
70 def show_revision(self):
71 """
72 Show the current git revision.
73 """
74 self._revision = super(GitKernel, self).get_revision()
75 logging.info(self._revision)
76
77
78 def install(self, host, build=True, builddir=None, revision=None):
79 """
80 Install the git tree in a host.
81
82 @param host: Host object
83 @param build: Whether to build the source tree
84 @param builddir: Specify a build dir. If no build dir is specified,
85 the job temporary directory will be used, so the build won't
86 be persistent.
87 @param revision: Desired commit hash. If ommited, will build from HEAD
88 of the branch.
89 """
90 if revision:
91 self.checkout(revision)
92 self._revision = super(GitKernel, self).get_revision()
93 logging.info('Checked out revision: %s', self._revision)
94
47 if not builddir: 95 if not builddir:
48 self.__build = os.path.join(host.get_tmp_dir(),"build") 96 self._build = os.path.join(host.get_tmp_dir(), "build")
49 print 'warning: builddir %s is not persistent' %(self.__build) 97 logging.warning('Builddir %s is not persistent (it will be erased '
98 'in future jobs)', self._build)
50 99
51 # push source to host for install 100 # push source to host for install
52 print 'pushing %s to host' %(self.source_material) 101 logging.info('Pushing %s to host', self.source_material)
53 host.send_file(self.source_material, self.__build) 102 host.send_file(self.source_material, self._build)
54 remote_source_material= os.path.join(self.__build,
55 os.path.basename(self.source_material))
56 103
57 # use a source_kernel to configure, patch, build and install. 104 # use a source_kernel to configure, patch, build and install.
58 sk = source_kernel.SourceKernel(remote_source_material) 105 sk = source_kernel.SourceKernel(self._build)
59 106
60 if build: 107 if build:
61 # apply patches 108 # apply patches
62 for p in self.__patches: 109 for p in self._patches:
63 sk.patch(p) 110 sk.patch(p)
64 111
65 # configure 112 # configure
66 sk.configure(self.__config) 113 sk.configure(self._config)
67 114
68 # build 115 # build
69 sk.build(host) 116 sk.build(host)
70 117
71 # install 118 # install
72 sk.install(host) 119 sk.install(host)
OLDNEW
« no previous file with comments | « server/git.py ('k') | server/hosts/remote.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698