Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jan 2004 20:52:03 +0100
From:      Oliver Eikemeier <eikemeier@fillmore-labs.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/61683: [PATCH] bsd.port.mk: enhanced OPTIONS handling
Message-ID:  <400ED863.9050209@fillmore-labs.com>
Resent-Message-ID: <200401212000.i0LK0ZrC037932@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         61683
>Category:       ports
>Synopsis:       [PATCH] bsd.port.mk: enhanced OPTIONS handling
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 21 12:00:35 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Oliver Eikemeier
>Release:        FreeBSD 4.9-STABLE i386
>Organization:
Fillmore Labs - http://www.fillmore-labs.com
>Environment:
System: FreeBSD nuuk.fillmore-labs.com 4.9-STABLE

>Description:

- include saved option only if the port is OPTIONS aware (defines OPTIONS)
- The options a saved if:
- ${OPTIONSFILE} if that is defined
- ${PORT_DBDIR}/${UNIQUENAME}/options if UNIQUENAME is defined
- ${PORT_DBDIR}/${LATEST_LINK}/options
  if UNIQUENAME is undefined and LATEST_LINK is defined
- ${PORT_DBDIR}/${PKGNAMEPREFIX}${PORTNAME}/options
  if UNIQUENAME and LATEST_LINK are undefined

This requires PKGNAMEPREFIX, UNIQUENAME and LATEST_LINK to be defined
*before* including bsd.port.pre.mk.

This patch tries to guard against errors by evaluating OPTIONSFILE early
and checking if this value does not change.

*ALL* -client/-server ports have to define LATEST_LINK or UNIQUENAME if
the client and server ports require different saved options.

- bring the ===> messages in line with the existing ones by using PKGNAME
  instead of PORTNAME
- the same for the dialog title
- use ECHO_CMD instead of ECHO_MSG to write the OPTIONSFILE comment,
  add a line with the PKGNAME
- issue a note during compiling that user-specified options have been found
- make the output of the showconfig target a little more user friendly, even
  though unformatted.

>How-To-Repeat:
>Fix:

Index: Mk/bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.480
diff -u -r1.480 bsd.port.mk
--- Mk/bsd.port.mk	20 Jan 2004 22:27:01 -0000	1.480
+++ Mk/bsd.port.mk	21 Jan 2004 18:48:01 -0000
@@ -70,7 +70,7 @@
 # PKGNAMESUFFIX	- Suffix to specify compilation options.  Optional.
 #				  Do not define this in your Makefile.
 # UNIQUENAME	- A name for your port that is globally unique.  By default,
-# 				  this is set to ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}
+# 				  this is set to ${LATEST_LINK} when set, ${PKGNAMEPREFIX}${PORTNAME} else
 # DISTNAME		- Name of port or distribution used in generating
 #				  WRKSRC and DISTFILES below (default:
 #				  ${PORTNAME}-${PORTVERSION}).
@@ -1019,13 +1019,20 @@
 # where 'make config' records user configuration options
 PORT_DBDIR?=	/var/db/ports
 
-UNIQUENAME?=${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}
-OPTIONSFILE?=${PORT_DBDIR}/${UNIQUENAME}/options
-.if exists(${OPTIONSFILE})
-.include "${OPTIONSFILE}"
+.if defined(LATEST_LINK)
+UNIQUENAME?=	${LATEST_LINK}
+.else
+UNIQUENAME?=	${PKGNAMEPREFIX}${PORTNAME}
+.endif
+OPTIONSFILE?=	${PORT_DBDIR}/${UNIQUENAME}/options
+_OPTIONSFILE!=	${ECHO_CMD} "${OPTIONSFILE}"
+.if defined(OPTIONS)
+.if exists(${_OPTIONSFILE}) && !make(rmconfig)
+.include "${_OPTIONSFILE}"
+.endif
+.if exists(${_OPTIONSFILE}.local)
+.include "${_OPTIONSFILE}.local"
 .endif
-.if exists(${OPTIONSFILE}.local)
-.include "${OPTIONSFILE}.local"
 .endif
 
 # check for old, crufty, makefile types, part 1:
@@ -2888,7 +2895,7 @@
 ################################################################
 .if (!defined(OPTIONS) || defined(CONFIG_DONE) || \
 	defined(PACKAGE_BUILDING) || defined(BATCH) || \
-	exists(${OPTIONSFILE}) || exists(${OPTIONSFILE}.local))
+	exists(${_OPTIONSFILE}) || exists(${_OPTIONSFILE}.local))
 _OPTIONS_OK=yes
 .endif
 
@@ -2965,6 +2972,13 @@
 .else
 	@${DO_NADA}
 .endif
+.if defined(_OPTIONS_READ)
+	@${ECHO_MSG} "===>  Found saved configuration for ${_OPTIONS_READ}"
+.if ${OPTIONSFILE} != ${_OPTIONSFILE}
+	@${ECHO_MSG} "===>  *** CAUTION *** Using wrong configuration file ${_OPTIONSFILE}"
+.endif
+.endif
+
 
 # Warn user about deprecated packages.  Advisory only.
 
@@ -4903,10 +4917,14 @@
 .if !defined(OPTIONS)
 	@${ECHO_MSG} "===> No options to configure"
 .else
-	@(${MKDIR} ${PORT_DBDIR}/${UNIQUENAME} 2> /dev/null) || \
-		(${ECHO_MSG} "===> Cannot create ${PORT_DBDIR}/${UNIQUENAME}, check permissions"; exit 1)
-	-@if [ -e ${OPTIONSFILE} ]; then \
-		. ${OPTIONSFILE}; \
+.if ${OPTIONSFILE} != ${_OPTIONSFILE}
+	@${ECHO_MSG} "===> Using wrong configuration file ${_OPTIONSFILE}"
+	@exit 1
+.endif
+	@(${MKDIR} `dirname ${_OPTIONSFILE}` 2> /dev/null) || \
+		(${ECHO_MSG} "===> Cannot create `dirname ${_OPTIONSFILE}`, check permissions"; exit 1)
+	-@if [ -e ${_OPTIONSFILE} ]; then \
+		. ${_OPTIONSFILE}; \
 	fi; \
 	set ${OPTIONS} XXX; \
 	while [ $$# -gt 3 ]; do \
@@ -4916,7 +4934,6 @@
 		withoutvar=WITHOUT_$$1; \
 		withval=$$(eval ${ECHO_CMD} $$\{$${withvar}\}); \
 		withoutval=$$(eval ${ECHO_CMD} $$\{$${withoutvar}\}); \
-		${ECHO_CMD} $${withval}; \
 		if [ ! -z "$${withval}" ]; then \
 			val=on; \
 		elif [ ! -z "$${withoutval}" ]; then \
@@ -4926,10 +4943,10 @@
 		fi; \
 		DEFOPTIONS="$${DEFOPTIONS} $$1 \"$$2\" $${val}"; \
 		shift 3; \
-	done > /dev/null; \
+	done; \
 	TMPOPTIONSFILE=$$(mktemp -t portoptions); \
 	trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \
-	${SH} -c "${DIALOG} --checklist \"Options for ${PORTNAME} ${PORTVERSION}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
+	${SH} -c "${DIALOG} --checklist \"Options for ${PKGNAME:C/-([^-]+)$/ \1/}\" 21 70 15 $${DEFOPTIONS} 2> $${TMPOPTIONSFILE}"; \
 	status=$$?; \
 	if [ $${status} -ne 0 ] ; then \
 		${RM} -f $${TMPOPTIONSFILE}; \
@@ -4937,19 +4954,21 @@
 		exit 0; \
 	fi; \
 	if [ ! -e ${TMPOPTIONSFILE} ]; then \
-		${ECHO_MSG} "===> No user-specified options to save for ${PORTNAME}"; \
+		${ECHO_MSG} "===> No user-specified options to save for ${PKGNAME}"; \
 		exit 0; \
 	fi; \
 	SELOPTIONS=$$(${CAT} $${TMPOPTIONSFILE}); \
 	${RM} -f $${TMPOPTIONSFILE}; \
-	${ECHO_MSG} "# This file is auto-generated by 'make config'.  No user-servicable parts" > ${OPTIONSFILE}; \
-	${ECHO_MSG} "# inside!" >> ${OPTIONSFILE}; \
+	${ECHO_CMD} "# This file is auto-generated by 'make config'." > ${_OPTIONSFILE}; \
+	${ECHO_CMD} "# No user-servicable parts inside!" >> ${_OPTIONSFILE}; \
+	${ECHO_CMD} "# Options for ${PKGNAME}" >> ${_OPTIONSFILE}; \
+	${ECHO_CMD} "_OPTIONS_READ=${PKGNAME}" >> ${_OPTIONSFILE}; \
 	for i in $${OPTIONSLIST}; do \
 		${ECHO_CMD} $${SELOPTIONS} | ${GREP} -qw $${i}; \
 		if [ $$? -eq 0 ]; then \
-			${ECHO_CMD} WITH_$${i}=true >> ${OPTIONSFILE}; \
+			${ECHO_CMD} WITH_$${i}=true >> ${_OPTIONSFILE}; \
 		else \
-			${ECHO_CMD} WITHOUT_$${i}=true >> ${OPTIONSFILE}; \
+			${ECHO_CMD} WITHOUT_$${i}=true >> ${_OPTIONSFILE}; \
 		fi; \
 	done
 .endif
@@ -4957,9 +4976,28 @@
 
 .if !target(showconfig)
 showconfig:
-.if exists(${OPTIONSFILE})
-	@${ECHO_MSG} "===> The following configuration options are set for ${PORTNAME}"; \
-	${GREP} -v ^# ${OPTIONSFILE}
+.if defined(OPTIONS) && exists(${_OPTIONSFILE})
+	@${ECHO_MSG} "===> The following configuration options are set for ${PKGNAME}:"
+	-@if [ -e ${_OPTIONSFILE} ]; then \
+		. ${_OPTIONSFILE}; \
+	fi; \
+	set ${OPTIONS} XXX; \
+	while [ $$# -gt 3 ]; do \
+		defaultval=$$3; \
+		withvar=WITH_$$1; \
+		withoutvar=WITHOUT_$$1; \
+		withval=$$(eval ${ECHO_CMD} $$\{$${withvar}\}); \
+		withoutval=$$(eval ${ECHO_CMD} $$\{$${withoutvar}\}); \
+		if [ ! -z "$${withval}" ]; then \
+			val=on; \
+		elif [ ! -z "$${withoutval}" ]; then \
+			val=off; \
+		else \
+			val="$$3 (default)"; \
+		fi; \
+		${ECHO_MSG} "     $$1=$${val} \"$$2\""; \
+		shift 3; \
+	done
 .else
 	@${ECHO_MSG} "===> No configuration options are set for this port"
 .if defined(OPTIONS)
@@ -4970,12 +5008,12 @@
 
 .if !target(rmconfig)
 rmconfig:
-.if exists(${OPTIONSFILE})
-	-@${ECHO_MSG} "===> Removing user-configured options for ${PORTNAME}"; \
-	${RM} -f ${OPTIONSFILE}; \
-	${RMDIR} ${PORT_DBDIR}/${UNIQUENAME}
+.if defined(OPTIONS) && exists(${_OPTIONSFILE})
+	-@${ECHO_MSG} "===> Removing user-configured options for ${PKGNAME}"; \
+	${RM} -f ${_OPTIONSFILE}; \
+	${RMDIR} `dirname ${_OPTIONSFILE}`
 .else
-	@${ECHO_MSG} "===> No user-specified options configured for ${PORTNAME}"
+	@${ECHO_MSG} "===> No user-specified options configured for ${PKGNAME}"
 .endif
 .endif
 

>Release-Note:
>Audit-Trail:
>Unformatted:



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