am 3f5326fd
: Merge "sha module is deprecated"
* commit '3f5326fd9fe2a5c46b4e6643e2b277e7f13cac04': sha module is deprecated
This commit is contained in:
commit
a74a4811ae
3 changed files with 19 additions and 7 deletions
|
@ -47,12 +47,16 @@ if sys.hexversion < 0x02040000:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sha
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
try:
|
||||||
|
from hashlib import sha1 as sha1
|
||||||
|
except ImportError:
|
||||||
|
from sha import sha as sha1
|
||||||
|
|
||||||
import common
|
import common
|
||||||
|
|
||||||
# Work around a bug in python's zipfile module that prevents opening
|
# Work around a bug in python's zipfile module that prevents opening
|
||||||
|
@ -112,7 +116,7 @@ class CertDB(object):
|
||||||
self.certs[cert] = self.certs[cert] + "," + name
|
self.certs[cert] = self.certs[cert] + "," + name
|
||||||
else:
|
else:
|
||||||
if name is None:
|
if name is None:
|
||||||
name = "unknown cert %s (%s)" % (sha.sha(cert).hexdigest()[:12],
|
name = "unknown cert %s (%s)" % (sha1(cert).hexdigest()[:12],
|
||||||
GetCertSubject(cert))
|
GetCertSubject(cert))
|
||||||
self.certs[cert] = name
|
self.certs[cert] = name
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import imp
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import sha
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -29,6 +28,11 @@ import threading
|
||||||
import time
|
import time
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
try:
|
||||||
|
from hashlib import sha1 as sha1
|
||||||
|
except ImportError:
|
||||||
|
from sha import sha as sha1
|
||||||
|
|
||||||
# missing in Python 2.4 and before
|
# missing in Python 2.4 and before
|
||||||
if not hasattr(os, "SEEK_SET"):
|
if not hasattr(os, "SEEK_SET"):
|
||||||
os.SEEK_SET = 0
|
os.SEEK_SET = 0
|
||||||
|
@ -659,7 +663,7 @@ class File(object):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.data = data
|
self.data = data
|
||||||
self.size = len(data)
|
self.size = len(data)
|
||||||
self.sha1 = sha.sha(data).hexdigest()
|
self.sha1 = sha1(data).hexdigest()
|
||||||
|
|
||||||
def WriteToTemp(self):
|
def WriteToTemp(self):
|
||||||
t = tempfile.NamedTemporaryFile()
|
t = tempfile.NamedTemporaryFile()
|
||||||
|
|
|
@ -56,12 +56,16 @@ import copy
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sha
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
|
try:
|
||||||
|
from hashlib import sha1 as sha1
|
||||||
|
except ImportError:
|
||||||
|
from sha import sha as sha1
|
||||||
|
|
||||||
import common
|
import common
|
||||||
import edify_generator
|
import edify_generator
|
||||||
|
|
||||||
|
@ -318,7 +322,7 @@ def MakeRecoveryPatch(output_zip, recovery_img, boot_img):
|
||||||
# we check to see if this recovery has already been installed by
|
# we check to see if this recovery has already been installed by
|
||||||
# testing just the first 2k.
|
# testing just the first 2k.
|
||||||
HEADER_SIZE = 2048
|
HEADER_SIZE = 2048
|
||||||
header_sha1 = sha.sha(recovery_img.data[:HEADER_SIZE]).hexdigest()
|
header_sha1 = sha1(recovery_img.data[:HEADER_SIZE]).hexdigest()
|
||||||
sh = """#!/system/bin/sh
|
sh = """#!/system/bin/sh
|
||||||
if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(header_size)d:%(header_sha1)s; then
|
if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(header_size)d:%(header_sha1)s; then
|
||||||
log -t recovery "Installing new recovery image"
|
log -t recovery "Installing new recovery image"
|
||||||
|
@ -501,7 +505,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
||||||
verbatim_targets.append((tf.name, tf.size))
|
verbatim_targets.append((tf.name, tf.size))
|
||||||
else:
|
else:
|
||||||
common.ZipWriteStr(output_zip, "patch/" + tf.name + ".p", d)
|
common.ZipWriteStr(output_zip, "patch/" + tf.name + ".p", d)
|
||||||
patch_list.append((tf.name, tf, sf, tf.size, sha.sha(d).hexdigest()))
|
patch_list.append((tf.name, tf, sf, tf.size, sha1(d).hexdigest()))
|
||||||
largest_source_size = max(largest_source_size, sf.size)
|
largest_source_size = max(largest_source_size, sf.size)
|
||||||
|
|
||||||
source_fp = GetBuildProp("ro.build.fingerprint", source_zip)
|
source_fp = GetBuildProp("ro.build.fingerprint", source_zip)
|
||||||
|
|
Loading…
Reference in a new issue