From owner-freebsd-ports-bugs@FreeBSD.ORG Mon May 24 17:10:17 2004 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3DEE916A4CE for ; Mon, 24 May 2004 17:10:17 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3333043D2F for ; Mon, 24 May 2004 17:10:17 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i4P0AHOF023019 for ; Mon, 24 May 2004 17:10:17 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i4P0AHCF023018; Mon, 24 May 2004 17:10:17 -0700 (PDT) (envelope-from gnats) Resent-Date: Mon, 24 May 2004 17:10:17 -0700 (PDT) Resent-Message-Id: <200405250010.i4P0AHCF023018@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Florent Thoumie Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9835116A4CE for ; Mon, 24 May 2004 17:02:48 -0700 (PDT) Received: from gw.xbsd.org (xbsd.org [81.56.254.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88B6443D3F for ; Mon, 24 May 2004 17:02:47 -0700 (PDT) (envelope-from flz@xbsd.org) Received: by gw.xbsd.org (Postfix, from userid 201) id ED5F6CD4; Tue, 25 May 2004 02:02:47 +0200 (CEST) Message-Id: <20040525000247.ED5F6CD4@gw.xbsd.org> Date: Tue, 25 May 2004 02:02:47 +0200 (CEST) From: Florent Thoumie To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/67151: Mk/bsd.port.mk - Add a way to handle PLIST_SUB like substitutions to a given file list. X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Florent Thoumie List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2004 00:10:17 -0000 >Number: 67151 >Category: ports >Synopsis: Mk/bsd.port.mk - Add a way to handle PLIST_SUB like substitutions to a given file list. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon May 24 17:10:16 PDT 2004 >Closed-Date: >Last-Modified: >Originator: Florent Thoumie >Release: FreeBSD 4.9-RC i386 >Organization: Xbsd.org >Environment: System: FreeBSD gw 4.9-RC FreeBSD 4.9-RC #4: Sun Oct 5 14:25:09 CEST 2003 rf@gw:/usr/src/sys/compile/GW i386 >Description: Rationale: x A lot of Makefiles are using %%...%% substitutions for pkg-* files (and other files). x These modified files are written to ${WRKDIR}. x Makefiles defines some related variables (PKGMESSAGE, PKGINSTALL, ...) for these files to be included in the port distribution. Goal: x Create a target that modifies a given list of files, and copy them in ${WRKDIR}. x If these files are specific files (ie. matching pkg-*), set some variables automatically. How: x Create a SUB_FILES variable to handle the list of files to be modified. x Create a SUB_LIST variable to handle substitutions to do. x Apply the substitution list to each file $i in ${SUB_FILES} and redirect output to ${WRKDIR}/$i. x Detect special files and set variables. Example: SUB_FILES= pkg-message pkg-install SUB_LIST+= "VERSION=${VERSION}" This looks for ${FILESDIR}/pkg-message.in and ${FILESDIR}/pkg-install.in Substitutions in SUB_LIST are applied to these files and the output is redirected to ${WRKDIR}/ PKGMESSAGE is set to ${WRKDIR}/pkg-message. PKGINSTALL is set to ${WRKDIR}/pkg-install. As I am introducing two new variables, there shouldn't be any breakage. Note: I haven't found a better name than apply-slist (for substitution list) for the new target name, so any proposition is welcome. >How-To-Repeat: N/A >Fix: --- apply-slist.diff begins here --- --- bsd.port.mk.old Tue May 25 00:34:45 2004 +++ bsd.port.mk Tue May 25 01:12:09 2004 @@ -718,6 +718,17 @@ # (default: ${WRKDIR}/.PLIST.mktmp). # PLIST_SUB - List of "variable=value" pair for substitution in ${PLIST} # (default: see below). +# +# SUB_FILES - Files that should be passed through sed and redirected to ${WRKDIR}. +# - For each file specified in SUB_FILES, there must be a corresponding +# file in ${FILESDIR} whose suffix is ".in". For instance, +# if the Makefile specifies "SUB_FILES= pkg-message" then there must be +# a file called pkg-message.in in ${FILESDIR}. +# - The substitution process is the same as PLIST_FILES, as described +# below +# SUB_LIST - List of "variable=value" pair for substitution in ${SUB_FILES} +# (some pair are added by default: eg. PREFIX=${PREFIX}). +# # INSTALLS_SHLIB - If set, bsd.port.mk will automatically run ldconfig commands # from post-install and also add appropriate @exec/@unexec # directives to directories listed in LDCONFIG_DIRS. @@ -1206,6 +1217,8 @@ INSTALL_WRKSRC?=${WRKSRC} PLIST_SUB+= OSREL=${OSREL} PREFIX=%D LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} +SUB_LIST+= PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} \ + DATADIR=${DATADIR} DOCSDIR=${DOCSDIR} EXAMPLESDIR=${EXAMPLESDIR} .if defined(WITHOUT_CPU_CFLAGS) .if defined(_CPUCFLAGS) @@ -3489,7 +3502,7 @@ _INSTALL_DEP= build _INSTALL_SEQ= install-message check-conflicts \ run-depends lib-depends pre-install pre-install-script \ - generate-plist check-already-installed + apply-slist generate-plist check-already-installed _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \ pre-su-install-script do-install post-install add-plist-info \ post-install-script add-plist-docs compress-man run-ldconfig fake-pkg \ @@ -4478,6 +4491,26 @@ @${ECHO_CMD} '" to run.' .endif .endif + +_SUB_LIST_TEMP= ${SUB_LIST:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} +.if !target(apply-slist) +apply-slist: +.if defined(SUB_FILES) +.for file in ${SUB_FILES} +.if !exists(${FILESDIR}/${file}.in) + @${ECHO_CMD} "** Missing ${FILESDIR}/${file}.in for ${PKGNAME}."; exit 1 +.else + @${CAT} ${FILESDIR}/${file}.in | ${SED} ${_SUB_LIST_TEMP} > ${WRKDIR}/${file} +.endif +.endfor +.for i in pkg-message pkg-install pkg-deinstall pkg-req +.if ${SUB_FILES:M${i}*}!="" +${i:S/-//:U}= ${WRKDIR}/${SUB_FILES:M${i}*} +.endif +.endfor +.endif +.endif + # Generate packing list. Also tests to make sure all required package # files exist. --- apply-slist.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: