Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 3 | # |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 4 | # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| 5 | # Use of this source code is governed by a BSD-style license that can be |
| 6 | # found in the LICENSE file. |
| 7 | |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 8 | """Script to checkout the ChromeOS source. |
| 9 | |
| 10 | This script sets up the ChromeOS source in the given directory, matching a |
| 11 | particular release of ChromeOS. |
| 12 | """ |
| 13 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame] | 14 | from __future__ import print_function |
| 15 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 16 | __author__ = ('asharif@google.com (Ahmad Sharif) ' |
| 17 | 'llozano@google.com (Luis Lozano) ' |
| 18 | 'raymes@google.com (Raymes Khoury) ' |
| 19 | 'shenhan@google.com (Han Shen)') |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 20 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame] | 21 | import argparse |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 22 | import os |
| 23 | import sys |
kbaclawski | 20082a0 | 2013-02-16 02:12:57 +0000 | [diff] [blame] | 24 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame] | 25 | from cros_utils import command_executer |
| 26 | from cros_utils import logger |
| 27 | from cros_utils import misc |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 28 | |
asharif | e3668f1 | 2013-02-15 04:46:29 +0000 | [diff] [blame] | 29 | |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 30 | def Usage(parser, message): |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame] | 31 | print('ERROR: %s' % message) |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 32 | parser.print_help() |
| 33 | sys.exit(0) |
| 34 | |
asharif | e3668f1 | 2013-02-15 04:46:29 +0000 | [diff] [blame] | 35 | |
bjanakiraman | 6496e5f | 2013-02-15 04:50:58 +0000 | [diff] [blame] | 36 | def Main(argv): |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 37 | """Build ChromeOS.""" |
| 38 | # Common initializations |
asharif | 5a9bb46 | 2013-02-15 04:50:57 +0000 | [diff] [blame] | 39 | cmd_executer = command_executer.GetCommandExecuter() |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 40 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame] | 41 | parser = argparse.ArgumentParser() |
Caroline Tice | f6ef439 | 2017-04-06 17:16:05 -0700 | [diff] [blame] | 42 | parser.add_argument( |
| 43 | '--chromeos_root', |
| 44 | dest='chromeos_root', |
| 45 | help='Target directory for ChromeOS installation.') |
| 46 | parser.add_argument( |
| 47 | '--clobber_chroot', |
| 48 | dest='clobber_chroot', |
| 49 | action='store_true', |
| 50 | help='Delete the chroot and start fresh', |
| 51 | default=False) |
| 52 | parser.add_argument( |
| 53 | '--clobber_board', |
| 54 | dest='clobber_board', |
| 55 | action='store_true', |
| 56 | help='Delete the board and start fresh', |
| 57 | default=False) |
| 58 | parser.add_argument( |
| 59 | '--rebuild', |
| 60 | dest='rebuild', |
| 61 | action='store_true', |
| 62 | help='Rebuild all board packages except the toolchain.', |
| 63 | default=False) |
| 64 | parser.add_argument( |
| 65 | '--cflags', |
| 66 | dest='cflags', |
| 67 | default='', |
| 68 | help='CFLAGS for the ChromeOS packages') |
| 69 | parser.add_argument( |
| 70 | '--cxxflags', |
| 71 | dest='cxxflags', |
| 72 | default='', |
| 73 | help='CXXFLAGS for the ChromeOS packages') |
| 74 | parser.add_argument( |
| 75 | '--ldflags', |
| 76 | dest='ldflags', |
| 77 | default='', |
| 78 | help='LDFLAGS for the ChromeOS packages') |
| 79 | parser.add_argument( |
| 80 | '--board', dest='board', help='ChromeOS target board, e.g. x86-generic') |
| 81 | parser.add_argument( |
| 82 | '--package', dest='package', help='The package needs to be built') |
| 83 | parser.add_argument( |
| 84 | '--label', |
| 85 | dest='label', |
| 86 | help='Optional label symlink to point to build dir.') |
| 87 | parser.add_argument( |
| 88 | '--dev', |
| 89 | dest='dev', |
| 90 | default=False, |
| 91 | action='store_true', |
| 92 | help=('Make the final image in dev mode (eg writable, ' |
| 93 | 'more space on image). Defaults to False.')) |
| 94 | parser.add_argument( |
| 95 | '--debug', |
| 96 | dest='debug', |
| 97 | default=False, |
| 98 | action='store_true', |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 99 | help=('Optional. Build chrome browser with "-g -O0". ' |
| 100 | "Notice, this also turns on '--dev'. " |
Caroline Tice | f6ef439 | 2017-04-06 17:16:05 -0700 | [diff] [blame] | 101 | 'Defaults to False.')) |
| 102 | parser.add_argument( |
| 103 | '--env', dest='env', default='', help='Env to pass to build_packages.') |
| 104 | parser.add_argument( |
| 105 | '--vanilla', |
| 106 | dest='vanilla', |
| 107 | default=False, |
| 108 | action='store_true', |
| 109 | help='Use default ChromeOS toolchain.') |
| 110 | parser.add_argument( |
| 111 | '--vanilla_image', |
| 112 | dest='vanilla_image', |
| 113 | default=False, |
| 114 | action='store_true', |
| 115 | help=('Use prebuild packages for building the image. ' |
| 116 | 'It also implies the --vanilla option is set.')) |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 117 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame] | 118 | options = parser.parse_args(argv[1:]) |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 119 | |
| 120 | if options.chromeos_root is None: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 121 | Usage(parser, '--chromeos_root must be set') |
Luis Lozano | 09b027f | 2015-03-30 13:29:49 -0700 | [diff] [blame] | 122 | options.chromeos_root = os.path.expanduser(options.chromeos_root) |
| 123 | scripts_dir = os.path.join(options.chromeos_root, 'src', 'scripts') |
| 124 | if not os.path.isdir(scripts_dir): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 125 | Usage(parser, '--chromeos_root must be set up first. Use setup_chromeos.py') |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 126 | |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 127 | if options.board is None: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 128 | Usage(parser, '--board must be set') |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 129 | |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 130 | if options.debug: |
| 131 | options.dev = True |
| 132 | |
asharif | 4447378 | 2013-02-19 19:58:15 +0000 | [diff] [blame] | 133 | build_packages_env = options.env |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 134 | if build_packages_env.find('EXTRA_BOARD_FLAGS=') != -1: |
| 135 | logger.GetLogger().LogFatal( |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 136 | ('Passing "EXTRA_BOARD_FLAGS" in "--env" is not supported. ' |
| 137 | 'This flags is used internally by this script. ' |
| 138 | 'Contact the author for more detail.')) |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 139 | |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 140 | if options.rebuild: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 141 | build_packages_env += ' EXTRA_BOARD_FLAGS=-e' |
llozano | 3a42892 | 2013-02-19 21:36:47 +0000 | [diff] [blame] | 142 | # EXTRA_BOARD_FLAGS=-e should clean up the object files for the chrome |
| 143 | # browser but it doesn't. So do it here. |
| 144 | misc.RemoveChromeBrowserObjectFiles(options.chromeos_root, options.board) |
asharif | 80b47dc | 2013-02-15 06:31:19 +0000 | [diff] [blame] | 145 | |
Luis Lozano | 09b027f | 2015-03-30 13:29:49 -0700 | [diff] [blame] | 146 | # Build with afdo_use by default. |
| 147 | # To change the default use --env="USE=-afdo_use". |
| 148 | build_packages_env = misc.MergeEnvStringWithDict( |
Luis A. Lozano | 09ce67b | 2017-06-15 17:57:49 -0700 | [diff] [blame] | 149 | build_packages_env, {'USE': 'chrome_internal afdo_use -cros-debug'}) |
asharif | 01e29a5 | 2013-02-15 04:56:41 +0000 | [diff] [blame] | 150 | |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 151 | build_packages_command = misc.GetBuildPackagesCommand( |
Caroline Tice | f6ef439 | 2017-04-06 17:16:05 -0700 | [diff] [blame] | 152 | board=options.board, usepkg=options.vanilla_image, debug=options.debug) |
yunlian | 5acba6e | 2013-02-19 22:34:37 +0000 | [diff] [blame] | 153 | |
| 154 | if options.package: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 155 | build_packages_command += ' {0}'.format(options.package) |
yunlian | 5acba6e | 2013-02-19 22:34:37 +0000 | [diff] [blame] | 156 | |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 157 | build_image_command = misc.GetBuildImageCommand(options.board, options.dev) |
asharif | ca8c5ef | 2013-02-15 04:57:02 +0000 | [diff] [blame] | 158 | |
Yunlian Jiang | d145a58 | 2013-08-19 13:59:34 -0700 | [diff] [blame] | 159 | if options.vanilla or options.vanilla_image: |
Caroline Tice | f6ef439 | 2017-04-06 17:16:05 -0700 | [diff] [blame] | 160 | command = misc.GetSetupBoardCommand( |
| 161 | options.board, |
| 162 | usepkg=options.vanilla_image, |
| 163 | force=options.clobber_board) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 164 | command += '; ' + build_packages_env + ' ' + build_packages_command |
| 165 | command += '&& ' + build_packages_env + ' ' + build_image_command |
asharif | ca3c6c1 | 2013-02-15 23:17:54 +0000 | [diff] [blame] | 166 | ret = cmd_executer.ChrootRunCommand(options.chromeos_root, command) |
asharif | b1752c8 | 2013-02-15 04:56:37 +0000 | [diff] [blame] | 167 | return ret |
| 168 | |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 169 | # Setup board |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 170 | if not os.path.isdir(options.chromeos_root + '/chroot/build/' + |
| 171 | options.board) or options.clobber_board: |
raymes | 04164a1 | 2013-02-15 04:36:03 +0000 | [diff] [blame] | 172 | # Run build_tc.py from binary package |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 173 | ret = cmd_executer.ChrootRunCommand( |
| 174 | options.chromeos_root, |
| 175 | misc.GetSetupBoardCommand(options.board, force=options.clobber_board)) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 176 | logger.GetLogger().LogFatalIf(ret, 'setup_board failed') |
raymes | 5f35b92 | 2013-02-15 04:35:57 +0000 | [diff] [blame] | 177 | else: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 178 | logger.GetLogger().LogOutput('Did not setup_board ' |
| 179 | 'because it already exists') |
raymes | bfb5799 | 2013-02-15 04:35:45 +0000 | [diff] [blame] | 180 | |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 181 | if options.debug: |
| 182 | # Perform 2-step build_packages to build a debug chrome browser. |
| 183 | |
| 184 | # Firstly, build everything that chromeos-chrome depends on normally. |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 185 | if options.rebuild: |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 186 | # Give warning about "--rebuild" and "--debug". Under this combination, |
| 187 | # only dependencies of "chromeos-chrome" get rebuilt. |
| 188 | logger.GetLogger().LogWarning( |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 189 | '--rebuild" does not correctly re-build every package when ' |
| 190 | '"--debug" is enabled. ') |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 191 | |
| 192 | # Replace EXTRA_BOARD_FLAGS=-e with "-e --onlydeps" |
| 193 | build_packages_env = build_packages_env.replace( |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 194 | 'EXTRA_BOARD_FLAGS=-e', 'EXTRA_BOARD_FLAGS="-e --onlydeps"') |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 195 | else: |
| 196 | build_packages_env += ' EXTRA_BOARD_FLAGS=--onlydeps' |
| 197 | |
| 198 | ret = cmd_executer.ChrootRunCommand( |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 199 | options.chromeos_root, 'CFLAGS="$(portageq-%s envvar CFLAGS) %s" ' |
| 200 | 'CXXFLAGS="$(portageq-%s envvar CXXFLAGS) %s" ' |
| 201 | 'LDFLAGS="$(portageq-%s envvar LDFLAGS) %s" ' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 202 | 'CHROME_ORIGIN=SERVER_SOURCE ' |
| 203 | '%s ' |
| 204 | '%s --skip_chroot_upgrade' |
| 205 | 'chromeos-chrome' % (options.board, options.cflags, options.board, |
| 206 | options.cxxflags, options.board, options.ldflags, |
| 207 | build_packages_env, build_packages_command)) |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 208 | |
| 209 | logger.GetLogger().LogFatalIf(\ |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 210 | ret, 'build_packages failed while trying to build chromeos-chrome deps.') |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 211 | |
| 212 | # Secondly, build chromeos-chrome using debug mode. |
| 213 | # Replace '--onlydeps' with '--nodeps'. |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 214 | if options.rebuild: |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 215 | build_packages_env = build_packages_env.replace( |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 216 | 'EXTRA_BOARD_FLAGS="-e --onlydeps"', 'EXTRA_BOARD_FLAGS=--nodeps') |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 217 | else: |
| 218 | build_packages_env = build_packages_env.replace( |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 219 | 'EXTRA_BOARD_FLAGS=--onlydeps', 'EXTRA_BOARD_FLAGS=--nodeps') |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 220 | ret = cmd_executer.ChrootRunCommand( |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 221 | options.chromeos_root, 'CFLAGS="$(portageq-%s envvar CFLAGS) %s" ' |
| 222 | 'CXXFLAGS="$(portageq-%s envvar CXXFLAGS) %s" ' |
| 223 | 'LDFLAGS="$(portageq-%s envvar LDFLAGS) %s" ' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 224 | 'CHROME_ORIGIN=SERVER_SOURCE BUILDTYPE=Debug ' |
| 225 | '%s ' |
| 226 | '%s --skip_chroot_upgrade' |
| 227 | 'chromeos-chrome' % (options.board, options.cflags, options.board, |
| 228 | options.cxxflags, options.board, options.ldflags, |
| 229 | build_packages_env, build_packages_command)) |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 230 | logger.GetLogger().LogFatalIf( |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 231 | ret, |
| 232 | 'build_packages failed while trying to build debug chromeos-chrome.') |
shenhan | 4873858 | 2013-02-19 22:45:41 +0000 | [diff] [blame] | 233 | |
| 234 | # Now, we have built chromeos-chrome and all dependencies. |
| 235 | # Finally, remove '-e' from EXTRA_BOARD_FLAGS, |
| 236 | # otherwise, chromeos-chrome gets rebuilt. |
| 237 | build_packages_env = build_packages_env.replace(\ |
| 238 | 'EXTRA_BOARD_FLAGS=--nodeps', '') |
| 239 | |
| 240 | # Up to now, we have a debug built chromos-chrome browser. |
| 241 | # Fall through to build the rest of the world. |
| 242 | |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 243 | # Build packages |
asharif | ca3c6c1 | 2013-02-15 23:17:54 +0000 | [diff] [blame] | 244 | ret = cmd_executer.ChrootRunCommand( |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 245 | options.chromeos_root, 'CFLAGS="$(portageq-%s envvar CFLAGS) %s" ' |
| 246 | 'CXXFLAGS="$(portageq-%s envvar CXXFLAGS) %s" ' |
| 247 | 'LDFLAGS="$(portageq-%s envvar LDFLAGS) %s" ' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 248 | 'CHROME_ORIGIN=SERVER_SOURCE ' |
| 249 | '%s ' |
Caroline Tice | f6ef439 | 2017-04-06 17:16:05 -0700 | [diff] [blame] | 250 | '%s --skip_chroot_upgrade' % |
| 251 | (options.board, options.cflags, options.board, options.cxxflags, |
| 252 | options.board, options.ldflags, build_packages_env, |
| 253 | build_packages_command)) |
raymes | bfb5799 | 2013-02-15 04:35:45 +0000 | [diff] [blame] | 254 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 255 | logger.GetLogger().LogFatalIf(ret, 'build_packages failed') |
yunlian | 5acba6e | 2013-02-19 22:34:37 +0000 | [diff] [blame] | 256 | if options.package: |
| 257 | return 0 |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 258 | # Build image |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 259 | ret = cmd_executer.ChrootRunCommand( |
| 260 | options.chromeos_root, build_packages_env + ' ' + build_image_command) |
raymes | bfb5799 | 2013-02-15 04:35:45 +0000 | [diff] [blame] | 261 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 262 | logger.GetLogger().LogFatalIf(ret, 'build_image failed') |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 263 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 264 | flags_file_name = 'flags.txt' |
| 265 | flags_file_path = ('%s/src/build/images/%s/latest/%s' % |
| 266 | (options.chromeos_root, options.board, flags_file_name)) |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 267 | with open(flags_file_path, 'w', encoding='utf-8') as flags_file: |
| 268 | flags_file.write('CFLAGS=%s\n' % options.cflags) |
| 269 | flags_file.write('CXXFLAGS=%s\n' % options.cxxflags) |
| 270 | flags_file.write('LDFLAGS=%s\n' % options.ldflags) |
asharif | 8697d4e | 2013-02-15 09:18:09 +0000 | [diff] [blame] | 271 | |
| 272 | if options.label: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 273 | image_dir_path = ('%s/src/build/images/%s/latest' % (options.chromeos_root, |
| 274 | options.board)) |
asharif | 8697d4e | 2013-02-15 09:18:09 +0000 | [diff] [blame] | 275 | real_image_dir_path = os.path.realpath(image_dir_path) |
Zhizhou Yang | 81d651f | 2020-02-10 16:51:20 -0800 | [diff] [blame] | 276 | command = ('ln -sf -T %s %s/%s' % (os.path.basename(real_image_dir_path), |
| 277 | os.path.dirname(real_image_dir_path), |
| 278 | options.label)) |
asharif | 8697d4e | 2013-02-15 09:18:09 +0000 | [diff] [blame] | 279 | |
| 280 | ret = cmd_executer.RunCommand(command) |
Caroline Tice | f6ef439 | 2017-04-06 17:16:05 -0700 | [diff] [blame] | 281 | logger.GetLogger().LogFatalIf( |
| 282 | ret, 'Failed to apply symlink label %s' % options.label) |
asharif | 8697d4e | 2013-02-15 09:18:09 +0000 | [diff] [blame] | 283 | |
| 284 | return ret |
raymes | 5154d7f | 2013-02-15 04:35:37 +0000 | [diff] [blame] | 285 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 286 | |
| 287 | if __name__ == '__main__': |
asharif | 2198c51 | 2013-02-15 09:21:35 +0000 | [diff] [blame] | 288 | retval = Main(sys.argv) |
| 289 | sys.exit(retval) |