bitbake-server 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. warnings.simplefilter("default")
  11. warnings.filterwarnings("ignore", category=DeprecationWarning, message=".*use.of.fork.*may.lead.to.deadlocks.in.the.child.*")
  12. import logging
  13. sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
  14. import bb
  15. bb.utils.check_system_locale()
  16. # Users shouldn't be running this code directly
  17. if len(sys.argv) != 11 or not sys.argv[1].startswith("decafbad"):
  18. print("bitbake-server is meant for internal execution by bitbake itself, please don't use it standalone.")
  19. sys.exit(1)
  20. import bb.server.process
  21. lockfd = int(sys.argv[2])
  22. readypipeinfd = int(sys.argv[3])
  23. logfile = sys.argv[4]
  24. lockname = sys.argv[5]
  25. sockname = sys.argv[6]
  26. timeout = float(sys.argv[7])
  27. profile = bool(int(sys.argv[8]))
  28. xmlrpcinterface = (sys.argv[9], int(sys.argv[10]))
  29. if xmlrpcinterface[0] == "None":
  30. xmlrpcinterface = (None, xmlrpcinterface[1])
  31. # Replace standard fds with our own
  32. with open('/dev/null', 'r') as si:
  33. os.dup2(si.fileno(), sys.stdin.fileno())
  34. with open(logfile, 'a+') as so:
  35. os.dup2(so.fileno(), sys.stdout.fileno())
  36. os.dup2(so.fileno(), sys.stderr.fileno())
  37. # Have stdout and stderr be the same so log output matches chronologically
  38. # and there aren't two seperate buffers
  39. sys.stderr = sys.stdout
  40. logger = logging.getLogger("BitBake")
  41. # Ensure logging messages get sent to the UI as events
  42. handler = bb.event.LogHandler()
  43. logger.addHandler(handler)
  44. bb.server.process.execServer(lockfd, readypipeinfd, lockname, sockname, timeout, xmlrpcinterface, profile)