Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Apr 2014 22:30:05 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r352073 - head/Mk/Scripts
Message-ID:  <201404242230.s3OMU5PD072205@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Thu Apr 24 22:30:05 2014
New Revision: 352073
URL: http://svnweb.freebsd.org/changeset/ports/352073
QAT: https://qat.redports.org/buildarchive/r352073/

Log:
  - Refactor a bit into functions
  
  With hat:	portmgr

Modified:
  head/Mk/Scripts/check-stagedir.sh

Modified: head/Mk/Scripts/check-stagedir.sh
==============================================================================
--- head/Mk/Scripts/check-stagedir.sh	Thu Apr 24 21:49:07 2014	(r352072)
+++ head/Mk/Scripts/check-stagedir.sh	Thu Apr 24 22:30:05 2014	(r352073)
@@ -13,55 +13,12 @@
 
 set -e
 export LC_ALL=C
-ret=0
-
-# lists an mtree file's contents, prefixed to dir.
-listmtree() { # mtreefile prefix
-	{
-		echo '#mtree'
-		sed 's/nochange$//;' $1
-	} | tar -tf- | sed "s,^,$2/,;s,^$2/\.$,$2,;s,^$,/,"
-}
-
-sort_dfs() {
-	while read dir; do
-		grep "^[0-9]* ${dir}$" ${WRKDIR}/.staged-dirs-dfs-sorted
-	done | sort -n | cut -d ' ' -f2-
-}
-
-# obtain operating mode from command line
-makeplist=0
-case "$1" in
-	checkplist)	;;
-	makeplist)	makeplist=1 ;;
-	*) echo >&2 "Usage: $0 {checkplist|makelist}" ; exit 1 ;;
-esac
-
-# validate environment
-envfault=
-for i in STAGEDIR PREFIX LOCALBASE WRKDIR WRKSRC MTREE_FILE GNOME_MTREE_FILE \
-    TMPPLIST PLIST_SUB_SED SCRIPTSDIR PACKAGE_DEPENDS WITH_PKGNG PKG_QUERY \
-    PORT_OPTIONS NO_PREFIX_RMDIR
-do
-    if ! ( eval ": \${${i}?}" ) 2>/dev/null ; then
-		envfault="${envfault}${envfault:+" "}${i}"
-    fi
-done
-if [ -n "$envfault" ] ; then
-	echo "Environment variables $envfault undefined. Aborting." \
-	| fmt >&2
-	exit 1
-fi
-
-set -u
 
 #### EXPAND TMPPLIST TO ABSOLUTE PATHS, SPLITTING FILES AND DIRS TO
 #    Use file descriptors 1 and 3 so that the while loop can write
 #    files to the pipe and dirs to a separate file.
-if [ $makeplist = 0 ] ; then
-	# check for orphans
-	echo "===> Checking for items in STAGEDIR missing from pkg-plist"
-
+parse_plist() {
+	echo "===> Parsing plist"
 	cwd=${PREFIX}
 	cwd_save=
 	commented_cwd=
@@ -160,44 +117,50 @@ if [ $makeplist = 0 ] ; then
 	    >${WRKDIR}/.plist-files-no-comments
 	sed -e 's/^@comment //' ${WRKDIR}/.plist-files-unsorted | sort \
 	    >${WRKDIR}/.plist-files
-else
-	# generate plist - pretend the plist had been empty
-	: >${WRKDIR}/.plist-dirs-unsorted
-	: >${WRKDIR}/.plist-files
-	echo '/you/have/to/check/what/makeplist/gives/you'
-fi
+}
+
+# lists an mtree file's contents, prefixed to dir.
+listmtree() { # mtreefile prefix
+	{
+		echo '#mtree'
+		sed 's/nochange$//;' $1
+	} | tar -tf- | sed "s,^,$2/,;s,^$2/\.$,$2,;s,^$,/,"
+}
 
 ### PRODUCE MTREE FILE
-{
-	listmtree /etc/mtree/BSD.root.dist ""
-	listmtree /etc/mtree/BSD.usr.dist /usr
-	listmtree /etc/mtree/BSD.var.dist /var
-
-	# Use MTREE_FILE if specified and it doesn't already match LOCALBASE
-	if [ -n "${MTREE_FILE}" ]; then
-		if [ "${PREFIX}" != "${LOCALBASE}" -o \
-		    "${MTREE_FILE}" != "${PORTSDIR}/Templates/BSD.local.dist" \
-		    ]; then
-			listmtree "${MTREE_FILE}" "${PREFIX}"
+parse_mtree() {
+	{
+		listmtree /etc/mtree/BSD.root.dist ""
+		listmtree /etc/mtree/BSD.usr.dist /usr
+		listmtree /etc/mtree/BSD.var.dist /var
+
+		# Use MTREE_FILE if specified and it doesn't already
+		# match LOCALBASE
+		if [ -n "${MTREE_FILE}" ]; then
+			if [ "${PREFIX}" != "${LOCALBASE}" -o "${MTREE_FILE}" \
+			    != "${PORTSDIR}/Templates/BSD.local.dist" ]; then
+				listmtree "${MTREE_FILE}" "${PREFIX}"
+			fi
 		fi
-	fi
-	listmtree "${PORTSDIR}/Templates/BSD.local.dist" "${LOCALBASE}"
+		listmtree "${PORTSDIR}/Templates/BSD.local.dist" "${LOCALBASE}"
 
-	if [ -n "${GNOME_MTREE_FILE}" ] && [ -f "${GNOME_MTREE_FILE}" ]; then
-		listmtree "${GNOME_MTREE_FILE}" "${PREFIX}"
-	fi
-	unset MTREE_FILE GNOME_MTREE_FILE
+		if [ -n "${GNOME_MTREE_FILE}" ] && \
+		    [ -f "${GNOME_MTREE_FILE}" ]; then
+			listmtree "${GNOME_MTREE_FILE}" "${PREFIX}"
+		fi
+		unset MTREE_FILE GNOME_MTREE_FILE
 
-	# Add in PREFIX if this port wants it
-	if [ ${NO_PREFIX_RMDIR} -eq 0 ]; then
-		a=${PREFIX}
-		while :; do
-			echo ${a}
-			a=${a%/*}
-			[ -z "${a}" ] && break
-		done
-	fi
-} >${WRKDIR}/.mtree
+		# Add in PREFIX if this port wants it
+		if [ ${NO_PREFIX_RMDIR} -eq 0 ]; then
+			a=${PREFIX}
+			while :; do
+				echo ${a}
+				a=${a%/*}
+				[ -z "${a}" ] && break
+			done
+		fi
+	} >${WRKDIR}/.mtree
+}
 
 pkg_get_recursive_deps() {
 	echo "$@"
@@ -212,87 +175,256 @@ pkg_get_recursive_deps() {
 }
 
 ### GATHER DIRS OWNED BY RUN-DEPENDS. WHY ARE WE SCREAMING?
-: >${WRKDIR}/.run-depends-dirs
-if [ -n "${WITH_PKGNG}" ]; then
-	echo "${PACKAGE_DEPENDS}" | while read pkg; do \
-	    PKG_CHECKED= pkg_get_recursive_deps "${pkg}"; done | sort -u | \
-	    xargs ${PKG_QUERY} "%D" | sed -e 's,/$,,' | sort -u \
-	    >>${WRKDIR}/.run-depends-dirs
-else
-	# Evaluate ACTUAL-PACKAGE-DEPENDS
-	packagelist=
-	package_depends=$(eval ${PACKAGE_DEPENDS})
-	if [ -n "${package_depends}" ]; then
-		# This ugly mess can go away with pkg_install EOL
-		awk_script=$(cat <<'EOF'
-			/Deinstall directory remove:/ {print $4}
-			/UNEXEC 'rmdir "[^"]*" 2>\/dev\/null \|\| true'/ {
-				gsub(/"%D\//, "\"", $0)
-				match($0, /"[^"]*"/)
-				dir=substr($0, RSTART+1, RLENGTH-2)
-				print dir
-			}
+lookup_dependency_dirs() {
+	: >${WRKDIR}/.run-depends-dirs
+	if [ -n "${WITH_PKGNG}" ]; then
+		echo "${PACKAGE_DEPENDS}" | while read pkg; do \
+		    PKG_CHECKED= pkg_get_recursive_deps "${pkg}"; done | \
+		    sort -u | \
+		    xargs ${PKG_QUERY} "%D" | sed -e 's,/$,,' | sort -u \
+		    >>${WRKDIR}/.run-depends-dirs
+	else
+		# Evaluate ACTUAL-PACKAGE-DEPENDS
+		packagelist=
+		package_depends=$(eval ${PACKAGE_DEPENDS})
+		if [ -n "${package_depends}" ]; then
+			# This ugly mess can go away with pkg_install EOL
+			awk_script=$(cat <<'EOF'
+				/Deinstall directory remove:/ {print $4}
+				/UNEXEC 'rmdir "[^"]*" 2>\/dev\/null \|\| true'/ {
+					gsub(/"%D\//, "\"", $0)
+					match($0, /"[^"]*"/)
+					dir=substr($0, RSTART+1, RLENGTH-2)
+					print dir
+				}
 EOF
 )
-		echo "${package_depends}" | tr ' ' '\n' | cut -d : -f 1 | \
-		    sort -u | xargs -n 1 ${PKG_QUERY} -f | \
-		    awk "${awk_script}" | \
-		    sed -e "/^[^/]/s,^,${LOCALBASE}/," | sort -u \
-		    >>${WRKDIR}/.run-depends-dirs
+			echo "${package_depends}" | tr ' ' '\n' | \
+			    cut -d : -f 1 | sort -u | \
+			    xargs -n 1 ${PKG_QUERY} -f | \
+			    awk "${awk_script}" | \
+			    sed -e "/^[^/]/s,^,${LOCALBASE}/," | sort -u \
+			    >>${WRKDIR}/.run-depends-dirs
+		fi
 	fi
-fi
-unset PACKAGE_DEPENDS PKG_QUERY
+}
 
-### HANDLE PORTDOCS/PORTEXAMPLES
-sed_portdocsexamples="/%%DOCSDIR%%/s!^!%%PORTDOCS%%!g; /%%EXAMPLESDIR%%/s!^!%%PORTEXAMPLES%%!g;"
-if [ ${makeplist} -eq 0 ]; then
-#	echo "=====> Using OPTIONS: ${PORT_OPTIONS}" | /usr/bin/fmt -w 79 | \
-#	    sed -e '2,$s/^/                      /'
-	# Handle magical PORT* features
-	for option in DOCS EXAMPLES; do
-		want_option=0
-		case " ${PORT_OPTIONS} " in
-		*\ ${option}\ *) want_option=1 ;;
+# Sort a directory list by the order of the dfs-sorted file (from find -ds)
+sort_dfs() {
+	while read dir; do
+		grep "^[0-9]* ${dir}$" ${WRKDIR}/.staged-dirs-dfs-sorted
+	done | sort -n | cut -d ' ' -f2-
+}
+
+# Prepare sed(1) regex for PLIST_SUB_SED/PORTEXAMPLES/OPTIONS/...
+setup_plist_seds() {
+	### HANDLE PORTDOCS/PORTEXAMPLES
+	sed_portdocsexamples="/%%DOCSDIR%%/s!^!%%PORTDOCS%%!g; /%%EXAMPLESDIR%%/s!^!%%PORTEXAMPLES%%!g;"
+	if [ ${makeplist} -eq 0 ]; then
+	#	echo "=====> Using OPTIONS: ${PORT_OPTIONS}" | /usr/bin/fmt -w 79 | \
+	#	    sed -e '2,$s/^/                      /'
+		# Handle magical PORT* features
+		for option in DOCS EXAMPLES; do
+			want_option=0
+			case " ${PORT_OPTIONS} " in
+			*\ ${option}\ *) want_option=1 ;;
+			esac
+			[ ${want_option} -eq 0 ] && \
+			    sed_portdocsexamples="${sed_portdocsexamples} /^%%PORT${option}%%/d;"
+		done
+		unset PORT_OPTIONS
+	fi
+
+	sed_plist_sub=$(echo "${PLIST_SUB_SED}" | /bin/sh ${SCRIPTSDIR}/plist_sub_sed_sort.sh)
+	unset PLIST_SUB_SED
+	sed_files="s!${PREFIX}/!!g; ${sed_plist_sub} ${sed_portdocsexamples} \
+	    /^share\/licenses/d;"
+
+	sed_dirs="s!${PREFIX}/!!g; ${sed_plist_sub} s,^,@dirrmtry ,; \
+	    ${sed_portdocsexamples} \
+	    s!@dirrmtry \(/.*\)!@unexec rmdir \"\1\" >/dev/null 2>\&1 || :!; \
+	    /^@dirrmtry share\/licenses/d;"
+}
+
+# Generate plist from staged files
+generate_plist() {
+	: >${WRKDIR}/.staged-plist
+
+	### HANDLE FILES
+	find ${STAGEDIR} -type f -o -type l | sort | \
+	    sed -e "s,${STAGEDIR},," >${WRKDIR}/.staged-files
+	comm -13 ${WRKDIR}/.plist-files ${WRKDIR}/.staged-files | \
+	    sed -e "${sed_files}" \
+	     >>${WRKDIR}/.staged-plist || :
+
+	### HANDLE DIRS
+	cat ${WRKDIR}/.plist-dirs-unsorted ${WRKDIR}/.mtree \
+	    ${WRKDIR}/.run-depends-dirs | sort -u >${WRKDIR}/.traced-dirs
+	find -sd ${STAGEDIR} -type d | sed -e "s,^${STAGEDIR},,;/^$/d" \
+	    >${WRKDIR}/.staged-dirs-dfs
+	sort ${WRKDIR}/.staged-dirs-dfs >${WRKDIR}/.staged-dirs-sorted
+	awk '{print FNR, $0}' ${WRKDIR}/.staged-dirs-dfs \
+	    >${WRKDIR}/.staged-dirs-dfs-sorted
+	# Find all staged dirs and then sort them by depth-first (find -ds)
+	comm -13 ${WRKDIR}/.traced-dirs ${WRKDIR}/.staged-dirs-sorted \
+	    | sort_dfs | sed "${sed_dirs}" \
+	    >>${WRKDIR}/.staged-plist || :
+}
+
+# Check for files in STAGEDIR missing from plist
+check_orphans_from_plist() {
+	local ret=0
+
+	echo "===> Checking for items in STAGEDIR missing from pkg-plist"
+	# Handle whitelisting
+	while read path; do
+		case "${path}" in
+		*.bak) ;;
+		*.orig) ;;
+		*/info/dir|info/dir) ;;
+		lib/X11/fonts/*/fonts.dir) ;;
+		lib/X11/fonts/*/fonts.scale) ;;
+		share/applications/mimeinfo.cache) ;;
+		share/mime/XMLnamespaces) ;;
+		share/mime/aliases) ;;
+		share/mime/generic-icons) ;;
+		share/mime/globs) ;;
+		share/mime/globs2) ;;
+		share/mime/icons) ;;
+		share/mime/magic) ;;
+		share/mime/mime.cache) ;;
+		share/mime/subclasses) ;;
+		share/mime/treemagic) ;;
+		share/mime/types) ;;
+		share/mime/version) ;;
+		*)
+			# An orphan was found, return non-zero status
+			ret=1
+			echo "Error: Orphaned: ${path}" >&2
+		;;
 		esac
-		[ ${want_option} -eq 0 ] && \
-		    sed_portdocsexamples="${sed_portdocsexamples} /^%%PORT${option}%%/d;"
-	done
-	unset PORT_OPTIONS
+	done < ${WRKDIR}/.staged-plist
+	return ${ret}
+}
+
+# Check for directories being removed that are handled by MTREE files.
+check_invalid_directories_mtree() {
+	local ret=0
+	# Anything listed in plist and in restricted-dirs is a failure. I.e.,
+	# it's owned by a run-time dependency or one of the MTREEs.
+	echo "===> Checking for directories owned by MTREEs"
+	cat ${WRKDIR}/.mtree | sort -u >${WRKDIR}/.restricted-dirs
+	: >${WRKDIR}/.invalid-plist-mtree
+	comm -12 ${WRKDIR}/.plist-dirs-sorted-no-comments \
+	    ${WRKDIR}/.restricted-dirs \
+	    | sort_dfs | sed "${sed_dirs}" \
+	    >>${WRKDIR}/.invalid-plist-mtree || :
+	if [ -s "${WRKDIR}/.invalid-plist-mtree" ]; then
+		ret=1
+		while read line; do
+			echo "Error: Owned by MTREE: ${line}" >&2
+		done < ${WRKDIR}/.invalid-plist-mtree
+	fi
+	return ${ret}
+}
+
+# Check for directories in plist that dependencies already handle.
+# XXX: This goes away when pkg learns auto dir tracking
+check_invalid_directories_from_dependencies() {
+	local ret=0
+	echo "===> Checking for directories handled by dependencies"
+	cat ${WRKDIR}/.run-depends-dirs | sort -u >${WRKDIR}/.restricted-dirs
+	: >${WRKDIR}/.invalid-plist-dependencies
+	comm -12 ${WRKDIR}/.plist-dirs-sorted-no-comments \
+	    ${WRKDIR}/.restricted-dirs \
+	    | sort_dfs | sed "${sed_dirs}" \
+	    >>${WRKDIR}/.invalid-plist-dependencies || :
+	if [ -s "${WRKDIR}/.invalid-plist-dependencies" ]; then
+	#	ret=1
+		while read line; do
+			echo "Warning: Possibly owned by dependency: ${line}" \
+			    >&2
+		done < ${WRKDIR}/.invalid-plist-dependencies
+	fi
+	return ${ret}
+}
+
+# Check for items in plist not in STAGEDIR (pkg lstat(2) errors)
+check_missing_plist_items() {
+	local ret=0
+	echo "===> Checking for items in pkg-plist which are not in STAGEDIR"
+	: >${WRKDIR}/.invalid-plist-missing
+	comm -23 ${WRKDIR}/.plist-files-no-comments ${WRKDIR}/.staged-files | \
+	    sed -e "${sed_files}" \
+	    >>${WRKDIR}/.invalid-plist-missing || :
+
+	# Look for directories, then sort them by DFS. Must create the dirs
+	# so find -ds can be used to sort them.
+	rm -rf ${WRKDIR}/.missing-dirs > /dev/null 2>&1 || :
+	mkdir ${WRKDIR}/.missing-dirs
+	comm -23 ${WRKDIR}/.plist-dirs-sorted-no-comments \
+	    ${WRKDIR}/.staged-dirs-sorted > ${WRKDIR}/.missing-plist-dirs
+	sed "s,^,${WRKDIR}/.missing-dirs," ${WRKDIR}/.missing-plist-dirs | \
+	    xargs mkdir -p
+	find -ds ${WRKDIR}/.missing-dirs | \
+	    sed -e "s,^${WRKDIR}/.missing-dirs,," | \
+	    while read dir; do \
+	    grep -x "${dir}" ${WRKDIR}/.missing-plist-dirs || :; done | \
+	    sed "${sed_dirs}" \
+	    >>${WRKDIR}/.invalid-plist-missing || :
+	rm -rf ${WRKDIR}/.missing-dirs
+	if [ -s "${WRKDIR}/.invalid-plist-missing" ]; then
+		ret=1
+		while read line; do
+			echo "Error: Missing: ${line}" >&2
+		done < ${WRKDIR}/.invalid-plist-missing
+	fi
+	return ${ret}
+}
+
+# obtain operating mode from command line
+ret=0
+makeplist=0
+case "$1" in
+	checkplist)	;;
+	makeplist)	makeplist=1 ;;
+	*) echo >&2 "Usage: $0 {checkplist|makelist}" ; exit 1 ;;
+esac
+
+# validate environment
+envfault=
+for i in STAGEDIR PREFIX LOCALBASE WRKDIR WRKSRC MTREE_FILE GNOME_MTREE_FILE \
+    TMPPLIST PLIST_SUB_SED SCRIPTSDIR PACKAGE_DEPENDS WITH_PKGNG PKG_QUERY \
+    PORT_OPTIONS NO_PREFIX_RMDIR
+do
+    if ! ( eval ": \${${i}?}" ) 2>/dev/null ; then
+		envfault="${envfault}${envfault:+" "}${i}"
+    fi
+done
+if [ -n "$envfault" ] ; then
+	echo "Environment variables $envfault undefined. Aborting." \
+	| fmt >&2
+	exit 1
 fi
 
-sed_plist_sub=$(echo "${PLIST_SUB_SED}" | /bin/sh ${SCRIPTSDIR}/plist_sub_sed_sort.sh)
-unset PLIST_SUB_SED
-sed_files="s!${PREFIX}/!!g; ${sed_plist_sub} ${sed_portdocsexamples} \
-    /^share\/licenses/d;"
-
-sed_dirs="s!${PREFIX}/!!g; ${sed_plist_sub} s,^,@dirrmtry ,; \
-    ${sed_portdocsexamples} \
-    s!@dirrmtry \(/.*\)!@unexec rmdir \"\1\" >/dev/null 2>\&1 || :!; \
-    /^@dirrmtry share\/licenses/d;"
-
-# If checking orphans, send all output to a temp file so whitelisting can be
-# done
-: >${WRKDIR}/.staged-plist
-
-### HANDLE FILES
-find ${STAGEDIR} -type f -o -type l | sort | \
-    sed -e "s,${STAGEDIR},," >${WRKDIR}/.staged-files
-comm -13 ${WRKDIR}/.plist-files ${WRKDIR}/.staged-files | \
-    sed -e "${sed_files}" \
-     >>${WRKDIR}/.staged-plist || :
-
-### HANDLE DIRS
-cat ${WRKDIR}/.plist-dirs-unsorted ${WRKDIR}/.mtree \
-    ${WRKDIR}/.run-depends-dirs | sort -u >${WRKDIR}/.traced-dirs
-find -sd ${STAGEDIR} -type d | sed -e "s,^${STAGEDIR},,;/^$/d" \
-    >${WRKDIR}/.staged-dirs-dfs
-sort ${WRKDIR}/.staged-dirs-dfs >${WRKDIR}/.staged-dirs-sorted
-awk '{print FNR, $0}' ${WRKDIR}/.staged-dirs-dfs \
-    >${WRKDIR}/.staged-dirs-dfs-sorted
-# Find all staged dirs and then sort them by depth-first (find -ds)
-comm -13 ${WRKDIR}/.traced-dirs ${WRKDIR}/.staged-dirs-sorted \
-    | sort_dfs | sed "${sed_dirs}" \
-    >>${WRKDIR}/.staged-plist || :
+set -u
+
+if [ $makeplist = 0 ] ; then
+	parse_plist
+else
+	# generate plist - pretend the plist had been empty
+	: >${WRKDIR}/.plist-dirs-unsorted
+	: >${WRKDIR}/.plist-files
+	echo '/you/have/to/check/what/makeplist/gives/you'
+fi
+
+parse_mtree
+
+lookup_dependency_dirs
+unset PACKAGE_DEPENDS PKG_QUERY
+
+setup_plist_seds
+generate_plist
 
 # If just making plist, show results and exit successfully.
 if [ ${makeplist} -eq 1 ]; then
@@ -300,91 +432,15 @@ if [ ${makeplist} -eq 1 ]; then
 	exit 0
 fi
 
-# Handle whitelisting
-while read path; do
-	case "${path}" in
-	*.bak) ;;
-	*.orig) ;;
-	*/info/dir|info/dir) ;;
-	lib/X11/fonts/*/fonts.dir) ;;
-	lib/X11/fonts/*/fonts.scale) ;;
-	share/applications/mimeinfo.cache) ;;
-	share/mime/XMLnamespaces) ;;
-	share/mime/aliases) ;;
-	share/mime/generic-icons) ;;
-	share/mime/globs) ;;
-	share/mime/globs2) ;;
-	share/mime/icons) ;;
-	share/mime/magic) ;;
-	share/mime/mime.cache) ;;
-	share/mime/subclasses) ;;
-	share/mime/treemagic) ;;
-	share/mime/types) ;;
-	share/mime/version) ;;
-	*)
-		# An orphan was found, return non-zero status
-		ret=1
-		echo "Error: Orphaned: ${path}" >&2
-	;;
-	esac
-done < ${WRKDIR}/.staged-plist
+check_orphans_from_plist || ret=1
 
+# Prepare plist-dirs for directory checks
 sort -u ${WRKDIR}/.plist-dirs-unsorted-no-comments \
     >${WRKDIR}/.plist-dirs-sorted-no-comments
 
-# Anything listed in plist and in restricted-dirs is a failure. I.e.,
-# it's owned by a run-time dependency or one of the MTREEs.
-echo "===> Checking for directories owned by MTREEs"
-cat ${WRKDIR}/.mtree | sort -u >${WRKDIR}/.restricted-dirs
-: >${WRKDIR}/.invalid-plist-mtree
-comm -12 ${WRKDIR}/.plist-dirs-sorted-no-comments ${WRKDIR}/.restricted-dirs \
-    | sort_dfs | sed "${sed_dirs}" \
-    >>${WRKDIR}/.invalid-plist-mtree || :
-if [ -s "${WRKDIR}/.invalid-plist-mtree" ]; then
-	ret=1
-	while read line; do
-		echo "Error: Owned by MTREE: ${line}" >&2
-	done < ${WRKDIR}/.invalid-plist-mtree
-fi
-
-echo "===> Checking for directories handled by dependencies"
-cat ${WRKDIR}/.run-depends-dirs | sort -u >${WRKDIR}/.restricted-dirs
-: >${WRKDIR}/.invalid-plist-dependencies
-comm -12 ${WRKDIR}/.plist-dirs-sorted-no-comments ${WRKDIR}/.restricted-dirs \
-    | sort_dfs | sed "${sed_dirs}" \
-    >>${WRKDIR}/.invalid-plist-dependencies || :
-if [ -s "${WRKDIR}/.invalid-plist-dependencies" ]; then
-#	ret=1
-	while read line; do
-		echo "Warning: Possibly owned by dependency: ${line}" >&2
-	done < ${WRKDIR}/.invalid-plist-dependencies
-fi
-
-echo "===> Checking for items in pkg-plist which are not in STAGEDIR"
-: >${WRKDIR}/.invalid-plist-missing
-comm -23 ${WRKDIR}/.plist-files-no-comments ${WRKDIR}/.staged-files | \
-    sed -e "${sed_files}" \
-    >>${WRKDIR}/.invalid-plist-missing || :
-
-# Look for directories, then sort them by DFS. Must create the dirs
-# so find -ds can be used to sort them.
-rm -rf ${WRKDIR}/.missing-dirs > /dev/null 2>&1 || :
-mkdir ${WRKDIR}/.missing-dirs
-comm -23 ${WRKDIR}/.plist-dirs-sorted-no-comments \
-    ${WRKDIR}/.staged-dirs-sorted > ${WRKDIR}/.missing-plist-dirs
-sed "s,^,${WRKDIR}/.missing-dirs," ${WRKDIR}/.missing-plist-dirs | \
-    xargs mkdir -p
-find -ds ${WRKDIR}/.missing-dirs | sed -e "s,^${WRKDIR}/.missing-dirs,," | \
-    while read dir; do grep -x "${dir}" ${WRKDIR}/.missing-plist-dirs || :; done | \
-    sed "${sed_dirs}" \
-    >>${WRKDIR}/.invalid-plist-missing || :
-rm -rf ${WRKDIR}/.missing-dirs
-if [ -s "${WRKDIR}/.invalid-plist-missing" ]; then
-	ret=1
-	while read line; do
-		echo "Error: Missing: ${line}" >&2
-	done < ${WRKDIR}/.invalid-plist-missing
-fi
+check_invalid_directories_mtree || ret=1
+check_invalid_directories_from_dependencies || ret=1
+check_missing_plist_items || ret=1
 
 if [ ${ret} -ne 0 ]; then
 	echo "===> Error: Plist issues found." >&2



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404242230.s3OMU5PD072205>