Skip to contentSkip to conversation

network based PR service(revised)

PATCH In review Lianhao Lu 4 participants 14 messages May 26, 2011

lore
Share & tools
lore

Lianhao Lu

author
#0 lore raw

cover network based PR service(revised)

This is a modification of the original patch to enable network based PR service.

The main difference between this series of patch to the original one is that this one uses the PKGR/PKGV during the package feed creation. It also made the PR service disabled by default(by leaving the PRSERV_HOST and PRSERV_PORT commented out) and revised some function names.

The following features from the previous patch comments are not included in this series:
1) automatically launch PR service in localhost use case.
2) respect OVERIDE to allow setting PRSERV_HOST/PORT per recipe basis
3) write permission control in the PR service.
4) way to sync up local PR database witht the central server.

I'll continue to work on some of those features. But I'd like to send this patch now to meet the schedule time window, and anyone interested can experiment and provide some comments.

Below is the excerpt from my last series of patch. ---------------BEGIN of last patch message------------------------------------ This series of 5 patches implemented the network based PR service and enabled the poky to use it during the task do_package and do_package_write_xxx. By using the network based PR service and the basichash for BB_SIGNATURE_HANDLER, the poky user may not need to bump the PR manually everytime he/she changes the recipe. The package will get automatically rebuilt and new revision number reflecting the change will be included in the package feed.

The first patch "[PATCH 1/5] Added the PR service." implemented the network based PR service on the server side. It is a XMLRPC server with the sqlite3 as the backend database. The users query an automated value from this service by giving a tuple of (version, checksum). The returned value will be used as a part of the package revision value during the package feed creation process. The following algorihtm is used so this PR service could give multiple build servers new values for the new index tuple and same values for the same index tuple:

IF the index tuple(version, checksum) is found, THEN
return the value.
ELSE
find the max value in the database with the same version. increment it and save it into the database along with the index tuple. return the incremented value.
(Note: If no matching version is found, save and return the value of 0).
ENDIF

To start the network based PR service daemon, run the following command after "sourcing" the environment file oe-init-build-env:

  bitbake-prserv --start

See bitbake-prserv --help to see a detailed description of the options.

The remaining 4 patches enable the poky to use the PR service. In order to use it, the user needs to set 2 varialbes of PRSERV_HOST and PRSERV_PORT (which specify the PR service ip address and port, default is "localhost" and "8585" respectively) in the file conf/local.conf under the building directory. Leaving these 2 variables commented out would disable the poky to use the PR service, so the poky would behave exactly like what is now. ------------------END of last patch message----------------------------------

The following changes since commit 2458da25a83df9dc8d849ccf3de7f80fb194a33a:
Darren Hart (1):
README.hardware: update installation instructions for beagleboard

are available in the git repository at:

git://git.pokylinux.org/poky-contrib llu/PR-service
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=llu/PR-service

Lianhao Lu (5):
Added the PR service.
conf/bitbake.conf: Added variables for PR service. classes/package(prserv).bbclass: Added PR service support. classes/package_xxx.class: Added PR service support. meta-yocto/local.conf.sample: Added PRSERV_HOST and PRSERV_PORT.

 bitbake/bin/bitbake-prserv        |   53 ++++++++++
 bitbake/lib/prserv/__init__.py    |   11 ++
 bitbake/lib/prserv/db.py          |  100 +++++++++++++++++++
 bitbake/lib/prserv/serv.py        |  198 +++++++++++++++++++++++++++++++++++++
 meta-yocto/conf/local.conf.sample |    5 +
 meta/classes/package.bbclass      |   51 +++++++---
 meta/classes/package_deb.bbclass  |    6 +-
 meta/classes/package_ipk.bbclass  |    6 +-
 meta/classes/package_rpm.bbclass  |   10 +-
 meta/classes/package_tar.bbclass  |    4 +-
 meta/classes/prserv.bbclass       |   29 ++++++
 meta/conf/bitbake.conf            |   18 +++-
 12 files changed, 461 insertions(+), 30 deletions(-)
 create mode 100755 bitbake/bin/bitbake-prserv
 create mode 100644 bitbake/lib/prserv/__init__.py
 create mode 100644 bitbake/lib/prserv/db.py
 create mode 100644 bitbake/lib/prserv/serv.py
 create mode 100644 meta/classes/prserv.bbclass
author
#1 lore raw

PATCH 1/5 Added the PR service.

Added the initial implementation of the server side PR service.

---
 bitbake/bin/bitbake-prserv     |   53 +++++++++++
 bitbake/lib/prserv/__init__.py |   11 ++
 bitbake/lib/prserv/db.py       |  100 ++++++++++++++++++++
 bitbake/lib/prserv/serv.py     |  198 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 362 insertions(+), 0 deletions(-)
 create mode 100755 bitbake/bin/bitbake-prserv
 create mode 100644 bitbake/lib/prserv/__init__.py
 create mode 100644 bitbake/lib/prserv/db.py
 create mode 100644 bitbake/lib/prserv/serv.py
bitbake/bin/bitbake-prserv new file +53 -0
new file mode 100755
index 0000000..14073ca
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+import os
+import sys,logging
+import optparse
+
+sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),'lib'))
+
+import prserv
+import prserv.serv
+
+__version__="1.0.0"
+
+PRHOST_DEFAULT=''
+PRPORT_DEFAULT=8585
+
+def main():
+    parser = optparse.OptionParser(
+        version="Bitbake PR Service Core version %s, %%prog version %s" % (prserv.__version__, __version__),
+        usage = "%prog [options]")
+
+    parser.add_option("-f", "--file", help="database filename(default prserv.db)", action="store",
+                      dest="dbfile", type="string", default="prserv.db")
+    parser.add_option("-l", "--log", help="log filename(default prserv.log)", action="store",
+                      dest="logfile", type="string", default="prserv.log")
+    parser.add_option("--loglevel", help="logging level, i.e. CRITICAL, ERROR, WARNING, INFO, DEBUG",
+                      action = "store", type="string", dest="loglevel", default = "WARNING")
+    parser.add_option("--start", help="start daemon",
+                      action="store_true", dest="start", default="True")
+    parser.add_option("--stop", help="stop daemon",
+                      action="store_false", dest="start")
+    parser.add_option("--host", help="ip address to bind", action="store",
+                      dest="host", type="string", default=PRHOST_DEFAULT)
+    parser.add_option("--port", help="port number(default 8585)", action="store",
+                      dest="port", type="int", default=PRPORT_DEFAULT)
+
+    options, args = parser.parse_args(sys.argv)
+
+    prserv.init_logger(os.path.abspath(options.logfile),options.loglevel)
+
+    if options.start:
+        prserv.serv.start_daemon(options)
+    else:
+        prserv.serv.stop_daemon()
+
+if __name__ == "__main__":
+    try:
+        ret = main()
+    except Exception:
+        ret = 1
+        import traceback
+        traceback.print_exc(5)
+    sys.exit(ret)
+
bitbake/lib/prserv/__init__.py new file +11 -0
new file mode 100644
index 0000000..2837e13
@@ -0,0 +1,11 @@
+__version__ = "1.0.0"
+
+import os, time
+import sys,logging
+
+def init_logger(logfile, loglevel):
+    numeric_level = getattr(logging, loglevel.upper(), None)
+    if not isinstance(numeric_level, int):
+        raise ValueError('Invalid log level: %s' % loglevel)
+    logging.basicConfig(level=numeric_level, filename=logfile)
+
bitbake/lib/prserv/db.py new file +100 -0

100 lines not on this page · raw message

bitbake/lib/prserv/serv.py new file +198 -0

198 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#2 lore raw

PATCH 2/5 conf/bitbake.conf: Added variables for PR service.

1. change BB_SIGNATURE_HANDLER from basic to basichash.

2. Added following variables for PR service:
USE_PR_SERV: flag of whether to use the network PR service
PRAUTOINX: search index for the network PR service PKGV/PKGR: version and revision used in package feed

---
 meta/conf/bitbake.conf |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
meta/conf/bitbake.conf +16 -2
index 35fd6f8..06f5fd6 100644
@@ -153,9 +153,17 @@ PR = "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[2] or 'r0
 PF = "${PN}-${EXTENDPE}${PV}-${PR}"
 EXTENDPE = "${@['','${PE\x7d_'][bb.data.getVar('PE',d,1) > 0]}"
 EXTENDPEVER = "${@['','${PE\x7d:'][bb.data.getVar('PE',d,1) > 0]}"
-EXTENDPV = "${EXTENDPEVER}${PV}-${PR}"
+EXTENDPV = "${EXTENDPEVER}${PV}-${PKGR}"
 P = "${PN}-${PV}"
 
+EXTENDPRAUTO = "${@['.${PRAUTO\x7d',''][bb.data.getVar('PRAUTO',d,1) is None]}"
+PRAUTOINX = "${PF}${DISTRO_PR}"
+
+PKGV ?= "${PV}"
+PKGR ?= "${PR}${DISTRO_PR}${EXTENDPRAUTO}"
+EXTENDPKGVER = "${@['','${PKGE\x7d:'][bb.data.getVar('PKGE',d,1) > 0]}"
+EXTENDPKGV ?= "${EXTENDPKGVER}${PKGV}-${PKGR}"
+
 # Base package name
 # Automatically derives "foo" from "foo-native", "foo-cross" or "foo-initial"
 # otherwise it is the same as PN and P
@@ -163,6 +171,11 @@ SPECIAL_PKGSUFFIX = "-native -cross -initial -intermediate -nativesdk -crosssdk
 BPN = "${@base_prune_suffix(bb.data.getVar('PN', d, True), bb.data.getVar('SPECIAL_PKGSUFFIX', d, True).split(), d)}"
 BP = "${BPN}-${PV}"
 
+#
+# network based PR service
+#
+USE_PR_SERV = "${@[1,0][(bb.data.getVar('PRSERV_HOST',d,1) is None) or (bb.data.getVar('PRSERV_PORT',d,1) is None)]}"
+
 # Package info.
 
 SECTION = "base"
@@ -649,6 +662,7 @@ PCMCIA_MANAGER ?= "pcmcia-cs"
 DEFAULT_TASK_PROVIDER ?= "task-base"
 MACHINE_TASK_PROVIDER ?= "${DEFAULT_TASK_PROVIDER}"
 IMAGE_ROOTFS_SIZE ?= "65536"
+DISTRO_PR ?= ''
 
 # Forcefully set CACHE now so future changes to things like 
 # MACHINE don't change the path to the cache
@@ -707,7 +721,7 @@ DISTRO[unexport] = "1"
 TRANSLATED_TARGET_ARCH ??= ${TARGET_ARCH}
 
 # Setup our default hash policy
-BB_SIGNATURE_HANDLER ?= "basic"
+BB_SIGNATURE_HANDLER ?= "basichash"
 BB_HASHTASK_WHITELIST ?= "(.*-cross$|.*-native$|.*-cross-initial$|.*-cross-intermediate$|^virtual:native:.*|^virtual:nativesdk:.*)"
 BB_HASHBASE_WHITELIST ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH DL_DIR SSTATE_DIR THISDIR FILESEXTRAPATHS FILE_DIRNAME HOME LOGNAME SHELL TERM USER FILESPATH USERNAME STAGING_DIR_HOST STAGING_DIR_TARGET COREBASE"
 
Signature · 1 line
1.7.0.4
#3 lore raw

Re: [PATCH 2/5] conf/bitbake.conf: Added variables for PR service.

meta/conf/bitbake.conf PR = "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[2] or 'r0 · line 156

Quoted 2 lines · Lianhao Lu
meta/conf/bitbake.conf +1 -1
-EXTENDPV = "${EXTENDPEVER}${PV}-${PR}"
+EXTENDPV = "${EXTENDPEVER}${PV}-${PKGR}"

That looks a bit weird. Is it really correct to be mixing PV and PKGR like that?

FWIW, oe master has:

EXTENDPE = "${@int('${PE}') and '${PE}_' or ''}" EXTENDPEVER = "${@int('${PE}') and '${PE}:' or ''}" EXTENDPV = "${EXTENDPEVER}${PV}-${PR}${DISTRO_PR}"

PKGV ?= "${PV}"
PKGR ?= "${PR}${DISTRO_PR}"

EXTENDPKGEVER = "${@['','${PKGE\x7d:'][bb.data.getVar('PKGE',d,1) > 0]}" EXTENDPKGV ?= "${EXTENDPKGEVER}${PKGV}-${PKGR}"

and, although there are a couple of uses of ${EXTENDPV} that should perhaps be ${EXTENDPKGV}, this arrangement seems sensible otherwise.

p.

#4 lore raw

Re: [PATCH 2/5] conf/bitbake.conf: Added variables for PR service.

Phil Blundell wrote on 2011-05-26:

Quoted 12 lines · Lianhao Lu

meta/conf/bitbake.conf PR = "${@bb.parse.BBHandler.vars_from_file(bb.data.getVar('FILE',d),d)[2] or 'r0 · line 156

Quoted 2 lines
meta/conf/bitbake.conf +1 -1
-EXTENDPV = "${EXTENDPEVER}${PV}-${PR}"
+EXTENDPV = "${EXTENDPEVER}${PV}-${PKGR}"

That looks a bit weird. Is it really correct to be mixing PV and PKGR like that?

FWIW, oe master has:

EXTENDPE = "${@int('${PE}') and '${PE}_' or ''}" EXTENDPEVER = "${@int('${PE}') and '${PE}:' or ''}" EXTENDPV = "${EXTENDPEVER}${PV}-${PR}${DISTRO_PR}"

Quoted 9 lines

PKGV ?= "${PV}"
PKGR ?= "${PR}${DISTRO_PR}"

EXTENDPKGEVER = "${@['','${PKGE\x7d:'][bb.data.getVar('PKGE',d,1) > 0]}" EXTENDPKGV ?= "${EXTENDPKGEVER}${PKGV}-${PKGR}"

and, although there are a couple of uses of ${EXTENDPV} that should perhaps be ${EXTENDPKGV}, this arrangement seems sensible otherwise.

The problem is that in OE-core the default -deb/-dbg packages are all using EXTENDPV, as well as some other recipes. Do you mean we should make them all using EXTENDPKGV instead of EXTENDPV? If this is the way, I think PKGE should be used instead of PE in package_xxx.bbclass, though currently I don't see any recipe in OE using PKGE, but some of them do use PE.

Best Regards,
Lianhao

#5 lore raw

Re: [PATCH 2/5] conf/bitbake.conf: Added variables for PR service.

Quoted 3 lines · Lianhao

The problem is that in OE-core the default -deb/-dbg packages are all using EXTENDPV, as well as some other recipes. Do you mean we should make them all using EXTENDPKGV instead of EXTENDPV?

As far as I can tell, yes, that would be the right thing to do. That's what I was thinking of when I mentioned the "couple of uses" before. The only reason I hesitate is that, although the current behaviour looks like it should be wrong, nobody has actually complained about it and that makes me wonder if I have misunderstood something.

I guess someone needs to do a few tests to figure out what exactly is going on there. But I am fairly sure that creating a hybrid PV+PKGR is not a good thing to do; it should be either one thing or the other, and as far as I know everything on the output side should be using PKGxx.

p.

#6 lore raw

Re: [PATCH 2/5] conf/bitbake.conf: Added variables for PR service.

Phil Blundell wrote on 2011-05-26:

Quoted 11 lines · Lianhao
Quoted 3 lines

The problem is that in OE-core the default -deb/-dbg packages are all using EXTENDPV, as well as some other recipes. Do you mean we should make them all using EXTENDPKGV instead of EXTENDPV?

As far as I can tell, yes, that would be the right thing to do. That's what I was thinking of when I mentioned the "couple of uses" before. The only reason I hesitate is that, although the current behaviour looks like it should be wrong, nobody has actually complained about it and that makes me wonder if I have misunderstood something.

Quoted 5 lines

I guess someone needs to do a few tests to figure out what exactly is going on there. But I am fairly sure that creating a hybrid PV+PKGR is not a good thing to do; it should be either one thing or the other, and as far as I know everything on the output side should be using PKGxx.

Maybe all the recipes are using the PKGV default value (?= ${PV}, so this just happens to make EXTENDPKGV equal to EXTENDPV. In what situation we should use EXTENDPV but not EXTENDPKGV then?

Best Regards,
Lianhao

#7 lore raw

Re: [PATCH 2/5] conf/bitbake.conf: Added variables for PR service.

Quoted 2 lines · Lianhao

Maybe all the recipes are using the PKGV default value (?= ${PV}, so this just happens to make EXTENDPKGV equal to EXTENDPV.

Yes, could be. The most common situation where PKGV != PV is when something like gitpkgv.bbclass is in use, which doesn't happen all that often. The main effect of using the wrong vars would be to make the -doc/-dbg/-dev packages of gitpkgv-using recipes uninstallable, and I guess I could believe that this might be happening without anybody having noticed.

Quoted 1 line

In what situation we should use EXTENDPV but not EXTENDPKGV then?

Good question. I suspect the answer is probably "none".

p.

#8 lore raw

Re: [PATCH 2/5] conf/bitbake.conf: Added variables for PR service.

Quoted 11 lines · Phil Blundell
Quoted 2 lines · Lianhao

Maybe all the recipes are using the PKGV default value (?= ${PV}, so this just happens to make EXTENDPKGV equal to EXTENDPV.

Yes, could be. The most common situation where PKGV != PV is when something like gitpkgv.bbclass is in use, which doesn't happen all that often. The main effect of using the wrong vars would be to make the -doc/-dbg/-dev packages of gitpkgv-using recipes uninstallable, and I guess I could believe that this might be happening without anybody having noticed.

Quoted 3 lines
Quoted 1 line

In what situation we should use EXTENDPV but not EXTENDPKGV then?

Good question. I suspect the answer is probably "none".

For what its worth I agree with your conclusions, it probably is broken and nobody has noticed.

Lets keep this simpler and just have one variable :)

Cheers,

Richard

author
#9 lore raw

PATCH 3/5 classes/package(prserv).bbclass: Added PR service support.

In reply to Lianhao Lu

1. Added package_get_auto_pr to PACKAGEFUNCS to get the auto incremented value(PRAUTO) from remote PR service.

2. use PKGV/PKGR for pkgdata which will be used by package_write_xxx.

3. Added supporting functions in prserv.bbclass.

---
 meta/classes/package.bbclass |   51 +++++++++++++++++++++++++++++------------
 meta/classes/prserv.bbclass  |   29 +++++++++++++++++++++++
 2 files changed, 65 insertions(+), 15 deletions(-)
 create mode 100644 meta/classes/prserv.bbclass
meta/classes/package.bbclass +36 -15
index 2c6d30c..a1b9482 100644
@@ -7,34 +7,37 @@
 #
 # There are the following default steps but PACKAGEFUNCS can be extended:
 #
-# a) perform_packagecopy - Copy D into PKGD
+# a) package_get_auto_pr - get PRAUTO from remote PR service
 #
-# b) package_do_split_locales - Split out the locale files, updates FILES and PACKAGES
+# b) perform_packagecopy - Copy D into PKGD
 #
-# c) split_and_strip_files - split the files into runtime and debug and strip them.
+# c) package_do_split_locales - Split out the locale files, updates FILES and PACKAGES
+#
+# d) split_and_strip_files - split the files into runtime and debug and strip them.
 #    Debug files include debug info split, and associated sources that end up in -dbg packages
 #
-# d) populate_packages - Split the files in PKGD into separate packages in PKGDEST/<pkgname>
+# e) populate_packages - Split the files in PKGD into separate packages in PKGDEST/<pkgname>
 #    Also triggers the binary stripping code to put files in -dbg packages.
 #
-# e) package_do_filedeps - Collect perfile run-time dependency metadata
+# f) package_do_filedeps - Collect perfile run-time dependency metadata
 #    The data is stores in FILER{PROVIDES,DEPENDS}_file_pkg variables with
 #    a list of affected files in FILER{PROVIDES,DEPENDS}FLIST_pkg
 #
-# f) package_do_shlibs - Look at the shared libraries generated and autotmatically add any 
+# g) package_do_shlibs - Look at the shared libraries generated and autotmatically add any 
 #    depenedencies found. Also stores the package name so anyone else using this library 
 #    knows which package to depend on.
 #
-# g) package_do_pkgconfig - Keep track of which packages need and provide which .pc files
+# h) package_do_pkgconfig - Keep track of which packages need and provide which .pc files
 #
-# h) read_shlibdeps - Reads the stored shlibs information into the metadata
+# i) read_shlibdeps - Reads the stored shlibs information into the metadata
 #
-# i) package_depchains - Adds automatic dependencies to -dbg and -dev packages
+# j) package_depchains - Adds automatic dependencies to -dbg and -dev packages
 #
-# j) emit_pkgdata - saves the packaging data into PKGDATA_DIR for use in later 
+# k) emit_pkgdata - saves the packaging data into PKGDATA_DIR for use in later 
 #    packaging steps
 
 inherit packagedata
+inherit prserv
 
 PKGD    = "${WORKDIR}/package"
 PKGDEST = "${WORKDIR}/packages-split"
@@ -326,6 +329,15 @@ def runtime_mapping_rename (varname, d):
 # Package functions suitable for inclusion in PACKAGEFUNCS
 #
 
+python package_get_auto_pr() {
+	if d.getVar('USE_PR_SERV', True):
+		auto_pr=prserv_get_pr_auto(d)
+		if auto_pr is None:
+			bb.fatal("Can NOT get auto PR revision from remote PR service")
+			return
+		d.setVar('PRAUTO',str(auto_pr))
+}
+
 python package_do_split_locales() {
 	if (bb.data.getVar('PACKAGE_NO_LOCALE', d, True) == '1'):
 		bb.debug(1, "package requested not splitting locales")
@@ -773,6 +785,8 @@ python emit_pkgdata() {
 		write_if_exists(sf, pkg, 'PN')
 		write_if_exists(sf, pkg, 'PV')
 		write_if_exists(sf, pkg, 'PR')
+		write_if_exists(sf, pkg, 'PKGV')
+		write_if_exists(sf, pkg, 'PKGR')
 		write_if_exists(sf, pkg, 'DESCRIPTION')
 		write_if_exists(sf, pkg, 'SUMMARY')
 		write_if_exists(sf, pkg, 'RDEPENDS')
@@ -911,9 +925,9 @@ python package_do_shlibs() {
 
 	workdir = bb.data.getVar('WORKDIR', d, True)
 
-	ver = bb.data.getVar('PV', d, True)
+	ver = bb.data.getVar('PKGV', d, True)
 	if not ver:
-		bb.error("PV not defined")
+		bb.error("PKGV not defined")
 		return
 
 	pkgdest = bb.data.getVar('PKGDEST', d, True)
@@ -1025,6 +1039,12 @@ python package_do_shlibs() {
 		needs_ldconfig = False
 		bb.debug(2, "calculating shlib provides for %s" % pkg)
 
+		pkgver = bb.data.getVar('PKGV_' + pkg, d, True)
+		if not pkgver:
+			pkgver = bb.data.getVar('PV_' + pkg, d, True)
+		if not pkgver:
+			pkgver = ver
+
 		needed[pkg] = []
 		sonames = list()
 		renames = list()
@@ -1048,10 +1068,10 @@ python package_do_shlibs() {
 			fd = open(shlibs_file, 'w')
 			for s in sonames:
 				fd.write(s + '\n')
-				shlib_provider[s] = (pkg, ver)
+				shlib_provider[s] = (pkg, pkgver)
 			fd.close()
 			fd = open(shver_file, 'w')
-			fd.write(ver + '\n')
+			fd.write(pkgver + '\n')
 			fd.close()
 		if needs_ldconfig and use_ldconfig:
 			bb.debug(1, 'adding ldconfig call to postinst for %s' % pkg)
@@ -1348,7 +1368,8 @@ python package_depchains() {
 }
 
 PACKAGE_PREPROCESS_FUNCS ?= ""
-PACKAGEFUNCS ?= "perform_packagecopy \
+PACKAGEFUNCS ?= "package_get_auto_pr \	
+                perform_packagecopy \
                 ${PACKAGE_PREPROCESS_FUNCS} \
 		package_do_split_locales \
 		split_and_strip_files \
meta/classes/prserv.bbclass new file +29 -0
new file mode 100644
index 0000000..de46ff6
@@ -0,0 +1,29 @@
+def prserv_make_conn(d):
+    import prserv.serv
+    host=d.getVar("PRSERV_HOST",True)
+    port=d.getVar("PRSERV_PORT",True)
+    try:
+        conn=None
+        conn=prserv.serv.PRServerConnection(host,int(port))
+        d.setVar("__PRSERV_CONN",conn)
+    except Exception, exc:
+        bb.fatal("Connecting to PR service %s:%s failed: %s" % (host, port, str(exc)))
+
+    return conn
+
+def prserv_get_pr_auto(d):
+    if not d.getVar('USE_PR_SERV', True):
+        bb.warn("Not using network based PR service")
+        return None
+
+    conn=d.getVar("__PRSERV_CONN", True)
+    if conn is None:
+        conn=prserv_make_conn(d)
+        if conn is None:
+            return None
+
+    version=d.getVar("PF", True)
+    checksum=d.getVar("BB_TASKHASH", True)
+    auto_rev=conn.getPR(version,checksum)
+    bb.debug(1,"prserv_get_pr_auto: version: %s checksum: %s result %d" % (version, checksum, auto_rev))
+    return auto_rev
Signature · 1 line
1.7.0.4
author
#10 lore raw

PATCH 4/5 classes/package_xxx.class: Added PR service support.

In reply to Lianhao Lu

Use PKGV/PKGR to build various package feed in tasks of pacakge_write_xxx.

---
 meta/classes/package_deb.bbclass |    6 +++---
 meta/classes/package_ipk.bbclass |    6 +++---
 meta/classes/package_rpm.bbclass |   10 +++++-----
 meta/classes/package_tar.bbclass |    4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)
meta/classes/package_deb.bbclass +3 -3
index 000d9ee..44e8419 100644
@@ -272,7 +272,7 @@ python do_package_deb () {
         except ValueError:
             pass
         if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1":
-            bb.note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, True), bb.data.getVar('PR', localdata, True)))
+            bb.note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PKGV', localdata, True), bb.data.getVar('PKGR', localdata, True)))
             bb.utils.unlockfile(lf)
             continue
 
@@ -290,9 +290,9 @@ python do_package_deb () {
         fields = []
         pe = bb.data.getVar('PE', d, True)
         if pe and int(pe) > 0:
-            fields.append(["Version: %s:%s-%s\n", ['PE', 'PV', 'PR']])
+            fields.append(["Version: %s:%s-%s\n", ['PE', 'PKGV', 'PKGR']])
         else:
-            fields.append(["Version: %s-%s\n", ['PV', 'PR']])
+            fields.append(["Version: %s-%s\n", ['PKGV', 'PKGR']])
         fields.append(["Description: %s\n", ['DESCRIPTION']])
         fields.append(["Section: %s\n", ['SECTION']])
         fields.append(["Priority: %s\n", ['PRIORITY']])
meta/classes/package_ipk.bbclass +3 -3
index a3dfc73..177be55 100644
@@ -241,7 +241,7 @@ python do_package_ipk () {
 		except ValueError:
 			pass
 		if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1":
-			bb.note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1)))
+			bb.note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PKGV', localdata, 1), bb.data.getVar('PKGR', localdata, 1)))
 			bb.utils.unlockfile(lf)
 			continue
 
@@ -256,9 +256,9 @@ python do_package_ipk () {
 		fields = []
 		pe = bb.data.getVar('PE', d, 1)
 		if pe and int(pe) > 0:
-			fields.append(["Version: %s:%s-%s\n", ['PE', 'PV', 'PR']])
+			fields.append(["Version: %s:%s-%s\n", ['PE', 'PKGV', 'PKGR']])
 		else:
-			fields.append(["Version: %s-%s\n", ['PV', 'PR']])
+			fields.append(["Version: %s-%s\n", ['PKGV', 'PKGR']])
 		fields.append(["Description: %s\n", ['DESCRIPTION']])
 		fields.append(["Section: %s\n", ['SECTION']])
 		fields.append(["Priority: %s\n", ['PRIORITY']])
meta/classes/package_rpm.bbclass +5 -5
index 1d8c686..6bfa877 100644
@@ -330,7 +330,7 @@ python write_specfile () {
 				if dep and ver:
 					if '-' in ver:
 						subd = oe.packagedata.read_subpkgdata_dict(dep, d)
-						pv = subd['PV']
+						pv = subd['PKGV']
 						reppv = pv.replace('-', '+')
 						ver = ver.replace(pv, reppv)
 				newdeps_dict[dep] = ver
@@ -383,8 +383,8 @@ python write_specfile () {
 	# Construct the SPEC file...
 	srcname    = bb.data.getVar('PN', d, True)
 	srcsummary = (bb.data.getVar('SUMMARY', d, True) or bb.data.getVar('DESCRIPTION', d, True) or ".")
-	srcversion = bb.data.getVar('PV', d, True).replace('-', '+')
-	srcrelease = bb.data.getVar('PR', d, True)
+	srcversion = bb.data.getVar('PKGV', d, True).replace('-', '+')
+	srcrelease = bb.data.getVar('PKGR', d, True)
 	srcepoch   = (bb.data.getVar('PE', d, True) or "")
 	srclicense = bb.data.getVar('LICENSE', d, True)
 	srcsection = bb.data.getVar('SECTION', d, True)
@@ -438,8 +438,8 @@ python write_specfile () {
 		splitname    = pkgname
 
 		splitsummary = (bb.data.getVar('SUMMARY', localdata, True) or bb.data.getVar('DESCRIPTION', localdata, True) or ".")
-		splitversion = (bb.data.getVar('PV', localdata, True) or "").replace('-', '+')
-		splitrelease = (bb.data.getVar('PR', localdata, True) or "")
+		splitversion = (bb.data.getVar('PKGV', localdata, True) or "").replace('-', '+')
+		splitrelease = (bb.data.getVar('PKGR', localdata, True) or "")
 		splitepoch   = (bb.data.getVar('PE', localdata, True) or "")
 		splitlicense = (bb.data.getVar('LICENSE', localdata, True) or "")
 		splitsection = (bb.data.getVar('SECTION', localdata, True) or "")
meta/classes/package_tar.bbclass +2 -2
index e546eb7..a806e45 100644
@@ -3,7 +3,7 @@ inherit package
 IMAGE_PKGTYPE ?= "tar"
 
 python package_tar_fn () {
-	fn = os.path.join(bb.data.getVar('DEPLOY_DIR_TAR', d), "%s-%s-%s.tar.gz" % (bb.data.getVar('PKG', d), bb.data.getVar('PV', d), bb.data.getVar('PR', d)))
+	fn = os.path.join(bb.data.getVar('DEPLOY_DIR_TAR', d), "%s-%s-%s.tar.gz" % (bb.data.getVar('PKG', d), bb.data.getVar('PKGV', d), bb.data.getVar('PKGR', d)))
 	fn = bb.data.expand(fn, d)
 	bb.data.setVar('PKGFN', fn, d)
 }
@@ -83,7 +83,7 @@ python do_package_tar () {
 		os.chdir(root)
 		from glob import glob
 		if not glob('*'):
-			bb.note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1)))
+			bb.note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PKGV', localdata, 1), bb.data.getVar('PKGR', localdata, 1)))
 			continue
 		ret = os.system("tar -czf %s %s" % (tarfn, '.'))
 		if ret != 0:
Signature · 1 line
1.7.0.4
author
#11 lore raw

PATCH 5/5 meta-yocto/local.conf.sample: Added PRSERV_HOST and PRSERV_PORT.

In reply to Lianhao Lu

Setting PRSERV_HOST and PRSERV_PORT would trigger the poky to use remote PR network service. Leaving them unset allow the user to build image without the PR network service

---
 meta-yocto/conf/local.conf.sample |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
meta-yocto/conf/local.conf.sample +5 -0
index a9b4998..359e510 100644
@@ -216,3 +216,8 @@ NO32LIBS = "1"
 # GNOME, SCREEN, XTERM and KONSOLE
 #TERMCMD = "${KONSOLE_TERMCMD}"
 #TERMCMDRUN = "${KONSOLE_TERMCMDRUN}"
+
+
+# The network based PR service host and port
+#PRSERV_HOST = "localhost"
+#PRSERV_PORT = "8585"
Signature · 1 line
1.7.0.4
#12 lore raw
In reply to Lianhao Lu

Op 26 mei 2011, om 13:55 heeft Lianhao Lu het volgende geschreven:

Quoted 7 lines

This is a modification of the original patch to enable network based PR service.

The main difference between this series of patch to the original one is that this one uses the PKGR/PKGV during the package feed creation. It also made the PR service disabled by default(by leaving the PRSERV_HOST and PRSERV_PORT commented out) and revised some function names.

Quoted 6 lines

The following features from the previous patch comments are not included in this series:
1) automatically launch PR service in localhost use case.
2) respect OVERIDE to allow setting PRSERV_HOST/PORT per recipe basis
3) write permission control in the PR service.
4) way to sync up local PR database witht the central server.

Does it support going thru HTTP_PROXY like the bitbake fetchers? It's not a must-have, but it would be nice if I can have the internal builds consistent with angstrom upstream.

regards,

Koen

#13 lore raw

Koen Kooi wrote on 2011-05-26:

Quoted 20 lines

Op 26 mei 2011, om 13:55 heeft Lianhao Lu het volgende geschreven:

Quoted 8 lines

This is a modification of the original patch to enable network based PR service.

The main difference between this series of patch to the original one is that this one uses the PKGR/PKGV during the package feed creation. It also made the PR service disabled by default(by leaving the PRSERV_HOST and PRSERV_PORT commented out) and revised some function names.

Quoted 8 lines

The following features from the previous patch comments are not included in this
series:
1) automatically launch PR service in localhost use case.
2) respect OVERIDE to allow setting PRSERV_HOST/PORT per recipe basis
3) write permission control in the PR service.
4) way to sync up local PR database witht the central server.

Quoted 4 lines

Does it support going thru HTTP_PROXY like the bitbake fetchers? It's not a must-have, but it would be nice if I can have the internal builds consistent with angstrom upstream.

It doesn't support now. But I think we can have this by implementing a custom transport, by leverage the urllib2.

Best Regards,
Lianhao