[Author: zork]
[google-gears.git] / gears / tools / build_sdk.py
blob2bba90bd8d1afb6bccb11f0126b69221fa42bbec
1 #!/usr/bin/python
3 # Copyright 2007, Google Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
8 # 1. Redistributions of source code must retain the above copyright notice,
9 # this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following disclaimer in the documentation
12 # and/or other materials provided with the distribution.
13 # 3. Neither the name of Google Inc. nor the names of its contributors may be
14 # used to endorse or promote products derived from this software without
15 # specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 # Creates the Gears SDK zipfile.
30 # Execute in your /googleclient/gears directory: ./tools/build_sdk.py
32 # Before running this script, create a directory in the /gears/sdk directory
33 # called targets and drag all the XPIs and EXEs you want to include, like
34 # this:
36 # [~/src/googleclient/gears]$ ls sdk/targets/
37 # GoogleGearsSetup.exe gears-0.1.51.0-linux.xpi
38 # gears-0.1.45.0-osx.xpi gears-0.1.52.0-win32.xpi
40 import glob
41 import os
42 import sys
43 import time
44 import zipfile
46 def AddFile(z, filename, prefix='', strip=0):
47 if strip:
48 fname = os.path.basename(filename)
49 else:
50 fname = filename
51 if (prefix):
52 prefix += '/'
53 z.write(filename, prefix + fname)
55 def AddFiles(z, filenames, prefix='', strip=0):
56 for f in filenames:
57 AddFile(z, f, prefix, strip)
59 def main():
60 # Make sure we are running from the right location.
61 if (not os.path.exists('sdk')):
62 print 'Please run this script from /googleclient/gears.'
63 sys.exit(1)
65 # Note: this will overwrite any existing GearsSDK.zip file, instead of
66 # appending the new files. (That is the behavior we want.)
67 z = zipfile.ZipFile('GearsSDK.zip', 'w', zipfile.ZIP_DEFLATED)
68 os.chdir('sdk')
69 AddFile(z, 'README.html')
70 AddFiles(z, glob.glob('doc/*'))
71 AddFiles(z, glob.glob('samples/*'))
73 ff_installers = glob.glob('targets/*.xpi')
74 if (ff_installers):
75 AddFiles(z, ff_installers, 'install/Firefox', 1)
76 else:
77 print 'WARNING: no Firefox installer(s) found. Please put in /sdk/targets.'
79 ie_installers = glob.glob('targets/*.exe')
80 if (ie_installers):
81 AddFiles(z, ie_installers, 'install/IE', 1)
82 else:
83 print 'WARNING: no IE installer(s) found. Please put in /sdk/targets.'
85 if __name__ == '__main__':
86 main()