diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-01-26 15:34:30 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-18 07:41:16 +0000 |
commit | ca552bb4b1d877193ba6235e6216d06b984c62db (patch) | |
tree | d6c12a0cf6b77e0a9a859dd85c51539207d87246 | |
parent | 8f61f2d8812df8d8e57affd7c8a45c1054c59b83 (diff) | |
download | openembedded-core-contrib-ca552bb4b1d877193ba6235e6216d06b984c62db.tar.gz |
bitbake: FileChecksumCache: add get_checksums() method
Move the local file checksum functionality from bb.fetch2 into
bb.checksum module.
(Bitbake rev: 4f60933283f377d68f191db849dac6c1dc7a0aed)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/checksum.py | 47 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 45 |
2 files changed, 48 insertions, 44 deletions
diff --git a/bitbake/lib/bb/checksum.py b/bitbake/lib/bb/checksum.py index 514ff0b1e6..7fb46d8db5 100644 --- a/bitbake/lib/bb/checksum.py +++ b/bitbake/lib/bb/checksum.py @@ -15,6 +15,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import glob +import operator import os import stat import bb.utils @@ -88,3 +90,48 @@ class FileChecksumCache(MultiProcessCache): dest[0][h] = source[0][h] else: dest[0][h] = source[0][h] + + def get_checksums(self, filelist, pn): + """Get checksums for a list of files""" + + def checksum_file(f): + try: + checksum = self.get_checksum(f) + except OSError as e: + bb.warn("Unable to get checksum for %s SRC_URI entry %s: %s" % (pn, os.path.basename(f), e)) + return None + return checksum + + def checksum_dir(pth): + # Handle directories recursively + dirchecksums = [] + for root, dirs, files in os.walk(pth): + for name in files: + fullpth = os.path.join(root, name) + checksum = checksum_file(fullpth) + if checksum: + dirchecksums.append((fullpth, checksum)) + return dirchecksums + + checksums = [] + for pth in filelist.split(): + exist = pth.split(":")[1] + if exist == "False": + continue + pth = pth.split(":")[0] + if '*' in pth: + # Handle globs + for f in glob.glob(pth): + if os.path.isdir(f): + checksums.extend(checksum_dir(f)) + else: + checksum = checksum_file(f) + checksums.append((f, checksum)) + elif os.path.isdir(pth): + checksums.extend(checksum_dir(pth)) + else: + checksum = checksum_file(pth) + checksums.append((pth, checksum)) + + checksums.sort(key=operator.itemgetter(1)) + return checksums diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index 83122e856c..914553aaf7 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -29,11 +29,9 @@ from __future__ import absolute_import from __future__ import print_function import os, re import signal -import glob import logging import urllib import urlparse -import operator import bb.persist_data, bb.utils import bb.checksum from bb import data @@ -1108,48 +1106,7 @@ def get_file_checksums(filelist, pn): it proceeds """ - - def checksum_file(f): - try: - checksum = _checksum_cache.get_checksum(f) - except OSError as e: - bb.warn("Unable to get checksum for %s SRC_URI entry %s: %s" % (pn, os.path.basename(f), e)) - return None - return checksum - - def checksum_dir(pth): - # Handle directories recursively - dirchecksums = [] - for root, dirs, files in os.walk(pth): - for name in files: - fullpth = os.path.join(root, name) - checksum = checksum_file(fullpth) - if checksum: - dirchecksums.append((fullpth, checksum)) - return dirchecksums - - checksums = [] - for pth in filelist.split(): - exist = pth.split(":")[1] - if exist == "False": - continue - pth = pth.split(":")[0] - if '*' in pth: - # Handle globs - for f in glob.glob(pth): - if os.path.isdir(f): - checksums.extend(checksum_dir(f)) - else: - checksum = checksum_file(f) - checksums.append((f, checksum)) - elif os.path.isdir(pth): - checksums.extend(checksum_dir(pth)) - else: - checksum = checksum_file(pth) - checksums.append((pth, checksum)) - - checksums.sort(key=operator.itemgetter(1)) - return checksums + return _checksum_cache.get_checksums(filelist, pn) class FetchData(object): |