Subject: Ordering of variables in Makefile
To: None <tech-pkg@netbsd.org>
From: Roland Illig <rillig@NetBSD.org>
List: tech-pkg
Date: 11/07/2005 02:22:33
Roland Illig wrote:
> Log Message:
> Updated pkglint to 4.38.
> 
> - PKGNAME is checked for being a valid package name.
> - PLIST files should not contain filenames that match */CVS/*.
> - Completely rewrote the check for variable ordering. The new code
>   operates on a data structure that's easily understandable and
>   extendable (see the source for an example). It also generates greatly
>   improved diagnostics. As the old code had been enabled only when
>   checking with -Wvague or -Wall, it has been seldom used anyway.

These changes add another 650 warnings to the complete pkgsrc tree
(excluding wip). Some of the warnings concerning the order of variables
are questionable, as there is no consensus about the Right Order. (At
least not between me and some other developers.)

The current order of variables, which I have just copied from the old
code of pkglint, is:

DISTNAME section:
   [ "DISTNAME", once ],
   [ "PKGNAME",  optional ],
   [ "PKGREVISION", optional ],
   [ "SVR4_PKGNAME", optional ],
   [ "CATEGORIES", once ],
   [ "MASTER_SITES", once ],
   [ "DYNAMIC_MASTER_SITES", optional ],
   [ "MASTER_SITE_SUBDIR", optional ],
   [ "EXTRACT_SUFX", optional ],
   [ "DISTFILES", optional ],
# The following are questionable.
# [ "NOT_FOR_PLATFORM", optional ],
# [ "ONLY_FOR_PLATFORM", optional ],
# [ "NO_BIN_ON_FTP", optional ],
# [ "NO_SRC_ON_FTP", optional ],
# [ "NO_BIN_ON_CDROM", optional ],
# [ "NO_SRC_ON_CDROM", optional ],

PATCH_SITES section:
   [ "PATCH_SITES", optional ], # or once?
   [ "PATCH_SITE_SUBDIR", optional ],
   [ "PATCHFILES", optional ], # or once?
   [ "PATCH_DIST_ARGS", optional ],
   [ "PATCH_DIST_STRIP", optional ],
   [ "PATCH_DIST_CAT", optional ],

MAINTAINER section:
   [ "MAINTAINER", once ],
   [ "HOMEPAGE", optional ],
   [ "COMMENT", once ],

DEPENDS section:
   [ "BUILD_DEPENDS", many ],
   [ "DEPENDS", many ],

See for example the misc/openoffice-bin package. It starts with defining
PKGNAME instead of DISTNAME, as DISTNAME highly depends on the
architecture. Should such a variable really be the one that is mandatory
for each package and mentioned at the top? I still prefer PKGNAME.

If I could decide on the order, there would be the following sections:

pkgsrc-specific information:
   PKGNAME, PKGREVISION, SVR4_PKGNAME, CATEGORIES, COMMENT, MAINTAINER.

Upstream package information:
   HOMEPAGE, MASTER_SITES, DYNAMIC_MASTER_SITES, MASTER_SITE_SUBDIR,
   DISTFILES, DISTNAME, EXTRACT_SUFX.

Downloading patches:
   (no change to this section)

Dependencies:
   (no change to this section)

The rationale for this is that the first section then contains the
pkgsrc-specific information, whereas the second category contains the
upstream package's information. Both clearly separated. This is also the
reason why I would put the HOMEPAGE into the second section. Also, this
change would make it much easier to see in how far the HOMEPAGE and the
MASTER_SITES equal each other, as they are in adjacent lines of the
Makefile.

The patches section should stay as it is now, first because it is seldom
needed, second because otherwise the upstream section gets too big.

I already know from experience that it is difficult to convince many of
you that the things you got used to can be improved. Or maybe it's just
that I don't find the right words to do that. Well, I keep trying. :)

Roland