More useradd cleanups
cover More useradd cleanups
Hello,
Richard pointed out that USERADDPN is no longer needed in useradd.bbclass. While removing that, I noticed that I was actually injecting the user/group preinst script into *all* packages whose recipe inherits useradd. That's not what we want, and is the reason for the USERADD_PACKAGES variable. So I refactored the class to fix that and clarified the useradd-example recipe documentation.
Finally, I added another check to avoid modifying -nativesdk packages.
The following changes since commit 25fae81538a92e15eab3fc169ebce44505f67839:
python: skip setup.py 'import check' when cross-compiling (2011-11-08 21:44:23 +0000)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib sgarman/useradd-cleanup-final
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=sgarman/useradd-cleanup-final
Scott Garman (4):
useradd.bbclass: only modify packages in USERADD_PACKAGES useradd.bbclass: do not modify -nativesdk packages useradd-example.bb: update example documentation comments
avahi: remove USERADDPN
.../recipes-skeleton/useradd/useradd-example.bb | 9 ++-- meta/classes/useradd.bbclass | 45 ++++++++------------ meta/recipes-connectivity/avahi/avahi.inc | 1 - 3 files changed, 22 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 1/4 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.
--- meta/classes/useradd.bbclass | 42 ++++++++++++++++-------------------------- 1 files changed, 16 insertions(+), 26 deletions(-)
meta/classes/useradd.bbclass +16 -26
@@ -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) }
Signature · 1 line
1.7.5.4
PATCH 2/4 useradd.bbclass: do not modify -nativesdk packages
In reply to Scott GarmanExclude the addition of user/group code and RDEPENDS changes for -nativesdk packages.
--- meta/classes/useradd.bbclass | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
meta/classes/useradd.bbclass +5 -4
@@ -153,10 +153,11 @@ 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) - + # 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) + if not bb.data.inherits_class('nativesdk', d): + useradd_packages = d.getVar('USERADD_PACKAGES', True) or "" + for pkg in useradd_packages.split(): + update_useradd_package(pkg) }
Signature · 1 line
1.7.5.4
PATCH 3/4 useradd-example.bb: update example documentation comments
In reply to Scott GarmanClarify that only packages listed in USERADD_PACKAGES will include the user/group creation code.
--- .../recipes-skeleton/useradd/useradd-example.bb | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
meta-skeleton/recipes-skeleton/useradd/useradd-example.bb +4 -5
@@ -17,13 +17,12 @@ PACKAGES =+ "${PN}-user3" inherit useradd -# Specify which package(s) should include the user/group code. -# Make sure that any packages which install files owned by custom -# users/groups are included here. The code which adds users and -# groups is idempotent. +# You must set USERADD_PACKAGES when you inherit useradd. This +# lists which output packages will include the user/group +# creation code. USERADD_PACKAGES = "${PN} ${PN}-user3" -# You *must* set USERADD_PARAM and/or GROUPADD_PARAM when +# You must also set USERADD_PARAM and/or GROUPADD_PARAM when # you inherit useradd. # USERADD_PARAM specifies command line options to pass to the
Signature · 1 line
1.7.5.4
PATCH 4/4 avahi: remove USERADDPN
In reply to Scott GarmanUSERADDPN is no longer used; remove it.
--- meta/recipes-connectivity/avahi/avahi.inc | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
meta/recipes-connectivity/avahi/avahi.inc +0 -1
@@ -23,7 +23,6 @@ SRC_URI = "http://avahi.org/download/avahi-${PV}.tar.gz \ file://99avahi-autoipd \ file://initscript.patch" -USERADDPN = "avahi-daemon" USERADD_PACKAGES = "avahi-daemon" USERADD_PARAM_avahi-daemon = "--system --home /var/run/avahi-daemon \ --no-create-home --shell /bin/false \
Signature · 1 line
1.7.5.4
Quoted 25 lines · Scott Garman
Hello,
Richard pointed out that USERADDPN is no longer needed in useradd.bbclass. While removing that, I noticed that I was actually injecting the user/group preinst script into *all* packages whose recipe inherits useradd. That's not what we want, and is the reason for the
USERADD_PACKAGESvariable. So I refactored the class to fix that and clarified the useradd-example recipe documentation.Finally, I added another check to avoid modifying -nativesdk packages.
The following changes since commit
25fae81538a92e15eab3fc169ebce44505f67839:python: skip setup.py 'import check' when cross-compiling (2011-11-08 21:44:23 +0000)are available in the git repository at:
git://git.pokylinux.org/poky-contribsgarman/useradd-cleanup-final
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=sgarman/useradd-cleanup-finalScott Garman (4):
useradd.bbclass: only modify packages inUSERADD_PACKAGESuseradd.bbclass: do not modify -nativesdk packages useradd-example.bb: update example documentation comments
avahi: remove USERADDPN
Quoted 5 lines
.../recipes-skeleton/useradd/useradd-example.bb | 9 ++-- meta/classes/useradd.bbclass | 45 ++++++++------------ meta/recipes-connectivity/avahi/avahi.inc | 1 - 3 files changed, 22 insertions(+), 33 deletions(-)
Merged int OE-Core
Thanks
Sau!