summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2018-02-02 23:51:15 +1000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-02-14 15:26:03 +0000
commitf2d5967982359b924406e3937a8e32807a5bb533 (patch)
treeef149278615cd8683e7893ef5ae0a69f658cf334 /bitbake/lib/bb/fetch2
parentbb3a634226c68b235d0110b9955d0aae7dde994a (diff)
downloadpoky-f2d5967982359b924406e3937a8e32807a5bb533.tar.gz
bitbake: fetch2: Handle missing donestamp file when content is valid
In order to allow users to manually populate the download directory with valid content change the assumption that missing the donestamp file means unfetched content. This allows users to populate the download dir without needing to create dummy .done files such that a user does not need a PREMIRROR when using BB_NO_NETWORK to provide valid content files in the download directory. To ensure the correct result this change also fails first if the localpath does not exist. This prevents further parts of the function attempting to calculating the checksum on non-existent files. This also fixes some edge conditions around where if the donestamp exists but the localpath does not it returns, and did not remove the donestamp. Also added test cases to cover this use case and additional use cases where for example the fetcher does not support checksums. (Bitbake rev: a335dbbb65d5b56e71d98cf3e4fa9bfbec1dcde6) Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 6bd040493e..72d6092deb 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -643,26 +643,25 @@ def verify_donestamp(ud, d, origud=None):
643 if not ud.needdonestamp or (origud and not origud.needdonestamp): 643 if not ud.needdonestamp or (origud and not origud.needdonestamp):
644 return True 644 return True
645 645
646 if not os.path.exists(ud.donestamp): 646 if not os.path.exists(ud.localpath):
647 # local path does not exist
648 if os.path.exists(ud.donestamp):
649 # done stamp exists, but the downloaded file does not; the done stamp
650 # must be incorrect, re-trigger the download
651 bb.utils.remove(ud.donestamp)
647 return False 652 return False
648 653
649 if (not ud.method.supports_checksum(ud) or 654 if (not ud.method.supports_checksum(ud) or
650 (origud and not origud.method.supports_checksum(origud))): 655 (origud and not origud.method.supports_checksum(origud))):
651 # done stamp exists, checksums not supported; assume the local file is 656 # if done stamp exists and checksums not supported; assume the local
652 # current 657 # file is current
653 return True 658 return os.path.exists(ud.donestamp)
654
655 if not os.path.exists(ud.localpath):
656 # done stamp exists, but the downloaded file does not; the done stamp
657 # must be incorrect, re-trigger the download
658 bb.utils.remove(ud.donestamp)
659 return False
660 659
661 precomputed_checksums = {} 660 precomputed_checksums = {}
662 # Only re-use the precomputed checksums if the donestamp is newer than the 661 # Only re-use the precomputed checksums if the donestamp is newer than the
663 # file. Do not rely on the mtime of directories, though. If ud.localpath is 662 # file. Do not rely on the mtime of directories, though. If ud.localpath is
664 # a directory, there will probably not be any checksums anyway. 663 # a directory, there will probably not be any checksums anyway.
665 if (os.path.isdir(ud.localpath) or 664 if os.path.exists(ud.donestamp) and (os.path.isdir(ud.localpath) or
666 os.path.getmtime(ud.localpath) < os.path.getmtime(ud.donestamp)): 665 os.path.getmtime(ud.localpath) < os.path.getmtime(ud.donestamp)):
667 try: 666 try:
668 with open(ud.donestamp, "rb") as cachefile: 667 with open(ud.donestamp, "rb") as cachefile: