users-groups-install: Make it pkg -r friendly

The generated pre-install scripts isn't pkg -r friendly for all
ports that have USERS/GROUPS with an homedir, fix that.

Reviewed by:	bapt
Approved by:	portmgr (bapt)
Differential Revision:	https://reviews.freebsd.org/D24531
This commit is contained in:
Emmanuel Vadot 2020-04-23 18:06:47 +00:00
parent 4c7ec298d7
commit ab88b482cc
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=532700

View file

@ -138,8 +138,18 @@ if [ -n "${USERS}" ]; then
/|/nonexistent|/var/empty)
;;
*)
echo "echo \"===> Creating homedir(s)\"" >> "${dp_UG_INSTALL}"
group=$(awk -F: -v gid=${gid} '$1 !~ /^#/ && $3 == gid { print $1 }' ${dp_GID_FILES})
echo "${dp_INSTALL} -d -g $group -o $login $homedir" >> "${dp_UG_INSTALL}"
cat >> "${dp_UG_INSTALL}" <<-blah
if [ -n "\${PKG_ROOTDIR}" ] && [ "\${PKG_ROOTDIR}" != "/" ]; then
HOMEDIR="\${PKG_ROOTDIR}/$homedir"
MDBDIR="-N \${PKG_ROOTDIR}/etc/"
else
HOMEDIR="$homedir"
MDBDIR=""
fi
${dp_INSTALL} \${MDBDIR} -d -g $group -o $login \${HOMEDIR}
blah
;;
esac
done <<-eot