bug 903620 - Make ExecutableFile support being put directly into a jar. r=gps

This commit is contained in:
Mike Hommey 2014-02-06 13:22:35 -05:00
parent fc41441c5b
commit 459d8c3649

View File

@ -27,6 +27,7 @@ from mozpack.errors import (
from mozpack.mozjar import JarReader
import mozpack.path
from collections import OrderedDict
from tempfile import mkstemp
class Dest(object):
@ -179,6 +180,11 @@ class ExecutableFile(File):
(see mozpack.executables.is_executable documentation).
'''
def copy(self, dest, skip_if_older=True):
real_dest = dest
if not isinstance(dest, basestring):
fd, dest = mkstemp()
os.close(fd)
os.remove(dest)
assert isinstance(dest, basestring)
# If File.copy didn't actually copy because dest is newer, check the
# file sizes. If dest is smaller, it means it is already stripped and
@ -194,6 +200,12 @@ class ExecutableFile(File):
except ErrorMessage:
os.remove(dest)
raise
if real_dest != dest:
f = File(dest)
ret = f.copy(real_dest, skip_if_older)
os.remove(dest)
return ret
return True