Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Apr 2014 16:22:20 +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: r351693 - head/Mk/Scripts
Message-ID:  <201404211622.s3LGMKkF014781@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Mon Apr 21 16:22:20 2014
New Revision: 351693
URL: http://svnweb.freebsd.org/changeset/ports/351693
QAT: https://qat.redports.org/buildarchive/r351693/

Log:
  - Sort directories by Lexicographical Depth-First order (find -ds)
  
  With hat:	portmgr

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

Modified: head/Mk/Scripts/check-stagedir.sh
==============================================================================
--- head/Mk/Scripts/check-stagedir.sh	Mon Apr 21 16:11:18 2014	(r351692)
+++ head/Mk/Scripts/check-stagedir.sh	Mon Apr 21 16:22:20 2014	(r351693)
@@ -23,6 +23,12 @@ listmtree() { # mtreefile prefix
 	} | 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
@@ -234,10 +240,14 @@ comm -13 ${WRKDIR}/.plist-files ${WRKDIR
 ### HANDLE DIRS
 cat ${WRKDIR}/.plist-dirs-unsorted ${WRKDIR}/.mtree \
     ${WRKDIR}/.run-depends-dirs | sort -u >${WRKDIR}/.traced-dirs
-find ${STAGEDIR} -type d | sed -e "s,^${STAGEDIR},,;/^$/d" | \
-    sort >${WRKDIR}/.staged-dirs
-comm -13 ${WRKDIR}/.traced-dirs ${WRKDIR}/.staged-dirs \
-    | sort -r | sed "${sed_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 || :
 
 # If just making plist, show results and exit successfully.
@@ -270,7 +280,7 @@ cat ${WRKDIR}/.mtree ${WRKDIR}/.run-depe
     >${WRKDIR}/.restricted-dirs
 : >${WRKDIR}/.invalid-plist-dependencies
 comm -12 ${WRKDIR}/.plist-dirs-sorted-no-comments ${WRKDIR}/.restricted-dirs \
-    | sort -r | sed "${sed_dirs}" \
+    | sort_dfs | sed "${sed_dirs}" \
     >>${WRKDIR}/.invalid-plist-dependencies || :
 if [ -s "${WRKDIR}/.invalid-plist-dependencies" ]; then
 	ret=1
@@ -285,9 +295,19 @@ comm -23 ${WRKDIR}/.plist-files-no-comme
     sed -e "${sed_files}" \
     >>${WRKDIR}/.invalid-plist-missing || :
 
-comm -23 ${WRKDIR}/.plist-dirs-sorted-no-comments ${WRKDIR}/.staged-dirs \
-    | sort -r | sed "${sed_dirs}" \
+# 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



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