diff options
-rw-r--r-- | bitbake/lib/bb/fetch2/perforce.py | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/perforce.py b/bitbake/lib/bb/fetch2/perforce.py index 83128cdeba..6f3c95b6ce 100644 --- a/bitbake/lib/bb/fetch2/perforce.py +++ b/bitbake/lib/bb/fetch2/perforce.py | |||
@@ -1,6 +1,20 @@ | |||
1 | """ | 1 | """ |
2 | BitBake 'Fetch' implementation for perforce | 2 | BitBake 'Fetch' implementation for perforce |
3 | 3 | ||
4 | Supported SRC_URI options are: | ||
5 | |||
6 | - module | ||
7 | The top-level location to fetch while preserving the remote paths | ||
8 | |||
9 | The value of module can point to either a directory or a file. The result, | ||
10 | in both cases, is that the fetcher will preserve all file paths starting | ||
11 | from the module path. That is, the top-level directory in the module value | ||
12 | will also be the top-level directory in P4DIR. | ||
13 | |||
14 | - remotepath | ||
15 | If the value "keep" is given, the full depot location of each file is | ||
16 | preserved in P4DIR. This option overrides the effect of the module option. | ||
17 | |||
4 | """ | 18 | """ |
5 | 19 | ||
6 | # Copyright (C) 2003, 2004 Chris Larson | 20 | # Copyright (C) 2003, 2004 Chris Larson |
@@ -88,14 +102,33 @@ class Perforce(FetchMethod): | |||
88 | logger.debug(1, 'Determined P4PORT to be: %s' % ud.host) | 102 | logger.debug(1, 'Determined P4PORT to be: %s' % ud.host) |
89 | if not ud.host: | 103 | if not ud.host: |
90 | raise FetchError('Could not determine P4PORT from P4CONFIG') | 104 | raise FetchError('Could not determine P4PORT from P4CONFIG') |
91 | 105 | ||
106 | # Fetcher options | ||
107 | ud.module = ud.parm.get('module') | ||
108 | ud.keepremotepath = (ud.parm.get('remotepath', '') == 'keep') | ||
109 | |||
92 | if ud.path.find('/...') >= 0: | 110 | if ud.path.find('/...') >= 0: |
93 | ud.pathisdir = True | 111 | ud.pathisdir = True |
94 | else: | 112 | else: |
95 | ud.pathisdir = False | 113 | ud.pathisdir = False |
96 | 114 | ||
115 | # Avoid using the "/..." syntax in SRC_URI when a module value is given | ||
116 | if ud.pathisdir and ud.module: | ||
117 | raise FetchError('SRC_URI depot path cannot not end in /... when a module value is given') | ||
118 | |||
97 | cleanedpath = ud.path.replace('/...', '').replace('/', '.') | 119 | cleanedpath = ud.path.replace('/...', '').replace('/', '.') |
98 | cleanedhost = ud.host.replace(':', '.') | 120 | cleanedhost = ud.host.replace(':', '.') |
121 | |||
122 | # Merge the path and module into the final depot location | ||
123 | if ud.module: | ||
124 | if ud.module.find('/') == 0: | ||
125 | raise FetchError('module cannot begin with /') | ||
126 | ud.path = os.path.join(ud.path, ud.module) | ||
127 | |||
128 | # Append the module path to the local pkg name | ||
129 | cleanedmodule = ud.module.replace('/...', '').replace('/', '.') | ||
130 | cleanedpath += '--%s' % cleanedmodule | ||
131 | |||
99 | ud.pkgdir = os.path.join(ud.dldir, cleanedhost, cleanedpath) | 132 | ud.pkgdir = os.path.join(ud.dldir, cleanedhost, cleanedpath) |
100 | 133 | ||
101 | ud.setup_revisions(d) | 134 | ud.setup_revisions(d) |
@@ -125,10 +158,20 @@ class Perforce(FetchMethod): | |||
125 | pathnrev = '%s' % (ud.path) | 158 | pathnrev = '%s' % (ud.path) |
126 | 159 | ||
127 | if depot_filename: | 160 | if depot_filename: |
128 | if ud.pathisdir: # Remove leading path to obtain filename | 161 | if ud.keepremotepath: |
162 | # preserve everything, remove the leading // | ||
163 | filename = depot_filename.lstrip('/') | ||
164 | elif ud.module: | ||
165 | # remove everything up to the module path | ||
166 | modulepath = ud.module.rstrip('/...') | ||
167 | filename = depot_filename[depot_filename.rfind(modulepath):] | ||
168 | elif ud.pathisdir: | ||
169 | # Remove leading (visible) path to obtain the filepath | ||
129 | filename = depot_filename[len(ud.path)-1:] | 170 | filename = depot_filename[len(ud.path)-1:] |
130 | else: | 171 | else: |
172 | # Remove everything, except the filename | ||
131 | filename = depot_filename[depot_filename.rfind('/'):] | 173 | filename = depot_filename[depot_filename.rfind('/'):] |
174 | |||
132 | filename = filename[:filename.find('#')] # Remove trailing '#rev' | 175 | filename = filename[:filename.find('#')] # Remove trailing '#rev' |
133 | 176 | ||
134 | if command == 'changes': | 177 | if command == 'changes': |