blob: 901e0ee5aeff3dee9a38625dc0043cb2e21b5484 [file] [log] [blame]
kjellander@webrtc.org89256622014-08-20 12:10:11 +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"""Setup links to a Chromium checkout for WebRTC.
11
12WebRTC standalone shares a lot of dependencies and build tools with Chromium.
13To do this, many of the paths of a Chromium checkout is emulated by creating
14symlinks to files and directories. This script handles the setup of symlinks to
15achieve this.
kjellander@webrtc.org89256622014-08-20 12:10:11 +000016"""
17
18
19import ctypes
20import errno
21import logging
22import optparse
23import os
24import shelve
25import shutil
26import subprocess
27import sys
28import textwrap
29
30
31DIRECTORIES = [
32 'build',
33 'buildtools',
kjellandere26e7872016-03-04 14:39:28 -080034 'mojo', # TODO(kjellander): Remove, see webrtc:5629.
kjellander@webrtc.org89256622014-08-20 12:10:11 +000035 'testing',
metzmanf89a5712016-07-25 02:14:09 -070036 'third_party/afl',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000037 'third_party/binutils',
38 'third_party/boringssl',
kjellander24d812d2016-11-22 07:02:11 -080039 'third_party/catapult',
ehmaldonado1249ddf2016-08-31 01:58:48 -070040 'third_party/closure_compiler',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000041 'third_party/colorama',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000042 'third_party/expat',
hbosa9a1d2a2016-01-11 10:19:02 -080043 'third_party/ffmpeg',
kjellander@webrtc.org4e4fe4f2014-10-01 08:03:19 +000044 'third_party/instrumented_libraries',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000045 'third_party/jsoncpp',
Henrik Kjellander26ab91b2015-11-26 10:26:32 +010046 'third_party/libc++-static',
kjellander@webrtc.org2addf3f2016-04-04 08:33:12 +020047 'third_party/libFuzzer',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000048 'third_party/libjpeg',
49 'third_party/libjpeg_turbo',
50 'third_party/libsrtp',
kjellandere26e7872016-03-04 14:39:28 -080051 'third_party/libvpx',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000052 'third_party/libyuv',
53 'third_party/llvm-build',
Patrik Höglundc92c23d2015-08-31 11:30:14 +020054 'third_party/lss',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000055 'third_party/nss',
tkchin@webrtc.org3a63a3c2015-01-06 07:21:34 +000056 'third_party/ocmock',
hbosa9a1d2a2016-01-11 10:19:02 -080057 'third_party/openh264',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000058 'third_party/openmax_dl',
59 'third_party/opus',
Patrik Höglundc92c23d2015-08-31 11:30:14 +020060 'third_party/proguard',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000061 'third_party/protobuf',
62 'third_party/sqlite',
63 'third_party/syzygy',
64 'third_party/usrsctp',
65 'third_party/yasm',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000066 'third_party/zlib',
kjellander752f36f2016-03-22 16:56:01 -070067 'third_party/WebKit', # TODO(kjellander): Remove, see webrtc:5629.
kjellander@webrtc.org89256622014-08-20 12:10:11 +000068 'tools/clang',
kjellander24d812d2016-11-22 07:02:11 -080069 'tools/clang_format_merge_driver',
ehmaldonadoa78213e2016-09-22 10:46:16 -070070 'tools/determinism',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000071 'tools/generate_library_loader',
hbos5602f652016-01-15 01:38:34 -080072 'tools/generate_stubs',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000073 'tools/gn',
ehmaldonado1249ddf2016-08-31 01:58:48 -070074 'tools/grit',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000075 'tools/gyp',
kjellandere532aec2016-04-17 20:08:20 -070076 'tools/luci-go',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000077 'tools/memory',
78 'tools/protoc_wrapper',
79 'tools/python',
80 'tools/swarming_client',
81 'tools/valgrind',
Andrew MacDonald65de7d22015-05-19 11:37:34 -070082 'tools/vim',
kjellander@webrtc.org89256622014-08-20 12:10:11 +000083 'tools/win',
84]
85
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000086from sync_chromium import get_target_os_list
Henrik Kjellanderca843022015-06-09 10:51:22 +020087target_os = get_target_os_list()
88if 'android' in target_os:
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000089 DIRECTORIES += [
90 'base',
ehmaldonado9f73f7a2016-07-28 01:20:22 -070091 'third_party/accessibility_test_framework',
Henrik Kjellander94a12322015-06-09 14:56:20 +020092 'third_party/android_platform',
kjellanderb1125682016-10-26 13:38:03 -070093 'third_party/android_support_test_runner',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +000094 'third_party/android_tools',
ehmaldonado9f73f7a2016-07-28 01:20:22 -070095 'third_party/apache_velocity',
kjellander@webrtc.orgcbe7ca82015-01-06 07:24:27 +000096 'third_party/appurify-python',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +000097 'third_party/ashmem',
ehmaldonado9f73f7a2016-07-28 01:20:22 -070098 'third_party/bouncycastle',
ehmaldonadocd8ae612016-08-24 02:44:14 -070099 'third_party/byte_buddy',
kjellanderf10976e2016-08-11 10:31:40 -0700100 'third_party/ced',
kjellander24d812d2016-11-22 07:02:11 -0800101 'third_party/espresso',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700102 'third_party/guava',
103 'third_party/hamcrest',
kjellander53761002015-11-10 10:58:22 -0800104 'third_party/icu',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700105 'third_party/icu4j',
Henrik Kjellandereecbab72015-09-16 19:19:04 +0200106 'third_party/ijar',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700107 'third_party/intellij',
kjellander24d812d2016-11-22 07:02:11 -0800108 'third_party/javax_inject',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000109 'third_party/jsr-305',
Henrik Kjellander10ba3ee2015-04-29 14:47:53 +0200110 'third_party/junit',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000111 'third_party/libxml',
Henrik Kjellander10ba3ee2015-04-29 14:47:53 +0200112 'third_party/mockito',
kjellander@webrtc.orgb8caf6a2014-09-30 18:05:02 +0000113 'third_party/modp_b64',
ehmaldonadocd8ae612016-08-24 02:44:14 -0700114 'third_party/objenesis',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700115 'third_party/ow2_asm',
kjellander@webrtc.orgcbe7ca82015-01-06 07:24:27 +0000116 'third_party/requests',
Henrik Kjellander10ba3ee2015-04-29 14:47:53 +0200117 'third_party/robolectric',
ehmaldonado9f73f7a2016-07-28 01:20:22 -0700118 'third_party/sqlite4java',
primianob332e5d2016-01-25 08:13:05 -0800119 'third_party/tcmalloc',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +0000120 'tools/android',
kjellander34a70542015-12-06 10:32:34 -0800121 'tools/telemetry',
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +0000122 ]
tommide3b0292016-04-22 01:47:02 -0700123else:
124 DIRECTORIES += [
125 'base/third_party/libevent',
126 ]
127
Henrik Kjellanderca843022015-06-09 10:51:22 +0200128if 'ios' in target_os:
129 DIRECTORIES.append('third_party/class-dump')
kjellander@webrtc.org3bd41562014-09-01 11:06:37 +0000130
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000131FILES = {
Henrik Kjellanderd6d27e72015-09-25 22:19:11 +0200132 'tools/isolate_driver.py': None,
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000133 'third_party/BUILD.gn': None,
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000134}
135
kjellander@webrtc.orge94f83a2014-09-18 13:47:23 +0000136ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000137CHROMIUM_CHECKOUT = os.path.join('chromium', 'src')
138LINKS_DB = 'links'
139
140# Version management to make future upgrades/downgrades easier to support.
141SCHEMA_VERSION = 1
142
143
144def query_yes_no(question, default=False):
145 """Ask a yes/no question via raw_input() and return their answer.
146
147 Modified from http://stackoverflow.com/a/3041990.
148 """
149 prompt = " [%s/%%s]: "
150 prompt = prompt % ('Y' if default is True else 'y')
151 prompt = prompt % ('N' if default is False else 'n')
152
153 if default is None:
154 default = 'INVALID'
155
156 while True:
157 sys.stdout.write(question + prompt)
158 choice = raw_input().lower()
159 if choice == '' and default != 'INVALID':
160 return default
161
162 if 'yes'.startswith(choice):
163 return True
164 elif 'no'.startswith(choice):
165 return False
166
167 print "Please respond with 'yes' or 'no' (or 'y' or 'n')."
168
169
170# Actions
171class Action(object):
172 def __init__(self, dangerous):
173 self.dangerous = dangerous
174
175 def announce(self, planning):
176 """Log a description of this action.
177
178 Args:
179 planning - True iff we're in the planning stage, False if we're in the
180 doit stage.
181 """
182 pass
183
184 def doit(self, links_db):
185 """Execute the action, recording what we did to links_db, if necessary."""
186 pass
187
188
189class Remove(Action):
190 def __init__(self, path, dangerous):
191 super(Remove, self).__init__(dangerous)
192 self._priority = 0
193 self._path = path
194
195 def announce(self, planning):
196 log = logging.warn
197 filesystem_type = 'file'
198 if not self.dangerous:
199 log = logging.info
200 filesystem_type = 'link'
201 if planning:
202 log('Planning to remove %s: %s', filesystem_type, self._path)
203 else:
204 log('Removing %s: %s', filesystem_type, self._path)
205
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200206 def doit(self, _):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000207 os.remove(self._path)
208
209
210class Rmtree(Action):
211 def __init__(self, path):
212 super(Rmtree, self).__init__(dangerous=True)
213 self._priority = 0
214 self._path = path
215
216 def announce(self, planning):
217 if planning:
218 logging.warn('Planning to remove directory: %s', self._path)
219 else:
220 logging.warn('Removing directory: %s', self._path)
221
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200222 def doit(self, _):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000223 if sys.platform.startswith('win'):
224 # shutil.rmtree() doesn't work on Windows if any of the directories are
225 # read-only, which svn repositories are.
226 subprocess.check_call(['rd', '/q', '/s', self._path], shell=True)
227 else:
228 shutil.rmtree(self._path)
229
230
231class Makedirs(Action):
232 def __init__(self, path):
233 super(Makedirs, self).__init__(dangerous=False)
234 self._priority = 1
235 self._path = path
236
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200237 def doit(self, _):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000238 try:
239 os.makedirs(self._path)
240 except OSError as e:
241 if e.errno != errno.EEXIST:
242 raise
243
244
245class Symlink(Action):
246 def __init__(self, source_path, link_path):
247 super(Symlink, self).__init__(dangerous=False)
248 self._priority = 2
249 self._source_path = source_path
250 self._link_path = link_path
251
252 def announce(self, planning):
253 if planning:
254 logging.info(
255 'Planning to create link from %s to %s', self._link_path,
256 self._source_path)
257 else:
258 logging.debug(
259 'Linking from %s to %s', self._link_path, self._source_path)
260
261 def doit(self, links_db):
262 # Files not in the root directory need relative path calculation.
263 # On Windows, use absolute paths instead since NTFS doesn't seem to support
264 # relative paths for symlinks.
265 if sys.platform.startswith('win'):
266 source_path = os.path.abspath(self._source_path)
267 else:
268 if os.path.dirname(self._link_path) != self._link_path:
269 source_path = os.path.relpath(self._source_path,
270 os.path.dirname(self._link_path))
271
272 os.symlink(source_path, os.path.abspath(self._link_path))
273 links_db[self._source_path] = self._link_path
274
275
276class LinkError(IOError):
277 """Failed to create a link."""
278 pass
279
280
kjellander844dd2a2016-04-05 00:13:58 -0700281# Use junctions instead of symlinks on the Windows platform.
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000282if sys.platform.startswith('win'):
283 def symlink(source_path, link_path):
kjellander844dd2a2016-04-05 00:13:58 -0700284 if os.path.isdir(source_path):
285 subprocess.check_call(['cmd.exe', '/c', 'mklink', '/J', link_path,
286 source_path])
287 else:
288 # Don't create symlinks to files on Windows, just copy the file instead
289 # (there's no way to create a link without administrator's privileges).
290 shutil.copy(source_path, link_path)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000291 os.symlink = symlink
292
293
Henrik Kjellander57e5fd22015-05-25 12:55:39 +0200294class WebRTCLinkSetup(object):
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000295 def __init__(self, links_db, force=False, dry_run=False, prompt=False):
296 self._force = force
297 self._dry_run = dry_run
298 self._prompt = prompt
299 self._links_db = links_db
300
301 def CreateLinks(self, on_bot):
302 logging.debug('CreateLinks')
303 # First, make a plan of action
304 actions = []
305
306 for source_path, link_path in FILES.iteritems():
307 actions += self._ActionForPath(
308 source_path, link_path, check_fn=os.path.isfile, check_msg='files')
309 for source_dir in DIRECTORIES:
310 actions += self._ActionForPath(
311 source_dir, None, check_fn=os.path.isdir,
312 check_msg='directories')
313
kjellander@webrtc.orge94f83a2014-09-18 13:47:23 +0000314 if not on_bot and self._force:
315 # When making the manual switch from legacy SVN checkouts to the new
316 # Git-based Chromium DEPS, the .gclient_entries file that contains cached
317 # URLs for all DEPS entries must be removed to avoid future sync problems.
318 entries_file = os.path.join(os.path.dirname(ROOT_DIR), '.gclient_entries')
319 if os.path.exists(entries_file):
320 actions.append(Remove(entries_file, dangerous=True))
321
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000322 actions.sort()
323
324 if self._dry_run:
325 for action in actions:
326 action.announce(planning=True)
327 logging.info('Not doing anything because dry-run was specified.')
328 sys.exit(0)
329
330 if any(a.dangerous for a in actions):
331 logging.warn('Dangerous actions:')
332 for action in (a for a in actions if a.dangerous):
333 action.announce(planning=True)
334 print
335
336 if not self._force:
337 logging.error(textwrap.dedent("""\
338 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
339 A C T I O N R E Q I R E D
340 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
341
kjellander844dd2a2016-04-05 00:13:58 -0700342 Setting up the checkout requires creating symlinks to directories in the
343 Chromium checkout inside chromium/src.
344 To avoid disrupting developers, we've chosen to not delete directories
345 forcibly, in case you have some work in progress in one of them :)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000346
347 ACTION REQUIRED:
348 Before running `gclient sync|runhooks` again, you must run:
349 %s%s --force
350
351 Which will replace all directories which now must be symlinks, after
352 prompting with a summary of the work-to-be-done.
kjellander844dd2a2016-04-05 00:13:58 -0700353 """), 'python ' if sys.platform.startswith('win') else '', __file__)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000354 sys.exit(1)
355 elif self._prompt:
356 if not query_yes_no('Would you like to perform the above plan?'):
357 sys.exit(1)
358
359 for action in actions:
360 action.announce(planning=False)
361 action.doit(self._links_db)
362
363 if not on_bot and self._force:
364 logging.info('Completed!\n\nNow run `gclient sync|runhooks` again to '
365 'let the remaining hooks (that probably were interrupted) '
366 'execute.')
367
368 def CleanupLinks(self):
369 logging.debug('CleanupLinks')
370 for source, link_path in self._links_db.iteritems():
371 if source == 'SCHEMA_VERSION':
372 continue
373 if os.path.islink(link_path) or sys.platform.startswith('win'):
374 # os.path.islink() always returns false on Windows
375 # See http://bugs.python.org/issue13143.
376 logging.debug('Removing link to %s at %s', source, link_path)
377 if not self._dry_run:
378 if os.path.exists(link_path):
379 if sys.platform.startswith('win') and os.path.isdir(link_path):
Henrik Kjellanderc444de62015-04-29 11:27:22 +0200380 subprocess.check_call(['rmdir', '/q', '/s', link_path],
381 shell=True)
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000382 else:
383 os.remove(link_path)
384 del self._links_db[source]
385
386 @staticmethod
387 def _ActionForPath(source_path, link_path=None, check_fn=None,
388 check_msg=None):
389 """Create zero or more Actions to link to a file or directory.
390
kjellander844dd2a2016-04-05 00:13:58 -0700391 This will be a symlink on POSIX platforms. On Windows it will result in:
392 * a junction for directories
393 * a copied file for single files.
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000394
395 Args:
396 source_path: Path relative to the Chromium checkout root.
397 For readability, the path may contain slashes, which will
398 automatically be converted to the right path delimiter on Windows.
399 link_path: The location for the link to create. If omitted it will be the
400 same path as source_path.
401 check_fn: A function returning true if the type of filesystem object is
402 correct for the attempted call. Otherwise an error message with
403 check_msg will be printed.
404 check_msg: String used to inform the user of an invalid attempt to create
405 a file.
406 Returns:
407 A list of Action objects.
408 """
409 def fix_separators(path):
410 if sys.platform.startswith('win'):
411 return path.replace(os.altsep, os.sep)
412 else:
413 return path
414
415 assert check_fn
416 assert check_msg
417 link_path = link_path or source_path
418 link_path = fix_separators(link_path)
419
420 source_path = fix_separators(source_path)
421 source_path = os.path.join(CHROMIUM_CHECKOUT, source_path)
422 if os.path.exists(source_path) and not check_fn:
kjellander844dd2a2016-04-05 00:13:58 -0700423 raise LinkError('Can only to link to %s: tried to link to: %s' %
424 (check_msg, source_path))
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000425
426 if not os.path.exists(source_path):
427 logging.debug('Silently ignoring missing source: %s. This is to avoid '
428 'errors on platform-specific dependencies.', source_path)
429 return []
430
431 actions = []
432
433 if os.path.exists(link_path) or os.path.islink(link_path):
434 if os.path.islink(link_path):
435 actions.append(Remove(link_path, dangerous=False))
436 elif os.path.isfile(link_path):
437 actions.append(Remove(link_path, dangerous=True))
438 elif os.path.isdir(link_path):
439 actions.append(Rmtree(link_path))
440 else:
441 raise LinkError('Don\'t know how to plan: %s' % link_path)
442
443 # Create parent directories to the target link if needed.
444 target_parent_dirs = os.path.dirname(link_path)
445 if (target_parent_dirs and
446 target_parent_dirs != link_path and
447 not os.path.exists(target_parent_dirs)):
448 actions.append(Makedirs(target_parent_dirs))
449
450 actions.append(Symlink(source_path, link_path))
451
452 return actions
453
454def _initialize_database(filename):
455 links_database = shelve.open(filename)
456
457 # Wipe the database if this version of the script ends up looking at a
458 # newer (future) version of the links db, just to be sure.
459 version = links_database.get('SCHEMA_VERSION')
460 if version and version != SCHEMA_VERSION:
461 logging.info('Found database with schema version %s while this script only '
462 'supports %s. Wiping previous database contents.', version,
463 SCHEMA_VERSION)
464 links_database.clear()
465 links_database['SCHEMA_VERSION'] = SCHEMA_VERSION
466 return links_database
467
468
469def main():
470 on_bot = os.environ.get('CHROME_HEADLESS') == '1'
471
472 parser = optparse.OptionParser()
473 parser.add_option('-d', '--dry-run', action='store_true', default=False,
474 help='Print what would be done, but don\'t perform any '
475 'operations. This will automatically set logging to '
476 'verbose.')
477 parser.add_option('-c', '--clean-only', action='store_true', default=False,
478 help='Only clean previously created links, don\'t create '
479 'new ones. This will automatically set logging to '
480 'verbose.')
481 parser.add_option('-f', '--force', action='store_true', default=on_bot,
482 help='Force link creation. CAUTION: This deletes existing '
483 'folders and files in the locations where links are '
484 'about to be created.')
485 parser.add_option('-n', '--no-prompt', action='store_false', dest='prompt',
486 default=(not on_bot),
487 help='Prompt if we\'re planning to do a dangerous action')
488 parser.add_option('-v', '--verbose', action='store_const',
489 const=logging.DEBUG, default=logging.INFO,
490 help='Print verbose output for debugging.')
491 options, _ = parser.parse_args()
492
493 if options.dry_run or options.force or options.clean_only:
494 options.verbose = logging.DEBUG
495 logging.basicConfig(format='%(message)s', level=options.verbose)
496
497 # Work from the root directory of the checkout.
498 script_dir = os.path.dirname(os.path.abspath(__file__))
499 os.chdir(script_dir)
500
501 if sys.platform.startswith('win'):
502 def is_admin():
503 try:
504 return os.getuid() == 0
505 except AttributeError:
506 return ctypes.windll.shell32.IsUserAnAdmin() != 0
kjellander844dd2a2016-04-05 00:13:58 -0700507 if is_admin():
508 logging.warning('WARNING: On Windows, you no longer need run as '
509 'administrator. Please run with user account privileges.')
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000510
511 if not os.path.exists(CHROMIUM_CHECKOUT):
Henrik Kjellanderedec0762016-11-15 22:39:13 +0100512 logging.warning('Cannot find a Chromium checkout at %s. Did you run '
513 '"gclient sync" before running this script?',
514 CHROMIUM_CHECKOUT)
515 return 0
kjellander@webrtc.org89256622014-08-20 12:10:11 +0000516
517 links_database = _initialize_database(LINKS_DB)
518 try:
519 symlink_creator = WebRTCLinkSetup(links_database, options.force,
520 options.dry_run, options.prompt)
521 symlink_creator.CleanupLinks()
522 if not options.clean_only:
523 symlink_creator.CreateLinks(on_bot)
524 except LinkError as e:
525 print >> sys.stderr, e.message
526 return 3
527 finally:
528 links_database.close()
529 return 0
530
531
532if __name__ == '__main__':
533 sys.exit(main())