blob: 4f46a1293ea4624aa9398bf00045ecda51abb7e1 [file] [log] [blame]
Shawn O. Pearcee756c412009-04-13 11:51:15 -07001#
2# Copyright (C) 2009 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from optparse import SUPPRESS_HELP
17import sys
18
19from command import Command, MirrorSafeCommand
20from subcmds.sync import _PostRepoUpgrade
21from subcmds.sync import _PostRepoFetch
22
23class Selfupdate(Command, MirrorSafeCommand):
24 common = False
25 helpSummary = "Update repo to the latest version"
26 helpUsage = """
27%prog
28"""
29 helpDescription = """
30The '%prog' command upgrades repo to the latest version, if a
31newer version is available.
32
33Normally this is done automatically by 'repo sync' and does not
34need to be performed by an end-user.
35"""
36
37 def _Options(self, p):
Shawn O. Pearcefd89b672009-04-18 11:28:57 -070038 g = p.add_option_group('repo Version options')
39 g.add_option('--no-repo-verify',
Shawn O. Pearcee756c412009-04-13 11:51:15 -070040 dest='no_repo_verify', action='store_true',
41 help='do not verify repo source code')
Shawn O. Pearcefd89b672009-04-18 11:28:57 -070042 g.add_option('--repo-upgraded',
Shawn O. Pearcee756c412009-04-13 11:51:15 -070043 dest='repo_upgraded', action='store_true',
44 help=SUPPRESS_HELP)
45
46 def Execute(self, opt, args):
47 rp = self.manifest.repoProject
48 rp.PreSync()
49
50 if opt.repo_upgraded:
51 _PostRepoUpgrade(self.manifest)
52
53 else:
54 if not rp.Sync_NetworkHalf():
55 print >>sys.stderr, "error: can't update repo"
56 sys.exit(1)
57
58 _PostRepoFetch(rp,
59 no_repo_verify = opt.no_repo_verify,
60 verbose = True)