blob: 57a6e6da9370df90f6e221277a5d0eca94775fdb [file] [log] [blame]
kjellander@webrtc.org0b0ac822014-10-09 09:11:27 +00001#!/usr/bin/env python
2# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3#
4# Use of this source code is governed by a BSD-style license
5# that can be found in the LICENSE file in the root of the source
6# tree. An additional intellectual property rights grant can be found
7# in the file PATENTS. All contributing project authors may
8# be found in the AUTHORS file in the root of the source tree.
9
10"""Checks for legacy root directory and instructs the user how to upgrade."""
11
12import os
13import sys
14
15SOLUTION_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
16 os.pardir)
17MESSAGE = """\
18@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
19 A C T I O N R E Q I R E D
20@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
21
22It looks like you have a legacy checkout where the solution's top-level
23directory is named 'trunk'. From now on, it must be named 'src'.
24
25What you need to do is to:
26
271. Edit your .gclient file and change the solution name from 'trunk' to 'src'
282. Rename your 'trunk' directory to 'src'
293. Re-run gclient sync (or gclient runhooks)"""
30
31
32def main():
33 gclient_filename = os.path.join(SOLUTION_ROOT_DIR, '.gclient')
34 config_dict = {}
35 try:
36 with open(gclient_filename, 'rb') as gclient_file:
37 exec(gclient_file, config_dict)
38 for solution in config_dict.get('solutions', []):
39 if solution['name'] == 'trunk':
40 print MESSAGE
41 if solution.get('custom_vars', {}).get('root_dir'):
42 print ('4. Optional: Remove your "root_dir" entry from the '
43 'custom_vars dictionary of the solution.')
44
45 # Remove the gclient cache file to avoid an error on the next sync.
46 entries_file = os.path.join(SOLUTION_ROOT_DIR, '.gclient_entries')
47 if os.path.exists(entries_file):
48 os.unlink(entries_file)
49 return 1
50 return 0
51 except Exception as e:
52 print >> sys.stderr, "Error while parsing .gclient: ", e
53 return 1
54
55
56if __name__ == '__main__':
57 sys.exit(main())