diff options
author | dbn <dbn@FreeBSD.org> | 2018-09-12 22:53:21 +0800 |
---|---|---|
committer | dbn <dbn@FreeBSD.org> | 2018-09-12 22:53:21 +0800 |
commit | fad9956b07f2a6c6c6291b9adf649da2aaa76cf5 (patch) | |
tree | 1410e62d7dc88864dfdc0374ca216596bd65a1b5 /Mk | |
parent | 6910131ca131fef8a7921ce91d335f6747ec0e40 (diff) | |
download | freebsd-ports-gnome-fad9956b07f2a6c6c6291b9adf649da2aaa76cf5.tar.gz freebsd-ports-gnome-fad9956b07f2a6c6c6291b9adf649da2aaa76cf5.tar.zst freebsd-ports-gnome-fad9956b07f2a6c6c6291b9adf649da2aaa76cf5.zip |
USES=mono: improve makenupkg
- add support for v3 of the nuget API
- switch to using v3 for NUGET [1]
- rewrite makenupkg to avoid full feed list [2]
- change fetch group to allow "+" in package name/version
[1] NUGET redirects to the source under the v2 API, however this breaks
`makenupkg` as curl fails to follow the redirect when getting the header.
[2] Previously, makenupkg got the complete list of packages (and versions)
a feed. However, for some feeds this takes a very really long time (slow
server response rate). To avoid this, rather check if the package is
available (without downloading it).
Diffstat (limited to 'Mk')
-rw-r--r-- | Mk/Uses/mono.mk | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/Mk/Uses/mono.mk b/Mk/Uses/mono.mk index f7de10c1b801..d1e56fd52ab2 100644 --- a/Mk/Uses/mono.mk +++ b/Mk/Uses/mono.mk @@ -102,7 +102,8 @@ _NUGET_PACKAGEDIR= ${WRKDIR}/.nuget/packages NUGET_PACKAGEDIR?= ${WRKSRC}/packages NUGET_LAYOUT?= legacy NUGET_FEEDS?= NUGET -NUGET_URL?= https://www.nuget.org/api/v2/ +NUGET_URL?= https://api.nuget.org/v3-flatcontainer/ +NUGET_VERSION?= v3 PAKET_PACKAGEDIR?= PAKET_DEPENDS?= @@ -112,19 +113,25 @@ NUGET_DEPENDS?= ${PAKET_DEPENDS} ${feed}_DEPENDS?= ${feed}_FILE?= ${PKGDIR}/nupkg-${feed:tl} ${feed}_URL?= https://dotnet.myget.org/F/${feed:tl:S/_/-/g}/api/v2/ +${feed}_VERSION?= v2 . if exists(${${feed}_FILE}) ${feed}_EXTRA!= ${CAT} ${${feed}_FILE} . else ${feed}_EXTRA= . endif +MAKENUPKG_ENV+= ${feed:tl}_URL="${${feed}_URL}" ${feed:tl}_VERSION="${${feed}_VERSION}" . for depend in ${${feed}_DEPENDS} ${${feed}_EXTRA} . if empty(_NUGET_DEPENDS:M${depend}) id= ${depend:C/=.*$//} version= ${depend:C/^.*=//} -group= nuget_${depend:S/.//g:S/-//g:S/=//g} +group= nuget_${depend:C/[.+=-]//g} nupkg= ${id:tl}.${version}.nupkg DISTFILES_${group}:= ${nupkg}:${group} +. if ${${feed}_VERSION} == v2 MASTER_SITES_${group}:= ${${feed}_URL}package/${id}/${version}?dummy=/:${group} +. else +MASTER_SITES_${group}:= ${${feed}_URL}${id:tl}/${version}/:${group} +. endif NUGET_NUPKGS_${group}:= ${nupkg}:${depend} NUPKGS_${id}:= ${NUPKGS_${id}} ${version} @@ -202,29 +209,26 @@ makenuget: patch -e '$$!s|$$| \\|g' makenupkg: - @[ -f ${NUGET_EXE} ] || fetch -o ${NUGET_EXE} ${NUGET_LATEST_URL} -.for feed in ${NUGET_FEEDS} - @[ -f ${WRKDIR}/.nupkg-${feed:tl} -o ${feed} = NUGET ] || mono ${NUGET_EXE} list -AllVersions -IncludeDelisted -PreRelease -Source ${${feed}_URL} | ${SED} 's/ /=/g' > ${WRKDIR}/.nupkg-${feed:tl} - @${RM} ${WRKDIR}/nupkg-${feed:tl} -.endfor + @${RM} ${WRKDIR}/nupkg-* @for nuspec in `${FIND} ${_NUGET_PACKAGEDIR} -name '*.nuspec'`; do \ name="`${SED} -nE 's|.*<id>(.*)</id>.*|\1|p' $$nuspec`"; \ version="`${SED} -nE 's|.*<version>(.*)</version>.*|\1|p' $$nuspec`"; \ - ${ECHO} $$name=$$version; \ - done | ${SORT} -u > ${WRKDIR}/.nupkgs - @${CAT} ${WRKDIR}/.nupkgs | while read nupkg; do \ - default=no; \ - for feed in ${NUGET_FEEDS:tl}; do \ - if [ $$feed = nuget ]; then \ - default=yes; \ - elif ${GREP} -q "^$$nupkg\$$" ${WRKDIR}/.nupkg-$$feed; then \ - ${ECHO} $$nupkg >> ${WRKDIR}/nupkg-$$feed; \ - default=na; \ + echo $$name=$$version ; \ + done | ${SORT} -u | ${SETENV} ${MAKENUPKG_ENV} ${XARGS} -n1 sh -c ' \ + for feed in ${NUGET_FEEDS:MNUGET:tl} ${NUGET_FEEDS:NNUGET:tl}; do \ + if eval [ "\$${$${feed}_VERSION}" = v2 ]; then \ + eval url="\$${$${feed}_URL}package/$${0%%=*}/$${0##*=}"; \ + else \ + eval url="\$${$${feed}_URL}$${0%%=*}/$${0##*=}/$${0%%=*}.$${0##*=}.nupkg"; \ + fi; \ + if curl --output /dev/null --silent --head --fail $$url; then\ + ${ECHO} $$0 >> ${WRKDIR}/nupkg-$$feed; \ + found=yes; \ break; \ fi; \ done; \ - if [ $$default = yes ]; then \ - ${ECHO} $$nupkg >> ${WRKDIR}/nupkg-nuget; \ - fi; \ - done + if [ -z "$$found" ]; then \ + echo "$$0: no feed found"; \ + exit 1; \ + fi' .endif |