diff options
Diffstat (limited to 'meta/classes/useradd.bbclass')
| -rw-r--r-- | meta/classes/useradd.bbclass | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass index 82f4d52758..326c04d0b1 100644 --- a/meta/classes/useradd.bbclass +++ b/meta/classes/useradd.bbclass | |||
| @@ -3,7 +3,7 @@ inherit useradd_base | |||
| 3 | # base-passwd-cross provides the default passwd and group files in the | 3 | # base-passwd-cross provides the default passwd and group files in the |
| 4 | # target sysroot, and shadow -native and -sysroot provide the utilities | 4 | # target sysroot, and shadow -native and -sysroot provide the utilities |
| 5 | # and support files needed to add and modify user and group accounts | 5 | # and support files needed to add and modify user and group accounts |
| 6 | DEPENDS_append_class-target = " base-files shadow-native shadow-sysroot shadow" | 6 | DEPENDS_append_class-target = " base-files shadow-native shadow-sysroot shadow base-passwd" |
| 7 | PACKAGE_WRITE_DEPS += "shadow-native" | 7 | PACKAGE_WRITE_DEPS += "shadow-native" |
| 8 | 8 | ||
| 9 | # This preinstall function can be run in four different contexts: | 9 | # This preinstall function can be run in four different contexts: |
| @@ -97,13 +97,13 @@ fi | |||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | useradd_sysroot () { | 99 | useradd_sysroot () { |
| 100 | # Pseudo may (do_install) or may not (do_populate_sysroot_setscene) be running | 100 | # Pseudo may (do_prepare_recipe_sysroot) or may not (do_populate_sysroot_setscene) be running |
| 101 | # at this point so we're explicit about the environment so pseudo can load if | 101 | # at this point so we're explicit about the environment so pseudo can load if |
| 102 | # not already present. | 102 | # not already present. |
| 103 | export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir_native}/pseudo" | 103 | export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${PSEUDO_SYSROOT}${bindir_native}/pseudo" |
| 104 | 104 | ||
| 105 | # Explicitly set $D since it isn't set to anything | 105 | # Explicitly set $D since it isn't set to anything |
| 106 | # before do_install | 106 | # before do_prepare_recipe_sysroot |
| 107 | D=${STAGING_DIR_TARGET} | 107 | D=${STAGING_DIR_TARGET} |
| 108 | 108 | ||
| 109 | # Add groups and users defined for all recipe packages | 109 | # Add groups and users defined for all recipe packages |
| @@ -117,17 +117,25 @@ useradd_sysroot () { | |||
| 117 | useradd_preinst | 117 | useradd_preinst |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | useradd_sysroot_sstate () { | 120 | python useradd_sysroot_sstate () { |
| 121 | if [ "${BB_CURRENTTASK}" = "package_setscene" -o "${BB_CURRENTTASK}" = "populate_sysroot_setscene" ] | 121 | task = d.getVar("BB_CURRENTTASK") |
| 122 | then | 122 | if task == "package_setscene": |
| 123 | useradd_sysroot | 123 | bb.build.exec_func("useradd_sysroot", d) |
| 124 | fi | 124 | elif task == "prepare_recipe_sysroot": |
| 125 | scriptfile = d.expand("${RECIPE_SYSROOT}${bindir}/postinst-useradd-${PN}") | ||
| 126 | bb.utils.mkdirhier(os.path.dirname(scriptfile)) | ||
| 127 | with open(scriptfile, 'w') as script: | ||
| 128 | script.write("#!/bin/sh\n") | ||
| 129 | bb.data.emit_func("useradd_sysroot", script, d) | ||
| 130 | script.write("useradd_sysroot\n") | ||
| 131 | os.chmod(scriptfile, 0o755) | ||
| 132 | bb.build.exec_func("useradd_sysroot", d) | ||
| 125 | } | 133 | } |
| 126 | 134 | ||
| 127 | userdel_sysroot_sstate () { | 135 | userdel_sysroot_sstate () { |
| 128 | if test "x${STAGING_DIR_TARGET}" != "x"; then | 136 | if test "x${STAGING_DIR_TARGET}" != "x"; then |
| 129 | if [ "${BB_CURRENTTASK}" = "clean" ]; then | 137 | if [ "${BB_CURRENTTASK}" = "clean" ]; then |
| 130 | export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${STAGING_DIR_NATIVE}${bindir_native}/pseudo" | 138 | export PSEUDO="${FAKEROOTENV} PSEUDO_LOCALSTATEDIR=${STAGING_DIR_TARGET}${localstatedir}/pseudo ${PSEUDO_SYSROOT}${bindir_native}/pseudo" |
| 131 | OPT="--root ${STAGING_DIR_TARGET}" | 139 | OPT="--root ${STAGING_DIR_TARGET}" |
| 132 | 140 | ||
| 133 | # Remove groups and users defined for package | 141 | # Remove groups and users defined for package |
| @@ -154,10 +162,10 @@ if test "x${STAGING_DIR_TARGET}" != "x"; then | |||
| 154 | fi | 162 | fi |
| 155 | } | 163 | } |
| 156 | 164 | ||
| 157 | SSTATECLEANFUNCS_append_class-target = " userdel_sysroot_sstate" | 165 | #SSTATECLEANFUNCS_append_class-target = " userdel_sysroot_sstate" |
| 158 | 166 | ||
| 159 | do_install[prefuncs] += "${SYSROOTFUNC}" | 167 | do_prepare_recipe_sysroot[postfuncs] += "${SYSROOTFUNC}" |
| 160 | SYSROOTFUNC_class-target = "useradd_sysroot" | 168 | SYSROOTFUNC_class-target = "useradd_sysroot_sstate" |
| 161 | SYSROOTFUNC = "" | 169 | SYSROOTFUNC = "" |
| 162 | 170 | ||
| 163 | SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate" | 171 | SSTATEPREINSTFUNCS_append_class-target = " useradd_sysroot_sstate" |
