Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Jun 2016 11:25:39 +0000 (UTC)
From:      Mathieu Arnold <mat@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r417112 - in head/Mk: . Scripts
Message-ID:  <201606191125.u5JBPdTV050367@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mat
Date: Sun Jun 19 11:25:39 2016
New Revision: 417112
URL: https://svnweb.freebsd.org/changeset/ports/417112

Log:
  Extract create-manifest.
  
  PR:		210198
  Submitted by:	mat
  Exp-run by:	antoine
  Sponsored by:	The FreeBSD Foundation, Absolight
  Differential Revision:	https://reviews.freebsd.org/D6779

Added:
  head/Mk/Scripts/create-manifest.sh   (contents, props changed)
Modified:
  head/Mk/bsd.port.mk   (contents, props changed)

Added: head/Mk/Scripts/create-manifest.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/Mk/Scripts/create-manifest.sh	Sun Jun 19 11:25:39 2016	(r417112)
@@ -0,0 +1,148 @@
+#!/bin/sh
+# $FreeBSD$
+#
+# MAINTAINER: portmgr@FreeBSD.org
+
+set -e
+
+. "${dp_SCRIPTSDIR}/functions.sh"
+
+validate_env dp_ACTUAL_PACKAGE_DEPENDS dp_CATEGORIES dp_COMMENT \
+	dp_COMPLETE_OPTIONS_LIST dp_DEPRECATED dp_DESCR dp_EXPIRATION_DATE \
+	dp_GROUPS dp_LICENSE dp_LICENSE_COMB dp_MAINTAINER dp_METADIR \
+	dp_NO_ARCH dp_PKGBASE dp_PKGDEINSTALL dp_PKGINSTALL dp_PKGMESSAGE \
+	dp_PKGORIGIN dp_PKGPOSTDEINSTALL dp_PKGPOSTINSTALL dp_PKGPOSTUPGRADE \
+	dp_PKGPREDEINSTALL dp_PKGPREINSTALL dp_PKGPREUPGRADE dp_PKGUPGRADE \
+	dp_PKGVERSION dp_PKG_BIN dp_PKG_IGNORE_DEPENDS dp_PKG_NOTES \
+	dp_PORT_OPTIONS dp_PREFIX dp_USERS dp_WWW
+
+[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CREATE_MANIFEST}" ] && set -x
+
+set -u
+
+listcontains() {
+	local str lst elt
+	str=$1
+	lst=$2
+
+	for elt in ${lst} ; do
+		if [ ${elt} = ${str} ]; then
+			return 0
+		fi
+	done
+	return 1
+}
+
+mkdir -p ${dp_METADIR}
+
+# Save stdout and redirect it to the manifest file.
+exec 3>&1 >${dp_METADIR}/+MANIFEST
+
+# First, all the required bits
+cat <<EOT
+name: "${dp_PKGBASE}"
+version: "${dp_PKGVERSION}"
+origin: ${dp_PKGORIGIN}
+comment: <<EOD
+${dp_COMMENT}
+EOD
+maintainer: ${dp_MAINTAINER}
+prefix: ${dp_PREFIX}
+categories: [ ${dp_CATEGORIES} ]
+licenselogic: ${dp_LICENSE_COMB:-single}
+EOT
+
+# Then, the optional bits
+[ -z "${dp_WWW}" ] || echo "www: ${dp_WWW}"
+[ -z "${dp_LICENSE}" ] || echo "licenses: [ ${dp_LICENSE} ]"
+[ -z "${dp_USERS}" ] || echo "users: [ ${dp_USERS} ]"
+[ -z "${dp_GROUPS}" ] || echo "groups: [ ${dp_GROUPS} ]"
+[ -n "${dp_NO_ARCH}" ] && echo "arch : `${dp_PKG_BIN} config abi | tr '[:upper:]' '[:lower:]' | cut -d: -f1,2`:*"
+[ -n "${dp_NO_ARCH}" ] && echo "abi : `${dp_PKG_BIN} config abi | cut -d: -f1,2`:*"
+
+# Then the key/values sections
+echo "deps: { "
+eval ${dp_ACTUAL_PACKAGE_DEPENDS} | grep -v -E ${dp_PKG_IGNORE_DEPENDS} | sort -u
+echo "}"
+
+echo "options: {"
+for opt in ${dp_COMPLETE_OPTIONS_LIST}; do
+	if listcontains ${opt} "${dp_PORT_OPTIONS}"; then
+		echo " ${opt}: on,"
+	else
+		echo " ${opt}: off,"
+	fi
+done
+echo "}"
+
+if [ -n "${dp_PKG_NOTES}" ]; then
+	echo "annotations: {"
+	for note in ${dp_PKG_NOTES}; do
+		echo " ${note}: <<EOD"
+		eval "echo \"\${dp_PKG_NOTE_${note}}\""
+		echo "EOD"
+	done
+	echo "}"
+fi
+
+# Copy the pkg-descr file
+cp ${dp_DESCR} ${dp_METADIR}/+DESC
+
+# Concatenate all the scripts
+for stage in INSTALL DEINSTALL UPGRADE; do
+	for prepost in '' PRE POST; do
+		eval files="\${dp_PKG${prepost}${stage}}"
+		output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}
+		rm -f ${output}
+		for input in ${files}; do
+			[ -f "${input}" ] && cat ${input} >> ${output}
+		done
+	done
+done
+
+# *** STARTING NOW, STDOUT is +DISPLAY ***
+
+exec >${dp_METADIR}/+DISPLAY
+
+[ -f ${dp_PKGMESSAGE} ] && cat ${dp_PKGMESSAGE}
+
+# Try and keep these messages in sync with check-deprecated
+if [ ${dp_MAINTAINER} = "ports@FreeBSD.org" ]; then
+	if [ -f "${dp_METADIR}/+DISPLAY" ]; then echo; fi
+	cat <<-EOT
+	===>   NOTICE:
+
+	The ${dp_PKGBASE} port currently does not have a maintainer. As a result, it is
+	more likely to have unresolved issues, not be up-to-date, or even be removed in
+	the future. To volunteer to maintain this port, please create an issue at:
+
+	https://bugs.freebsd.org/bugzilla
+
+	More information about port maintainership is available at:
+
+	https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port
+	EOT
+fi
+
+if [ -n "${dp_DEPRECATED}" ]; then
+	if [ -f "${dp_METADIR}/+DISPLAY" ]; then echo; fi
+	cat <<-EOT
+	===>   NOTICE:
+
+	This port is deprecated; you may wish to reconsider installing it:
+
+	${dp_DEPRECATED}.
+
+	EOT
+
+	if [ -n "${dp_EXPIRATION_DATE}" ]; then
+		cat <<-EOT
+		It is scheduled to be removed on or after ${dp_EXPIRATION_DATE}.
+
+		EOT
+	fi
+fi
+
+if [ ! -s ${dp_METADIR}/+DISPLAY ]; then
+	rm -f ${dp_METADIR}/+DISPLAY
+fi

Modified: head/Mk/bsd.port.mk
==============================================================================
--- head/Mk/bsd.port.mk	Sun Jun 19 11:25:35 2016	(r417111)
+++ head/Mk/bsd.port.mk	Sun Jun 19 11:25:39 2016	(r417112)
@@ -1862,7 +1862,6 @@ CO_ENV+=	NO_PREFIX_RMDIR=0
 
 
 METADIR=		${WRKDIR}/.metadir
-MANIFESTF=		${METADIR}/+MANIFEST
 
 PKGPREINSTALL?=		${PKGDIR}/pkg-pre-install
 PKGPOSTINSTALL?=	${PKGDIR}/pkg-post-install
@@ -2968,7 +2967,7 @@ ${PKG_DBDIR} ${PREFIX} ${WRKDIR} ${EXTRA
 # Warn user about deprecated packages.  Advisory only.
 
 .if !target(check-deprecated)
-# Try and keep these messages in sync with the ones in create-manifest
+# Try and keep these messages in sync with the ones in Mk/Scripts/create-manifest.sh
 check-deprecated:
 .if ${MAINTAINER} == "ports@FreeBSD.org"
 	@${ECHO_MSG} "===>   NOTICE:"
@@ -4211,99 +4210,49 @@ ACTUAL-PACKAGE-DEPENDS?= \
 	done ; \
 	${SETENV} PKG_BIN="${PKG_BIN}" ${SH} ${SCRIPTSDIR}/actual-package-depends.sh $${depfiles} ${RUN_DEPENDS:C/(.*)\:.*/"\1"/}
 
-create-manifest:
-	@${MKDIR} ${METADIR}; \
-	(\
-		echo "name: \"${PKGBASE}\"" ; \
-		echo "version: \"${PKGVERSION}\"" ; \
-		echo "origin: ${PKGORIGIN}" ; \
-		echo "comment: <<EOD" ; \
-		echo ${COMMENT:Q} ; \
-		echo "EOD" ; \
-		echo "maintainer: ${MAINTAINER}" ; \
-		echo "prefix: ${PREFIX}" ; \
-		[ -z "${WWW}" ] || echo "www: ${WWW}" ; \
-		echo "deps: { "; \
-		${ACTUAL-PACKAGE-DEPENDS} | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u ; \
-		echo "}" ; \
-		echo "categories: [ ${CATEGORIES:u:S/$/,/} ]" ; \
-		l=${LICENSE_COMB} ; \
-		[ -n "${NO_ARCH}" ] && echo "arch : `${PKG_BIN} config abi | tr '[:upper:]' '[:lower:]' | ${CUT} -d: -f1,2`:*" ; \
-		[ -n "${NO_ARCH}" ] && echo "abi : `${PKG_BIN} config abi | ${CUT} -d: -f1,2`:*" ; \
-		echo "licenselogic: $${l:-single}" ; \
-		[ -z "${LICENSE}" ] || echo "licenses: [ ${LICENSE:u:S/$/,/} ]" ; \
-		[ -z "${USERS}" ] || echo "users: [ ${USERS:u:S/$/,/} ]" ; \
-		[ -z "${GROUPS}" ] || echo "groups: [ ${GROUPS:u:S/$/,/} ]" ; \
-	) > ${MANIFESTF}
-	@${ECHO_CMD} -n "options: {" >> ${MANIFESTF}
-.for opt in ${COMPLETE_OPTIONS_LIST}
-	@[ -z "${PORT_OPTIONS:M${opt}}" ] || match="on" ; ${ECHO_MSG} -n " ${opt}: $${match:-off}," >> ${MANIFESTF}
-.endfor
-	@${ECHO_CMD} "}" >> ${MANIFESTF}
-.if defined(PKG_NOTES)
-	@${ECHO_CMD} -n "annotations: {" >> ${MANIFESTF}
+PKG_NOTES_ENV?=
 .for note in ${PKG_NOTES}
-	@${ECHO_CMD} -n ' ${note}: "${PKG_NOTE_${note}:S/"/\"/g}",' >> ${MANIFESTF}
+PKG_NOTES_ENV+=	dp_PKG_NOTE_${note}=${PKG_NOTE_${note}:Q}
 .endfor
-	@${ECHO_CMD} " }" >> ${MANIFESTF}
-.endif
-	@[ -f ${PKGINSTALL} ] && ${CP} ${PKGINSTALL} ${METADIR}/+INSTALL; \
-	${RM} -f ${METADIR}/+PRE_INSTALL ; \
-	for a in ${PKGPREINSTALL}; do \
-		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+PRE_INSTALL ; \
-	done ; \
-	${RM} -f ${METADIR}/+POST_INSTALL ; \
-	for a in ${PKGPOSTINSTALL}; do \
-		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+POST_INSTALL ; \
-	done ; \
-	[ -f ${PKGDEINSTALL} ] && ${CP} ${PKGDEINSTALL} ${METADIR}/+DEINSTALL; \
-	${RM} -f ${METADIR}/+PRE_DEINSTALL ; \
-	for a in ${PKGPREDEINSTALL}; do \
-		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+PRE_DEINSTALL ; \
-	done ; \
-	${RM} -f ${METADIR}/+POST_DEINSTALL ; \
-	for a in ${PKGPOSTDEINSTALL}; do \
-		[ -f $$a ] && ${CAT} $$a >> ${METADIR}/+POST_DEINSTALL ; \
-	done ; \
-	[ -f ${PKGUPGRADE} ] && ${CP} ${PKGUPGRADE} ${METADIR}/+UPGRADE; \
-	[ -f ${PKGPREUPGRADE} ] && ${CP} ${PKGPREUPGRADE} ${METADIR}/+PRE_UPGRADE; \
-	[ -f ${PKGPOSTUPGRADE} ] && ${CP} ${PKGPOSTUPGRADE} ${METADIR}/+POST_UPGRADE; \
-	${CP} ${DESCR} ${METADIR}/+DESC; \
-	[ -f ${PKGMESSAGE} ] && ${CP} ${PKGMESSAGE} ${METADIR}/+DISPLAY || return 0
-# Try and keep these messages in sync with check-deprecated
-.if ${MAINTAINER} == "ports@FreeBSD.org"
-	@( \
-		if [ -f "${METADIR}/+DISPLAY" ]; then ${ECHO_CMD}; fi; \
-		${ECHO_CMD} "===>   NOTICE:"; \
-		${ECHO_CMD}; \
-		${ECHO_CMD} "The ${PORTNAME} port currently does not have a maintainer. As a result, it is"; \
-		${ECHO_CMD} "more likely to have unresolved issues, not be up-to-date, or even be removed in"; \
-		${ECHO_CMD} "the future. To volunteer to maintain this port, please create an issue at:"; \
-		${ECHO_CMD}; \
-		${ECHO_CMD} "https://bugs.freebsd.org/bugzilla"; \
-		${ECHO_CMD}; \
-		${ECHO_CMD} "More information about port maintainership is available at:"; \
-		${ECHO_CMD}; \
-		${ECHO_CMD} "https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port"; \
-	) >> ${METADIR}/+DISPLAY
-.endif
-.if defined(DEPRECATED)
-	@( \
-		if [ -f "${METADIR}/+DISPLAY" ]; then ${ECHO_CMD}; fi; \
-		${ECHO_CMD} "===>   NOTICE:"; \
-		${ECHO_CMD}; \
-		${ECHO_CMD} "This port is deprecated; you may wish to reconsider installing it:"; \
-		${ECHO_CMD}; \
-		${ECHO_CMD} ${DEPRECATED:Q}.; \
-		${ECHO_CMD}; \
-	) >> ${METADIR}/+DISPLAY
-.if defined(EXPIRATION_DATE)
-	@( \
-		${ECHO_CMD} "It is scheduled to be removed on or after ${EXPIRATION_DATE}."; \
-		${ECHO_CMD}; \
-	) >> ${METADIR}/+DISPLAY
-.endif
-.endif
+
+create-manifest:
+	@${SETENV} \
+			dp_SCRIPTSDIR='${SCRIPTSDIR}'                         \
+			dp_ACTUAL_PACKAGE_DEPENDS='${ACTUAL-PACKAGE-DEPENDS}' \
+			dp_CATEGORIES='${CATEGORIES:u:S/$/,/}'                \
+			dp_COMMENT=${COMMENT:Q}                               \
+			dp_COMPLETE_OPTIONS_LIST='${COMPLETE_OPTIONS_LIST}'   \
+			dp_DEPRECATED='${DEPRECATED:Q}'                       \
+			dp_DESCR='${DESCR}'                                   \
+			dp_EXPIRATION_DATE='${EXPIRATION_DATE}'               \
+			dp_GROUPS='${GROUPS:u:S/$/,/}'                        \
+			dp_LICENSE='${LICENSE:u:S/$/,/}'                      \
+			dp_LICENSE_COMB='${LICENSE_COMB}'                     \
+			dp_MAINTAINER='${MAINTAINER}'                         \
+			dp_METADIR='${METADIR}'                               \
+			dp_NO_ARCH='${NO_ARCH}'                               \
+			dp_PKGBASE='${PKGBASE}'                               \
+			dp_PKGDEINSTALL='${PKGDEINSTALL}'                     \
+			dp_PKGINSTALL='${PKGINSTALL}'                         \
+			dp_PKGMESSAGE='${PKGMESSAGE}'                         \
+			dp_PKGORIGIN='${PKGORIGIN}'                           \
+			dp_PKGPOSTDEINSTALL='${PKGPOSTDEINSTALL}'             \
+			dp_PKGPOSTINSTALL='${PKGPOSTINSTALL}'                 \
+			dp_PKGPOSTUPGRADE='${PKGPOSTUPGRADE}'                 \
+			dp_PKGPREDEINSTALL='${PKGPREDEINSTALL}'               \
+			dp_PKGPREINSTALL='${PKGPREINSTALL}'                   \
+			dp_PKGPREUPGRADE='${PKGPREUPGRADE}'                   \
+			dp_PKGUPGRADE='${PKGUPGRADE}'                         \
+			dp_PKGVERSION='${PKGVERSION}'                         \
+			dp_PKG_BIN='${PKG_BIN}'                               \
+			dp_PKG_IGNORE_DEPENDS='${PKG_IGNORE_DEPENDS}'         \
+			dp_PKG_NOTES='${PKG_NOTES}'                           \
+			dp_PORT_OPTIONS='${PORT_OPTIONS}'                     \
+			dp_PREFIX='${PREFIX}'                                 \
+			dp_USERS='${USERS:u:S/$/,/}'                          \
+			dp_WWW='${WWW}'                                       \
+			${PKG_NOTES_ENV}                                      \
+			${SH} ${SCRIPTSDIR}/create-manifest.sh
 
 
 # Print out package names.



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