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