mirror of
https://git.yoctoproject.org/poky
synced 2026-02-07 17:26:36 +01:00
Introduce a PRSERVER_UPSTREAM variable that makes the local PR server connect to an "upstream" one. This makes it possible to implement local fixes to an upstream package (revision "x", in a way that gives the local update priority (revision "x.y"). Update the calculation of the new revisions to support the case when prior revisions are not integers, but have an "x.y..." format." Set the comments in the handle_get_pr() function in serv.py for details about the calculation of the local revision. This is done by going on supporting the "history" mode that wasn't used so far (revisions can return to a previous historical value), in addition to the default "no history" mode (revisions can never decrease). Rather than storing the history mode in the database table itself (i.e. "PRMAIN_hist" and "PRMAIN_nohist"), the history mode is now passed through the client requests. As a consequence, the table name is now "PRMAIN", which is incompatible with what was generated before, but avoids confusion if we kept the "PRMAIN_nohist" name for both "history" and "no history" modes. Update the server version to "2.0.0". (Bitbake rev: 48857ec3e075791bd73d92747c609a0a4fda0e0c) Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Cc: Joshua Watt <JPEWhacker@gmail.com> Cc: Tim Orling <ticotimo@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
96 lines
2.4 KiB
Python
96 lines
2.4 KiB
Python
#
|
|
# Copyright BitBake Contributors
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
|
|
|
|
__version__ = "2.0.0"
|
|
|
|
import logging
|
|
logger = logging.getLogger("BitBake.PRserv")
|
|
|
|
from bb.asyncrpc.client import parse_address, ADDR_TYPE_UNIX, ADDR_TYPE_WS
|
|
|
|
def create_server(addr, dbpath, upstream=None, read_only=False):
|
|
from . import serv
|
|
|
|
s = serv.PRServer(dbpath, upstream=upstream, read_only=read_only)
|
|
host, port = addr.split(":")
|
|
s.start_tcp_server(host, int(port))
|
|
|
|
return s
|
|
|
|
def increase_revision(ver):
|
|
"""Take a revision string such as "1" or "1.2.3" or even a number and increase its last number
|
|
This fails if the last number is not an integer"""
|
|
|
|
fields=str(ver).split('.')
|
|
last = fields[-1]
|
|
|
|
try:
|
|
val = int(last)
|
|
except Exception as e:
|
|
logger.critical("Unable to increase revision value %s: %s" % (ver, e))
|
|
raise e
|
|
|
|
return ".".join(fields[0:-1] + list(str(val + 1)))
|
|
|
|
def _revision_greater_or_equal(rev1, rev2):
|
|
"""Compares x.y.z revision numbers, using integer comparison
|
|
Returns True if rev1 is greater or equal to rev2"""
|
|
|
|
fields1 = rev1.split(".")
|
|
fields2 = rev2.split(".")
|
|
l1 = len(fields1)
|
|
l2 = len(fields2)
|
|
|
|
for i in range(l1):
|
|
val1 = int(fields1[i])
|
|
if i < l2:
|
|
val2 = int(fields2[i])
|
|
if val2 < val1:
|
|
return True
|
|
elif val2 > val1:
|
|
return False
|
|
else:
|
|
return True
|
|
return True
|
|
|
|
def revision_smaller(rev1, rev2):
|
|
"""Compares x.y.z revision numbers, using integer comparison
|
|
Returns True if rev1 is strictly smaller than rev2"""
|
|
return not(_revision_greater_or_equal(rev1, rev2))
|
|
|
|
def revision_greater(rev1, rev2):
|
|
"""Compares x.y.z revision numbers, using integer comparison
|
|
Returns True if rev1 is strictly greater than rev2"""
|
|
return _revision_greater_or_equal(rev1, rev2) and (rev1 != rev2)
|
|
|
|
def create_client(addr):
|
|
from . import client
|
|
|
|
c = client.PRClient()
|
|
|
|
try:
|
|
(typ, a) = parse_address(addr)
|
|
c.connect_tcp(*a)
|
|
return c
|
|
except Exception as e:
|
|
c.close()
|
|
raise e
|
|
|
|
async def create_async_client(addr):
|
|
from . import client
|
|
|
|
c = client.PRAsyncClient()
|
|
|
|
try:
|
|
(typ, a) = parse_address(addr)
|
|
await c.connect_tcp(*a)
|
|
return c
|
|
|
|
except Exception as e:
|
|
await c.close()
|
|
raise e
|