From 403d5e0b7dd0d124d3b7e0540a67e4da17694c21 Mon Sep 17 00:00:00 2001 From: Scott Garman Date: Tue, 8 Nov 2011 18:23:48 -0800 Subject: useradd.bbclass: only modify packages in USERADD_PACKAGES Previously we injected the user/group preinstall script into all output packages. This fixes that so that only packages listed in USERADD_PACKAGES get modified. It also removes the USERADDPN variable, which is no longer needed. (From OE-Core rev: 2f73466eb5018040a123ccb0e2af8c519525f958) (From OE-Core rev: 424b6447ebce761c9027ffdaf68ecbcd6f28e4ec) Signed-off-by: Scott Garman Signed-off-by: Richard Purdie --- meta/classes/useradd.bbclass | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass index a8a1c14f48..3b2d1dbfe8 100644 --- a/meta/classes/useradd.bbclass +++ b/meta/classes/useradd.bbclass @@ -1,5 +1,3 @@ -USERADDPN ?= "${PN}" - # base-passwd-cross provides the default passwd and group files in the # target sysroot, and shadow -native and -sysroot provide the utilities # and support files needed to add and modify user and group accounts @@ -106,30 +104,29 @@ SYSROOTPOSTFUNC_virtclass-nativesdk = "" # Recipe parse-time sanity checks def update_useradd_after_parse(d): - if not d.getVar('USERADD_PACKAGES', False): - if not d.getVar('USERADD_PARAM', False) and not d.getVar('GROUPADD_PARAM', False): - raise bb.build.FuncFailed, "%s inherits useradd but doesn't set USERADD_PARAM or GROUPADD_PARAM" % bb.data.getVar('FILE', d) + useradd_packages = d.getVar('USERADD_PACKAGES', True) + + if not useradd_packages: + raise bb.build.FuncFailed, "%s inherits useradd but doesn't set USERADD_PACKAGES" % bb.data.getVar('FILE', d) + + for pkg in useradd_packages.split(): + if not d.getVar('USERADD_PARAM_%s' % pkg, True) and not d.getVar('GROUPADD_PARAM_%s' % pkg, True): + raise bb.build.FuncFailed, "%s inherits useradd but doesn't set USERADD_PARAM or GROUPADD_PARAM for package %s" % (bb.data.getVar('FILE', d), pkg) python __anonymous() { update_useradd_after_parse(d) } # Return a single [GROUP|USER]ADD_PARAM formatted string which includes the -# [group|user]add parameters for all packages in this recipe +# [group|user]add parameters for all USERADD_PACKAGES in this recipe def get_all_cmd_params(d, cmd_type): import string param_type = cmd_type.upper() + "ADD_PARAM_%s" params = [] - pkgs = d.getVar('USERADD_PACKAGES', True) - if not pkgs: - pkgs = d.getVar('USERADDPN', True) - packages = (d.getVar('PACKAGES', True) or "").split() - if packages and pkgs not in packages: - pkgs = packages[0] - - for pkg in pkgs.split(): + useradd_packages = d.getVar('USERADD_PACKAGES', True) or "" + for pkg in useradd_packages.split(): param = d.getVar(param_type % pkg, True) if param: params.append(param) @@ -156,17 +153,10 @@ fakeroot python populate_packages_prepend () { rdepends = d.getVar("RDEPENDS_%s" % pkg, True) or "" rdepends += " base-passwd shadow" bb.data.setVar("RDEPENDS_%s" % pkg, rdepends, d) - - # We add the user/group calls to all packages to allow any package - # to contain files owned by the users/groups defined in the recipe. - # The user/group addition code is careful not to create duplicate - # entries, so this is safe. - pkgs = d.getVar('USERADD_PACKAGES', True) - if not pkgs: - pkgs = d.getVar('USERADDPN', True) - packages = (d.getVar('PACKAGES', True) or "").split() - if packages and pkgs not in packages: - pkgs = packages[0] - for pkg in pkgs.split(): + + # Add the user/group preinstall scripts and RDEPENDS requirements + # to packages specified by USERADD_PACKAGES + useradd_packages = d.getVar('USERADD_PACKAGES', True) or "" + for pkg in useradd_packages.split(): update_useradd_package(pkg) } -- cgit v1.2.3-54-g00ecf