Skip to content

Instantly share code, notes, and snippets.

@kergoth

kergoth/_test.sh Secret

Last active January 31, 2018 16:07
Show Gist options
  • Save kergoth/fa967c354a8ce4538b8456bd6b99a9d8 to your computer and use it in GitHub Desktop.
Save kergoth/fa967c354a8ce4538b8456bd6b99a9d8 to your computer and use it in GitHub Desktop.
named-config-image prototype
#!/bin/sh
bitbake core-image-minimal core-image-minimal-prod core-image-minimal-debug
IMAGE_CLASSES_append = " named-config-image"
inherit named-config
BBCLASSEXTEND += "named-config:debug named-config:prod"
PROVIDES_remove_virtclass-named-config-debug = "${BPN}"
PROVIDES_remove_virtclass-named-config-prod = "${BPN}"
RPROVIDES_${PN}_remove_virtclass-named-config-debug = "${BPN}"
RPROVIDES_${PN}_remove_virtclass-named-config-prod = "${BPN}"
DEBUG_IMAGE_FEATURES = "dbg-pkgs debug-tweaks ssh-server-openssh tools-profile"
IMAGE_FEATURES_remove_virtclass-named-config-prod = "${DEBUG_IMAGE_FEATURES}"
IMAGE_FEATURES_append_virtclass-named-config-debug = " ${DEBUG_IMAGE_FEATURES}"
NAMED_CONFIG_SUFFIX ?= ""
python named_config_virtclass_handler () {
cls = d.getVar("BBEXTENDCURR", True)
variant = d.getVar("BBEXTENDVARIANT", True)
if cls != "named-config" or not variant:
return
save_var_name = d.getVar("NAMED_CONFIG_SAVE_VARNAME", True) or ""
for name in save_var_name.split():
val = d.getVar(name, True)
if val:
d.setVar(name + "_NAMED_CONFIG_ORIGINAL", val)
override = ":virtclass-named-config-" + variant
overrides = d.getVar("OVERRIDES", False)
pn = d.getVar("PN", False)
overrides = overrides.replace("pn-${PN}", "pn-${PN}:pn-" + pn) + override
d.setVar("OVERRIDES", overrides)
# The variants provide the base, and aren't default
d.appendVar("PROVIDES", " " + pn)
# We want BPN to strip off the suffix
d.appendVar("SPECIAL_PKGSUFFIX", " -" + variant)
if not d.getVar("DEFAULT_PREFERENCE", True):
d.setVar("DEFAULT_PREFERENCE", "-1")
d.setVar("PN", d.getVar("PN", False) + "-" + variant)
d.setVar("NAMED_CONFIG_SUFFIX", "-" + variant)
pn_expanded = d.expand(pn)
for pkg in (d.getVar("PACKAGES", True) or '').split():
orig_pkg = pkg.replace(pn_expanded + "-" + variant, pn)
d.appendVar("RPROVIDES_%s" % pkg, " " + orig_pkg)
d.appendVar("RREPLACES_%s" % pkg, " " + orig_pkg)
d.appendVar("RCONFLICTS_%s" % pkg, " " + orig_pkg)
}
addhandler named_config_virtclass_handler
named_config_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment