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 # elfhacked, so we can skip. if not File.copy(self, dest, skip_if_older) and \ os.path.getsize(self.path) > os.path.getsize(dest): return False try: if may_strip(dest): strip(dest) if may_elfhack(dest): elfhack(dest) 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
def copy(self, dest): assert isinstance(dest, basestring) File.copy(self, dest) try: if may_strip(dest): strip(dest) if may_elfhack(dest): elfhack(dest) except ErrorMessage: os.remove(dest) raise return True
def copy(self, dest): assert isinstance(dest, basestring) tmpfiles = [] try: for p in [self.path1, self.path2]: fd, f = mkstemp() os.close(fd) tmpfiles.append(f) shutil.copy2(p, f) strip(f) subprocess.call(['lipo', '-create'] + tmpfiles + ['-output', dest]) finally: for f in tmpfiles: os.unlink(f)