Bug 246196 - Mk/bsd.port.mk: github groups conflict with WRKSRC_SUBDIR
Summary: Mk/bsd.port.mk: github groups conflict with WRKSRC_SUBDIR
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-04 21:23 UTC by Sergei Vyshenski
Modified: 2020-09-08 17:56 UTC (History)
4 users (show)

See Also:


Attachments
patch to fix bsd.port.mk (542 bytes, patch)
2020-05-04 21:23 UTC, Sergei Vyshenski
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Vyshenski 2020-05-04 21:23:23 UTC
Created attachment 214127 [details]
patch to fix bsd.port.mk

Problem: Using github groups 
(see 5.4.3.1. "Fetching Multiple Files from GitHub" of Porter's Handbook)
along with non-empty WRKSRC_SUBDIR
leads to garbage in WRKSRC variable.

Consider hypotetical port from Example 5.15 of Porter's Handbook,
with addition of non-empty WRKSRC_SUBDIR.

security/foo/Makefile:
--------------------------
PORTNAME=       foo
DISTVERSION=    1.0.2
CATEGORIES=     security

USE_GITHUB=     yes
GH_ACCOUNT=     bar:icons,contrib
GH_PROJECT=     foo-icons:icons foo-contrib:contrib
GH_TAGNAME=     1.0:icons fa579bc:contrib

WRKSRC_SUBDIR=  core/server/

.include <bsd.port.mk>
--------------------------

Experiment 1. With original file Mk/bsd.port.mk.orig:
$ cd /usr/ports/security/foo
$ make -V WRKSRC
/usr/ports/security/foo/work/foo-icons:icons foo-contrib:contrib-1.0.2/core/server/

which definitely puts garbage into WRKSRC variable.

Experiment 2. With patched file Mk/bsd.port.mk:
$ cd /usr/ports/security/foo
$ make -V WRKSRC
/usr/ports/security/foo/work/foo-1.0.2/core/server/

which works as intended.

The reason of failure with original file Mk/bsd.port.mk.orig is in its lines 1725-1727:

.if defined(WRKSRC_SUBDIR)
WRKSRC:=                ${WRKSRC}/${WRKSRC_SUBDIR}
.endif

which come earlier, than line 2245:
.include "${PORTSDIR}/Mk/bsd.sites.mk"

Hence value of GH_PROJECT in line 1705:
WRKSRC?=                ${WRKDIR}/${GH_PROJECT}-${GH_TAGNAME_EXTRACT}
contains a list of data: 
GH_PROJECT== foo-icons:icons foo-contrib:contrib
instead of needed value:
GH_PROJECT== foo

Proposed change to line 1705, that is substitute
GH_PROJECT ---> GH_PROJECT_DEFAULT
solves the problem, because GH_PROJECT_DEFAULT==foo 
during all stages of "make" operation.
Comment 1 Sergei Vyshenski 2020-05-04 21:35:13 UTC
This patch also works fine for ports with github origin, which do not have submodules (groups).
Comment 2 Sergei Vyshenski 2020-05-04 22:33:22 UTC
See PR#245375 for a real example of existing port with conflict between github groups and non-empty WRKSRC_SUBDIR.