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