Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/mono.mk
# $FreeBSD: head/Mk/Uses/mono.mk 440759 2017-05-13 07:48:27Z dbn $ | # $FreeBSD$ | ||||
# | # | ||||
# mono (c#) support | # mono (c#) support | ||||
# | # | ||||
# Feature: mono | # Feature: mono | ||||
# Usage: USES=mono:ARGS | # Usage: USES=mono:ARGS | ||||
# Valid ARGS: nuget | # Valid ARGS: nuget | ||||
# | # | ||||
# MAINTAINER= mono@FreeBSD.org | # MAINTAINER= mono@FreeBSD.org | ||||
# | # | ||||
# Arguments: | # Arguments: | ||||
# | # | ||||
# nuget Specifies that the port uses nuget packages. The | # nuget Specifies that the port uses nuget packages. | ||||
# variables NUGET_DEPENDS needs to be set with the names, | |||||
# versions and optionally the port origin of the nuget | |||||
# packages in the format: | |||||
# ${name}=${version}(:${PKGORIGIN}) | |||||
# | # | ||||
# EXTRACT_ONLY is conditionally overridden to exclude all | # EXTRACT_ONLY is conditionally overridden to exclude all | ||||
# files with a '.nupkg' extension. | # files with a '.nupkg' extension. | ||||
# | # | ||||
# Targets: | # Targets: | ||||
# | # | ||||
# makenuget This target will output the NUGET_DEPENDS based on the | # makenuget This target will output the NUGET_DEPENDS based on the | ||||
# port's packages.config file. | # port's packages.config file. | ||||
# | # | ||||
# Variables overrideable by the port: | # Variables overrideable by the port: | ||||
# | # | ||||
# NUGET_PACKAGEDIR The directory in which the port expects the | # NUGET_PACKAGEDIR The directory in which the port expects the | ||||
# nuget packages to be available | # nuget packages to be available | ||||
# default: ${WRKSRC}/packages | # default: ${WRKSRC}/packages | ||||
# | |||||
# NUGET_FEEDS A list of nuget feed names | |||||
# default: NUGET | |||||
# | |||||
# ${NAME}_URL: The base URL for the feed ${NAME} | |||||
# defaults: | |||||
# NUGET_URL=https://www.nuget.org/api/v2/ | |||||
# | |||||
# ${NAME}_FILE: The file containing a list of nuget packages from | |||||
# feed ${NAME} in the format: | |||||
# ${name}=${version} | |||||
# | |||||
# ${NAME}_DEPENDS: The list of nuget packages from feed ${NAME} in the | |||||
# format: | |||||
# ${name}=${version} | |||||
# defaults: | |||||
# NUGET_DEPENDS=${PAKET_DEPENDS} | |||||
# | |||||
# PAKET_PACKAGEDIR The directory in which the port expects the | |||||
# nuget packages (managed by paket) to be available | |||||
# | |||||
# PAKET_DEPENDS The list of nuget packages from a nuget feed. The | |||||
# version used needs to be resolved (unlike how paket | |||||
# works). The format is: | |||||
# ${name}=${version} | |||||
.if !defined(_INCLUDE_USES_MONO_MK) | .if !defined(_INCLUDE_USES_MONO_MK) | ||||
_INCLUDE_USES_MONO_MK= yes | _INCLUDE_USES_MONO_MK= yes | ||||
.if !empty(mono_ARGS:Nnuget) | .if !empty(mono_ARGS:Nnuget) | ||||
russ.haley_gmail.com: Just a sanity check that mono_ARGS:Nnuget and mono_ARGS:Mnuget on line 77 are actually two… | |||||
dbnAuthorUnsubmitted Done Inline ActionsYes, this line should use :N and line 77 should use :M. The former means "all that don't match" whereas the latter means "all that match". Sanity checked ;-) dbn: Yes, this line should use :N and line 77 should use :M. The former means "all that don't… | |||||
IGNORE= USES=mono only supports an optional nuget argument | IGNORE= USES=mono only supports an optional nuget argument | ||||
.endif | .endif | ||||
# Set the location of the .wapi directory so we write to a location we | # Set the location of the .wapi directory so we write to a location we | ||||
# can always assume to be writable. | # can always assume to be writable. | ||||
MONO_SHARED_DIR= ${WRKDIR} | MONO_SHARED_DIR= ${WRKDIR} | ||||
CONFIGURE_ENV+= MONO_SHARED_DIR="${MONO_SHARED_DIR}" | CONFIGURE_ENV+= MONO_SHARED_DIR="${MONO_SHARED_DIR}" | ||||
MAKE_ENV+= MONO_SHARED_DIR="${MONO_SHARED_DIR}" TZ=UTC | MAKE_ENV+= MONO_SHARED_DIR="${MONO_SHARED_DIR}" TZ=UTC | ||||
BUILD_DEPENDS+= mono:lang/mono | BUILD_DEPENDS+= mono:lang/mono | ||||
RUN_DEPENDS+= mono:lang/mono | RUN_DEPENDS+= mono:lang/mono | ||||
# Set the location that webaps served by XSP should use. | # Set the location that webaps served by XSP should use. | ||||
XSP_DOCROOT= ${PREFIX}/www/xsp | XSP_DOCROOT= ${PREFIX}/www/xsp | ||||
# gac utilities | # gac utilities | ||||
GACUTIL=${LOCALBASE}/bin/gacutil /root ${PREFIX}/lib/ /gacdir ${PREFIX}/lib | GACUTIL=${LOCALBASE}/bin/gacutil /root ${PREFIX}/lib/ /gacdir ${PREFIX}/lib | ||||
GACUTIL_INSTALL=${GACUTIL} /i | GACUTIL_INSTALL=${GACUTIL} /i | ||||
GACUTIL_INSTALL_PACKAGE=${GACUTIL} /i /package 1.0 /package 2.0 | GACUTIL_INSTALL_PACKAGE=${GACUTIL} /i /package 1.0 /package 2.0 | ||||
.if ${mono_ARGS:Mnuget} | .if ${mono_ARGS:Mnuget} | ||||
MAKE_ENV+= NUGET_PACKAGES=${NUGET_PACKAGEDIR} | |||||
# TODO: add nuget as a Port, use it for makenupkg | |||||
NUGET_EXE?= ${WRKSRC}/external/nuget-binary/nuget.exe | |||||
_NUGET_PACKAGEDIR= ${WRKDIR}/.nuget/packages | |||||
NUGET_PACKAGEDIR?= ${WRKSRC}/packages | NUGET_PACKAGEDIR?= ${WRKSRC}/packages | ||||
NUGET_FEEDS?= NUGET | |||||
NUGET_URL?= https://www.nuget.org/api/v2/ | |||||
. for depend in ${NUGET_DEPENDS} | PAKET_PACKAGEDIR?= | ||||
PAKET_DEPENDS?= | |||||
NUGET_DEPENDS?= ${PAKET_DEPENDS} | |||||
. for feed in ${NUGET_FEEDS} | |||||
${feed}_DEPENDS?= | |||||
${feed}_FILE?= ${PKGDIR}/nupkg-${feed:tl} | |||||
. if exists(${${feed}_FILE}) | |||||
${feed}_EXTRA!= ${CAT} ${${feed}_FILE} | |||||
. else | |||||
${feed}_EXTRA= | |||||
. endif | |||||
. for depend in ${${feed}_DEPENDS} ${${feed}_EXTRA} | |||||
. if empty(_NUGET_DEPENDS:M${depend}) | |||||
id= ${depend:C/=.*$//} | id= ${depend:C/=.*$//} | ||||
version= ${depend:C/^.*=//} | version= ${depend:C/^.*=//} | ||||
group= nuget_${id:S/.//g:S/-//g} | group= nuget_${depend:S/.//g:S/-//g:S/=//g} | ||||
nupkg= ${id:tl}.${version}.nupkg | nupkg= ${id:tl}.${version}.nupkg | ||||
DISTFILES_${group}:= ${nupkg}:${group} | DISTFILES_${group}:= ${nupkg}:${group} | ||||
MASTER_SITES_${group}:= https://www.nuget.org/api/v2/package/${id}/${version}?dummy=/:${group} | MASTER_SITES_${group}:= ${${feed}_URL}package/${id}/${version}?dummy=/:${group} | ||||
NUGET_NUPKGS_${group}:= ${nupkg}:${depend} | NUGET_NUPKGS_${group}:= ${nupkg}:${depend} | ||||
DISTFILES+= ${DISTFILES_nuget_${depend:C/=.*$//:S/.//g:S/-//g}} | DISTFILES+= ${DISTFILES_nuget_${depend:S/.//g:S/-//g:S/=//g}} | ||||
MASTER_SITES+= ${MASTER_SITES_nuget_${depend:C/=.*$//:S/.//g:S/-//g}} | MASTER_SITES+= ${MASTER_SITES_nuget_${depend:S/.//g:S/-//g:S/=//g}} | ||||
NUGET_NUPKGS+= ${NUGET_NUPKGS_nuget_${depend:C/=.*$//:S/.//g:S/-//g}} | NUGET_NUPKGS+= ${NUGET_NUPKGS_nuget_${depend:S/.//g:S/-//g:S/=//g}} | ||||
_NUGET_DEPENDS+= ${depend} | |||||
. endif | |||||
. endfor | . endfor | ||||
. endfor | |||||
EXTRACT_ONLY?= ${_DISTFILES:N*.nupkg} | EXTRACT_ONLY?= ${_DISTFILES:N*.nupkg} | ||||
_USES_extract+= 600:nuget-extract | _USES_extract+= 600:nuget-extract | ||||
nuget-extract: | nuget-extract: | ||||
@${MKDIR} ${_NUGET_PACKAGEDIR} ${PAKET_PACKAGEDIR} | |||||
. for nupkg in ${NUGET_NUPKGS} | . for nupkg in ${NUGET_NUPKGS} | ||||
@${MKDIR} ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./} | @${MKDIR} ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|} | ||||
@${RM} -f ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:C/=.*//} | @tar -xf ${DISTDIR}/${nupkg:C/:.*$//} -C ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|} \ | ||||
@${LN} -s ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./} ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:C/=.*//} | |||||
@tar -xf ${DISTDIR}/${nupkg:C/:.*$//} -C ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./} \ | |||||
-s/%2B/\+/g -s/%2B/\+/g -s/%2B/\+/g \ | -s/%2B/\+/g -s/%2B/\+/g -s/%2B/\+/g \ | ||||
--exclude '\[Content_Types\].xml' \ | --exclude '\[Content_Types\].xml' \ | ||||
--exclude package/ \ | --exclude package/ \ | ||||
--exclude _rels/ | --exclude _rels/ | ||||
@${CP} ${DISTDIR}/${nupkg:C/:.*$//} ${NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./}/${nupkg:C/^.*://:S/=/./}.nupkg | @${CP} ${DISTDIR}/${nupkg:C/:.*$//} ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:S/=/./}.nupkg | ||||
@openssl dgst -sha512 -binary ${DISTDIR}/${nupkg:C/:.*$//} | openssl enc -base64 | ${TR} -d "\n" \ | |||||
> ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:S/=/./}.nupkg.sha512 | |||||
russ.haley_gmail.comUnsubmitted Done Inline ActionsCan you please give me a brief on what this section is doing? russ.haley_gmail.com: Can you please give me a brief on what this section is doing? | |||||
dbnAuthorUnsubmitted Done Inline ActionsNuget "caches" (I think nuget uses a different term) the packages in an extracted format, plus a few extra files:
The above line calculates the cache in base64 format, without trailing space. I would have used sha512 however our implemntationd doesn't support base64 output. dbn: Nuget "caches" (I think nuget uses a different term) the packages in an extracted format, plus… | |||||
@${LN} -s ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|} ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./} | |||||
. if ${nupkg:C/^.*://:tl} != ${nupkg:C/^.*://} | |||||
@${LN} -s ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:C/=.*$//}.nuspec ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:C/=.*$//:tl}.nuspec | |||||
@${LN} -s ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:S/=/./}.nupkg ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:S/=/./:tl}.nupkg | |||||
@${LN} -s ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:S/=/./}.nupkg.sha512 ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|}/${nupkg:C/^.*://:S/=/./:tl}.nupkg.sha512 | |||||
@${LN} -s ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S|=|/|} ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:S/=/./:tl} | |||||
@[ -e ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:C/=.*$//:tl} ] || ${LN} -s ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:C/=.*$//} ${_NUGET_PACKAGEDIR}/${nupkg:C/^.*://:C/=.*$//:tl} | |||||
. endif | |||||
. endfor | . endfor | ||||
@${LN} -s ${_NUGET_PACKAGEDIR} ${NUGET_PACKAGEDIR} | |||||
@${TOUCH} ${WRKDIR}/.nuget-sentinal | |||||
_USES_extract+= 601:paket-extract | |||||
paket-extract: | |||||
. for nupkg in ${PAKET_DEPENDS} | |||||
@${LN} -s ${_NUGET_PACKAGEDIR}/${nupkg:S|=|/|} ${PAKET_PACKAGEDIR}/${nupkg:C/=.*$//} | |||||
. endfor | |||||
.endif | .endif | ||||
makenuget: patch | makenuget: patch | ||||
@${FIND} ${WRKSRC} -name packages.config | \ | @${FIND} ${WRKSRC} -name packages.config | \ | ||||
${XARGS} ${SED} -nE 's|.*<package id="([^"]+)" version="([^"]+)"[^/]*/>.*|\1=\2|gp' | \ | ${XARGS} ${SED} -nE 's|.*<package id="([^"]+)" version="([^"]+)"[^/]*/>.*|\1=\2|gp' | \ | ||||
${SORT} -u | \ | ${SORT} -u | \ | ||||
${SED} \ | ${SED} \ | ||||
-e '1s|^|NUGET_DEPENDS= |' \ | -e '1s|^|NUGET_DEPENDS= |' \ | ||||
-e '2,$$s|^| |g' \ | -e '2,$$s|^| |g' \ | ||||
-e '$$!s|$$| \\|g' | -e '$$!s|$$| \\|g' | ||||
makenupkg: | |||||
.for feed in ${NUGET_FEEDS} | |||||
@[ -f ${WRKDIR}/.nupkg-${feed:tl} ] || mono ${NUGET_EXE} list -IncludeDelisted -PreRelease -Source ${${feed}_URL} | ${SED} 's/ .*//g' > ${WRKDIR}/.nupkg-${feed:tl} | |||||
@${RM} ${WRKDIR}/nupkg-${feed:tl} | |||||
.endfor | |||||
@for nupkg in `${FIND} ${_NUGET_PACKAGEDIR} -name '*.sha512' | ${SED} 's/\.sha512//g'`; \ | |||||
do \ | |||||
name="`tar -tf $${nupkg} | ${GREP} nuspec | ${SED} 's/.nuspec//g'`"; \ | |||||
version="`${BASENAME} $$(${DIRNAME} $$nupkg)`"; \ | |||||
${ECHO} "$$name=$${version#$$name.}"; \ | |||||
done | ${SORT} -u > ${WRKDIR}/.nupkgs | |||||
@${CAT} ${WRKDIR}/.nupkgs | while read nupkg; do \ | |||||
for feed in ${NUGET_FEEDS:tl}; do \ | |||||
if ${GREP} -q "^$${nupkg%%=*}\$$" ${WRKDIR}/.nupkg-$$feed; then \ | |||||
${ECHO} $$nupkg >> ${WRKDIR}/nupkg-$$feed; \ | |||||
break; \ | |||||
fi; \ | |||||
done; \ | |||||
done | |||||
.endif | .endif | ||||
Just a sanity check that mono_ARGS:Nnuget and mono_ARGS:Mnuget on line 77 are actually two different things and not a typo?