diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk --- a/Mk/bsd.port.mk +++ b/Mk/bsd.port.mk @@ -619,6 +619,7 @@ # - Create a package for a port and _all_ of its dependencies. # describe - Try to generate a one-line description for each port for # use in INDEX files and the like. +# describe-json - Generate a JSON-compliant representation of each port. # check-plist - Checks for files missing from the plist, and files in the plist # that are not installed by the port. # check-sanity - Perform some basic checks of the port layout. @@ -4406,6 +4407,36 @@ . endif # empty(FLAVORS) . endif +. if empty(FLAVORS) || defined(_DESCRIBE_WITH_FLAVOR) +describe-json: + @(${ECHO_CMD} "{") + @(${ECHO_CMD} "\"uses\":[\"${USES:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"flavors\":[\"${FLAVORS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"options_default\":[\"${OPTIONS_DEFAULT:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"fetch_depends\":[\"${FETCH_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"extract_depends\":[\"${EXTRACT_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"patch_depends\":[\"${PATCH_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"build_depends\":[\"${BUILD_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"lib_depends\":[\"${LIB_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"run_depends\":[\"${RUN_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"test_depends\":[\"${TEST_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"pkg_depends\":[\"${PKG_DEPENDS:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"complete_options_list\":[\"${COMPLETE_OPTIONS_LIST:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"categories\":[\"${CATEGORIES:ts,:S/,/\",\"/g}\"]," | ${SED} ${SED_ARGS} >> ${INDEX_OUT}) + @(${ECHO_CMD} "\"comment\":\""${COMMENT:Q:S/"/\\\"/g:S/\\\*/*/g:S/\\\'/'/g}"\",") + @(${ECHO_CMD} "\"deprecated\":\""${DEPRECATED:Q:S/"/\\\"/g:S/\\\\*/*/g:S/\\\'/'/g}"\",") + @(${ECHO_CMD} -e "\"broken\":\"${BROKEN}\",\n\"distversion\":\"${DISTVERSION}\",\n\"distversionprefix\":\"${DISTVERSIONPREFIX}\",\n\"distversionsuffix\":\"${DISTVERSIONSUFFIX}\",\n\"expiration_date\":\"${EXPIRATION_DATE}\",\n\"flavor\":\"${FLAVOR}\",\n\"gh_account\":\"${GH_ACCOUNT}\",\n\"gh_project\":\"${GH_PROJECT}\",\n\"gh_tagname\":\"${GH_TAGNAME}\",\n\"gl_account\":\"${GL_ACCOUNT}\",\n\"gl_commit\":\"${GL_COMMIT}\",\n\"gl_project\":\"${GL_PROJECT}\",\n\"gl_site\":\"${GL_SITE}\",\n\"maintainer\":\"${MAINTAINER}\",\n\"makefiles\":\"${MAKEFILES}\",\n\"pkgbase\":\"${PKGBASE}\",\n\"pkgname\":\"${PKGNAME}\",\n\"pkgnamesuffix\":\"${PKGNAMESUFFIX}\",\n\"pkgorigin\":\"${PKGORIGIN}\",\n\"pkg_depends\":\"${PKG_DEPENDS}\",\n\"portepoch\":\"${PORTEPOCH}\",\n\"portname\":\"${PORTNAME}\",\n\"portrevision\":\"${PORTREVISION}\",\n\"portversion\":\"${PORTVERSION}\",\n\"use_github\":\"${USE_GITHUB}\",\n\"use_gitlab\":\"${USE_GITLAB}\",\n\"www\":\"${WWW}\"") + @(${ECHO_CMD} "}" >> ${INDEX_OUT}) +. else # empty(FLAVORS) +describe-json: ${FLAVORS:S/^/describe-json-/} +. for f in ${FLAVORS} +describe-json-${f}: + @cd ${.CURDIR} && ${SETENV} FLAVOR=${f} ${MAKE} -B -D_DESCRIBE_WITH_FLAVOR describe-json +. endfor +. endif # empty(FLAVORS) + + + www-site: @${ECHO_CMD} ${_WWW} diff --git a/Mk/bsd.port.subdir.mk b/Mk/bsd.port.subdir.mk --- a/Mk/bsd.port.subdir.mk +++ b/Mk/bsd.port.subdir.mk @@ -300,6 +300,26 @@ . endif .endif +# Store last subdir name +LAST_DIR = ${SUBDIR:[-1]} +describe-json: + @${ECHO_MSG} -e "{\n" + @for sub in ${SUBDIR}; do \ + if ${TEST} -d ${.CURDIR}/$${sub}; then \ + cd ${.CURDIR}/$${sub}; \ + (${ECHO_MSG} "\"$${sub}\": ") ;\ + ${MAKE} -B describe-json || \ + (${ECHO_CMD} "===> ${DIRPRFX}$${sub} failed" >&2; \ + exit 1) ;\ + if [ "$${sub}" != "${LAST_DIR}" ]; then \ + (${ECHO_MSG} ",") ; \ + fi; \ + else \ + ${ECHO_MSG} "===> ${DIRPRFX}$${sub} non-existent"; \ + fi; \ + done + @${ECHO_MSG} -e "\n}" + .if !target(readmes) . if defined(PORTSTOP) readmes: readme ${SUBDIR:S/^/_/:S/$/.readmes/}