mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Add a --platform flag
Projects may optionally specify their platform (eg, groups="platform-linux" in the manifest). By default, repo will automatically detect the platform. However, users may specify --platform=[auto|all|linux|darwin]. Change-Id: Ie678851fb2fec5b0938aede01f16c53138a16537
This commit is contained in:
parent
971de8ea7b
commit
d21720db31
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import optparse
|
import optparse
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ class Command(object):
|
|||||||
|
|
||||||
groups = mp.config.GetString('manifest.groups')
|
groups = mp.config.GetString('manifest.groups')
|
||||||
if groups is None:
|
if groups is None:
|
||||||
groups = 'default'
|
groups = 'default,platform-' + platform.system().lower()
|
||||||
groups = [x for x in re.split('[,\s]+', groups) if x]
|
groups = [x for x in re.split('[,\s]+', groups) if x]
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
|
5
repo
5
repo
@ -129,6 +129,11 @@ group.add_option('-g', '--groups',
|
|||||||
dest='groups', default='default',
|
dest='groups', default='default',
|
||||||
help='restrict manifest projects to ones with a specified group',
|
help='restrict manifest projects to ones with a specified group',
|
||||||
metavar='GROUP')
|
metavar='GROUP')
|
||||||
|
group.add_option('-p', '--platform',
|
||||||
|
dest='platform', default="auto",
|
||||||
|
help='restrict manifest projects to ones with a specified'
|
||||||
|
'platform group [auto|all|none|linux|darwin|...]',
|
||||||
|
metavar='PLATFORM')
|
||||||
|
|
||||||
|
|
||||||
# Tool
|
# Tool
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
@ -91,6 +92,11 @@ to update the working directory files.
|
|||||||
dest='groups', default='default',
|
dest='groups', default='default',
|
||||||
help='restrict manifest projects to ones with a specified group',
|
help='restrict manifest projects to ones with a specified group',
|
||||||
metavar='GROUP')
|
metavar='GROUP')
|
||||||
|
g.add_option('-p', '--platform',
|
||||||
|
dest='platform', default='auto',
|
||||||
|
help='restrict manifest projects to ones with a specified'
|
||||||
|
'platform group [auto|all|none|linux|darwin|...]',
|
||||||
|
metavar='PLATFORM')
|
||||||
|
|
||||||
# Tool
|
# Tool
|
||||||
g = p.add_option_group('repo Version options')
|
g = p.add_option_group('repo Version options')
|
||||||
@ -141,9 +147,24 @@ to update the working directory files.
|
|||||||
r.Save()
|
r.Save()
|
||||||
|
|
||||||
groups = re.split('[,\s]+', opt.groups)
|
groups = re.split('[,\s]+', opt.groups)
|
||||||
|
all_platforms = ['linux', 'darwin']
|
||||||
|
platformize = lambda x: 'platform-' + x
|
||||||
|
if opt.platform == 'auto':
|
||||||
|
if (not opt.mirror and
|
||||||
|
not m.config.GetString('repo.mirror') == 'true'):
|
||||||
|
groups.append(platformize(platform.system().lower()))
|
||||||
|
elif opt.platform == 'all':
|
||||||
|
groups.extend(map(platformize, all_platfroms))
|
||||||
|
elif opt.platform in all_platforms:
|
||||||
|
groups.extend(platformize(opt.platform))
|
||||||
|
elif opt.platform != 'none':
|
||||||
|
print >>sys.stderr, 'fatal: invalid platform flag'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
groups = [x for x in groups if x]
|
groups = [x for x in groups if x]
|
||||||
groupstr = ','.join(groups)
|
groupstr = ','.join(groups)
|
||||||
if groupstr == 'default':
|
if opt.platform == 'auto' and
|
||||||
|
groupstr == 'default,platform-' + platform.system.lower():
|
||||||
groupstr = None
|
groupstr = None
|
||||||
m.config.SetString('manifest.groups', groupstr)
|
m.config.SetString('manifest.groups', groupstr)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user