In https://reviews.freebsd.org/D19087 I added an optional patchset to an existing port. The main distfile for the port is fetched via ftp/http, but the patchset comes from GitHub. As such, I used USE_GITHUB=nodefault so that it would only be used for the optional patchset. However, when I did that, DISTFILES was set to only include the patchset from GitHub and did not include the "default" DISTFILES setting for the main distfile. I had to explicitly set DISTFILES to the default value as a workaround. I'm not sure if this is fixable? Maybe when USE_GITHUB sets DISTFILES it could include the default DISTFILES value in the "nodefault" case if DISTFILES isn't already defined? Looking at other ports using USE_GITHUB=nodefault, it seems like the following ports use the same workaround: audio/x42-plugins-lv2 lang/dmd2 databases/mantis graphics/vkd3d math/py-pynleq2 net/wireguard-go (uses a DISTFILES that is effectively the default) security/obfs4proxy-tor sysutils/tmux sysutils/tmux23 www/nginx www/nginx-devel On the other hand, it seems like the following ports depend on the current behavior and only have non default distfiles from GitHub. It's not clear to me why they need to use 'nodefault' vs just 'yes' in that case? devel/abi-compliance-checker games/redeclipse-data lang/dmd2 One I'm not sure about is dns/amass. It says it only uses nodefault to avoid a circular dependency? One more special case is science/dalton which uses GitLab for the default distfile. Finally, www/kurly uses both USE_GITLAB=nodefault and USE_GITHUB=nodefault and doesn't have a default distfile at all. I think it would be nice if "nodefault" kept the default DISTFILES setting if DISTFILES wasn't explicitly set by the Makefile (and perhaps a port could set it to empty when it has no default distfiles), but if that's too hard to fix, then perhaps update the docs to note this? When I was reading the section on fetching distfiles from GitHub and nodefault, I had assumed it would preserve the default behavior for the default DISTFILES rather than requiring DISTFILES to be explicitly set.
I have been pondering about this for a while, and while working on some cleanup of the USE_GITHUB code today, I looked into it in more depth. It is a bit hard to fix in a non kludgy way because the USE_GITHUB (and USE_GITLAB) code appears earlier in the framework than the place where DISTFILES is set, and neither can really be moved... I thought our documentation talked about this, but it looks like it is one of the things that slipped my mind. I will add a note and an example about it.
A commit references this bug: Author: mat Date: Thu May 2 14:18:22 UTC 2019 New revision: 52974 URL: https://svnweb.freebsd.org/changeset/doc/52974 Log: Document that USE_GIT(HUB|LAB)=nodefault needs some special handling. PR: 235762 Reported by: jhb Changes: head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml
A simple, but very ugly, fix would be this: diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk index 2f3abff5130d..f3441049c130 100644 --- a/Mk/bsd.port.mk +++ b/Mk/bsd.port.mk @@ -2198,6 +2198,10 @@ INSTALL_TARGET+= ${LATE_INSTALL_ARGS} .include "${PORTSDIR}/Mk/bsd.licenses.mk" .endif +.if empty(DISTFILES) +_I_MAY_NEED_TO_SET_DISTFILES= probably +.endif + # Popular master sites .include "${PORTSDIR}/Mk/bsd.sites.mk" @@ -2427,7 +2431,9 @@ NOFETCHFILES?= # Organize DISTFILES, PATCHFILES, _MASTER_SITES_ALL, _PATCH_SITES_ALL # according to grouping rules (:something) -DISTFILES?= ${DISTNAME}${EXTRACT_SUFX} +.if defined(_I_MAY_NEED_TO_SET_DISTFILES) +DISTFILES+= ${DISTNAME}${EXTRACT_SUFX} +.endif _MASTER_SITES_ALL= ${_MASTER_SITES_DEFAULT} _PATCH_SITES_ALL= ${_PATCH_SITES_DEFAULT} _G_TEMP= DEFAULT diff --git a/Mk/bsd.sites.mk b/Mk/bsd.sites.mk index f54e82b36dcf..426dd975734c 100644 --- a/Mk/bsd.sites.mk +++ b/Mk/bsd.sites.mk @@ -452,6 +452,7 @@ _GITHUB_EXTRACT_SUFX= .tar.gz _GITHUB_CLONE_DIR?= ${WRKDIR}/git-clone _PORTS_DIRECTORIES+= ${_GITHUB_CLONE_DIR} . if !${USE_GITHUB:Mnodefault} && empty(MASTER_SITES:MGHC) +.undef _I_MAY_NEED_TO_SET_DISTFILES # GH_TAGNAME defaults to DISTVERSIONFULL; Avoid adding DISTVERSIONFULL in twice . if ${GH_TAGNAME} != ${DISTVERSIONFULL} DISTNAME= ${GH_ACCOUNT}-${GH_PROJECT}-${DISTVERSIONFULL}-${GH_TAGNAME_SANITIZED} @@ -595,6 +596,7 @@ _GITLAB_EXTRACT_SUFX= .tar.gz _GITLAB_CLONE_DIR?= ${WRKDIR}/git-clone _PORTS_DIRECTORIES+= ${_GITLAB_CLONE_DIR} . if !${USE_GITLAB:Mnodefault} +.undef _I_MAY_NEED_TO_SET_DISTFILES DISTNAME:= ${GL_ACCOUNT}-${GL_PROJECT}-${GL_COMMIT}_GL${_GITLAB_REV} DISTFILES+= ${DISTNAME}${_GITLAB_EXTRACT_SUFX} git-clone: git-clone-DEFAULT
I think documenting it is probably the best option. You might have a port that uses 'nodefault' for GitHub but not GitLab and I'm not sure it's easy to make all the different combinations work cleanly. I am somewhat confused by the ports I mentioned that use nodefault instead of 'yes' and only have non-default distfiles. That does seem unusual, but separate from this.
I think those ports do that because they try to go around the framework that does not work as they please. I tried to make them see the light a few times, got fed up, stopped caring.