summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--command.py3
-rwxr-xr-xrepo5
-rw-r--r--subcmds/init.py23
3 files changed, 29 insertions, 2 deletions
diff --git a/command.py b/command.py
index 2ee0a43a..936ab408 100644
--- a/command.py
+++ b/command.py
@@ -15,6 +15,7 @@
15 15
16import os 16import os
17import optparse 17import optparse
18import platform
18import re 19import re
19import sys 20import sys
20 21
@@ -69,7 +70,7 @@ class Command(object):
69 70
70 groups = mp.config.GetString('manifest.groups') 71 groups = mp.config.GetString('manifest.groups')
71 if groups is None: 72 if groups is None:
72 groups = 'default' 73 groups = 'default,platform-' + platform.system().lower()
73 groups = [x for x in re.split('[,\s]+', groups) if x] 74 groups = [x for x in re.split('[,\s]+', groups) if x]
74 75
75 if not args: 76 if not args:
diff --git a/repo b/repo
index 0aabc0d8..860a15d5 100755
--- a/repo
+++ b/repo
@@ -129,6 +129,11 @@ group.add_option('-g', '--groups',
129 dest='groups', default='default', 129 dest='groups', default='default',
130 help='restrict manifest projects to ones with a specified group', 130 help='restrict manifest projects to ones with a specified group',
131 metavar='GROUP') 131 metavar='GROUP')
132group.add_option('-p', '--platform',
133 dest='platform', default="auto",
134 help='restrict manifest projects to ones with a specified'
135 'platform group [auto|all|none|linux|darwin|...]',
136 metavar='PLATFORM')
132 137
133 138
134# Tool 139# Tool
diff --git a/subcmds/init.py b/subcmds/init.py
index d1c497c1..2e3215b2 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -14,6 +14,7 @@
14# limitations under the License. 14# limitations under the License.
15 15
16import os 16import os
17import platform
17import re 18import re
18import shutil 19import shutil
19import sys 20import sys
@@ -91,6 +92,11 @@ to update the working directory files.
91 dest='groups', default='default', 92 dest='groups', default='default',
92 help='restrict manifest projects to ones with a specified group', 93 help='restrict manifest projects to ones with a specified group',
93 metavar='GROUP') 94 metavar='GROUP')
95 g.add_option('-p', '--platform',
96 dest='platform', default='auto',
97 help='restrict manifest projects to ones with a specified'
98 'platform group [auto|all|none|linux|darwin|...]',
99 metavar='PLATFORM')
94 100
95 # Tool 101 # Tool
96 g = p.add_option_group('repo Version options') 102 g = p.add_option_group('repo Version options')
@@ -141,9 +147,24 @@ to update the working directory files.
141 r.Save() 147 r.Save()
142 148
143 groups = re.split('[,\s]+', opt.groups) 149 groups = re.split('[,\s]+', opt.groups)
150 all_platforms = ['linux', 'darwin']
151 platformize = lambda x: 'platform-' + x
152 if opt.platform == 'auto':
153 if (not opt.mirror and
154 not m.config.GetString('repo.mirror') == 'true'):
155 groups.append(platformize(platform.system().lower()))
156 elif opt.platform == 'all':
157 groups.extend(map(platformize, all_platfroms))
158 elif opt.platform in all_platforms:
159 groups.extend(platformize(opt.platform))
160 elif opt.platform != 'none':
161 print >>sys.stderr, 'fatal: invalid platform flag'
162 sys.exit(1)
163
144 groups = [x for x in groups if x] 164 groups = [x for x in groups if x]
145 groupstr = ','.join(groups) 165 groupstr = ','.join(groups)
146 if groupstr == 'default': 166 if opt.platform == 'auto' and
167 groupstr == 'default,platform-' + platform.system.lower():
147 groupstr = None 168 groupstr = None
148 m.config.SetString('manifest.groups', groupstr) 169 m.config.SetString('manifest.groups', groupstr)
149 170