local.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env python
  2. # ex:ts=4:sw=4:sts=4:et
  3. # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
  4. """
  5. BitBake 'Fetch' implementations
  6. Classes for obtaining upstream sources for the
  7. BitBake build tools.
  8. """
  9. # Copyright (C) 2003, 2004 Chris Larson
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License version 2 as
  13. # published by the Free Software Foundation.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License along
  21. # with this program; if not, write to the Free Software Foundation, Inc.,
  22. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. #
  24. # Based on functions from the base bb module, Copyright 2003 Holger Schurig
  25. import os, re
  26. import bb
  27. from bb import data
  28. from bb.fetch import Fetch
  29. class Local(Fetch):
  30. def supports(self, url, urldata, d):
  31. """
  32. Check to see if a given url can be fetched with cvs.
  33. """
  34. return urldata.type in ['file','patch']
  35. def localpath(self, url, urldata, d):
  36. """Return the local filename of a given url assuming a successful fetch.
  37. """
  38. path = url.split("://")[1]
  39. newpath = path
  40. if path[0] != "/":
  41. filespath = data.getVar('FILESPATH', d, 1)
  42. if filespath:
  43. newpath = bb.which(filespath, path)
  44. if not newpath:
  45. filesdir = data.getVar('FILESDIR', d, 1)
  46. if filesdir:
  47. newpath = os.path.join(filesdir, path)
  48. # We don't set localfile as for this fetcher the file is already local!
  49. return newpath
  50. def go(self, url, urldata, d):
  51. """Fetch urls (no-op for Local method)"""
  52. # no need to fetch local files, we'll deal with them in place.
  53. return 1