diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2012-06-13 16:08:54 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2012-06-14 10:27:43 +0200 |
commit | 83f1aaf343b3620ce43c9d0e83faa2b3952af1fa (patch) | |
tree | c5741b964bce9770dde7e0b9959566b453eba0eb /scripts/lib/ptxd_make_xpkg_pkg.sh | |
parent | 0fe1845de0b5dea0dc55bba39424955864f61a40 (diff) | |
download | ptxdist-83f1aaf343b3620ce43c9d0e83faa2b3952af1fa.tar.gz ptxdist-83f1aaf343b3620ce43c9d0e83faa2b3952af1fa.tar.xz |
ptxd_make_xpkg_pkg: add possibility to specify user/group as names
Before this patch, the user/group information has to specified as numeric
values. With this patch it's possible to write their names, too. E.g.:
- @$(call install_copy, apache2, 12, 102, 0755, $(PTXCONF_APACHE2_SERVERROOT))
+ @$(call install_copy, apache2, www, www, 0755, $(PTXCONF_APACHE2_SERVERROOT))
The files /etc/passwd and /etc/group are used to lookup the numeric values.
As always the files in the BSP's projectroot have precedence over the generic
files in ptxdist.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'scripts/lib/ptxd_make_xpkg_pkg.sh')
-rw-r--r-- | scripts/lib/ptxd_make_xpkg_pkg.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh index e6d84b450..d60363b3c 100644 --- a/scripts/lib/ptxd_make_xpkg_pkg.sh +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh @@ -24,6 +24,74 @@ ptxd_install_error() { } export -f ptxd_install_error +# +# ptxd_install_getent_id +# +# convert usr or grp into numeric value +# +# $1: "usr", "grp" +# +ptxd_install_getent_id() { + local key="${1}" + local db id + + case "${key}" in + usr) + id="user id" + db="/etc/passwd" + ;; + grp) + id="group id" + db="/etc/group" + ;; + esac + + eval ${key}_name='\(${!key}\)' + + if ! ptxd_get_alternative "projectroot" "${db}"; then + ptxd_bailout " + + Unable to find '${db}'. + +" + fi + + local line + if ! line="$(grep -e "^${!key}" "${ptxd_reply}")"; then + ptxd_bailout " + +${id} '${!key}' not found in '$(ptxd_print_path ${ptxd_reply})' for: + '${dst:-${dir}}' + +" + fi + local orig_IFS="${IFS}" + local IFS=":" + set -- $line + IFS="${orig_IFS}" + eval ${key}="${3}" +} +export -f ptxd_install_getent_id + +# +# ptxd_install_resolve_usr_grp +# +# convert usr/grp that contain names into numeric values +# +ptxd_install_resolve_usr_grp() { + if ! [ 0 -le $usr ] 2>/dev/null; then + ptxd_install_getent_id usr || return + else + unset usr_name + fi + if ! [ 0 -le $grp ] 2>/dev/null; then + ptxd_install_getent_id grp || return + else + unset grp_name + fi +} +export -f ptxd_install_resolve_usr_grp + ptxd_install_setup() { case "${dst}" in /*|"") ;; @@ -47,6 +115,10 @@ ptxd_install_setup() { mod_nfs="$(printf "0%o" $(( 0${mod} & ~06000 )))" && mod_rw="$(printf "0%o" $(( 0${mod} | 0200 )))" && + # + # mangle user/group + # + ptxd_install_resolve_usr_grp } export -f ptxd_install_setup |