I've developed a rather simplistic method for managing "binary" packages
within OE in order to satisfy certain licensing requirements. I am not
sure whether other users would have an interest in such a system, but
I'll go ahead and pitch what I have working so far to see if there is
any interest in improving it further or merging upstream.

Problem: Some packages we maintain internally are proprietary, and we
need mechanisms for dealing with different licensing schemes.

Approach: Allow third parties to build images using the packages but
without seeing source.

Solution: binary_ipk.bbclass defines a type of package which simply
installs a prebuilt .ipk for use in an image. 

Also, for ease of deployment, I've added a flag to the standard
package_ipk.bbclass which will copy relevant packages into the WORKDIR
for a 'binreleasable' package.

The result is a developer with access to the code builds package FOO out
of the overlay and deploys the WORKDIR/binrelease .ipks onto a mirror.

Another developer without access to the code uses the FOO-bin recipe
which inherits the binary_ipk.bbclass. It pulls the ipk from the mirror
and tells OE about any runtime dependencies of the package.

A simple binary recipe looks like this (I'll just put it inline since
it's so short)

####################EXAMPLE FOO BINARY RECIPE
inherit binary_ipk

DESCRIPTION = "FOO"
HOMEPAGE = ""
LICENSE = "FOO License"
RPROVIDES += "foo"
RDEPENDS += "bar"
BIN_PR = "r21"

SRC_URI = "${FOO_MIRROR}/foo-bin/foo_${PV}-${BIN_PR}_
${PACKAGE_ARCH}.ipk"
############END EXAMPLE


Perhaps there is a smarter way to do this with ipkg feeds, but I saw no
clear route to get here using them.

Thoughts, comments, questions, patches, etc... are all welcomed.



--Chris Conroy





diff --git a/classes/binary_ipk.bbclass b/classes/binary_ipk.bbclass
new file mode 100644
index 0000000..8cb1eb3
--- /dev/null
+++ b/classes/binary_ipk.bbclass
@@ -0,0 +1,56 @@
+### A class for installing prebuilt packages
+
+inherit package_ipk
+
+PACKAGES="${PN}"
+
+do_configure() {
+    :
+}
+do_compile() {
+    :
+}
+do_stage() {
+    :
+}
+do_install() {
+    :
+}
+do_populate_staging() {
+    :
+}
+do_install() {
+    :
+}
+
+python do_package_ipk() {
+    import sys, bb, os, re, glob
+
+    outdir = bb.data.getVar('DEPLOY_DIR_IPK', d, 1)
+    if not outdir:
+        bb.error("DEPLOY_DIR_IPK not defined, unable to package")
+        return
+
+    tmpdir = bb.data.getVar('TMPDIR', d, 1)
+    if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
+        os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
+
+
+    path = bb.data.getVar('PATH', d, 1)
+    workdir = bb.data.getVar('WORKDIR', d, 1)
+    packages = glob.glob("%s/*.ipk" % (workdir))
+
+    for pkg in packages:
+        ipkgPipe = os.popen("PATH=%s ipkg-list-fields %s | grep \"Architecture\" | cut -d \' \' -sf2" % (path, pkg))
+        arch = ipkgPipe.readline()
+        bb.debug(1, "PKG %s, ARCH %s" % (pkg, arch))
+        ipkgPipe.close()
+        if arch == '' or arch == None:
+            bb.fatal("Unable to read architecture from %s" % (pkg))
+
+        pkgoutdir = "%s/%s" % (outdir, arch)
+
+        bb.note("Installing %s into %s" % (pkg, pkgoutdir))
+        os.system("cp %s %s" % (pkg, pkgoutdir))
+}
+
diff --git a/classes/package_ipk.bbclass b/classes/package_ipk.bbclass
index e556108..853da21 100644
--- a/classes/package_ipk.bbclass
+++ b/classes/package_ipk.bbclass
@@ -302,6 +302,21 @@ python do_package_ipk () {
 			bb.utils.unlockfile(lf)
 			raise bb.build.FuncFailed("ipkg-build execution failed")
 
+		#for binary packaging, a release package will also install into its WORKDIR
+		binrelease = bb.data.getVar("BINRELEASE", d, 1)
+		if binrelease == '1':
+			bindir = "%s/binrelease" % (workdir)
+			bb.mkdirhier(bindir)
+			ret = os.system("PATH=\"%s\" %s %s %s" % (bb.data.getVar("PATH", localdata, 1), bb.data.getVar("IPKGBUILDCMD",d,1), pkg, bindir))
+
+			#Don't binrelease dbg/dev/doc packages
+			todelPkgs = glob("%s/*-dbg*.ipk" % (bindir))
+			todelPkgs.extend(glob("%s/*-dev*.ipk" % (bindir)))
+			todelPkgs.extend(glob("%s/*-doc*.ipk" % (bindir)))
+			for todel in todelPkgs:
+				bb.debug(1, "Uninstalling %s for binrelease" % (todel))
+				os.system("rm -f %s" % (todel))
+
 		bb.utils.prunedir(controldir)
 		bb.utils.unlockfile(lf)
 }
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Reply via email to