Date: Mon, 11 Feb 2013 15:42:49 +0000 (UTC) From: Mark Linimon <linimon@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r246683 - projects/portbuild/admin/tools Message-ID: <201302111542.r1BFgnDn049130@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: linimon (doc,ports committer) Date: Mon Feb 11 15:42:48 2013 New Revision: 246683 URL: http://svnweb.freebsd.org/changeset/base/246683 Log: Reorder operations so that all zfs creates are done before permission definitions. Although PORTBUILD_USER has only one subdirectory of ZFS_VOLUME to administer, parameterize it. Clean up some noise from the id(1) commands. Note: this is still not sufficient. Modified: projects/portbuild/admin/tools/newmkportbuild Modified: projects/portbuild/admin/tools/newmkportbuild ============================================================================== --- projects/portbuild/admin/tools/newmkportbuild Mon Feb 11 15:13:28 2013 (r246682) +++ projects/portbuild/admin/tools/newmkportbuild Mon Feb 11 15:42:48 2013 (r246683) @@ -13,9 +13,10 @@ DEFAULT_VCS_REPOSITORY="svn://svn.FreeBS DEFAULT_ZFS_VOLUME="a" DEFAULT_ZFS_PERMISSIONSET="clone,create,destroy,mount,promote,rename,rollback,send,share,snapshot" DEFAULT_ZFS_PERMISSIONSET_SNAPS="clone,snapshot" +SNAP_DIRECTORY=snap # ownership of direct subdirectories of DEFAULT_ZFS_VOLUME -SRCBUILD_OWNED_SUBDIRS="chroot pxeroot snap" +SRCBUILD_OWNED_SUBDIRS="chroot pxeroot ${SNAP_DIRECTORY}" PORTBUILD_OWNED_SUBDIRS="portbuild" if [ `id -u` != 0 ]; then @@ -27,7 +28,7 @@ if [ -z "${PORTBUILD_USER}" ]; then echo "You must export PORTBUILD_USER, for example, export PORTBUILD_USER=${DEFAULT_PORTBUILD_USER}." exit 1 fi -if [ ! `id ${PORTBUILD_USER} 2> /dev/null` ]; then +if [ ! `id -u ${PORTBUILD_USER} 2> /dev/null` ]; then echo "User ${PORTBUILD_USER} must exist." exit 1 fi @@ -35,7 +36,7 @@ if [ -z "${SRCBUILD_USER}" ]; then echo "You must export SRCBUILD_USER, for example, export SRCBUILD_USER=${DEFAULT_SRCBUILD_USER}." exit 1 fi -if [ ! `id ${SRCBUILD_USER} 2> /dev/null` ]; then +if [ ! `id -u ${SRCBUILD_USER} 2> /dev/null` ]; then echo "User ${SRCBUILD_USER} must exist." exit 1 fi @@ -51,11 +52,13 @@ if [ -z "${VCS_PORTBUILD_REPOSITORY}" ]; fi VCS_PORTBUILD_REPOSITORY="${VCS_REPOSITORY}/base/projects/portbuild" fi + if [ -z "${ZFS_VOLUME}" ]; then echo "You must export ZFS_VOLUME, for example, export ZFS_VOLUME=${DEFAULT_ZFS_VOLUME}." exit 1 fi ZFS_MOUNTPOINT="/${ZFS_VOLUME}" + if [ -z "${ZFS_PERMISSIONSET}" ]; then echo "You have not set ZFS_PERMISSIONSET. I will use the default: ${DEFAULT_ZFS_PERMISSIONSET}." ZFS_PERMISSIONSET="${DEFAULT_ZFS_PERMISSIONSET}" @@ -81,13 +84,24 @@ if [ ! -z "${mounted}" -a "${mounted}" ! zfs umount ${ZFS_VOLUME} 2> /dev/null fi -# create a place to hold all portbuild-managed files. All other ZFS_VOLUME -# files are managed by srcbuild. -name=`zfs list -H -t filesystem -o name ${ZFS_VOLUME}/portbuild` -if [ -z "${name}" ]; then - echo "ZFS volume ${ZFS_VOLUME}/portbuild does not exist. I'll create it for you." - zfs create ${ZFS_VOLUME}/portbuild || exit 1 -fi +# create subdirectories for portbuild-managed files. All other ZFS_VOLUME +# subdirectories are managed by srcbuild. +for subdir in ${PORTBUILD_OWNED_SUBDIRS}; do + name=`zfs list -H -t filesystem -o name ${ZFS_VOLUME}/${subdir}` + if [ -z "${name}" ]; then + echo "ZFS volume ${ZFS_VOLUME}/${subdir} does not exist. I'll create it for you." + zfs create ${ZFS_VOLUME}/${subdir} || exit 1 + fi +done + +# create subdirectories for srcbuild-managed files. +for subdir in ${SRCBUILD_OWNED_SUBDIRS}; do + name=`zfs list -H -t filesystem -o name ${ZFS_VOLUME}/${subdir}` + if [ -z "${name}" ]; then + echo "ZFS volume ${ZFS_VOLUME}/${subdir} does not exist. I'll create it for you." + zfs create ${ZFS_VOLUME}/${subdir} || exit 1 + fi +done # reset the "zfsalladmin" permission set if it already exists. zfs unallow -s @zfsalladmin ${ZFS_VOLUME} 2> /dev/null @@ -113,6 +127,7 @@ zfs allow -s @zfssnapadmin ${ZFS_PERMISS zfs allow -du ${SRCBUILD_USER} @zfsalladmin ${ZFS_VOLUME} || exit 1 zfs allow -lu ${SRCBUILD_USER} @zfsalladmin ${ZFS_VOLUME} || exit 1 +# after (possibly) modifying permissions, now it's permissable to remount. mounted=`zfs list -H -t filesystem -o mounted ${ZFS_VOLUME}` if [ -z "${mounted}" -o "${mounted}" = "no" ]; then echo "ZFS volume ${ZFS_VOLUME} is not mounted. I'll remount it for you." @@ -120,12 +135,8 @@ if [ -z "${mounted}" -o "${mounted}" = " fi chown ${SRCBUILD_USER} ${ZFS_MOUNTPOINT} 2> /dev/null -# create various subdirectories to be managed by srcbuild. +# (re)mount various subdirectories to be managed by srcbuild. for subdir in ${SRCBUILD_OWNED_SUBDIRS}; do - if [ ! -d ${ZFS_MOUNTPOINT}/${subdir} ]; then - echo "ZFS volume ${ZFS_VOLUME}/${subdir} does not exist. I'll create it for you." - zfs create ${ZFS_VOLUME}/${subdir} || exit 1 - fi mounted=`zfs list -H -t filesystem -o mounted ${ZFS_VOLUME}/${subdir}` if [ -z "${mounted}" -o "${mounted}" = "no" ]; then echo "ZFS volume ${ZFS_VOLUME}/${subdir} is not mounted. I'll (re)mount it for you." @@ -144,12 +155,8 @@ echo "results of ZFS operations:" zfs list ${ZFS_VOLUME} zfs allow ${ZFS_VOLUME} -# create various subdirectories to be managed by portbuild. +# (re)mount various subdirectories to be managed by portbuild. for subdir in ${PORTBUILD_OWNED_SUBDIRS}; do - if [ ! -d ${ZFS_MOUNTPOINT}/${subdir} ]; then - echo "ZFS volume ${ZFS_VOLUME}/${subdir} does not exist. I'll create it for you." - zfs create ${ZFS_VOLUME}/${subdir} || exit 1 - fi mounted=`zfs list -H -t filesystem -o mounted ${ZFS_VOLUME}/${subdir}` if [ -z "${mounted}" -o "${mounted}" = "no" ]; then echo "ZFS volume ${ZFS_VOLUME}/${subdir} is not mounted. I'll (re)mount it for you." @@ -158,16 +165,17 @@ for subdir in ${PORTBUILD_OWNED_SUBDIRS} chown ${PORTBUILD_USER} ${ZFS_MOUNTPOINT}/${subdir} 2> /dev/null done - echo "checking out the repository as user ${PORTBUILD_USER} ..." su -m ${PORTBUILD_USER} -c "${VCS_CHECKOUT_COMMAND} ${VCS_PORTBUILD_REPOSITORY} ${ZFS_MOUNTPOINT}/portbuild" || exit 1 # XXX MCL now have to move some directories over, create different # XXX MCL ownerships, and so forth. -echo "$0: you should now be able to edit files in ${ZFS_MOUNTPOINT}/portbuild/conf." +echo -n "$0: you should now be able to edit files in ${ZFS_MOUNTPOINT}/portbuild/admin/conf" +echo " and ${ZFS_MOUNTPOINT}/portbuild/conf." -# create convenience directories. failure is annoying but non-fatal. +# create convenience directories for PORTBUILD_USER. failure is annoying +# but non-fatal. extra_dirs="lockfiles log" for extra_dir in ${extra_dirs}; do if [ ! -d ${ZFS_MOUNTPOINT}/portbuild/${extra_dir} ]; then
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302111542.r1BFgnDn049130>