summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAlexandru N. Onea <onea.alex@gmail.com>2020-06-23 12:00:50 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-25 10:24:02 +0100
commitb7006f50c7b4b98ed15a1d8c15aeeb88719a9d8a (patch)
treeadf0c75bb0c3484fbe961e5be180427408b34881 /bitbake
parentcb1fbec4d95e9cbb36ec84c605981444eeb81dd4 (diff)
downloadpoky-b7006f50c7b4b98ed15a1d8c15aeeb88719a9d8a.tar.gz
bitbake: perforce: add local path handling SRC_URI options
This patch implements three new SRC_URI options for the perforce fetcher, namely: * module * remotepath The options are intended to provide the user more control over the downloaded file paths by allowing the user to specify how much of the remote path should be preserved locally. The changes in this patch are backwards compatible, i.e. if none of the introduced options is specified, the default (old) behavior is enforced. (Bitbake rev: aab228822d2f221c01337dd57d7582c51ce9a505) Signed-off-by: Alexandru N. Onea <onea.alex@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/perforce.py47
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"""
2BitBake 'Fetch' implementation for perforce 2BitBake 'Fetch' implementation for perforce
3 3
4Supported 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':