Subject: mk/bulk/post-build portability
To: None <tech-pkg@netbsd.org>
From: Gavan Fantom <gavan@coolfactor.org>
List: tech-pkg
Date: 08/18/2003 14:30:54
I've reimplemented a couple of bits in mk/bulk/post-build to remove
dependence on RCS indent and a powerful awk. This aids portability to
Solaris, and also means we're not calling awk quite so much to do work
that perl really ought to be able to do.

Any objections if I commit this?

Index: post-build
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bulk/post-build,v
retrieving revision 1.22
diff -b -u -r1.22 post-build
--- post-build	2003/05/06 17:42:03	1.22
+++ post-build	2003/08/18 13:39:36
@@ -135,15 +135,25 @@
 	$nunpackaged++;
     }

-    # The idea of this is stolen from bsd.pkg.mk's
-    # show-pkgtools-version target - thanks Al! :-)
-    $whofile = `find ${USR_PKGSRC}/${pkg} -type f -print  | xargs ident 2>/dev/null | awk '\$1 ~ /\\\$NetBSD/ { gsub("/", "", \$4); print \$4 " " \$6 " " \$2 }' | sort -n | tail -n 1 | awk '{ print \$2 " " \$3 }' `;
-    $whofile=~s/,v$//;
-    chomp($whofile);
-    ($who,$file) = split(/\s+/, $whofile);
+    @idents = `find ${USR_PKGSRC}/${pkg} -type f -print | xargs grep \\\$NetBSD`;
+    $datetime = "";
+    $who = "nobody";
+    $file = "";
+    $ver = "";
+    foreach $ident (@idents) {
+	$ident =~ /\$NetBSD: ([^ ]*),v ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) Exp \$/;
+	if ("$3 $4" gt $datetime) {
+	    $datetime = "$3 $4";
+	    $who = $5;
+	    $file = $1;
+	    $ver = $1;
+	}
+    }

-    # $maintainer=`( cd $USR_PKGSRC/$pkg ; ( echo '.include "Makefile"' ; echo 'bla: ; \@echo ${MAINTAINER}' ) | $ENV{"BMAKE"} -f - bla )`;
-    $maintainer=`grep ^MAINTAINER $USR_PKGSRC/$pkg/Makefile | awk '{ print \$2\$3\$4\$5\$6}' | sed -e 's/\</&lt;/g' -e 's/\>/&gt;/g'`;
+    $maintainer=`grep ^MAINTAINER $USR_PKGSRC/$pkg/Makefile`;
+    $maintainer =~ s/MAINTAINER=[ \t]*//;
+    $maintainer =~ s/</&lt;/g;
+    $maintainer =~ s/>/&gt;/g;
     chomp($maintainer);

     print HTML "<TR><TD><A HREF=\"$bf\">$pkg</A>";


-- 
Gillette - the best a man can forget