Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # SPDX-License-Identifier: GPL-2.0-only |
| 4 | # |
| 5 | # Copyright (C) 2020 Richard Purdie |
| 6 | # |
| 7 | |
| 8 | import os |
| 9 | import sys |
| 10 | import warnings |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 11 | warnings.simplefilter("default") |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 12 | import logging |
| 13 | sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) |
| 14 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 15 | import bb |
| 16 | |
| 17 | bb.utils.check_system_locale() |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 18 | |
| 19 | # Users shouldn't be running this code directly |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 20 | if len(sys.argv) != 11 or not sys.argv[1].startswith("decafbad"): |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 21 | print("bitbake-server is meant for internal execution by bitbake itself, please don't use it standalone.") |
| 22 | sys.exit(1) |
| 23 | |
| 24 | import bb.server.process |
| 25 | |
| 26 | lockfd = int(sys.argv[2]) |
| 27 | readypipeinfd = int(sys.argv[3]) |
| 28 | logfile = sys.argv[4] |
| 29 | lockname = sys.argv[5] |
| 30 | sockname = sys.argv[6] |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 31 | timeout = float(sys.argv[7]) |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 32 | profile = bool(int(sys.argv[8])) |
| 33 | xmlrpcinterface = (sys.argv[9], int(sys.argv[10])) |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 34 | if xmlrpcinterface[0] == "None": |
| 35 | xmlrpcinterface = (None, xmlrpcinterface[1]) |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 36 | |
| 37 | # Replace standard fds with our own |
| 38 | with open('/dev/null', 'r') as si: |
| 39 | os.dup2(si.fileno(), sys.stdin.fileno()) |
| 40 | |
| 41 | so = open(logfile, 'a+') |
| 42 | os.dup2(so.fileno(), sys.stdout.fileno()) |
| 43 | os.dup2(so.fileno(), sys.stderr.fileno()) |
| 44 | |
| 45 | # Have stdout and stderr be the same so log output matches chronologically |
| 46 | # and there aren't two seperate buffers |
| 47 | sys.stderr = sys.stdout |
| 48 | |
| 49 | logger = logging.getLogger("BitBake") |
| 50 | # Ensure logging messages get sent to the UI as events |
| 51 | handler = bb.event.LogHandler() |
| 52 | logger.addHandler(handler) |
| 53 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 54 | bb.server.process.execServer(lockfd, readypipeinfd, lockname, sockname, timeout, xmlrpcinterface, profile) |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 55 | |