Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Apr 2007 21:11:39 -0600
From:      "James E. Flemer" <jflemer@uvm.edu>
To:        ports@freebsd.org
Cc:        James Flemer <jflemer@uvm.edu>
Subject:   Tracking port and package flags/options
Message-ID:  <46258C6B.2050407@uvm.edu>

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

[Please maintain CC.]

Here are some patches to the FreeBSD package tools, and the ports 
infrastructure to track make flags/options used to build a port/package. 
  I've been using these changes locally for something like 2-3 years. 
This greatly helps me manage packages across several machines, and 
across port upgrades.

There are some quirks, such as recursively built ports inherit the port 
flags used for the explicitly built port.  Sometimes this recursive 
behavior is intentional, but most often the implicitly built ports do 
not necessarily use the flags for the explicitly built port.

There are also two other unrelated tweaks to the ports infrastructure in 
the patch, but I've included them as I've been using them for a long 
time as well.  First is to make backups when using USE_DOS2UNIX.  Second 
is to change dependency tracking to first-order only (versus recursive); 
see http://docs.freebsd.org/cgi/mid.cgi?427E4687.40901 for previous 
discussion.

I'm posting these now, as I see there are at least two SoC projects 
aimed at the ports/package infrastructure, and perhaps these changes 
(conceptual or implementation) could be considered by the SoC 
participants for incorporation.

-James

--------------070205080408030608040608
Content-Type: text/x-patch;
 name="pkgtools.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pkgtools.diff"

#
# Updates to FreeBSD package tools to track compile flags/options
# for ports/packages.
#
# Submitted By: James Flemer <jflemer@alum.rpi.edu>
#
Index: usr.sbin/pkg_install/add/perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/add/perform.c,v
retrieving revision 1.77.8.3
diff -u -b -u -r1.77.8.3 perform.c
--- usr.sbin/pkg_install/add/perform.c	14 May 2006 06:52:24 -0000	1.77.8.3
+++ usr.sbin/pkg_install/add/perform.c	18 Apr 2007 02:30:02 -0000
@@ -238,6 +238,8 @@
 	Plist.name = "anonymous";
     if (Plist.origin == NULL)
 	Plist.origin = "anonymous/anonymous";
+    if (Plist.makeflags == NULL)
+	Plist.makeflags = "";
 
     /*
      * See if we're already registered either with the same name (the same
Index: usr.sbin/pkg_install/create/create.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/create.h,v
retrieving revision 1.25.2.1
diff -u -b -u -r1.25.2.1 create.h
--- usr.sbin/pkg_install/create/create.h	11 Nov 2005 08:07:24 -0000	1.25.2.1
+++ usr.sbin/pkg_install/create/create.h	18 Apr 2007 02:30:02 -0000
@@ -41,6 +41,7 @@
 extern char	*Pkgdeps;
 extern char	*Conflicts;
 extern char	*Origin;
+extern char	*Makeflags;
 extern char	*InstalledPkg;
 extern char	PlayPen[];
 extern int	Dereference;
Index: usr.sbin/pkg_install/create/main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/main.c,v
retrieving revision 1.36.2.2
diff -u -b -u -r1.36.2.2 main.c
--- usr.sbin/pkg_install/create/main.c	14 May 2006 07:01:47 -0000	1.36.2.2
+++ usr.sbin/pkg_install/create/main.c	18 Apr 2007 02:30:02 -0000
@@ -16,7 +16,7 @@
 #include "lib.h"
 #include "create.h"
 
-static char Options[] = "EGYNORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:";
+static char Options[] = "EGYNORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:F:b:";
 
 match_t	MatchType	= MATCH_GLOB;
 char	*Prefix		= NULL;
@@ -36,6 +36,7 @@
 char	*Pkgdeps	= NULL;
 char	*Conflicts	= NULL;
 char	*Origin		= NULL;
+char	*Makeflags	= NULL;
 char	*InstalledPkg	= NULL;
 char	PlayPen[FILENAME_MAX];
 int	Dereference	= FALSE;
@@ -163,6 +164,10 @@
 	    Origin = optarg;
 	    break;
 
+	case 'F':
+	    Makeflags = optarg;
+	    break;
+
 	case 'y':
 	case 'j':
 	    Zipper = BZIP2;
@@ -231,7 +236,7 @@
 "usage: pkg_create [-YNOhvyz] [-P pkgs] [-C conflicts] [-p prefix] ",
 "                  [-i iscript] [-I piscript] [-k dscript] [-K pdscript] ",
 "                  [-r rscript] [-t template] [-X excludefile] ",
-"                  [-D displayfile] [-m mtreefile] [-o origin] ",
+"                  [-D displayfile] [-m mtreefile] [-o origin] [-F flags]",
 "                  [-s srcdir] [-S basedir] ",
 "                  -c comment -d description -f packlist pkg-filename",
 "       pkg_create [-EGYNhvxyzR] -b pkg-name [pkg-filename]");
Index: usr.sbin/pkg_install/create/perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/perform.c,v
retrieving revision 1.80.2.2
diff -u -b -u -r1.80.2.2 perform.c
--- usr.sbin/pkg_install/create/perform.c	10 Jan 2006 22:15:05 -0000	1.80.2.2
+++ usr.sbin/pkg_install/create/perform.c	18 Apr 2007 02:30:03 -0000
@@ -210,6 +210,10 @@
     if (Prefix)
 	add_plist_top(&plist, PLIST_CWD, Prefix);
 
+    /* Add the make flags if asked, at the top */
+    if (Makeflags)
+	add_plist_top(&plist, PLIST_MAKEFLAGS, Makeflags);
+
     /* Add the origin if asked, at the top */
     if (Origin)
 	add_plist_top(&plist, PLIST_ORIGIN, Origin);
Index: usr.sbin/pkg_install/create/pkg_create.1
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/create/pkg_create.1,v
retrieving revision 1.68.2.2
diff -u -b -u -r1.68.2.2 pkg_create.1
--- usr.sbin/pkg_install/create/pkg_create.1	10 Jan 2006 22:15:05 -0000	1.68.2.2
+++ usr.sbin/pkg_install/create/pkg_create.1	18 Apr 2007 02:30:03 -0000
@@ -47,6 +47,7 @@
 .Op Fl D Ar displayfile
 .Op Fl m Ar mtreefile
 .Op Fl o Ar originpath
+.Op Fl F Ar flags
 .Fl c Ar comment
 .Fl d Ar description
 .Fl f Ar packlist
@@ -304,6 +305,10 @@
 .Em "Ports Collection" .
 It should be in the form
 .Pa MASTERCATEGORY/PORTDIR .
+.It Fl F Ar flags
+Record
+.Ar flags ,
+as the make flags with which the package has been built.
 .It Fl j
 Use
 .Xr bzip2 1
Index: usr.sbin/pkg_install/info/info.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/info.h,v
retrieving revision 1.28.2.1
diff -u -b -u -r1.28.2.1 info.h
--- usr.sbin/pkg_install/info/info.h	16 Jan 2006 19:48:17 -0000	1.28.2.1
+++ usr.sbin/pkg_install/info/info.h	18 Apr 2007 02:30:03 -0000
@@ -52,6 +52,7 @@
 #define SHOW_PTREV	0x10000
 #define SHOW_DEPEND	0x20000
 #define SHOW_PKGNAME	0x40000
+#define SHOW_MAKEFLAGS	0x80000
 
 struct which_entry {
     TAILQ_ENTRY(which_entry) next;
@@ -79,6 +80,7 @@
 extern void	show_size(const char *, Package *);
 extern void	show_cksum(const char *, Package *);
 extern void	show_origin(const char *, Package *);
+extern void	show_makeflags(const char *, Package *);
 extern void	show_fmtrev(const char *, Package *);
 
 #endif	/* _INST_INFO_H_INCLUDE */
Index: usr.sbin/pkg_install/info/main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/main.c,v
retrieving revision 1.47.2.2
diff -u -b -u -r1.47.2.2 main.c
--- usr.sbin/pkg_install/info/main.c	16 Jan 2006 19:48:17 -0000	1.47.2.2
+++ usr.sbin/pkg_install/info/main.c	18 Apr 2007 02:30:03 -0000
@@ -26,7 +26,7 @@
 #include "info.h"
 #include <err.h>
 
-static char Options[] = "abcdDe:EfgGhiIjkKl:LmoO:pPqQrRst:vVW:xX";
+static char Options[] = "abcdDe:EfFgGhiIjkKl:LmoO:pPqQrRst:vVW:xX";
 
 int	Flags		= 0;
 match_t	MatchType	= MATCH_GLOB;
@@ -151,6 +151,10 @@
 	    Flags |= SHOW_ORIGIN;
 	    break;
 
+	case 'F':
+	    Flags |= SHOW_MAKEFLAGS;
+	    break;
+
 	case 'O':
 	    LookUpOrigin = strdup(optarg);
 	    if (LookUpOrigin == NULL)
@@ -266,7 +270,7 @@
 usage()
 {
     fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
-	"usage: pkg_info [-bcdDEfgGiIjkKLmopPqQrRsvVxX] [-e package] [-l prefix]",
+	"usage: pkg_info [-bcdDEfFgGiIjkKLmopPqQrRsvVxX] [-e package] [-l prefix]",
 	"                [-t template] -a | pkg-name ...",
 	"       pkg_info [-qQ] -W filename",
 	"       pkg_info [-qQ] -O origin",
Index: usr.sbin/pkg_install/info/perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/perform.c,v
retrieving revision 1.53.8.1
diff -u -b -u -r1.53.8.1 perform.c
--- usr.sbin/pkg_install/info/perform.c	16 Jan 2006 19:48:17 -0000	1.53.8.1
+++ usr.sbin/pkg_install/info/perform.c	18 Apr 2007 02:30:03 -0000
@@ -221,6 +221,8 @@
 	    show_cksum("Mismatched Checksums:\n", &plist);
 	if (Flags & SHOW_ORIGIN)
 	    show_origin("Origin:\n", &plist);
+	if (Flags & SHOW_MAKEFLAGS)
+	    show_makeflags("Make flags:\n", &plist);
 	if (Flags & SHOW_FMTREV)
 	    show_fmtrev("Packing list format revision:\n", &plist);
 	if (!Quiet)
Index: usr.sbin/pkg_install/info/pkg_info.1
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/pkg_info.1,v
retrieving revision 1.54.2.2
diff -u -b -u -r1.54.2.2 pkg_info.1
--- usr.sbin/pkg_install/info/pkg_info.1	16 Jan 2006 19:48:17 -0000	1.54.2.2
+++ usr.sbin/pkg_install/info/pkg_info.1	18 Apr 2007 02:30:03 -0000
@@ -25,7 +25,7 @@
 .Nd a utility for displaying information on software packages
 .Sh SYNOPSIS
 .Nm
-.Op Fl bcdDEfgGijIkKLmopPqQrRsvVxX
+.Op Fl bcdDEfFgGijIkKLmopPqQrRsvVxX
 .Op Fl e Ar package
 .Op Fl l Ar prefix
 .Op Fl t Ar template
@@ -94,6 +94,8 @@
 Show the install-message file for each package.
 .It Fl f
 Show the packing list instructions for each package.
+.It Fl F
+Show the make flags for each package.
 .It Fl g
 Show files that do not match the recorded checksum.
 .It Fl i
Index: usr.sbin/pkg_install/info/show.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/info/show.c,v
retrieving revision 1.38.2.3
diff -u -b -u -r1.38.2.3 show.c
--- usr.sbin/pkg_install/info/show.c	14 Feb 2007 09:33:34 -0000	1.38.2.3
+++ usr.sbin/pkg_install/info/show.c	18 Apr 2007 02:30:03 -0000
@@ -197,6 +197,11 @@
 		"\tPackage origin: %s\n", p->name); 
 	    break;
 
+	case PLIST_MAKEFLAGS:
+	    printf(Quiet ? "@comment MAKEFLAGS:%s\n" :
+		"\tMake flags: %s\n", p->name); 
+	    break;
+
 	default:
 	    cleanup(0);
 	    errx(2, "%s: unknown command type %d (%s)",
@@ -370,6 +375,16 @@
     printf("%s\n", plist->origin != NULL ? plist->origin : "");
 }
 
+/* Show make flags */
+void
+show_makeflags(const char *title, Package *plist)
+{
+
+    if (!Quiet)
+	printf("%s%s", InfoPrefix, title);
+    printf("%s\n", plist->makeflags != NULL ? plist->makeflags : "");
+}
+
 /* Show revision number of the packing list */
 void
 show_fmtrev(const char *title, Package *plist)
Index: usr.sbin/pkg_install/lib/lib.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/lib.h,v
retrieving revision 1.56.2.2
diff -u -b -u -r1.56.2.2 lib.h
--- usr.sbin/pkg_install/lib/lib.h	14 May 2006 07:06:37 -0000	1.56.2.2
+++ usr.sbin/pkg_install/lib/lib.h	18 Apr 2007 02:30:03 -0000
@@ -111,7 +111,7 @@
     PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY,
     PLIST_PKGDEP, PLIST_CONFLICTS, PLIST_MTREE, PLIST_DIR_RM,
     PLIST_IGNORE_INST, PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN,
-    PLIST_NOINST
+    PLIST_NOINST, PLIST_MAKEFLAGS
 };
 typedef enum _plist_t plist_t;
 
@@ -135,6 +135,7 @@
     struct _plist *head, *tail;
     const char *name;
     const char *origin;
+    const char *makeflags;
     int fmtver_maj, fmtver_mnr;
 };
 typedef struct _pack Package;
Index: usr.sbin/pkg_install/lib/plist.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/lib/plist.c,v
retrieving revision 1.50.2.1
diff -u -b -u -r1.50.2.1 plist.c
--- usr.sbin/pkg_install/lib/plist.c	10 Jan 2006 22:15:06 -0000	1.50.2.1
+++ usr.sbin/pkg_install/lib/plist.c	18 Apr 2007 02:30:03 -0000
@@ -51,6 +51,10 @@
 	p->origin = tmp->name;
 	break;
 
+    case PLIST_MAKEFLAGS:
+	p->makeflags = tmp->name;
+	break;
+
     default:
 	break;
     }
@@ -228,6 +232,9 @@
 	if (!strncmp(*arg, "ORIGIN:", 7)) {
 	    *arg += 7;
 	    return PLIST_ORIGIN;
+	} else if (!strncmp(*arg, "MAKEFLAGS:", 10)) {
+	    *arg += 10;
+	    return PLIST_MAKEFLAGS;
 	} else if (!strncmp(*arg, "DEPORIGIN:", 10)) {
 	    *arg += 10;
 	    return PLIST_DEPORIGIN;
@@ -265,6 +272,7 @@
     pkg->fmtver_maj = 1;
     pkg->fmtver_mnr = 0;
     pkg->origin = NULL;
+    pkg->makeflags = NULL;
     while (fgets(pline, FILENAME_MAX, fp)) {
 	int len = strlen(pline);
 
@@ -392,6 +400,10 @@
 	    fprintf(fp, "%ccomment ORIGIN:%s\n", CMD_CHAR, plist->name);
 	    break;
 
+	case PLIST_MAKEFLAGS:
+	    fprintf(fp, "%ccomment MAKEFLAGS:%s\n", CMD_CHAR, plist->name);
+	    break;
+
 	case PLIST_DEPORIGIN:
 	    fprintf(fp, "%ccomment DEPORIGIN:%s\n", CMD_CHAR, plist->name);
 	    break;

--------------070205080408030608040608
Content-Type: text/x-patch;
 name="ports_Mk.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ports_Mk.diff"

#
# Updates to FreeBSD port infrastructure to track compile flags/options
# for ports.
#
# There are a few other tiny tweaks in this diff as well...
#   See: http://docs.freebsd.org/cgi/mid.cgi?427E4687.40901
#
# Submitted By: James Flemer <jflemer@alum.rpi.edu>
#
Index: Mk/bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.545
diff -u -b -u -r1.545 bsd.port.mk
--- Mk/bsd.port.mk	8 Jan 2007 00:00:33 -0000	1.545
+++ Mk/bsd.port.mk	18 Apr 2007 02:37:15 -0000
@@ -1583,6 +1583,13 @@
 WWWOWN?=	www
 WWWGRP?=	www
 
+# Trace user supplied make flags through entire make for storing in pkg db
+.if !defined(PORT_MAKEFLAGS)
+PORT_MAKEFLAGS:=	${.MAKEFLAGS}
+.MAKEFLAGS: \
+	PORT_MAKEFLAGS="${PORT_MAKEFLAGS:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}"
+.endif
+
 .endif
 # End of pre-makefile section.
 
@@ -2337,6 +2344,9 @@
 .endif
 .if !defined(PKG_ARGS)
 PKG_ARGS=		-v -c -${COMMENT:Q} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`cd ${.CURDIR} && ${MAKE} package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u`" ${EXTRA_PKG_ARGS} $${_LATE_PKG_ARGS}
+.if !(${PORT_MAKEFLAGS} == "")
+PKG_ARGS+=            -F ${PORT_MAKEFLAGS:Q}
+.endif
 .if !defined(NO_MTREE)
 PKG_ARGS+=		-m ${MTREE_FILE}
 .endif
@@ -3481,7 +3491,7 @@
 .if ${USE_DOS2UNIX:U}=="YES"
 	@${ECHO_MSG} "===>   Converting DOS text files to UNIX text files"
 	@${FIND} ${WRKSRC} -type f -print0 | \
-			${XARGS} -0 ${REINPLACE_CMD} -i '' -e 's/
$$//'
+			${XARGS} -0 ${REINPLACE_CMD} -i '.bak' -e 's/
$$//'
 .else
 .for f in ${USE_DOS2UNIX}
 	@${ECHO_MSG} "===>   Converting DOS text file to UNIX text file: ${f}"
@@ -5178,7 +5188,7 @@
 		for pkgname in $$installed; do \
 			${ECHO_CMD} "$$pkgname ${.CURDIR} ${PKGORIGIN}"; \
 		done; \
-	fi; \
+	else \
 	checked="${PARENT_CHECKED}"; \
 	for dir in $$(${ECHO_CMD} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${SED} -e 'y/ /\n/' | ${CUT} -f 2 -d ':') $$(${ECHO_CMD} ${DEPENDS} | ${SED} -e 'y/ /\n/' | ${CUT} -f 1 -d ':'); do \
 		dir=$$(${REALPATH} $$dir); \
@@ -5197,7 +5207,8 @@
 		else \
 			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
 		fi; \
-	done
+		done; \
+	fi
 
 # Print out package names.
 

--------------070205080408030608040608--



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