Path: blob/main/Mk/Scripts/create-manifest.sh
16461 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_WWW dp_VITAL1617[ -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):*"60[ -n "${dp_VITAL}" ] && echo "vital : true"6162# Then the key/values sections63echo "deps: { "64# Ignore grep's return value.65eval ${dp_ACTUAL_PACKAGE_DEPENDS} | { grep -v -E ${dp_PKG_IGNORE_DEPENDS} || :; } | sort -u66echo "}"6768echo "options: {"69for opt in ${dp_COMPLETE_OPTIONS_LIST}; do70if listcontains ${opt} "${dp_PORT_OPTIONS}"; then71echo " ${opt}: on,"72else73echo " ${opt}: off,"74fi75done76echo "}"7778if [ -n "${dp_PKG_NOTES}" ]; then79echo "annotations: {"80for note in ${dp_PKG_NOTES}; do81echo " ${note}: <<EOD"82eval "echo \"\${dp_PKG_NOTE_${note}}\""83echo "EOD"84done85echo "}"86fi8788# Copy the pkg-descr file89cp ${dp_DESCR} ${dp_METADIR}/+DESC9091# Concatenate all the scripts92output_files=93for stage in INSTALL DEINSTALL; do94for prepost in '' PRE POST; do95output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}96[ -f "${output}" ] && output_files="${output_files:+${output_files} }${output}"97done98done99[ -n "${output_files}" ] && rm -f ${output_files}100101for stage in INSTALL DEINSTALL; do102for prepost in '' PRE POST; do103eval files="\${dp_PKG${prepost}${stage}}"104output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}105for input in ${files}; do106[ -f "${input}" ] && cat ${input} >> ${output}107[ -f "${input}.lua" ] && cp ${input}.lua ${dp_METADIR}108done109done110done111112# *** STARTING NOW, STDOUT is +DISPLAY ***113114exec >${dp_METADIR}/+DISPLAY115116echo '['117for message in ${dp_PKGMESSAGES}; do118if [ -f "${message}" ]; then119#if if starts with [ then it is ucl and we do drop last and first line120if head -1 "${message}" | grep -q '^\['; then121sed '1d;$d' "${message}"122else123echo '{type: install, message=<<EOD'124cat "${message}"125printf 'EOD\n},\n'126fi127fi128done129130# Try and keep these messages in sync with check-deprecated131if [ ${dp_MAINTAINER} = "[email protected]" ]; then132cat <<-EOT133{ message=<<EOD134===> NOTICE:135136The ${dp_PKGBASE} port currently does not have a maintainer. As a result, it is137more likely to have unresolved issues, not be up-to-date, or even be removed in138the future. To volunteer to maintain this port, please create an issue at:139140https://bugs.freebsd.org/bugzilla141142More information about port maintainership is available at:143144https://docs.freebsd.org/en/articles/contributing/#ports-contributing145EOD146},147EOT148fi149150if [ -n "${dp_DEPRECATED}" ]; then151cat <<-EOT152{ message=<<EOD153===> NOTICE:154155This port is deprecated; you may wish to reconsider installing it:156157${dp_DEPRECATED}.158159EOT160161if [ -n "${dp_EXPIRATION_DATE}" ]; then162cat <<-EOT163It is scheduled to be removed on or after ${dp_EXPIRATION_DATE}.164165EOT166fi167printf 'EOD\n},\n'168fi169echo ']'170171172