Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Mar 2019 22:54:34 +0000 (UTC)
From:      Rene Ladan <rene@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r494751 - head/Tools/scripts
Message-ID:  <201903052254.x25MsYCt087116@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rene
Date: Tue Mar  5 22:54:34 2019
New Revision: 494751
URL: https://svnweb.freebsd.org/changeset/ports/494751

Log:
  rmport: fix and speed up the find_expired() function.
  
  find_expired() is used with -F (report on all expired ports using the
  format "date category/port: reason") and -a (remove all expired ports).
  
  Some speedups:
  - only calculate the deprecation reason for -F
  - use nested loops instead of nested recursion for traversing all ports.
    The nested recursion would also stop after finding the first port.
  
  Approved by:	maintainer (crees) (implicit, fixit)

Modified:
  head/Tools/scripts/rmport

Modified: head/Tools/scripts/rmport
==============================================================================
--- head/Tools/scripts/rmport	Tue Mar  5 22:00:40 2019	(r494750)
+++ head/Tools/scripts/rmport	Tue Mar  5 22:54:34 2019	(r494751)
@@ -116,27 +116,21 @@ find_catport()
 	fi
 }
 
-find_expired() # [category [port]]
+find_expired()
 {
-	EXPVAR=EXPIRATION_DATE
-
-	# Called bare, just discovers categories
-	if [ -z "$1" ]; then
-		for category in $(make -C ${PORTSDIR} -VSUBDIR); do
-			find_expired $category
+	for category in $(make -C ${PORTSDIR} -V SUBDIR); do
+		for port in $(make -C ${PORTSDIR}/${category} -V SUBDIR); do
+			DATE="$(make -C ${PORTSDIR}/${category}/${port} -V EXPIRATION_DATE)"
+			if [ -n "${DATE}" -a ! "${DATE}" \> "${TODAY}" ] ; then
+				if [ "$1" = 1 ] ; then
+					echo -n "${DATE} ${category}/${port}: "
+					make -C ${PORTSDIR}/${category}/${port} -V DEPRECATED
+				else
+					echo "${category}/${port}"
+				fi
+			fi
 		done
-	elif [ -z "$2" ]; then
-		for port in $(make -C ${PORTSDIR}/$1 -VSUBDIR); do
-			find_expired $1 $port
-		done
-	else
-		DATE="$(make -C${PORTSDIR}/$1/$2 -V${EXPVAR})"
-		[ -n "$DATE" ] || return
-		if [ ! "$DATE" \> "${TODAY}" ]; then
-			echo "${DATE} $1/$2: ";
-			make -C${PORTSDIR}/$1/$2 -VDEPRECATED
-		fi
-	fi
+	done
 }
 
 # create temporary checkout directory
@@ -496,7 +490,7 @@ if [ ${1} = "-F" ] ; then
 	if [ ${#} -ne 1 ] ; then
 		usage
 	fi
-	find_expired
+	find_expired 1
 	exit
 fi
 
@@ -504,7 +498,7 @@ if [ ${1} = "-a" ] ; then
 	if [ ${#} -ne 1 ] ; then
 		usage
 	fi
-	${0} `find_expired |cut -f 2 -d ' ' |cut -f 1 -d :`
+	${0} `find_expired 0`
 	exit
 fi
 



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