Path: blob/main/Mk/Scripts/create-manifest.sh
16124 views
#!/bin/sh1#2# MAINTAINER: [email protected]34set -e5set -o pipefail67. "${dp_SCRIPTSDIR}/functions.sh"89validate_env dp_ACTUAL_PACKAGE_DEPENDS dp_CATEGORIES dp_COMMENT \10dp_COMPLETE_OPTIONS_LIST dp_DEPRECATED dp_DESCR dp_EXPIRATION_DATE \11dp_GROUPS dp_LICENSE dp_LICENSE_COMB dp_MAINTAINER dp_METADIR \12dp_NO_ARCH dp_PKGBASE dp_PKGDEINSTALL dp_PKGINSTALL dp_PKGMESSAGES \13dp_PKGORIGIN dp_PKGPOSTDEINSTALL dp_PKGPOSTINSTALL dp_PKGPREDEINSTALL \14dp_PKGPREINSTALL dp_PKGVERSION dp_PKG_BIN dp_PKG_IGNORE_DEPENDS \15dp_PKG_NOTES dp_PORT_OPTIONS dp_PREFIX dp_USERS dp_WWW1617[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CREATE_MANIFEST}" ] && set -x1819set -u2021listcontains() {22local str lst elt23str=$124lst=$22526for elt in ${lst} ; do27if [ ${elt} = ${str} ]; then28return 029fi30done31return 132}3334mkdir -p ${dp_METADIR}3536# Save stdout and redirect it to the manifest file.37exec 3>&1 >${dp_METADIR}/+MANIFEST3839# First, all the required bits40cat <<EOT41name: "${dp_PKGBASE}"42version: "${dp_PKGVERSION}"43origin: ${dp_PKGORIGIN}44comment: <<EOD45${dp_COMMENT}46EOD47maintainer: ${dp_MAINTAINER}48prefix: ${dp_PREFIX}49categories: [ ${dp_CATEGORIES} ]50licenselogic: ${dp_LICENSE_COMB:-single}51EOT5253# Then, the optional bits54[ -z "${dp_WWW}" ] || echo "www: ${dp_WWW}"55[ -z "${dp_LICENSE}" ] || echo "licenses: [ ${dp_LICENSE} ]"56[ -z "${dp_USERS}" ] || echo "users: [ ${dp_USERS} ]"57[ -z "${dp_GROUPS}" ] || echo "groups: [ ${dp_GROUPS} ]"58[ -n "${dp_NO_ARCH}" ] && echo "arch : $(${dp_PKG_BIN} config abi | tr '[:upper:]' '[:lower:]' | cut -d: -f1,2):*"59[ -n "${dp_NO_ARCH}" ] && echo "abi : $(${dp_PKG_BIN} config abi | cut -d: -f1,2):*"6061# Then the key/values sections62echo "deps: { "63# Ignore grep's return value.64eval ${dp_ACTUAL_PACKAGE_DEPENDS} | { grep -v -E ${dp_PKG_IGNORE_DEPENDS} || :; } | sort -u65echo "}"6667echo "options: {"68for opt in ${dp_COMPLETE_OPTIONS_LIST}; do69if listcontains ${opt} "${dp_PORT_OPTIONS}"; then70echo " ${opt}: on,"71else72echo " ${opt}: off,"73fi74done75echo "}"7677if [ -n "${dp_PKG_NOTES}" ]; then78echo "annotations: {"79for note in ${dp_PKG_NOTES}; do80echo " ${note}: <<EOD"81eval "echo \"\${dp_PKG_NOTE_${note}}\""82echo "EOD"83done84echo "}"85fi8687# Copy the pkg-descr file88cp ${dp_DESCR} ${dp_METADIR}/+DESC8990# Concatenate all the scripts91output_files=92for stage in INSTALL DEINSTALL; do93for prepost in '' PRE POST; do94output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}95[ -f "${output}" ] && output_files="${output_files:+${output_files} }${output}"96done97done98[ -n "${output_files}" ] && rm -f ${output_files}99100for stage in INSTALL DEINSTALL; do101for prepost in '' PRE POST; do102eval files="\${dp_PKG${prepost}${stage}}"103output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}104for input in ${files}; do105[ -f "${input}" ] && cat ${input} >> ${output}106[ -f "${input}.lua" ] && cp ${input}.lua ${dp_METADIR}107done108done109done110111# *** STARTING NOW, STDOUT is +DISPLAY ***112113exec >${dp_METADIR}/+DISPLAY114115echo '['116for message in ${dp_PKGMESSAGES}; do117if [ -f "${message}" ]; then118#if if starts with [ then it is ucl and we do drop last and first line119if head -1 "${message}" | grep -q '^\['; then120sed '1d;$d' "${message}"121else122echo '{type: install, message=<<EOD'123cat "${message}"124printf 'EOD\n},\n'125fi126fi127done128129# Try and keep these messages in sync with check-deprecated130if [ ${dp_MAINTAINER} = "[email protected]" ]; then131cat <<-EOT132{ message=<<EOD133===> NOTICE:134135The ${dp_PKGBASE} port currently does not have a maintainer. As a result, it is136more likely to have unresolved issues, not be up-to-date, or even be removed in137the future. To volunteer to maintain this port, please create an issue at:138139https://bugs.freebsd.org/bugzilla140141More information about port maintainership is available at:142143https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port144EOD145},146EOT147fi148149if [ -n "${dp_DEPRECATED}" ]; then150cat <<-EOT151{ message=<<EOD152===> NOTICE:153154This port is deprecated; you may wish to reconsider installing it:155156${dp_DEPRECATED}.157158EOT159160if [ -n "${dp_EXPIRATION_DATE}" ]; then161cat <<-EOT162It is scheduled to be removed on or after ${dp_EXPIRATION_DATE}.163164EOT165fi166printf 'EOD\n},\n'167fi168echo ']'169170171