Advertisement
Guest User

Untitled

a guest
Jul 11th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.94 KB | None | 0 0
  1. diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
  2. index ac557176..ec6cd731 100644
  3. --- a/lib/bb/fetch2/__init__.py
  4. +++ b/lib/bb/fetch2/__init__.py
  5. @@ -1213,32 +1213,6 @@ def srcrev_internal_helper(ud, d, name):
  6.  
  7.      return srcrev
  8.  
  9. -def get_checksum_file_list(d):
  10. -    """ Get a list of files checksum in SRC_URI
  11. -
  12. -    Returns the resolved local paths of all local file entries in
  13. -    SRC_URI as a space-separated string
  14. -    """
  15. -    fetch = Fetch([], d, cache = False, localonly = True)
  16. -
  17. -    dl_dir = d.getVar('DL_DIR')
  18. -    filelist = []
  19. -    for u in fetch.urls:
  20. -        ud = fetch.ud[u]
  21. -
  22. -        if ud and isinstance(ud.method, local.Local):
  23. -            paths = ud.method.localpaths(ud, d)
  24. -            for f in paths:
  25. -                pth = ud.decodedurl
  26. -                if f.startswith(dl_dir):
  27. -                    # The local fetcher's behaviour is to return a path under DL_DIR if it couldn't find the file anywhere else
  28. -                    if os.path.exists(f):
  29. -                        bb.warn("Getting checksum for %s SRC_URI entry %s: file not found except in DL_DIR" % (d.getVar('PN'), os.path.basename(f)))
  30. -                    else:
  31. -                        bb.warn("Unable to get checksum for %s SRC_URI entry %s: file could not be found" % (d.getVar('PN'), os.path.basename(f)))
  32. -                filelist.append(f + ":" + str(os.path.exists(f)))
  33. -
  34. -    return " ".join(filelist)
  35.  
  36.  def get_file_checksums(filelist, pn, localdirsexclude):
  37.      """Get a list of the checksums for a list of local files
  38. diff --git a/lib/bb/fetch2/local.py b/lib/bb/fetch2/local.py
  39. index e7d1c8c5..bef405fb 100644
  40. --- a/lib/bb/fetch2/local.py
  41. +++ b/lib/bb/fetch2/local.py
  42. @@ -17,7 +17,7 @@ import os
  43.  import urllib.request, urllib.parse, urllib.error
  44.  import bb
  45.  import bb.utils
  46. -from   bb.fetch2 import FetchMethod, FetchError, ParameterError
  47. +from   bb.fetch2 import FetchMethod, FetchError, ParameterError, Fetch
  48.  from   bb.fetch2 import logger
  49.  
  50.  class Local(FetchMethod):
  51. @@ -37,6 +37,32 @@ class Local(FetchMethod):
  52.              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)
  53.          return
  54.  
  55. +    def get_checksum_file_list(d):
  56. +        """ Get a list of files checksum in SRC_URI
  57. +
  58. +        Returns the resolved local paths of all local file entries in
  59. +        SRC_URI as a space-separated string
  60. +        """
  61. +        fetch = Fetch([], d, cache = False, localonly = True)
  62. +
  63. +        filelist = []
  64. +        for u in fetch.urls:
  65. +            ud = fetch.ud[u]
  66. +
  67. +            path = ud.decodedurl
  68. +            candidate = ""
  69. +            if path[0] == "/":
  70. +                candidate = path
  71. +            else:
  72. +                filespath = d.getVar('FILESPATH')
  73. +                candidate = bb.utils.which(filespath, path)
  74. +            if candidate == "":
  75. +                bb.fatal("Unable to get checksum for %s SRC_URI entry %s: file could not be found" % (d.getVar('PN'), ud.decodedurl))
  76. +            # We already checked in the bb.utils.which that it exists
  77. +            filelist.append(candidate + ":True")
  78. +
  79. +        return " ".join(filelist)
  80. +
  81.      def localpath(self, urldata, d):
  82.          """
  83.          Return the local filename of a given url assuming a successful fetch.
  84. diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
  85. index ee41bff4..252f023f 100644
  86. --- a/lib/bb/tests/fetch.py
  87. +++ b/lib/bb/tests/fetch.py
  88. @@ -693,6 +693,11 @@ class FetcherLocalTest(FetcherTest):
  89.          flst.sort()
  90.          return flst
  91.  
  92. +    def test_local_checksum_fails_no_file(self):
  93. +        self.d.setVar("SRC_URI", "file://404")
  94. +        with self.assertRaises(bb.BBHandledException):
  95. +            bb.fetch.local.Local.get_checksum_file_list(self.d)
  96. +
  97.      def test_local(self):
  98.          tree = self.fetchUnpack(['file://a', 'file://dir/c'])
  99.          self.assertEqual(tree, ['a', 'dir/c'])
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement