bitbake-server 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env python3
  2. #
  3. # SPDX-License-Identifier: GPL-2.0-only
  4. #
  5. # Copyright (C) 2020 Richard Purdie
  6. #
  7. import os
  8. import sys
  9. import warnings
  10. import logging
  11. sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
  12. if sys.getfilesystemencoding() != "utf-8":
  13. sys.exit("Please use a locale setting which supports UTF-8 (such as LANG=en_US.UTF-8).\nPython can't change the filesystem locale after loading so we need a UTF-8 when Python starts or things won't work.")
  14. # Users shouldn't be running this code directly
  15. if len(sys.argv) != 10 or not sys.argv[1].startswith("decafbad"):
  16. print("bitbake-server is meant for internal execution by bitbake itself, please don't use it standalone.")
  17. sys.exit(1)
  18. import bb.server.process
  19. lockfd = int(sys.argv[2])
  20. readypipeinfd = int(sys.argv[3])
  21. logfile = sys.argv[4]
  22. lockname = sys.argv[5]
  23. sockname = sys.argv[6]
  24. timeout = sys.argv[7]
  25. xmlrpcinterface = (sys.argv[8], int(sys.argv[9]))
  26. if xmlrpcinterface[0] == "None":
  27. xmlrpcinterface = (None, xmlrpcinterface[1])
  28. if timeout == "None":
  29. timeout = None
  30. # Replace standard fds with our own
  31. with open('/dev/null', 'r') as si:
  32. os.dup2(si.fileno(), sys.stdin.fileno())
  33. so = open(logfile, 'a+')
  34. os.dup2(so.fileno(), sys.stdout.fileno())
  35. os.dup2(so.fileno(), sys.stderr.fileno())
  36. # Have stdout and stderr be the same so log output matches chronologically
  37. # and there aren't two seperate buffers
  38. sys.stderr = sys.stdout
  39. logger = logging.getLogger("BitBake")
  40. # Ensure logging messages get sent to the UI as events
  41. handler = bb.event.LogHandler()
  42. logger.addHandler(handler)
  43. bb.server.process.execServer(lockfd, readypipeinfd, lockname, sockname, timeout, xmlrpcinterface)