Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright (c) 2009-2012 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | """Script that strips a given package and places the stripped version in |
Bertrand SIMONNET | dface90 | 2015-04-29 15:06:54 -0700 | [diff] [blame^] | 8 | <sysroot>/stripped-packages.""" |
Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 9 | |
Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 10 | import optparse |
Yu-Ju Hong | e2b3f74 | 2013-11-08 11:33:09 -0800 | [diff] [blame] | 11 | import sys |
Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 12 | |
Gilad Arnold | abb352e | 2012-09-23 01:24:27 -0700 | [diff] [blame] | 13 | import builder |
| 14 | |
Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 15 | |
| 16 | def main(): |
| 17 | parser = optparse.OptionParser(usage='usage: %prog [options] package') |
| 18 | parser.add_option('--board', type='string', action='store', |
| 19 | help=('The board that the package being processed belongs ' |
| 20 | 'to.')) |
Bertrand SIMONNET | dface90 | 2015-04-29 15:06:54 -0700 | [diff] [blame^] | 21 | parser.add_option('--sysroot', type='string', action='store', |
| 22 | help=('Sysroot that the package being processed belongs to.' |
| 23 | 'This is incompatible with --board.')) |
Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 24 | parser.add_option('--deep', action='store_true', default=False, |
| 25 | help=('Also strip dependencies of package.')) |
| 26 | |
| 27 | (options, args) = parser.parse_args() |
| 28 | if len(args) != 1: |
| 29 | parser.print_help() |
| 30 | parser.error('Need exactly one package name') |
| 31 | |
Bertrand SIMONNET | dface90 | 2015-04-29 15:06:54 -0700 | [diff] [blame^] | 32 | if not options.board and not options.sysroot: |
| 33 | parser.error('Need to specify --board or --sysroot.') |
| 34 | |
| 35 | if options.board and options.sysroot: |
| 36 | parser.error('--board and --sysroot are mutually exclusive.') |
| 37 | |
| 38 | sysroot = options.sysroot or '/build/%s/' % options.board |
Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 39 | |
Yu-Ju Hong | e2b3f74 | 2013-11-08 11:33:09 -0800 | [diff] [blame] | 40 | # Check if package was installed. |
Bertrand SIMONNET | dface90 | 2015-04-29 15:06:54 -0700 | [diff] [blame^] | 41 | if not builder.UpdateGmergeBinhost(sysroot, args[0], options.deep): |
Yu-Ju Hong | e2b3f74 | 2013-11-08 11:33:09 -0800 | [diff] [blame] | 42 | sys.exit(1) |
Ryan Cui | 0af7a91 | 2012-06-18 18:00:47 -0700 | [diff] [blame] | 43 | |
| 44 | |
| 45 | if __name__ == '__main__': |
| 46 | main() |