aboutsummaryrefslogtreecommitdiffstats
path: root/Mk
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2014-04-22 00:22:20 +0800
committerbdrewery <bdrewery@FreeBSD.org>2014-04-22 00:22:20 +0800
commit2b29420b5fd071704e7c00d545884e36048b46a1 (patch)
tree387937a8fcdb3f4d93af88ba9bb05be20a3fa052 /Mk
parentbf1996c0e142cf36f0d0ef83892db042c88049ca (diff)
downloadfreebsd-ports-gnome-2b29420b5fd071704e7c00d545884e36048b46a1.tar.gz
freebsd-ports-gnome-2b29420b5fd071704e7c00d545884e36048b46a1.tar.zst
freebsd-ports-gnome-2b29420b5fd071704e7c00d545884e36048b46a1.zip
- Sort directories by Lexicographical Depth-First order (find -ds)
With hat: portmgr
Diffstat (limited to 'Mk')
-rw-r--r--Mk/Scripts/check-stagedir.sh34
1 files changed, 27 insertions, 7 deletions
diff --git a/Mk/Scripts/check-stagedir.sh b/Mk/Scripts/check-stagedir.sh
index 0f7af97956c4..dfab7de31c67 100644
--- a/Mk/Scripts/check-stagedir.sh
+++ b/Mk/Scripts/check-stagedir.sh
@@ -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}/.staged-files | \
### 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-depends-dirs | sort -u \
>${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-comments ${WRKDIR}/.staged-files | \
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