All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage
@ 2010-10-23 13:45 Koen Kooi
  2010-10-23 17:03 ` Chris Larson
  2010-10-25 23:00 ` Khem Raj
  0 siblings, 2 replies; 7+ messages in thread
From: Koen Kooi @ 2010-10-23 13:45 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Koen Kooi

From: Koen Kooi <k-kooi@ti.com>

Signed-off-by: Koen Kooi <k-kooi@ti.com>

---
 classes/module.bbclass |  191 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 186 insertions(+), 5 deletions(-)

diff --git a/classes/module.bbclass b/classes/module.bbclass
index e41dd6e..7d53d2d 100644
--- a/classes/module.bbclass
+++ b/classes/module.bbclass
@@ -24,19 +24,200 @@ module_do_install() {
 	oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" ${MODULE_MAKE_FLAGS} modules_install
 }
 
-pkg_postinst_append () {
+python populate_packages_prepend () {
+	import os
+	def extract_modinfo(file):
+		import tempfile, re
+		tempfile.tempdir = bb.data.getVar("WORKDIR", d, 1)
+		tf = tempfile.mkstemp()
+		tmpfile = tf[1]
+		cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (bb.data.getVar("PATH", d, 1), bb.data.getVar("HOST_PREFIX", d, 1) or "", file, tmpfile)
+		os.system(cmd)
+		f = open(tmpfile)
+		l = f.read().split("\000")
+		f.close()
+		os.close(tf[0])
+		os.unlink(tmpfile)
+		exp = re.compile("([^=]+)=(.*)")
+		vals = {}
+		for i in l:
+			m = exp.match(i)
+			if not m:
+				continue
+			vals[m.group(1)] = m.group(2)
+		return vals
+	
+	def parse_depmod():
+		import re
+
+		dvar = bb.data.getVar('PKGD', d, 1)
+		if not dvar:
+			bb.error("PKGD not defined")
+			return
+
+		kernelver = bb.data.getVar('KERNEL_VERSION', d, 1)
+		kerneldir = bb.data.getVar('STAGING_KERNEL_DIR', d, 1)
+		kernelver_stripped = kernelver
+		m = re.match('^(.*-hh.*)[\.\+].*$', kernelver)
+		if m:
+			kernelver_stripped = m.group(1)
+		path = bb.data.getVar("PATH", d, 1)
+		host_prefix = bb.data.getVar("HOST_PREFIX", d, 1) or ""
+		major_version = bb.data.getVar('KERNEL_MAJOR_VERSION', d, 1)
+
+		cmd = "PATH=\"%s\" %sdepmod-%s -n -a -r -b %s -F %s/System.map-%s %s" % (path, host_prefix, major_version, dvar, kerneldir, kernelver, kernelver_stripped)
+		f = os.popen(cmd, 'r')
+
+		deps = {}
+		pattern0 = "^(.*\.k?o):..*$"
+		pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
+		pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
+		pattern3 = "^\t(.*\.k?o)\s*\\\$"
+		pattern4 = "^\t(.*\.k?o)\s*$"
+
+		line = f.readline()
+		while line:
+			if not re.match(pattern0, line):
+				line = f.readline()
+				continue
+			m1 = re.match(pattern1, line)
+			if m1:
+				deps[m1.group(1)] = m1.group(2).split()
+			else:
+				m2 = re.match(pattern2, line)
+				if m2:
+					deps[m2.group(1)] = m2.group(2).split()
+					line = f.readline()
+					m3 = re.match(pattern3, line)
+					while m3:
+						deps[m2.group(1)].extend(m3.group(1).split())
+						line = f.readline()
+						m3 = re.match(pattern3, line)
+					m4 = re.match(pattern4, line)
+					deps[m2.group(1)].extend(m4.group(1).split())
+			line = f.readline()
+		f.close()
+		return deps
+	
+	def get_dependencies(file, pattern, format):
+		file = file.replace(bb.data.getVar('PKGD', d, 1) or '', '', 1)
+
+		if module_deps.has_key(file):
+			import re
+			dependencies = []
+			for i in module_deps[file]:
+				m = re.match(pattern, os.path.basename(i))
+				if not m:
+					continue
+				on = legitimize_package_name(m.group(1))
+				dependency_pkg = format % on
+				dependencies.append(dependency_pkg)
+			return dependencies
+		return []
+
+	def frob_metadata(file, pkg, pattern, format, basename):
+		import re
+		vals = extract_modinfo(file)
+
+		dvar = bb.data.getVar('PKGD', d, 1)
+
+		# If autoloading is requested, output /etc/modutils/<name> and append
+		# appropriate modprobe commands to the postinst
+		autoload = bb.data.getVar('module_autoload_%s' % basename, d, 1)
+		if not autoload:
+		    # Also, try canonical name with dashes
+		    autoload = bb.data.getVar('module_autoload_%s' % basename.replace('_', '-'), d, 1)
+		if autoload:
+			name = '%s/etc/modutils/%s' % (dvar, basename)
+			f = open(name, 'w')
+			for m in autoload.split():
+				f.write('%s\n' % m)
+			f.close()
+			postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1)
+			if not postinst:
+				bb.fatal("pkg_postinst_%s not defined" % pkg)
+			postinst += bb.data.getVar('autoload_postinst_fragment', d, 1) % autoload
+			bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
+
+		# Write out any modconf fragment
+		modconf = bb.data.getVar('module_conf_%s' % basename, d, 1)
+		if modconf:
+			if bb.data.getVar("KERNEL_MAJOR_VERSION", d, 1) == "2.6":
+				name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
+			else:
+				name = '%s/etc/modutils/%s.conf' % (dvar, basename)
+			f = open(name, 'w')
+			f.write("%s\n" % modconf)
+			f.close()
+
+		files = bb.data.getVar('FILES_%s' % pkg, d, 1)
+		files = "%s /etc/modutils/%s /etc/modutils/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename, basename)
+		bb.data.setVar('FILES_%s' % pkg, files, d)
+
+		if vals.has_key("description"):
+			old_desc = bb.data.getVar('DESCRIPTION_' + pkg, d, 1) or ""
+			bb.data.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"], d)
+
+		rdepends_str = bb.data.getVar('RDEPENDS_' + pkg, d, 1)
+		if rdepends_str:
+			rdepends = rdepends_str.split()
+		else:
+			rdepends = []
+		rdepends.extend(get_dependencies(file, pattern, format))
+		bb.data.setVar('RDEPENDS_' + pkg, ' '.join(rdepends), d)
+
+	module_deps = parse_depmod()
+	module_regex = '^(.*)\.k?o$'
+	module_pattern = 'kernel-module-%s'
+
+	postinst = bb.data.getVar('pkg_postinst_modules', d, 1)
+	postrm = bb.data.getVar('pkg_postrm_modules', d, 1)
+
+        maybe_update_modules = "update-modules "
+        if bb.data.getVar("ONLINE_PACKAGE_MANAGEMENT", d) == "none":
+                maybe_update_modules = ""
+	
+	do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+	do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
+	do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%skernel-%s' % (maybe_update_modules, bb.data.getVar("KERNEL_VERSION", d, 1)))
+
+	import re
+	metapkg = bb.data.getVar("PN", d, 1)
+	bb.data.setVar('ALLOW_EMPTY_' + metapkg, "1", d)
+	bb.data.setVar('FILES_' + metapkg, "", d)
+	blacklist = [ metapkg, metapkg + '-doc', metapkg + '-dev', metapkg + '-dbg', metapkg + '-locale', metapkg + '-static' ]
+	depchains = (d.getVar("DEPCHAIN_POST", True) or "").split()
+	for l in module_deps.values():
+		for i in l:
+			pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1))
+			blacklist.append(pkg)
+	metapkg_rrecommends = []
+	packages = bb.data.getVar('PACKAGES', d, 1).split()
+	for pkg in packages[1:]:
+		if not pkg in blacklist and not pkg in metapkg_rrecommends and not any(pkg.endswith(post) for post in depchains):
+			metapkg_rrecommends.append(pkg)
+	bb.data.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rrecommends), d)
+	bb.data.setVar('DESCRIPTION_' + metapkg, metapkg + ' modules meta package', d)
+}
+
+pkg_postinst_modules () {
 if [ -n "$D" ]; then
-	exit 1
+	${HOST_PREFIX}depmod-${KERNEL_MAJOR_VERSION} -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
 else
 	depmod -a ${KERNEL_VERSION}
 	update-modules || true
 fi
 }
 
-pkg_postrm_append () {
-	update-modules || true
+pkg_postrm_modules () {
+update-modules || true
+}
+
+autoload_postinst_fragment() {
+if [ x"$D" = "x" ]; then
+	modprobe %s || true
+fi
 }
 
 EXPORT_FUNCTIONS do_compile do_install
 
-FILES_${PN} = "/etc /lib/modules"
-- 
1.6.6.1




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage
  2010-10-23 13:45 [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage Koen Kooi
@ 2010-10-23 17:03 ` Chris Larson
  2010-10-23 18:15   ` Koen Kooi
  2010-11-02 12:38   ` Koen Kooi
  2010-10-25 23:00 ` Khem Raj
  1 sibling, 2 replies; 7+ messages in thread
From: Chris Larson @ 2010-10-23 17:03 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Koen Kooi

On Sat, Oct 23, 2010 at 6:45 AM, Koen Kooi <koen.kooi@gmail.com> wrote:

> From: Koen Kooi <k-kooi@ti.com>
>
> Signed-off-by: Koen Kooi <k-kooi@ti.com>
>
> ---
>  classes/module.bbclass |  191
> ++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 186 insertions(+), 5 deletions(-)
>


How about moving the common functions into oe.module or oe.package and using
them from module.bbclass and kernel.bbclass?
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage
  2010-10-23 17:03 ` Chris Larson
@ 2010-10-23 18:15   ` Koen Kooi
  2010-10-23 19:15     ` Chris Larson
  2010-11-02 12:38   ` Koen Kooi
  1 sibling, 1 reply; 7+ messages in thread
From: Koen Kooi @ 2010-10-23 18:15 UTC (permalink / raw)
  To: openembedded-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 23-10-10 19:03, Chris Larson wrote:
> On Sat, Oct 23, 2010 at 6:45 AM, Koen Kooi <koen.kooi@gmail.com> wrote:
> 
>> From: Koen Kooi <k-kooi@ti.com>
>>
>> Signed-off-by: Koen Kooi <k-kooi@ti.com>
>>
>> ---
>>  classes/module.bbclass |  191
>> ++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 files changed, 186 insertions(+), 5 deletions(-)
>>
> 
> 
> How about moving the common functions into oe.module or oe.package and using
> them from module.bbclass and kernel.bbclass?

I thought about that, but that needs more work :( We need to pass in a
different path to System.map, use PN as metapackage name, use a
different blacklist, etc.
That requires a lot more python skill than I currently have.

Apart from the horrendous code duplication, how does this look? It seems
to do the right thing for the recipes I tested with :)

regards,

Koen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFMwyY2MkyGM64RGpERAvl7AJ9vvDrrfJoJv2uWbBYFNMtmUSQBlQCgqyU/
g7/rxYKqcNnGn5ar1d+mFSY=
=9tBi
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage
  2010-10-23 18:15   ` Koen Kooi
@ 2010-10-23 19:15     ` Chris Larson
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Larson @ 2010-10-23 19:15 UTC (permalink / raw)
  To: openembedded-devel

On Sat, Oct 23, 2010 at 11:15 AM, Koen Kooi <k.kooi@student.utwente.nl>wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 23-10-10 19:03, Chris Larson wrote:
> > On Sat, Oct 23, 2010 at 6:45 AM, Koen Kooi <koen.kooi@gmail.com> wrote:
> >
> >> From: Koen Kooi <k-kooi@ti.com>
> >>
> >> Signed-off-by: Koen Kooi <k-kooi@ti.com>
> >>
> >> ---
> >>  classes/module.bbclass |  191
> >> ++++++++++++++++++++++++++++++++++++++++++++++-
> >>  1 files changed, 186 insertions(+), 5 deletions(-)
> >>
> >
> >
> > How about moving the common functions into oe.module or oe.package and
> using
> > them from module.bbclass and kernel.bbclass?
>
> I thought about that, but that needs more work :( We need to pass in a
> different path to System.map, use PN as metapackage name, use a
> different blacklist, etc.
> That requires a lot more python skill than I currently have.
>
> Apart from the horrendous code duplication, how does this look? It seems
> to do the right thing for the recipes I tested with :)
>

Looks reasonable otherwise, can always consolidate in a second pass later
on.

Acked-by: Chris Larson <chris_larson@mentor.com>
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage
  2010-10-23 13:45 [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage Koen Kooi
  2010-10-23 17:03 ` Chris Larson
@ 2010-10-25 23:00 ` Khem Raj
  2010-10-25 23:13   ` Chris Larson
  1 sibling, 1 reply; 7+ messages in thread
From: Khem Raj @ 2010-10-25 23:00 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Koen Kooi

On Sat, Oct 23, 2010 at 6:45 AM, Koen Kooi <koen.kooi@gmail.com> wrote:
> From: Koen Kooi <k-kooi@ti.com>
>
> Signed-off-by: Koen Kooi <k-kooi@ti.com>
>
> ---
>  classes/module.bbclass |  191 ++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 186 insertions(+), 5 deletions(-)
>
> diff --git a/classes/module.bbclass b/classes/module.bbclass
> index e41dd6e..7d53d2d 100644
> --- a/classes/module.bbclass
> +++ b/classes/module.bbclass
> @@ -24,19 +24,200 @@ module_do_install() {
>        oe_runmake DEPMOD=echo INSTALL_MOD_PATH="${D}" ${MODULE_MAKE_FLAGS} modules_install
>  }
>
> -pkg_postinst_append () {
> +python populate_packages_prepend () {
> +       import os
> +       def extract_modinfo(file):
> +               import tempfile, re
> +               tempfile.tempdir = bb.data.getVar("WORKDIR", d, 1)
> +               tf = tempfile.mkstemp()
> +               tmpfile = tf[1]
> +               cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (bb.data.getVar("PATH", d, 1), bb.data.getVar("HOST_PREFIX", d, 1) or "", file, tmpfile)
> +               os.system(cmd)


may be we can get rid of os.system and use subprocess popen or something

> +               f = open(tmpfile)
> +               l = f.read().split("\000")
> +               f.close()
> +               os.close(tf[0])
> +               os.unlink(tmpfile)
> +               exp = re.compile("([^=]+)=(.*)")
> +               vals = {}
> +               for i in l:
> +                       m = exp.match(i)
> +                       if not m:
> +                               continue
> +                       vals[m.group(1)] = m.group(2)
> +               return vals
> +
> +       def parse_depmod():
> +               import re
> +
> +               dvar = bb.data.getVar('PKGD', d, 1)
> +               if not dvar:
> +                       bb.error("PKGD not defined")
> +                       return
> +
> +               kernelver = bb.data.getVar('KERNEL_VERSION', d, 1)
> +               kerneldir = bb.data.getVar('STAGING_KERNEL_DIR', d, 1)
> +               kernelver_stripped = kernelver
> +               m = re.match('^(.*-hh.*)[\.\+].*$', kernelver)
> +               if m:
> +                       kernelver_stripped = m.group(1)
> +               path = bb.data.getVar("PATH", d, 1)
> +               host_prefix = bb.data.getVar("HOST_PREFIX", d, 1) or ""
> +               major_version = bb.data.getVar('KERNEL_MAJOR_VERSION', d, 1)
> +
> +               cmd = "PATH=\"%s\" %sdepmod-%s -n -a -r -b %s -F %s/System.map-%s %s" % (path, host_prefix, major_version, dvar, kerneldir, kernelver, kernelver_stripped)
> +               f = os.popen(cmd, 'r')
> +
> +               deps = {}
> +               pattern0 = "^(.*\.k?o):..*$"
> +               pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
> +               pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
> +               pattern3 = "^\t(.*\.k?o)\s*\\\$"
> +               pattern4 = "^\t(.*\.k?o)\s*$"
> +
> +               line = f.readline()
> +               while line:
> +                       if not re.match(pattern0, line):
> +                               line = f.readline()
> +                               continue
> +                       m1 = re.match(pattern1, line)
> +                       if m1:
> +                               deps[m1.group(1)] = m1.group(2).split()
> +                       else:
> +                               m2 = re.match(pattern2, line)
> +                               if m2:
> +                                       deps[m2.group(1)] = m2.group(2).split()
> +                                       line = f.readline()
> +                                       m3 = re.match(pattern3, line)
> +                                       while m3:
> +                                               deps[m2.group(1)].extend(m3.group(1).split())
> +                                               line = f.readline()
> +                                               m3 = re.match(pattern3, line)
> +                                       m4 = re.match(pattern4, line)
> +                                       deps[m2.group(1)].extend(m4.group(1).split())
> +                       line = f.readline()
> +               f.close()
> +               return deps
> +
> +       def get_dependencies(file, pattern, format):
> +               file = file.replace(bb.data.getVar('PKGD', d, 1) or '', '', 1)
> +
> +               if module_deps.has_key(file):
> +                       import re
> +                       dependencies = []
> +                       for i in module_deps[file]:
> +                               m = re.match(pattern, os.path.basename(i))
> +                               if not m:
> +                                       continue
> +                               on = legitimize_package_name(m.group(1))
> +                               dependency_pkg = format % on
> +                               dependencies.append(dependency_pkg)
> +                       return dependencies
> +               return []
> +
> +       def frob_metadata(file, pkg, pattern, format, basename):
> +               import re
> +               vals = extract_modinfo(file)
> +
> +               dvar = bb.data.getVar('PKGD', d, 1)
> +
> +               # If autoloading is requested, output /etc/modutils/<name> and append
> +               # appropriate modprobe commands to the postinst
> +               autoload = bb.data.getVar('module_autoload_%s' % basename, d, 1)
> +               if not autoload:
> +                   # Also, try canonical name with dashes
> +                   autoload = bb.data.getVar('module_autoload_%s' % basename.replace('_', '-'), d, 1)
> +               if autoload:
> +                       name = '%s/etc/modutils/%s' % (dvar, basename)
> +                       f = open(name, 'w')
> +                       for m in autoload.split():
> +                               f.write('%s\n' % m)
> +                       f.close()
> +                       postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1)
> +                       if not postinst:
> +                               bb.fatal("pkg_postinst_%s not defined" % pkg)
> +                       postinst += bb.data.getVar('autoload_postinst_fragment', d, 1) % autoload
> +                       bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
> +
> +               # Write out any modconf fragment
> +               modconf = bb.data.getVar('module_conf_%s' % basename, d, 1)
> +               if modconf:
> +                       if bb.data.getVar("KERNEL_MAJOR_VERSION", d, 1) == "2.6":
> +                               name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
> +                       else:
> +                               name = '%s/etc/modutils/%s.conf' % (dvar, basename)
> +                       f = open(name, 'w')
> +                       f.write("%s\n" % modconf)
> +                       f.close()
> +
> +               files = bb.data.getVar('FILES_%s' % pkg, d, 1)
> +               files = "%s /etc/modutils/%s /etc/modutils/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename, basename)
> +               bb.data.setVar('FILES_%s' % pkg, files, d)
> +
> +               if vals.has_key("description"):
> +                       old_desc = bb.data.getVar('DESCRIPTION_' + pkg, d, 1) or ""
> +                       bb.data.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"], d)
> +
> +               rdepends_str = bb.data.getVar('RDEPENDS_' + pkg, d, 1)
> +               if rdepends_str:
> +                       rdepends = rdepends_str.split()
> +               else:
> +                       rdepends = []
> +               rdepends.extend(get_dependencies(file, pattern, format))
> +               bb.data.setVar('RDEPENDS_' + pkg, ' '.join(rdepends), d)
> +
> +       module_deps = parse_depmod()
> +       module_regex = '^(.*)\.k?o$'
> +       module_pattern = 'kernel-module-%s'
> +
> +       postinst = bb.data.getVar('pkg_postinst_modules', d, 1)
> +       postrm = bb.data.getVar('pkg_postrm_modules', d, 1)
> +
> +        maybe_update_modules = "update-modules "
> +        if bb.data.getVar("ONLINE_PACKAGE_MANAGEMENT", d) == "none":
> +                maybe_update_modules = ""
> +
> +       do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
> +       do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
> +       do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%skernel-%s' % (maybe_update_modules, bb.data.getVar("KERNEL_VERSION", d, 1)))
> +
> +       import re
> +       metapkg = bb.data.getVar("PN", d, 1)
> +       bb.data.setVar('ALLOW_EMPTY_' + metapkg, "1", d)
> +       bb.data.setVar('FILES_' + metapkg, "", d)
> +       blacklist = [ metapkg, metapkg + '-doc', metapkg + '-dev', metapkg + '-dbg', metapkg + '-locale', metapkg + '-static' ]
> +       depchains = (d.getVar("DEPCHAIN_POST", True) or "").split()
> +       for l in module_deps.values():
> +               for i in l:
> +                       pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1))
> +                       blacklist.append(pkg)
> +       metapkg_rrecommends = []
> +       packages = bb.data.getVar('PACKAGES', d, 1).split()
> +       for pkg in packages[1:]:
> +               if not pkg in blacklist and not pkg in metapkg_rrecommends and not any(pkg.endswith(post) for post in depchains):
> +                       metapkg_rrecommends.append(pkg)
> +       bb.data.setVar('RRECOMMENDS_' + metapkg, ' '.join(metapkg_rrecommends), d)
> +       bb.data.setVar('DESCRIPTION_' + metapkg, metapkg + ' modules meta package', d)
> +}
> +
> +pkg_postinst_modules () {
>  if [ -n "$D" ]; then
> -       exit 1
> +       ${HOST_PREFIX}depmod-${KERNEL_MAJOR_VERSION} -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>  else
>        depmod -a ${KERNEL_VERSION}
>        update-modules || true
>  fi
>  }
>
> -pkg_postrm_append () {
> -       update-modules || true
> +pkg_postrm_modules () {
> +update-modules || true
> +}
> +
> +autoload_postinst_fragment() {
> +if [ x"$D" = "x" ]; then
> +       modprobe %s || true
> +fi
>  }
>
>  EXPORT_FUNCTIONS do_compile do_install
>
> -FILES_${PN} = "/etc /lib/modules"
> --
> 1.6.6.1
>
>
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage
  2010-10-25 23:00 ` Khem Raj
@ 2010-10-25 23:13   ` Chris Larson
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Larson @ 2010-10-25 23:13 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Koen Kooi

On Mon, Oct 25, 2010 at 4:00 PM, Khem Raj <raj.khem@gmail.com> wrote:

> > +               cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s"
> % (bb.data.getVar("PATH", d, 1), bb.data.getVar("HOST_PREFIX", d, 1) or "",
> file, tmpfile)
> > +               os.system(cmd)
>
>
> may be we can get rid of os.system and use subprocess popen or something


We have convenience wrappers around subprocess both in utils.bbclass and in
oe.process -- probably easiest to use one of those.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage
  2010-10-23 17:03 ` Chris Larson
  2010-10-23 18:15   ` Koen Kooi
@ 2010-11-02 12:38   ` Koen Kooi
  1 sibling, 0 replies; 7+ messages in thread
From: Koen Kooi @ 2010-11-02 12:38 UTC (permalink / raw)
  To: openembedded-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ping on the patch?

On 23-10-10 20:15, Koen Kooi wrote:
> On 23-10-10 19:03, Chris Larson wrote:
>> On Sat, Oct 23, 2010 at 6:45 AM, Koen Kooi <koen.kooi@gmail.com> wrote:
> 
>>> From: Koen Kooi <k-kooi@ti.com>
>>>
>>> Signed-off-by: Koen Kooi <k-kooi@ti.com>
>>>
>>> ---
>>>  classes/module.bbclass |  191
>>> ++++++++++++++++++++++++++++++++++++++++++++++-
>>>  1 files changed, 186 insertions(+), 5 deletions(-)
>>>
> 
> 
>> How about moving the common functions into oe.module or oe.package and using
>> them from module.bbclass and kernel.bbclass?
> 
> I thought about that, but that needs more work :( We need to pass in a
> different path to System.map, use PN as metapackage name, use a
> different blacklist, etc.
> That requires a lot more python skill than I currently have.
> 
> Apart from the horrendous code duplication, how does this look? It seems
> to do the right thing for the recipes I tested with :)
> 
> regards,
> 
> Koen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFM0AY1MkyGM64RGpERAiiyAJ943e16oJx5KQDr6qpidHbsLPEONwCfYKx1
pgEjHF82FwDETI6pPt94BcA=
=lO75
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-11-02 12:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-23 13:45 [RFC][PATCH] module bbclass: split each module into a kernel-module-<foo> subpackage and use PN as metapackage Koen Kooi
2010-10-23 17:03 ` Chris Larson
2010-10-23 18:15   ` Koen Kooi
2010-10-23 19:15     ` Chris Larson
2010-11-02 12:38   ` Koen Kooi
2010-10-25 23:00 ` Khem Raj
2010-10-25 23:13   ` Chris Larson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.