| Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # | 
 | 2 | # Copyright OpenEmbedded Contributors | 
 | 3 | # | 
 | 4 | # SPDX-License-Identifier: MIT | 
 | 5 | # | 
 | 6 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | inherit useradd_base | 
 | 8 |  | 
 | 9 | # base-passwd-cross provides the default passwd and group files in the | 
 | 10 | # target sysroot, and shadow -native and -sysroot provide the utilities | 
 | 11 | # and support files needed to add and modify user and group accounts | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 12 | DEPENDS:append:class-target = " base-files shadow-native shadow-sysroot shadow base-passwd" | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | PACKAGE_WRITE_DEPS += "shadow-native" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14 |  | 
 | 15 | # This preinstall function can be run in four different contexts: | 
 | 16 | # | 
 | 17 | # a) Before do_install | 
 | 18 | # b) At do_populate_sysroot_setscene when installing from sstate packages | 
 | 19 | # c) As the preinst script in the target package at do_rootfs time | 
 | 20 | # d) As the preinst script in the target package on device as a package upgrade | 
 | 21 | # | 
 | 22 | useradd_preinst () { | 
 | 23 | OPT="" | 
 | 24 | SYSROOT="" | 
 | 25 |  | 
 | 26 | if test "x$D" != "x"; then | 
 | 27 | 	# Installing into a sysroot | 
 | 28 | 	SYSROOT="$D" | 
 | 29 | 	OPT="--root $D" | 
 | 30 |  | 
 | 31 | 	# Make sure login.defs is there, this is to make debian package backend work | 
 | 32 | 	# correctly while doing rootfs. | 
 | 33 | 	# The problem here is that if /etc/login.defs is treated as a config file for | 
 | 34 | 	# shadow package, then while performing preinsts for packages that depend on | 
 | 35 | 	# shadow, there might only be /etc/login.def.dpkg-new there in root filesystem. | 
 | 36 | 	if [ ! -e $D${sysconfdir}/login.defs -a -e $D${sysconfdir}/login.defs.dpkg-new ]; then | 
 | 37 | 	    cp $D${sysconfdir}/login.defs.dpkg-new $D${sysconfdir}/login.defs | 
 | 38 | 	fi | 
 | 39 |  | 
 | 40 | 	# user/group lookups should match useradd/groupadd --root | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 41 | 	export PSEUDO_PASSWD="$SYSROOT" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | fi | 
 | 43 |  | 
 | 44 | # If we're not doing a special SSTATE/SYSROOT install | 
 | 45 | # then set the values, otherwise use the environment | 
 | 46 | if test "x$UA_SYSROOT" = "x"; then | 
 | 47 | 	# Installing onto a target | 
 | 48 | 	# Add groups and users defined only for this package | 
 | 49 | 	GROUPADD_PARAM="${GROUPADD_PARAM}" | 
 | 50 | 	USERADD_PARAM="${USERADD_PARAM}" | 
 | 51 | 	GROUPMEMS_PARAM="${GROUPMEMS_PARAM}" | 
 | 52 | fi | 
 | 53 |  | 
 | 54 | # Perform group additions first, since user additions may depend | 
 | 55 | # on these groups existing | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 56 | if test "x`echo $GROUPADD_PARAM | tr -d '[:space:]'`" != "x"; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | 	echo "Running groupadd commands..." | 
 | 58 | 	# Invoke multiple instances of groupadd for parameter lists | 
 | 59 | 	# separated by ';' | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 60 | 	opts=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` | 
 | 61 | 	remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'` | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | 	while test "x$opts" != "x"; do | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 63 | 		perform_groupadd "$SYSROOT" "$OPT $opts" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | 		if test "x$opts" = "x$remaining"; then | 
 | 65 | 			break | 
 | 66 | 		fi | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 67 | 		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` | 
 | 68 | 		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'` | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | 	done | 
 | 70 | fi  | 
 | 71 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 72 | if test "x`echo $USERADD_PARAM | tr -d '[:space:]'`" != "x"; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | 	echo "Running useradd commands..." | 
 | 74 | 	# Invoke multiple instances of useradd for parameter lists | 
 | 75 | 	# separated by ';' | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 76 | 	opts=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` | 
 | 77 | 	remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'` | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 78 | 	while test "x$opts" != "x"; do | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 79 | 		perform_useradd "$SYSROOT" "$OPT $opts" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 80 | 		if test "x$opts" = "x$remaining"; then | 
 | 81 | 			break | 
 | 82 | 		fi | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 83 | 		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` | 
 | 84 | 		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'` | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | 	done | 
 | 86 | fi | 
 | 87 |  | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 88 | if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | 	echo "Running groupmems commands..." | 
 | 90 | 	# Invoke multiple instances of groupmems for parameter lists | 
 | 91 | 	# separated by ';' | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 92 | 	opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` | 
 | 93 | 	remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'` | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | 	while test "x$opts" != "x"; do | 
| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 95 | 		perform_groupmems "$SYSROOT" "$OPT $opts" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 96 | 		if test "x$opts" = "x$remaining"; then | 
 | 97 | 			break | 
 | 98 | 		fi | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 99 | 		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'` | 
 | 100 | 		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'` | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | 	done | 
 | 102 | fi | 
 | 103 | } | 
 | 104 |  | 
 | 105 | useradd_sysroot () { | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 106 | 	# Pseudo may (do_prepare_recipe_sysroot) or may not (do_populate_sysroot_setscene) be running  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | 	# at this point so we're explicit about the environment so pseudo can load if  | 
 | 108 | 	# not already present. | 
| Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 109 | 	# PSEUDO_SYSROOT can contain references to the build architecture and COMPONENT_DIR | 
 | 110 | 	# so needs the STAGING_FIXME below | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 111 | 	export PSEUDO="${FAKEROOTENV} ${PSEUDO_SYSROOT}${bindir_native}/pseudo" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 112 |  | 
 | 113 | 	# Explicitly set $D since it isn't set to anything | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 114 | 	# before do_prepare_recipe_sysroot | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | 	D=${STAGING_DIR_TARGET} | 
 | 116 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 117 | 	# base-passwd's postinst may not have run yet in which case we'll get called later, just exit. | 
 | 118 | 	# Beware that in some cases we might see the fake pseudo passwd here, in which case we also must | 
 | 119 | 	# exit. | 
 | 120 | 	if [ ! -f $D${sysconfdir}/passwd ] || | 
 | 121 | 			grep -q this-is-the-pseudo-passwd $D${sysconfdir}/passwd; then | 
 | 122 | 		exit 0 | 
 | 123 | 	fi | 
 | 124 |  | 
 | 125 | 	# It is also possible we may be in a recipe which doesn't have useradd dependencies and hence the | 
 | 126 | 	# useradd/groupadd tools are unavailable. If there is no dependency, we assume we don't want to | 
 | 127 | 	# create users in the sysroot | 
 | 128 | 	if ! command -v useradd; then | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 129 | 		bbwarn "command useradd not found!" | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 130 | 		exit 0 | 
 | 131 | 	fi | 
 | 132 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 133 | 	# Add groups and users defined for all recipe packages | 
 | 134 | 	GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}" | 
 | 135 | 	USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}" | 
 | 136 | 	GROUPMEMS_PARAM="${@get_all_cmd_params(d, 'groupmems')}" | 
 | 137 |  | 
 | 138 | 	# Tell the system to use the environment vars | 
 | 139 | 	UA_SYSROOT=1 | 
 | 140 |  | 
 | 141 | 	useradd_preinst | 
 | 142 | } | 
 | 143 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 144 | # The export of PSEUDO in useradd_sysroot() above contains references to | 
| Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 145 | # ${PSEUDO_SYSROOT} and ${PSEUDO_LOCALSTATEDIR}. Additionally, the logging | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 146 | # shell functions use ${LOGFIFO}. These need to be handled when restoring | 
 | 147 | # postinst-useradd-${PN} from the sstate cache. | 
| Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 148 | EXTRA_STAGING_FIXMES += "PSEUDO_SYSROOT PSEUDO_LOCALSTATEDIR LOGFIFO" | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 149 |  | 
 | 150 | python useradd_sysroot_sstate () { | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 151 |     scriptfile = None | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 152 |     task = d.getVar("BB_CURRENTTASK") | 
 | 153 |     if task == "package_setscene": | 
 | 154 |         bb.build.exec_func("useradd_sysroot", d) | 
 | 155 |     elif task == "prepare_recipe_sysroot": | 
 | 156 |         # Used to update this recipe's own sysroot so the user/groups are available to do_install | 
 | 157 |         scriptfile = d.expand("${RECIPE_SYSROOT}${bindir}/postinst-useradd-${PN}") | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 158 |         bb.build.exec_func("useradd_sysroot", d) | 
 | 159 |     elif task == "populate_sysroot": | 
 | 160 |         # Used when installed in dependent task sysroots | 
 | 161 |         scriptfile = d.expand("${SYSROOT_DESTDIR}${bindir}/postinst-useradd-${PN}") | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 162 |  | 
 | 163 |     if scriptfile: | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 164 |         bb.utils.mkdirhier(os.path.dirname(scriptfile)) | 
 | 165 |         with open(scriptfile, 'w') as script: | 
 | 166 |             script.write("#!/bin/sh\n") | 
 | 167 |             bb.data.emit_func("useradd_sysroot", script, d) | 
 | 168 |             script.write("useradd_sysroot\n") | 
 | 169 |         os.chmod(scriptfile, 0o755) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 170 | } | 
 | 171 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 172 | do_prepare_recipe_sysroot[postfuncs] += "${SYSROOTFUNC}" | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 173 | SYSROOTFUNC:class-target = "useradd_sysroot_sstate" | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 174 | SYSROOTFUNC = "" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 175 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 176 | SYSROOT_PREPROCESS_FUNCS += "${SYSROOTFUNC}" | 
 | 177 |  | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 178 | SSTATEPREINSTFUNCS:append:class-target = " useradd_sysroot_sstate" | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 179 |  | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | do_package_setscene[depends] += "${USERADDSETSCENEDEPS}" | 
 | 181 | do_populate_sysroot_setscene[depends] += "${USERADDSETSCENEDEPS}" | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 182 | USERADDSETSCENEDEPS:class-target = "${MLPREFIX}base-passwd:do_populate_sysroot_setscene pseudo-native:do_populate_sysroot_setscene shadow-native:do_populate_sysroot_setscene ${MLPREFIX}shadow-sysroot:do_populate_sysroot_setscene" | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 183 | USERADDSETSCENEDEPS = "" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 184 |  | 
 | 185 | # Recipe parse-time sanity checks | 
 | 186 | def update_useradd_after_parse(d): | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 187 |     useradd_packages = d.getVar('USERADD_PACKAGES') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 188 |  | 
 | 189 |     if not useradd_packages: | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 190 |         bb.fatal("%s inherits useradd but doesn't set USERADD_PACKAGES" % d.getVar('FILE', False)) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 191 |  | 
 | 192 |     for pkg in useradd_packages.split(): | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 193 |         d.appendVarFlag("do_populate_sysroot", "vardeps", "USERADD_PARAM:%s GROUPADD_PARAM:%s GROUPMEMS_PARAM:%s" % (pkg, pkg, pkg)) | 
 | 194 |         if not d.getVar('USERADD_PARAM:%s' % pkg) and not d.getVar('GROUPADD_PARAM:%s' % pkg) and not d.getVar('GROUPMEMS_PARAM:%s' % pkg): | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 |             bb.fatal("%s inherits useradd but doesn't set USERADD_PARAM, GROUPADD_PARAM or GROUPMEMS_PARAM for package %s" % (d.getVar('FILE', False), pkg)) | 
 | 196 |  | 
 | 197 | python __anonymous() { | 
 | 198 |     if not bb.data.inherits_class('nativesdk', d) \ | 
 | 199 |         and not bb.data.inherits_class('native', d): | 
 | 200 |         update_useradd_after_parse(d) | 
 | 201 | } | 
 | 202 |  | 
 | 203 | # Return a single [GROUP|USER]ADD_PARAM formatted string which includes the | 
 | 204 | # [group|user]add parameters for all USERADD_PACKAGES in this recipe | 
 | 205 | def get_all_cmd_params(d, cmd_type): | 
 | 206 |     import string | 
 | 207 |      | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 208 |     param_type = cmd_type.upper() + "_PARAM:%s" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 209 |     params = [] | 
 | 210 |  | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 211 |     useradd_packages = d.getVar('USERADD_PACKAGES') or "" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 212 |     for pkg in useradd_packages.split(): | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 213 |         param = d.getVar(param_type % pkg) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 214 |         if param: | 
| Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 215 |             params.append(param.rstrip(" ;")) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 216 |  | 
 | 217 |     return "; ".join(params) | 
 | 218 |  | 
 | 219 | # Adds the preinst script into generated packages | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 220 | fakeroot python populate_packages:prepend () { | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 221 |     def update_useradd_package(pkg): | 
 | 222 |         bb.debug(1, 'adding user/group calls to preinst for %s' % pkg) | 
 | 223 |  | 
 | 224 |         """ | 
 | 225 |         useradd preinst is appended here because pkg_preinst may be | 
 | 226 |         required to execute on the target. Not doing so may cause | 
 | 227 |         useradd preinst to be invoked twice, causing unwanted warnings. | 
 | 228 |         """ | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 229 |         preinst = d.getVar('pkg_preinst:%s' % pkg) or d.getVar('pkg_preinst') | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 230 |         if not preinst: | 
 | 231 |             preinst = '#!/bin/sh\n' | 
 | 232 |         preinst += 'bbnote () {\n\techo "NOTE: $*"\n}\n' | 
 | 233 |         preinst += 'bbwarn () {\n\techo "WARNING: $*"\n}\n' | 
 | 234 |         preinst += 'bbfatal () {\n\techo "ERROR: $*"\n\texit 1\n}\n' | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 235 |         preinst += 'perform_groupadd () {\n%s}\n' % d.getVar('perform_groupadd') | 
 | 236 |         preinst += 'perform_useradd () {\n%s}\n' % d.getVar('perform_useradd') | 
 | 237 |         preinst += 'perform_groupmems () {\n%s}\n' % d.getVar('perform_groupmems') | 
 | 238 |         preinst += d.getVar('useradd_preinst') | 
| Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 239 |         # Expand out the *_PARAM variables to the package specific versions | 
 | 240 |         for rep in ["GROUPADD_PARAM", "USERADD_PARAM", "GROUPMEMS_PARAM"]: | 
 | 241 |             val = d.getVar(rep + ":" + pkg) or "" | 
 | 242 |             preinst = preinst.replace("${" + rep + "}", val) | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 243 |         d.setVar('pkg_preinst:%s' % pkg, preinst) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 244 |  | 
 | 245 |         # RDEPENDS setup | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 246 |         rdepends = d.getVar("RDEPENDS:%s" % pkg) or "" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 247 |         rdepends += ' ' + d.getVar('MLPREFIX', False) + 'base-passwd' | 
 | 248 |         rdepends += ' ' + d.getVar('MLPREFIX', False) + 'shadow' | 
 | 249 |         # base-files is where the default /etc/skel is packaged | 
 | 250 |         rdepends += ' ' + d.getVar('MLPREFIX', False) + 'base-files' | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 251 |         d.setVar("RDEPENDS:%s" % pkg, rdepends) | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 |  | 
 | 253 |     # Add the user/group preinstall scripts and RDEPENDS requirements | 
 | 254 |     # to packages specified by USERADD_PACKAGES | 
 | 255 |     if not bb.data.inherits_class('nativesdk', d) \ | 
 | 256 |         and not bb.data.inherits_class('native', d): | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 257 |         useradd_packages = d.getVar('USERADD_PACKAGES') or "" | 
| Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 258 |         for pkg in useradd_packages.split(): | 
 | 259 |             update_useradd_package(pkg) | 
 | 260 | } | 
 | 261 |  | 
 | 262 | # Use the following to extend the useradd with custom functions | 
 | 263 | USERADDEXTENSION ?= "" | 
 | 264 |  | 
 | 265 | inherit ${USERADDEXTENSION} |