Subject: bsd.pkg.mk: running mtree as non-root? [patch]
To: None <tech-pkg@netbsd.org>
From: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
List: tech-pkg
Date: 10/06/2003 05:14:59
Right now, bsd.pkg.mk doesn't run mtree at all if pkg operation is
performed as non-root. This leads to directories not present, and being
installed as files. E.g. when something like pkgsrc/misc/figlet does "cp
file $PREFIX/man/man6"  and man6 is not a directory, one ends up with a
file $PREFIX/man/man6, and pkg_delete fails too.

I understand that mtree prints a lot of errors about wrong ownership etc.,
but I think that's still better than not having the dirs at all.

Any objections to commit the patch below?


 - Hubert


Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1293
diff -u -r1.1293 bsd.pkg.mk
--- bsd.pkg.mk	2 Oct 2003 15:45:31 -0000	1.1293
+++ bsd.pkg.mk	6 Oct 2003 03:11:45 -0000
@@ -2535,19 +2535,15 @@
 	done
 .endif	# INSTALLATION_DIRS
 .if !defined(NO_MTREE)
-	${_PKG_SILENT}${_PKG_DEBUG}if [ `${ID} -u` = 0 ]; then		\
-		if [ ! -f ${MTREE_FILE} ]; then				\
-			${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
-			exit 1;						\
-		else							\
-			if [ ! -d ${PREFIX} ]; then			\
-				${MKDIR} ${PREFIX};			\
-			fi;						\
-			${MTREE} ${MTREE_ARGS} ${PREFIX}/;		\
-		fi;							\
-	else								\
-		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
-		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
+	${_PKG_SILENT}${_PKG_DEBUG}					\
+	if [ ! -f ${MTREE_FILE} ]; then				\
+		${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
+		exit 1;						\
+	else							\
+		if [ ! -d ${PREFIX} ]; then			\
+			${MKDIR} ${PREFIX};			\
+		fi;						\
+		${MTREE} ${MTREE_ARGS} ${PREFIX}/;		\
 	fi
 .else
 	${_PKG_SILENT}${_PKG_DEBUG}[ -d ${PREFIX} ] || ${MKDIR} ${PREFIX}

-- 
  ___ _ _  _   _        * Harddisk Image Cloning *
 / __| | || | | |           www.feyrer.de/g4u/
| (_ |_  _| |_| |
 \___| |_| \___/          v1.12 out now, including partition support!