local.py 2.0 KB

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