Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Jul 2007 19:44:42 -0500
From:      Stephen Montgomery-Smith <stephen@math.missouri.edu>
To:        ports@freebsd.org
Subject:   Speedup for pkg_version
Message-ID:  <46ABE2FA.8030607@math.missouri.edu>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------050709070607040801020400
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

This is a kludge, but it makes pkg_version 4 times faster on my set up. 
  The idea is that "make -V PKGNAME" should ordinarily be a very fast 
operation.  So it runs a very cut down version of bsd.port.mk.  If that 
bombs with an error, then it does the full bsd.port.mk.

Maybe portsmanager and similar tools could use this idea.


--------------050709070607040801020400
Content-Type: text/plain;
 name="ddd"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ddd"

--- usr.sbin/pkg_install/version/perform.c-orig	2007-07-28 19:20:33.000000000 -0500
+++ usr.sbin/pkg_install/version/perform.c	2007-07-28 19:24:23.000000000 -0500
@@ -124,6 +124,30 @@
  * we look for it's corresponding Makefile. If that fails we pull in
  * the INDEX, and check there.
  */
+char exec_string[] = 
+"makefile=`grep -v -E '\\.include.*\\<bsd\\.port\\.' Makefile`\n"
+"if ! make -V PKGNAME -f - 2>/dev/null <<EOM\n"
+"$makefile\n"
+".if defined(PORTVERSION)\n"
+"DISTVERSION?=	\\${PORTVERSION:S/:/::/g}\n"
+".elif defined(DISTVERSION)\n"
+"PORTVERSION=	\\${DISTVERSION:L:C/([a-z])[a-z]+/\\1/g:C/([0-9])([a-z])/\\1.\\2/g:C/:(.)/\\1/g:C/[^a-z0-9+]+/./g}\n"
+".endif\n"
+"PORTREVISION?=	0\n"
+".if \\${PORTREVISION} != 0\n"
+"_SUF1=	_\\${PORTREVISION}\n"
+".endif\n"
+"PORTEPOCH?=		0\n"
+".if \\${PORTEPOCH} != 0\n"
+"_SUF2=	,\\${PORTEPOCH}\n"
+".endif\n"
+"PKGVERSION=	\\${PORTVERSION:C/[-_,]/./g}\\${_SUF1}\\${_SUF2}\n"
+"PKGNAME=	\\${PKGNAMEPREFIX}\\${PORTNAME}\\${PKGNAMESUFFIX}-\\${PKGVERSION}\n"
+"DISTNAME?=	\\${PORTNAME}-\\${DISTVERSIONPREFIX}\\${DISTVERSION:C/:(.)/\\1/g}\\${DISTVERSIONSUFFIX}\n"
+"EOM\n"
+"then make -V PKGNAME\n"
+"fi\n";
+
 static int
 pkg_do(char *pkg)
 {
@@ -158,7 +182,7 @@
     if (plist.origin != NULL && !UseINDEXOnly) {
 	snprintf(tmp, PATH_MAX, "%s/%s", PORTS_DIR, plist.origin);
 	if (isdir(tmp) && chdir(tmp) != FAIL && isfile("Makefile")) {
-	    if ((latest = vpipe("/usr/bin/make -V PKGNAME", tmp)) == NULL)
+	    if ((latest = vpipe(exec_string, tmp)) == NULL)
 		warnx("Failed to get PKGNAME from %s/Makefile!", tmp);
 	    else
 		show_version(plist, latest, "port");

--------------050709070607040801020400--



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