Index: packagerChrome.py |
diff --git a/packagerChrome.py b/packagerChrome.py |
index 948a9074ce55b2e359237582c27474efcc1cdad6..0fcd48377e60dfed6140f4327f754566a7b57b78 100644 |
--- a/packagerChrome.py |
+++ b/packagerChrome.py |
@@ -8,10 +8,10 @@ import io |
import json |
import os |
import re |
-from StringIO import StringIO |
import struct |
import subprocess |
import sys |
+import random |
from packager import (readMetadata, getDefaultFileName, getBuildVersion, |
getTemplate, Files) |
@@ -44,13 +44,15 @@ def processFile(path, data, params): |
def makeIcons(files, filenames): |
- try: |
- from PIL import Image |
- except ImportError: |
- import Image |
icons = {} |
for filename in filenames: |
- width, height = Image.open(StringIO(files[filename])).size |
+ try: |
+ magic, width, height = struct.unpack_from('>8s8xii', |
+ files[filename]) |
+ except struct.error: |
+ magic = None |
+ if magic != '\x89PNG\r\n\x1a\n': |
+ raise Exception(filename + ' is no valid PNG.') |
if(width != height): |
print >>sys.stderr, 'Warning: %s size is %ix%i, icon should be square' % (filename, width, height) |
icons[width] = filename |
@@ -319,6 +321,18 @@ def writePackage(outputFile, pubkey, signature, zipdata): |
file.write(zipdata) |
+def add_devenv_requirements(files, metadata, params): |
+ files.read(os.path.join(os.path.dirname(__file__), |
+ 'chromeDevenvPoller__.js'), |
+ relpath='devenvPoller__.js') |
+ files['devenvVersion__'] = str(random.random()) |
+ |
+ if metadata.has_option('general', 'testScripts'): |
+ files['qunit/index.html'] = createScriptPage( |
+ params, 'testIndex.html.tmpl', ('general', 'testScripts') |
+ ) |
+ |
+ |
def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuild=False, keyFile=None, devenv=False): |
metadata = readMetadata(baseDir, type) |
version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum) |
@@ -363,15 +377,7 @@ def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuil |
fix_translations_for_chrome(files) |
if devenv: |
- import buildtools |
- import random |
- files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js') |
- files['devenvVersion__'] = str(random.random()) |
- |
- if metadata.has_option('general', 'testScripts'): |
- files['qunit/index.html'] = createScriptPage( |
- params, 'testIndex.html.tmpl', ('general', 'testScripts') |
- ) |
+ add_devenv_requirements(files, metadata, params) |
zipdata = files.zipToString() |
signature = None |