diff options
| -rw-r--r-- | meta/classes-recipe/kernel-module-split.bbclass | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/meta/classes-recipe/kernel-module-split.bbclass b/meta/classes-recipe/kernel-module-split.bbclass index a2d81f18e2..75ed696b72 100644 --- a/meta/classes-recipe/kernel-module-split.bbclass +++ b/meta/classes-recipe/kernel-module-split.bbclass | |||
| @@ -86,11 +86,7 @@ python split_kernel_module_packages () { | |||
| 86 | vals[m.group(1)] = m.group(2) | 86 | vals[m.group(1)] = m.group(2) |
| 87 | return vals | 87 | return vals |
| 88 | 88 | ||
| 89 | def frob_metadata(file, pkg, pattern, format, basename): | 89 | def handle_conf_files(d, basename, pkg): |
| 90 | vals = extract_modinfo(file) | ||
| 91 | |||
| 92 | dvar = d.getVar('PKGD') | ||
| 93 | |||
| 94 | # If autoloading is requested, output ${modulesloaddir}/<name>.conf and append | 90 | # If autoloading is requested, output ${modulesloaddir}/<name>.conf and append |
| 95 | # appropriate modprobe commands to the postinst | 91 | # appropriate modprobe commands to the postinst |
| 96 | autoloadlist = (d.getVar("KERNEL_MODULE_AUTOLOAD") or "").split() | 92 | autoloadlist = (d.getVar("KERNEL_MODULE_AUTOLOAD") or "").split() |
| @@ -102,7 +98,7 @@ python split_kernel_module_packages () { | |||
| 102 | 98 | ||
| 103 | # The .conf file can either be installed by a recipe or generated from module_autoload_* | 99 | # The .conf file can either be installed by a recipe or generated from module_autoload_* |
| 104 | conf = '%s/%s.conf' % (d.getVar('modulesloaddir'), basename) | 100 | conf = '%s/%s.conf' % (d.getVar('modulesloaddir'), basename) |
| 105 | name = '%s%s' % (dvar, conf) | 101 | name = '%s%s' % (d.getVar('PKGD'), conf) |
| 106 | # If module name is in KERNEL_MODULE_AUTOLOAD, then generate the .conf file and write to `name`. | 102 | # If module name is in KERNEL_MODULE_AUTOLOAD, then generate the .conf file and write to `name`. |
| 107 | if basename in autoloadlist: | 103 | if basename in autoloadlist: |
| 108 | os.makedirs(os.path.dirname(name), exist_ok=True) | 104 | os.makedirs(os.path.dirname(name), exist_ok=True) |
| @@ -120,7 +116,7 @@ python split_kernel_module_packages () { | |||
| 120 | d.appendVar('CONFFILES:%s' % pkg, conf2append) | 116 | d.appendVar('CONFFILES:%s' % pkg, conf2append) |
| 121 | postinst = d.getVar('pkg_postinst:%s' % pkg) | 117 | postinst = d.getVar('pkg_postinst:%s' % pkg) |
| 122 | if not postinst: | 118 | if not postinst: |
| 123 | bb.fatal("pkg_postinst:%s not defined" % pkg) | 119 | postinst = d.getVar('pkg_postinst:modules') |
| 124 | postinst += d.getVar('autoload_postinst_fragment') % (autoload or basename) | 120 | postinst += d.getVar('autoload_postinst_fragment') % (autoload or basename) |
| 125 | d.setVar('pkg_postinst:%s' % pkg, postinst) | 121 | d.setVar('pkg_postinst:%s' % pkg, postinst) |
| 126 | 122 | ||
| @@ -130,7 +126,7 @@ python split_kernel_module_packages () { | |||
| 130 | 126 | ||
| 131 | # The .conf file can either be installed by a recipe or generated from module_conf_* | 127 | # The .conf file can either be installed by a recipe or generated from module_conf_* |
| 132 | conf = '%s/%s.conf' % (d.getVar('modprobedir'), basename) | 128 | conf = '%s/%s.conf' % (d.getVar('modprobedir'), basename) |
| 133 | name = '%s%s' % (dvar, conf) | 129 | name = '%s%s' % (d.getVar('PKGD'), conf) |
| 134 | # If module name is in KERNEL_MODULE_PROBECONF, then generate the .conf file and write to `name`. | 130 | # If module name is in KERNEL_MODULE_PROBECONF, then generate the .conf file and write to `name`. |
| 135 | if modconf and basename in modconflist: | 131 | if modconf and basename in modconflist: |
| 136 | os.makedirs(os.path.dirname(name), exist_ok=True) | 132 | os.makedirs(os.path.dirname(name), exist_ok=True) |
| @@ -145,6 +141,55 @@ python split_kernel_module_packages () { | |||
| 145 | d.appendVar('FILES:%s' % pkg, conf2append) | 141 | d.appendVar('FILES:%s' % pkg, conf2append) |
| 146 | d.appendVar('CONFFILES:%s' % pkg, conf2append) | 142 | d.appendVar('CONFFILES:%s' % pkg, conf2append) |
| 147 | 143 | ||
| 144 | def generate_conf_files(d, root, file_regex, output_pattern): | ||
| 145 | """ | ||
| 146 | Arguments: | ||
| 147 | root -- the path in which to search. Contains system lib path | ||
| 148 | so needs expansion. | ||
| 149 | file_regex -- regular expression to match searched files. Use | ||
| 150 | parentheses () to mark the part of this expression | ||
| 151 | that should be used to derive the module name (to be | ||
| 152 | substituted where %s is used in other function | ||
| 153 | arguments as noted below) | ||
| 154 | output_pattern -- pattern to use for the package names. Must include %s. | ||
| 155 | """ | ||
| 156 | import re, stat | ||
| 157 | |||
| 158 | dvar = d.getVar('PKGD') | ||
| 159 | root = d.expand(root) | ||
| 160 | |||
| 161 | # if the root directory doesn't exist, it's fatal - exit from the current execution. | ||
| 162 | if not os.path.exists(dvar + root): | ||
| 163 | bb.fatal("kernel module root directory path does not exist") | ||
| 164 | |||
| 165 | # walk through kernel module directory. for each entry in the directory, check if it | ||
| 166 | # matches the desired regex pattern and file type. if it fullfills, process it to generate | ||
| 167 | # it's conf file based on its package name. | ||
| 168 | for walkroot, dirs, files in os.walk(dvar + root): | ||
| 169 | for file in files: | ||
| 170 | relpath = os.path.join(walkroot, file).replace(dvar + root + '/', '', 1) | ||
| 171 | if not relpath: | ||
| 172 | continue | ||
| 173 | m = re.match(file_regex, os.path.basename(relpath)) | ||
| 174 | if not m: | ||
| 175 | continue | ||
| 176 | file_f = os.path.join(dvar + root, relpath) | ||
| 177 | mode = os.lstat(file_f).st_mode | ||
| 178 | if not (stat.S_ISREG(mode) or (allow_links and stat.S_ISLNK(mode)) or (allow_dirs and stat.S_ISDIR(mode))): | ||
| 179 | continue | ||
| 180 | |||
| 181 | basename = m.group(1) | ||
| 182 | on = legitimize_package_name(basename) | ||
| 183 | pkg = output_pattern % on | ||
| 184 | handle_conf_files(d, basename, pkg) | ||
| 185 | |||
| 186 | |||
| 187 | def frob_metadata(file, pkg, pattern, format, basename): | ||
| 188 | vals = extract_modinfo(file) | ||
| 189 | dvar = d.getVar('PKGD') | ||
| 190 | |||
| 191 | handle_conf_files(d, basename, pkg) | ||
| 192 | |||
| 148 | if "description" in vals: | 193 | if "description" in vals: |
| 149 | old_desc = d.getVar('DESCRIPTION:' + pkg) or "" | 194 | old_desc = d.getVar('DESCRIPTION:' + pkg) or "" |
| 150 | d.setVar('DESCRIPTION:' + pkg, old_desc + "; " + vals["description"]) | 195 | d.setVar('DESCRIPTION:' + pkg, old_desc + "; " + vals["description"]) |
| @@ -178,19 +223,20 @@ python split_kernel_module_packages () { | |||
| 178 | postinst = d.getVar('pkg_postinst:modules') | 223 | postinst = d.getVar('pkg_postinst:modules') |
| 179 | postrm = d.getVar('pkg_postrm:modules') | 224 | postrm = d.getVar('pkg_postrm:modules') |
| 180 | 225 | ||
| 181 | if splitmods != '1': | ||
| 182 | d.appendVar('FILES:' + metapkg, '%s %s %s/modules' % | ||
| 183 | (d.getVar('modulesloaddir'), d.getVar('modprobedir'), d.getVar("nonarch_base_libdir"))) | ||
| 184 | d.appendVar('pkg_postinst:%s' % metapkg, postinst) | ||
| 185 | d.prependVar('pkg_postrm:%s' % metapkg, postrm); | ||
| 186 | return | ||
| 187 | |||
| 188 | module_regex = r'^(.*)\.k?o(?:\.(gz|xz|zst))?$' | 226 | module_regex = r'^(.*)\.k?o(?:\.(gz|xz|zst))?$' |
| 189 | 227 | ||
| 190 | module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX') | 228 | module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX') |
| 191 | module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX') | 229 | module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX') |
| 192 | module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix | 230 | module_pattern = module_pattern_prefix + kernel_package_name + '-module-%s' + module_pattern_suffix |
| 193 | 231 | ||
| 232 | if splitmods != '1': | ||
| 233 | d.appendVar('FILES:' + metapkg, '%s %s %s/modules' % | ||
| 234 | (d.getVar('modulesloaddir'), d.getVar('modprobedir'), d.getVar("nonarch_base_libdir"))) | ||
| 235 | d.appendVar('pkg_postinst:%s' % metapkg, postinst) | ||
| 236 | d.prependVar('pkg_postrm:%s' % metapkg, postrm) | ||
| 237 | generate_conf_files(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern) | ||
| 238 | return | ||
| 239 | |||
| 194 | modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version)) | 240 | modules = do_split_packages(d, root='${nonarch_base_libdir}/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='%s-%s' % (kernel_package_name, kernel_version)) |
| 195 | if modules: | 241 | if modules: |
| 196 | d.appendVar('RDEPENDS:' + metapkg, ' '+' '.join(modules)) | 242 | d.appendVar('RDEPENDS:' + metapkg, ' '+' '.join(modules)) |
