blob: afce2192fdab6fd5656b1b7278df07798c593366 [file] [log] [blame]
Ryan Cui0af7a912012-06-18 18:00:47 -07001#!/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 SIMONNETdface902015-04-29 15:06:54 -07008 <sysroot>/stripped-packages."""
Ryan Cui0af7a912012-06-18 18:00:47 -07009
Ryan Cui0af7a912012-06-18 18:00:47 -070010import optparse
Yu-Ju Honge2b3f742013-11-08 11:33:09 -080011import sys
Ryan Cui0af7a912012-06-18 18:00:47 -070012
Gilad Arnoldabb352e2012-09-23 01:24:27 -070013import builder
14
Ryan Cui0af7a912012-06-18 18:00:47 -070015
16def 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 SIMONNETdface902015-04-29 15:06:54 -070021 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 Cui0af7a912012-06-18 18:00:47 -070024 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 SIMONNETdface902015-04-29 15:06:54 -070032 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 Cui0af7a912012-06-18 18:00:47 -070039
Yu-Ju Honge2b3f742013-11-08 11:33:09 -080040 # Check if package was installed.
Bertrand SIMONNETdface902015-04-29 15:06:54 -070041 if not builder.UpdateGmergeBinhost(sysroot, args[0], options.deep):
Yu-Ju Honge2b3f742013-11-08 11:33:09 -080042 sys.exit(1)
Ryan Cui0af7a912012-06-18 18:00:47 -070043
44
45if __name__ == '__main__':
46 main()