Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
- index ac557176..ec6cd731 100644
- --- a/lib/bb/fetch2/__init__.py
- +++ b/lib/bb/fetch2/__init__.py
- @@ -1213,32 +1213,6 @@ def srcrev_internal_helper(ud, d, name):
- return srcrev
- -def get_checksum_file_list(d):
- - """ Get a list of files checksum in SRC_URI
- -
- - Returns the resolved local paths of all local file entries in
- - SRC_URI as a space-separated string
- - """
- - fetch = Fetch([], d, cache = False, localonly = True)
- -
- - dl_dir = d.getVar('DL_DIR')
- - filelist = []
- - for u in fetch.urls:
- - ud = fetch.ud[u]
- -
- - if ud and isinstance(ud.method, local.Local):
- - paths = ud.method.localpaths(ud, d)
- - for f in paths:
- - pth = ud.decodedurl
- - if f.startswith(dl_dir):
- - # The local fetcher's behaviour is to return a path under DL_DIR if it couldn't find the file anywhere else
- - if os.path.exists(f):
- - bb.warn("Getting checksum for %s SRC_URI entry %s: file not found except in DL_DIR" % (d.getVar('PN'), os.path.basename(f)))
- - else:
- - bb.warn("Unable to get checksum for %s SRC_URI entry %s: file could not be found" % (d.getVar('PN'), os.path.basename(f)))
- - filelist.append(f + ":" + str(os.path.exists(f)))
- -
- - return " ".join(filelist)
- def get_file_checksums(filelist, pn, localdirsexclude):
- """Get a list of the checksums for a list of local files
- diff --git a/lib/bb/fetch2/local.py b/lib/bb/fetch2/local.py
- index e7d1c8c5..bef405fb 100644
- --- a/lib/bb/fetch2/local.py
- +++ b/lib/bb/fetch2/local.py
- @@ -17,7 +17,7 @@ import os
- import urllib.request, urllib.parse, urllib.error
- import bb
- import bb.utils
- -from bb.fetch2 import FetchMethod, FetchError, ParameterError
- +from bb.fetch2 import FetchMethod, FetchError, ParameterError, Fetch
- from bb.fetch2 import logger
- class Local(FetchMethod):
- @@ -37,6 +37,32 @@ class Local(FetchMethod):
- raise bb.fetch2.ParameterError("file:// urls using globbing are no longer supported. Please place the files in a directory and reference that instead.", ud.url)
- return
- + def get_checksum_file_list(d):
- + """ Get a list of files checksum in SRC_URI
- +
- + Returns the resolved local paths of all local file entries in
- + SRC_URI as a space-separated string
- + """
- + fetch = Fetch([], d, cache = False, localonly = True)
- +
- + filelist = []
- + for u in fetch.urls:
- + ud = fetch.ud[u]
- +
- + path = ud.decodedurl
- + candidate = ""
- + if path[0] == "/":
- + candidate = path
- + else:
- + filespath = d.getVar('FILESPATH')
- + candidate = bb.utils.which(filespath, path)
- + if candidate == "":
- + bb.fatal("Unable to get checksum for %s SRC_URI entry %s: file could not be found" % (d.getVar('PN'), ud.decodedurl))
- + # We already checked in the bb.utils.which that it exists
- + filelist.append(candidate + ":True")
- +
- + return " ".join(filelist)
- +
- def localpath(self, urldata, d):
- """
- Return the local filename of a given url assuming a successful fetch.
- diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
- index ee41bff4..252f023f 100644
- --- a/lib/bb/tests/fetch.py
- +++ b/lib/bb/tests/fetch.py
- @@ -693,6 +693,11 @@ class FetcherLocalTest(FetcherTest):
- flst.sort()
- return flst
- + def test_local_checksum_fails_no_file(self):
- + self.d.setVar("SRC_URI", "file://404")
- + with self.assertRaises(bb.BBHandledException):
- + bb.fetch.local.Local.get_checksum_file_list(self.d)
- +
- def test_local(self):
- tree = self.fetchUnpack(['file://a', 'file://dir/c'])
- self.assertEqual(tree, ['a', 'dir/c'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement