Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Oct 2002 20:11:08 +0200
From:      Neil Blakey-Milner <nbm@mithrandr.moria.org>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        ports@FreeBSD.org, eivind@FreeBSD.org
Subject:   Re: Updated dialog-based config patches
Message-ID:  <20021010181108.GB19338@mithrandr.moria.org>
In-Reply-To: <20021010132556.GA17714@mithrandr.moria.org>
References:  <20020930062804.GA50001@xor.obsecurity.org> <20021006202120.GA96047@xor.obsecurity.org> <20021010132556.GA17714@mithrandr.moria.org>

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

--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I knew that'd happen.  It's attached here.

Neil
-- 
Neil Blakey-Milner
nbm@mithrandr.moria.org

--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bsd.port.mk.portconf.patch"

Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.426
diff -u -r1.426 bsd.port.mk
--- bsd.port.mk	2 Oct 2002 07:18:17 -0000	1.426
+++ bsd.port.mk	10 Oct 2002 17:53:35 -0000
@@ -519,6 +519,8 @@
 # PATCH_DEBUG	- If set, print out more information about the patches as
 #				  it attempts to apply them.
 # PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
+# PORT_DBDIR	- Where port configuration options are recorded
+#				  (default: /var/db/port)
 # NO_PKG_REGISTER - Don't register a port installation as a package.
 # FORCE_PKG_REGISTER - If set, it will overwrite any existing package
 #				  registration information in ${PKG_DBDIR}/${PKGNAME}.
@@ -555,6 +557,7 @@
 CP?=		/bin/cp
 CUT?=		/usr/bin/cut
 DC?=		/usr/bin/dc
+DIALOG?=	/usr/bin/dialog
 EGREP?=		/usr/bin/egrep
 EXPR?=		/bin/expr
 FALSE?=		false				# Shell builtin
@@ -653,6 +656,15 @@
 .include "${MASTERDIR}/Makefile.local"
 .endif
 
+# where 'make config' records user configuration options
+PORT_DBDIR?=	/var/db/port
+
+OPTIONSFILE?=${PORT_DBDIR}/${PORTNAME}/options
+WRKOPTIONSFILE?=${WRKDIR}/portoptions
+.if exists(${WRKOPTIONSFILE})
+.include "${WRKOPTIONSFILE}"
+.endif
+
 .if !defined(PORTNAME) || !defined(PORTVERSION) || defined(PKGNAME)
 .BEGIN:
 	@${ECHO_CMD} "${PKGNAME}: You need to define PORTNAME and PORTVERSION instead of PKGNAME."
@@ -2179,7 +2191,6 @@
 
 .if !target(do-extract)
 do-extract:
-	@${RM} -rf ${WRKDIR}
 	@${MKDIR} ${WRKDIR}
 	@for file in ${EXTRACT_ONLY}; do \
 		if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
@@ -2542,12 +2553,18 @@
 				pre-install-script do-install generate-plist post-install \
 				post-install-script compress-man run-ldconfig fake-pkg \
 				security-check
+.if defined(OPTIONS) && exists(${WRKOPTIONSFILE}) && !defined(CONFIG_NOSAVE)
+_INSTALL_SEQ+=	saveconfig
+.endif
 _PACKAGE_DEP=	install
 _PACKAGE_SEQ=	package-message pre-package pre-package-script \
 				do-package post-package-script
 
-.if !target(fetch)
+.if !target(fetch) && (!defined(OPTIONS) || defined(CONFIG_DONE))
 fetch: ${_FETCH_SEQ}
+.else
+fetch: config
+	@cd ${.CURDIR} && ${MAKE} CONFIG_DONE=1 ${__softMAKEFLAGS} ${_FETCH_SEQ}
 .endif
 
 # Main logick. The loop generates 6 main targets and using cookies
@@ -2555,8 +2572,11 @@
 
 .for target in extract patch configure build install package
 
-.if !target(${target})
+.if !target(${target}) && (!defined(OPTIONS) || defined(CONFIG_DONE))
 ${target}: ${${target:U}_COOKIE}
+.else
+${target}: config
+	@cd ${.CURDIR} && ${MAKE} CONFIG_DONE=1 ${__softMAKEFLAGS} ${${target:U}_COOKIE}
 .endif
 
 .if !exists(${${target:U}_COOKIE})
@@ -3501,6 +3521,121 @@
 	OSVERSION="${OSVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
 	PORTOBJFORMAT="${PORTOBJFORMAT:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
 	SYSTEMVERSION="${SYSTEMVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}"
+.endif
+
+.if !target(reconfig)
+reconfig:
+	@cd ${.CURDIR} && ${MAKE} SPECIFIC_RECONFIG=yes config
+.endif
+
+.if !target(config)
+config:
+	@${MKDIR} ${WRKDIR}
+.if !defined(OPTIONS)
+	@${ECHO_MSG} "==> No options to configure"
+.elif !defined(ALWAYS_RECONFIG) && exists(${OPTIONSFILE}) && !defined(SPECIFIC_RECONFIG)
+.  if !exists(${WRKOPTIONSFILE})
+	${CP} ${OPTIONSFILE} ${WRKOPTIONSFILE}
+.  endif
+	@#${ECHO_MSG} "==> Already configured"
+.elif defined(ALWAYS_RECONFIG) && exists(${WRKOPTIONSFILE}) && !defined(SPECIFIC_RECONFIG)
+	@#${ECHO_MSG} "==> ALWAYS_CONFIG, but WRKOPTIONSFILE exists..."
+.elif !defined(ALWAYS_RECONFIG) && exists(${WRKOPTIONSFILE}) && !defined(SPECIFIC_RECONFIG)
+	@#${ECHO_MSG} "==> Already configured"
+.else
+.if !exists(${WRKOPTIONSFILE})
+.  if exists(${OPTIONSFILE})
+	@${CP} ${OPTIONSFILE} ${WRKOPTIONSFILE}
+.  endif
+.endif
+	-@if [ -e ${WRKOPTIONSFILE} ]; then \
+		. ${WRKOPTIONSFILE}; \
+	fi; \
+	set ${OPTIONS} XXX; \
+	while [ $$# -gt 3 ]; do \
+		OPTIONSLIST="$${OPTIONSLIST} $$1"; \
+		defaultval=$$3; \
+		withvar=WITH_$$1; \
+		withoutvar=WITHOUT_$$1; \
+		withval=$$(eval echo $$\{$${withvar}\}); \
+		withoutval=$$(eval echo $$\{$${withoutvar}\}); \
+		echo $${withval}; \
+		if [ ! -z "$${withval}" ]; then \
+			val=on; \
+		elif [ ! -z "$${withoutval}" ]; then \
+			val=off; \
+		else \
+			val=$$3; \
+		fi; \
+		DEFOPTIONS="$${DEFOPTIONS} $$1 \"$$2\" $${val}"; \
+		shift 3; \
+	done > /dev/null; \
+	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}"; \
+	status=$$?; \
+	if [ $${status} -ne 0 ] ; then \
+		${RM} -f $${TMPOPTIONSFILE}; \
+		${ECHO_MSG} "==> Options unchanged"; \
+		exit 0; \
+	fi; \
+	if [ ! -e ${TMPOPTIONSFILE} ]; then \
+		${ECHO_MSG} "==> No user-specified options to save for ${PORTNAME}"; \
+		exit 0; \
+	fi; \
+	SELOPTIONS=$$(cat $${TMPOPTIONSFILE}); \
+	${RM} -f $${TMPOPTIONSFILE}; \
+	${ECHO_MSG} "# This file is auto-generated by 'make config'.  No user-servicable parts" > ${WRKOPTIONSFILE}; \
+	${ECHO_MSG} "# inside!" >> ${WRKOPTIONSFILE}; \
+	for i in $${OPTIONSLIST}; do \
+		${ECHO_CMD} $${SELOPTIONS} | grep -qw $${i}; \
+		if [ $$? -eq 0 ]; then \
+			${ECHO_CMD} WITH_$${i}=true >> ${WRKOPTIONSFILE}; \
+		else \
+			${ECHO_CMD} WITHOUT_$${i}=true >> ${WRKOPTIONSFILE}; \
+		fi; \
+	done
+.elif defined(PACKAGE_BUILDING) || defined(BATCH)
+.endif
+.endif
+
+.if !target(saveconfig)
+saveconfig:
+.if !exists(${WRKOPTIONSFILE})
+	@${ECHO_MSG} "==> No user-specified options to save for ${PORTNAME}"
+.else
+	@${MKDIR} ${PORT_DBDIR}/${PORTNAME} 2> /dev/null || \
+		(${ECHO_MSG} "==> Cannot create ${PORT_DBDIR}/${PORTNAME}, check permissions"; exit 1)
+	@${CP} ${WRKOPTIONSFILE} ${OPTIONSFILE}
+	@${RM} ${WRKOPTIONSFILE}
+.endif
+.endif
+
+.if !target(showconfig)
+showconfig:
+.if exists(${WRKOPTIONSFILE})
+	@${ECHO_MSG} "==> The following unsaved configuration options are set for ${PORTNAME}"; \
+	${GREP} -v ^# ${WRKOPTIONSFILE}
+.elif exists(${OPTIONSFILE})
+	@${ECHO_MSG} "==> The following saved configuration options are set for ${PORTNAME}"; \
+	${GREP} -v ^# ${OPTIONSFILE}
+.else
+	@${ECHO_MSG} "==> No configuration options are set for this port"
+.if defined(OPTIONS)
+	@${ECHO_MSG} "    Use 'make config' to set default values"
+.endif
+.endif
+.endif
+
+.if !target(rmconfig)
+rmconfig:
+.if exists(${OPTIONSFILE})
+	-@${ECHO_MSG} "==> Removing user-configured options for ${PORTNAME}"; \
+	${RM} -f ${OPTIONSFILE}; \
+	${RMDIR} ${PORT_DBDIR}/${PORTNAME}
+.else
+	@${ECHO_MSG} "==> No user-specified options configured for ${PORTNAME}"
+.endif
 .endif
 
 .endif

--Kj7319i9nmIyA2yE--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




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