Gervase Markham wrote:
> 
> JTK wrote:
> 
> > Total number of files:           33202
> > Total number of licensed files:  14393
> > Total number of NPLed files:     9640
> > Total number of MPLed files:     4753
> > Total number of GPLed files:     2047
> > Total number of LGPLed files:    0
> > Total number of BSD files:       56
> > Total number of MIT files:       8
> >
> > Percent licensed under the NPL:  67%
> > Percent of MPL files also GPLed: 43%
> >
> > Notes:
> > - Whoah: is the squeaky wheel finally getting a little grease?!?
> > Fifty-one FEWER NPLed files this time, 14 MORE MPLed, and 3 more
> > GPLed.  Perhaps the proverbial single step on that journey of 9,640
> > miles?
> 

Damn, it would have been a better joke had I said "9,640 /files/".  Ah
well, live and learn if you're not careful.

> Well, if it's 9640 miles, then we've gone 51 miles, not a single step. :-)
>

Always the technicalities with you Gerv. ;-)
 
> > - Script is now Perlescent (in addition to its former
> > Bootyliscousness), hence better, stronger, faster.  Yep, I learned a
> > little Perl due solely to Mozilla, and will now never write another
> > shell script.  So don't say Mozilla never did nothing for me.
> 
> We won't say that - the question is, will you?
> 

Not in mixed company. ;-)

> > - Script has been made a bit more discerning at the request of Mr.
> > Markham, resulting in the new counts for LGPL (none),
> 
> That's not true. There are at least two. Can you find them?
> 

Ah, I can now.  And it's more like 70-some.  I was looking for "Lesser"
and not taking crusty old "Library" into account.  Fixed and fixed.  But
be it 70 or 0, I still call it "negligible".

> (This is so like "Where's Wally", which I think you guys call "Where's
> Waldo...)
>

Well, except the licenses aren't wearing striped shirts and goofy
stocking caps.
 
> > BSD (56), and
> > MIT (8) licenses.
> 
> Your script will have to be quite smart to catch all the BSD variants.

Oh it is Gerv, it is.  In fact, it may be the smartest Perl script ever
devised.  But as far as BSD goes, it just looks for "Regents of the
University of California".  Will that not catch any and all variants?

> Here are a few more fun things to think about:
> 
> Are you excluding the CVS special files in the CVS directories?

Um, no, why?  Nothing in them is licensed at all to my knowledge.  But
excluding them might speed up the script a bit, and get the total source
file count a bit more accurate, so I'll get that in there.

> How about the binary macbuild files in macbuild directories?

Why would I have mac binaries on my WhyME machine?

> What about gifs, jpegs, pngs and other assorted binaries with about 20
> different file extensions?

Here's the binary situation: Any obj's, exe's, and dll's are explicitly
excluded.  Everything else is left to the auspices of grep's -I option. 
But it probably wouldn't hurt to explicitly exclude known binary files,
again in the interest of speed if nothing else, so I'll add some of that
too.

That said, any graphics files in there are covered by some sort of
license, right?  How is that specified?

> Have you taken into account the large amount of dual licensing in the tree?

Yes.  All licenses are counted separately.

> If your tree is from yesterday or before, can you find the one file that
> is triply-licensed?
>

Can I pick it out?  No.  Is it counted?  Yes.

As for the age of the tree, all of my License Statsistics posts except
for the first one were from checkouts done immediately before running
the script, and the descrepancy on that first one was of course duly
noted.
 
> This is fun :-)
>

It'll get more fun the fewer NPLed files show up in my posts.  Oh wait,
and it'll get even funner than that if I attach the script!  Take a look
and see what you think.  This version incoporates a few of these
suggestions, so is not exactly the one which generated the above
numbers.

But be warned: it's GPLed.  Only GPLed.
 
> Gerv
#!/usr/local/bin/perl

#    lstats: A cool Perl script to summarize the licensing status of a project
#    Copyright (C) 2000  Gary R. Van Sickle
#    (tiberius at remove_this_if_you_are_not_a_spammer_braemarinc dot com)
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


use File::Find;
use Time::localtime;
use Cwd;

$ALL_FILES;
$NUM_FILES=0;
$NUM_NEW_FILES=0;
$NUM_NPL_FILES=0;
$NUM_MPL_FILES=0;
$NUM_GPL_FILES=0;
$NUM_LGPL_FILES=0;
$NUM_BSD_FILES=0;
$NUM_MIT_FILES=0;
$NUM_LICENSED_FILES=0;
$PCT_NPL=0;
$PCT_MPL_GPL=0;

$ELAPSED_TIME=time;

$ROOT_DIR=@ARGV[0];
if(length($ROOT_DIR) == 0)
{
        $ROOT_DIR = ".";
}

sub ScanFiles
{
        my (@NPL_FILES, @MPL_FILES, @GPL_FILES, @LGPL_FILES, @BSD_FILES, @MIT_FILES);
        
        #%NPLL_FILES = `grep -lisI "Mozilla Public" $_[0]`;
        #print "$NPLL_FILES[0]\n";
        
        print "N";
        @NPL_FILES = `grep -lisI "Netscape Public" $_[0]`;
        $NUM_NPL_FILES += scalar(@NPL_FILES);
        print "M";
        @MPL_FILES = `grep -lisI "Mozilla Public" $_[0]`;
        $NUM_MPL_FILES += scalar(@MPL_FILES);
        print "G";
        @GPL_FILES = `grep -lisI "GNU General Public License" $_[0]`;
        $NUM_GPL_FILES += scalar(@GPL_FILES);
        print "L";
        @LGPL_FILES = `egrep -lisI "GNU Lesser General Public|GNU Library General 
Public" $_[0]`;
        $NUM_LGPL_FILES += scalar(@LGPL_FILES);
        print "B";
        @BSD_FILES = `grep -lisI "Regents of the University of California" $_[0]`;
        $NUM_BSD_FILES += scalar(@BSD_FILES);
        print "m";
        @MIT_FILES = `grep -lisI "Massachusetts Institute of Technology" $_[0]`;
        $NUM_MIT_FILES += scalar(@MIT_FILES);
}

sub do_stats
{
        unless(grep(/\.obj$|\.exe$|\.dll$|\.jpg$|\.gif$|\.png$/i, $_))
        {
                $NUM_FILES++;
                $ALL_FILES=$ALL_FILES."\"".getcwd."/".$_."\" ";
                $NUM_NEW_FILES++;
                if($NUM_NEW_FILES == 500)
                {
                        ScanFiles($ALL_FILES);
                        $ALL_FILES = "";
                        $NUM_NEW_FILES = 0;
                }
        }
}

find(\&do_stats, $ROOT_DIR);

# Finish up any remainder files
if($NUM_NEW_FILES > 0)
{
        ScanFiles($ALL_FILES);
}
print "\n";

$ELAPSED_TIME=time-$ELAPSED_TIME;

$NUM_LICENSED_FILES = $NUM_NPL_FILES + $NUM_MPL_FILES;
if($NUM_LICENSED_FILES > 0)
{
        $PCT_NPL = ($NUM_NPL_FILES*100)/$NUM_LICENSED_FILES;
}
else
{
        $PCT_NPL = "--";
}
if($NUM_MPL_FILES > 0)
{
        $PCT_MPL_GPL = ($NUM_GPL_FILES*100)/$NUM_MPL_FILES;
}
else
{
        $PCT_MPL_GPL = "--";
}

printf "\nLicensing Statistics (%d-%.2d-%.2d)\n", localtime->year+1900, 
localtime->mon+1, localtime->mday;
print "Elapsed time:                    ", $ELAPSED_TIME, " seconds\n";
print "Total number of files:           ", $NUM_FILES, "\n";
print "Total number of licensed files:  ", $NUM_LICENSED_FILES, "\n";
print "Total number of NPLed files:     ", $NUM_NPL_FILES, "\n";
print "Total number of MPLed files:     ", $NUM_MPL_FILES, "\n";
print "Total number of GPLed files:     ", $NUM_GPL_FILES, "\n";
print "Total number of LGPLed files:    ", $NUM_LGPL_FILES, "\n";
print "Total number of BSD files:       ", $NUM_BSD_FILES, "\n";
print "Total number of MIT files:       ", $NUM_MIT_FILES, "\n";
print "\n";
printf("Percent licensed under the NPL:  %2.0f%%\n", $PCT_NPL);
printf("Percent of MPL files also GPLed: %2.0f%%\n", $PCT_MPL_GPL);


Reply via email to