summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2019-01-04 10:20:14 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-08 11:16:03 +0000
commitdf85dd54857b06ca514d01091929b577753ce94e (patch)
treebeff08af54f80783dcacef45fc34220dadca6a33 /bitbake/bin
parentcea00c128311539a870d0cd233366480ddaff605 (diff)
downloadpoky-df85dd54857b06ca514d01091929b577753ce94e.tar.gz
bitbake: bitbake: hashserv: Add hash equivalence reference server
Implements a reference implementation of the hash equivalence server. This server has minimal dependencies (and no dependencies outside of the standard Python library), and implements the minimum required to be a conforming hash equivalence server. [YOCTO #13030] (Bitbake rev: 1bb2ad0b44b94ee04870bf3f7dac4e663bed6e4d) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake-hashserv67
-rwxr-xr-xbitbake/bin/bitbake-selftest2
2 files changed, 69 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-hashserv b/bitbake/bin/bitbake-hashserv
new file mode 100755
index 0000000000..c49397b73a
--- /dev/null
+++ b/bitbake/bin/bitbake-hashserv
@@ -0,0 +1,67 @@
1#! /usr/bin/env python3
2#
3# Copyright (C) 2018 Garmin Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17import os
18import sys
19import logging
20import argparse
21import sqlite3
22
23sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),'lib'))
24
25import hashserv
26
27VERSION = "1.0.0"
28
29DEFAULT_HOST = ''
30DEFAULT_PORT = 8686
31
32def main():
33 parser = argparse.ArgumentParser(description='HTTP Equivalence Reference Server. Version=%s' % VERSION)
34 parser.add_argument('--address', default=DEFAULT_HOST, help='Bind address (default "%(default)s")')
35 parser.add_argument('--port', type=int, default=DEFAULT_PORT, help='Bind port (default %(default)d)')
36 parser.add_argument('--prefix', default='', help='HTTP path prefix (default "%(default)s")')
37 parser.add_argument('--database', default='./hashserv.db', help='Database file (default "%(default)s")')
38 parser.add_argument('--log', default='WARNING', help='Set logging level')
39
40 args = parser.parse_args()
41
42 logger = logging.getLogger('hashserv')
43
44 level = getattr(logging, args.log.upper(), None)
45 if not isinstance(level, int):
46 raise ValueError('Invalid log level: %s' % args.log)
47
48 logger.setLevel(level)
49 console = logging.StreamHandler()
50 console.setLevel(level)
51 logger.addHandler(console)
52
53 db = sqlite3.connect(args.database)
54
55 server = hashserv.create_server((args.address, args.port), db, args.prefix)
56 server.serve_forever()
57 return 0
58
59if __name__ == '__main__':
60 try:
61 ret = main()
62 except Exception:
63 ret = 1
64 import traceback
65 traceback.print_exc()
66 sys.exit(ret)
67
diff --git a/bitbake/bin/bitbake-selftest b/bitbake/bin/bitbake-selftest
index c970dcae90..99f1af910f 100755
--- a/bitbake/bin/bitbake-selftest
+++ b/bitbake/bin/bitbake-selftest
@@ -22,6 +22,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib
22import unittest 22import unittest
23try: 23try:
24 import bb 24 import bb
25 import hashserv
25 import layerindexlib 26 import layerindexlib
26except RuntimeError as exc: 27except RuntimeError as exc:
27 sys.exit(str(exc)) 28 sys.exit(str(exc))
@@ -35,6 +36,7 @@ tests = ["bb.tests.codeparser",
35 "bb.tests.parse", 36 "bb.tests.parse",
36 "bb.tests.persist_data", 37 "bb.tests.persist_data",
37 "bb.tests.utils", 38 "bb.tests.utils",
39 "hashserv.tests",
38 "layerindexlib.tests.layerindexobj", 40 "layerindexlib.tests.layerindexobj",
39 "layerindexlib.tests.restapi", 41 "layerindexlib.tests.restapi",
40 "layerindexlib.tests.cooker"] 42 "layerindexlib.tests.cooker"]