diff options
Diffstat (limited to 'subcmds/init.py')
-rw-r--r-- | subcmds/init.py | 23 |
1 files changed, 22 insertions, 1 deletions
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 | ||
16 | import os | 16 | import os |
17 | import platform | ||
17 | import re | 18 | import re |
18 | import shutil | 19 | import shutil |
19 | import sys | 20 | import 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 | ||