diff options
author | mat <mat@FreeBSD.org> | 2016-06-19 19:25:39 +0800 |
---|---|---|
committer | mat <mat@FreeBSD.org> | 2016-06-19 19:25:39 +0800 |
commit | 4355a44f5fcc35a912543d35ebe0da429206a74e (patch) | |
tree | 9408a2afdb3c64c2096a6719f8b847a8f06e7746 /Mk | |
parent | 21db7caa84c289a2fbfad488c929384ed2d1167a (diff) | |
download | freebsd-ports-gnome-4355a44f5fcc35a912543d35ebe0da429206a74e.tar.gz freebsd-ports-gnome-4355a44f5fcc35a912543d35ebe0da429206a74e.tar.zst freebsd-ports-gnome-4355a44f5fcc35a912543d35ebe0da429206a74e.zip |
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
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/Scripts/create-manifest.sh | 148 | ||||
-rw-r--r-- | Mk/bsd.port.mk | 135 |
2 files changed, 190 insertions, 93 deletions
diff --git a/Mk/Scripts/create-manifest.sh b/Mk/Scripts/create-manifest.sh new file mode 100644 index 000000000000..a960505cbb48 --- /dev/null +++ b/Mk/Scripts/create-manifest.sh @@ -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 diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk index dad780000f07..09aa3f76b905 100644 --- a/Mk/bsd.port.mk +++ b/Mk/bsd.port.mk @@ -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} ${EXTRACT_WRKDIR}: # 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. |