Something wrong with portlint?

Frank Laszlo laszlof at vonostingroup.com
Tue Jan 24 13:15:05 PST 2006


__________________________________________________
Frank Laszlo
System Administrator
The VonOstin Group
Email:  laszlof at tvog.net
WWW:    http://www.vonostingroup.com
Mobile: 248-863-7584



Paul Schmehl wrote:
> --On Tuesday, January 24, 2006 15:57:43 -0500 Frank Laszlo
> <laszlof at vonostingroup.com> wrote:
>
>> Paul Schmehl wrote:
>>> --On Tuesday, January 24, 2006 12:47:40 -0800 Brooks Davis
>>> <brooks at one-eyed-alien.net> wrote:
>>>
>>>> On Tue, Jan 24, 2006 at 02:38:56PM -0600, Paul Schmehl wrote:
>>>>> --On Tuesday, January 24, 2006 15:24:43 -0500 Frank Laszlo
>>>>> <laszlof at vonostingroup.com> wrote:
>>>>> >
>>>>> > Put a newline after the "commented" section on the top, all is
>>>>> fine.
>>>>> > Like so:
>>>>> >
>>>>> ># New ports collection makefile for:    barnyard
>>>>> ># Date created:                         1 Feb 2005
>>>>> ># Whom:                                 pauls
>>>>> >#
>>>>> ># $FreeBSD: ports/security/barnyard/Makefile,v 1.5 2005/11/15
>>>>> 06:50:54
>>>>> > ade Exp $
>>>>> >#
>>>>> > <newline here>
>>>>> > PORTNAME=       barnyard
>>>>> >
>>>>> >
>>>>> > Cheers,
>>>>> >    Frank
>>>>>
>>>>> Sheesh.  Wouldn't it be nice if the Handbook actually stipulated
>>>>> that?
>>>>
>>>> Or better yet if the worthless comment section died except for the
>>>> $FreeBSD$ bit. :-P
>>>>
>>> But you'd still have the required newline between that and the text of
>>> the Makefile, right?
>>>
>>>
>> It shouldn't really be required, its mostly just cosmetic.
>>
> But if you leave it out, it drives portlint nuts.
>
Portlint splits the Makefile up into sections, and I believe the code to
do this is where the 'requirement' for the newline exists. Here is the
applicable code:
<--- Begin Code --->
    #
    # break the makefile into sections.
    #
    $tmp = $rawwhole;
    # keep comment, blank line, comment in the same section
    $tmp =~ s/(#.*\n)\n+(#.*)/$1$2/g;
    @sections = split(/\n\n+/, $tmp);
    for ($i = 0; $i <= $#sections; $i++) {
        if ($sections[$i] !~ /\n$/) {
            $sections[$i] .= "\n";
        }
    }
    $idx = 0;

    #
    # section 1: comment lines.
    #
    print "OK: checking comment section of $file.\n" if ($verbose);
    my @linestocheck = split("\n", <<EOF);
Whom
Date [cC]reated
EOF

<..snip..>

    $tmp = $sections[$idx++];
    $tmp = "\n" . $tmp; # to make the begin-of-line check easier

    if ($tmp =~ /\n[^#]/) {
        &perror("FATAL: $file: non-comment line in comment section.");
    }

<--- End Code--->

As you can see it splits the sections based on 2 consecutive \n's.
(equivalent to the end of one line, and a blank line) Then when it gets
to the actual checking portion, it checks the 'comment' section, which
now contains everything in the "PORTNAME" section because there was no
newline to split it. This part does not start with a '#' so it errors
out, and complains about missing the PORTNAME, CATEGORIES, etc. because
they were in the comment section, Seems like there should be a matter
way to do this.

Regards,
    Frank


More information about the freebsd-ports mailing list