Bug in ports system's DISTFILES handling?

Conrad J. Sabatier conrads at cox.net
Mon Jan 17 19:14:48 UTC 2005


As the (relatively new) maintainer of games/gnuchess, I recently
encountered a peculiar problem re: the handling of DISTFILES=
declarations (actually DISTFILES+= declarations, to be more precise),
which I think may have exposed an actual bug in the ports build system.

Basically, this port has both a standard source distfile
"gnuchess-5.0.7.tar.gz", i.e., ${PORTNAME}${PORTVERSION}${EXTRACT_SUFX},
as well as an optional file "book_1.01.pgn.gz", which is used to
creating the opening book for gnuchess, based on the setting of the
Makefile's OPENING_BOOK option.  This latter file is handled via a
script, as it must be renamed to book.dat after extraction, before being
submitted to gnuchess to generate its opening book file, hence the use
of EXTRACT_ONLY= within the conditional block.

Here's the current CVS version of the Makefile:

# New ports collection makefile for:	Gnu Chess
# Date created:		04 July 1996
# Whom:			markm
#
# $FreeBSD: ports/games/gnuchess/Makefile,v 1.20 2004/12/28 23:19:42
edwin Exp $#

PORTNAME=	gnuchess
PORTVERSION=	5.07
CATEGORIES=	games
MASTER_SITES=	${MASTER_SITE_GNU}
MASTER_SITE_SUBDIR=	chess

MAINTAINER=	conrads at cox.net
COMMENT=	"Classic" Gnu Chess

PLIST_FILES=	bin/gnuchess \
		bin/gnuchessx

.if !defined(NOPORTDOCS)
PORTDOCS=	ChangeLog \
		NEWS \
		README
.endif

OPTIONS=    OPENING_BOOK "Install opening book (24 MB download)" on

.include <bsd.port.pre.mk>

.if defined(WITH_OPENING_BOOK)
DISTFILES+=	book_1.01.pgn.gz
PLIST_DIRS+=	%%DATADIR%%
PLIST_FILES+=	%%DATADIR%%/book.dat
EXTRACT_ONLY=	${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX}
.endif

USE_REINPLACE=	yes
GNU_CONFIGURE=	yes
CONFIGURE_TARGET=	--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
CONFIGURE_ENV=	LIBS="${PTHREAD_LIBS}"

post-patch:
	@${REINPLACE_CMD} -e 's|-D_THREAD_SAFE|${PTHREAD_CFLAGS:S/"//g}|g ; \
		 s|-pthread ||g' ${WRKSRC}/configure

pre-install:
.if defined(WITH_OPENING_BOOK)
	@${SH} ${SCRIPTDIR}/create_opening_book.sh ${DISTDIR} ${WRKSRC}
.endif

post-install:
	${LN} -f ${PREFIX}/bin/gnuchess ${PREFIX}/bin/gnuchessx
.if defined(WITH_OPENING_BOOK)
	@${ECHO_CMD} Installing opening book
	${MKDIR} ${DATADIR} && \
	${CP} ${WRKSRC}/src/book.dat ${DATADIR}
.endif
.if !defined(NOPORTDOCS)
	@${ECHO_CMD} Installing documentation
	${MKDIR} ${DOCSDIR} && \
	${CP} ${WRKSRC}/NEWS ${DOCSDIR} && \
	${CP} ${WRKSRC}/doc/* ${DOCSDIR}
.endif

.include <bsd.port.post.mk>


This all appears to be fine, and portlint accepts it without complaint,
yet when the fetch target is run, the source package, i.e., 
gnuchess-5.0.7.tar.gz, is not retrieved, regardless of the setting of
the OPENING_BOOK option, whereas the book file is handled properly.

Running 'portlint-v' on the port reveals that the conditionally executed
"DISTFILES+=	book_1.01.pgn.gz" line is, in fact, appending to a
previously null variable, whereas one would expect that DISTFILES would
have already been set equal to DISTNAME automatically.

In order to please portlint, my first attempt at remedying the problem
was to add an explicit DISTNAME= line to the first block of
declarations, but this still didn't work, producing exactly the same
errors.

It was only by adding an explicit
"DISTFILES=${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX}" to the first block
that the problem went away, although portlint now complains about using
DISTFILES= for only a single file, apparently not taking into
consideration at all the later, optional appending of the opening book
file.

Incidentally, portlint also complains that the EXTRACT_ONLY= line should
appear earlier, but I have to agree with Edwin Groothuis (who made a few
small mods to the Makefile after my original submission) that this line
belongs where it is now, within the conditional block.

Anyway, does this look like a genuine bug to anyone?  It sure does to
me.  You'll note that the Makefile also uses PLIST_DIRS+= and
PLIST_FILES+= declarations, but these behave exactly as one would
expect, whereas DISTFILES+= seems to be badly broken.  Shouldn't
DISTFILES be automatically set equal to DISTNAME early on, prior to any
other declarations which may alter or override it?

Thanks for taking the time to read this.

-- 
Conrad J. Sabatier <conrads at cox.net> -- "In Unix veritas"



More information about the freebsd-ports-bugs mailing list