[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Pkg-octave-devel] Some packages ported to gbp + new version of octave-pkg-dev



* Sébastien Villemot <sebastien.villemot@ens.fr> [2012-03-09 11:43]:                                                                                        
                                                                                                                                                            
> Also, I would recommend that all the packages that have already a                                                                                         
> machine-readable debian/copyright upgrade to the finalized specification                                                                                  
> (see [1]). It can be helpful to run "cme fix dpkg-copyright" from                                                                                         
> package libconfig-model-perl.                                                                                                                             
>                                                                                                                                                           
> [1] http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/                                                                                     
                                                                                                                                                            
Generating the debian/copyright is really time-consuming.  I wrote a                                                                                        
Python script that (sort of) automates the process.  It is attached                                                                                         
below.  As an example, also attached below is the stdout output when                                                                                        
running it from the top-level directory of the octave-optim package.                                                                                        
                                                                                                                                                            
Note that files and years/authors are grouped in a sensible way.  The                                                                                       
output is not 100% perfect and will need further edition.  The script                                                                                       
appears to correctly detect the (L)GPL terms and the license version, but                                                                                   
only if the standard text recommended by the FSF is present.                                                                                                
                                                                                                                                                            
Tell me what you think, please.  Should we include this script in                                                                                           
octave-pkg-dev?                                                                                                                                             
                                                                                                                                                            
Rafael                                                                                                                                                      
#!/usr/bin/python

### Copyright (C) 2012  Rafael Laboissiere
###
### 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 3 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, see <http://www.gnu.org/licenses/>.

import re
import os
import subprocess
import textwrap

lgpl_re = re.compile (r'.*L(?:esser|ibrary).*General.*Public.*License.*either.*version[^\d](\d).*',
                     re.MULTILINE | re.DOTALL)
gpl_re = re.compile (r'.*General.*Public.*License.*either.*version[^\d](\d).*',
                     re.MULTILINE | re.DOTALL)

for d in ['inst', 'src']:

    if os.path.isdir (d):

        proc = subprocess.Popen (['grep', '-r', 'Copyright', d],
                                 stdout = subprocess.PIPE)
        lines = proc.communicate () [0].splitlines ()
        files = dict ()

        for i in range (len (lines)):
            line = lines [i]
            m = re.match (r'([^:]+):\D+(\d\d\d\d[^<]+)', line)
            if m:
                name = m.group (1)
                notice = re.sub (r' +', ' ', m.group (2).rstrip ())
                notice = re.sub (r'\. All rights reserved\.', '', notice)
                if name in files:
                    files [name] += ('\n           %s' % notice)
                else:
                    files [name] = notice

        for k in files:
             files [k] += '\nLicense:'
             fid = open (k)
             content = fid.read ()
             fid.close ()
             m = lgpl_re.match (content)
             if m:
                 files [k] += ' LGPL-%s+' % m.group (1)
             else:
                 m = gpl_re.match (content)
                 if m:
                     files [k] += ' GPL-%s+' % m.group (1)

        copyrights = dict ()

        for k, v in files.iteritems ():
            if v in copyrights:
                copyrights [v].append (k)
            else:
                copyrights [v] = [k]

        for k, v in copyrights.iteritems ():
            print ('Files: %s\nCopyright: %s\n'
                   % (textwrap.fill (' '.join (v),
                                     width = 75,
                                     initial_indent = '',
                                     subsequent_indent = ' '),
                      k))
Files: inst/nelder_mead_min.m
Copyright: 2002-2008 Etienne Grossmann
License: GPL-2+

Files: inst/nmsmax.m inst/adsmax.m inst/mdsmax.m
Copyright: 2002 N.J.Higham
License:

Files: inst/nrm.m inst/line_min.m
Copyright: 2000 Ben Sapp
License: GPL-2+

Files: inst/deriv.m
Copyright: 2000 Ben Sapp
           2011 Joaquín Ignacio Aramendía
           2011 Carnë Draug
License: GPL-3+

Files: inst/de_min.m
Copyright: 2009-2010 Christian Fischer
           1996, 1997 R. Storn
License: GPL-3+

Files: inst/vfzero.m
Copyright: 2008, 2009 VZLU Prague, a.s.
License: GPL-3+

Files: inst/optim_problems.m
Copyright: 2010 Olaf Till
           2007 Paul Kienzle (sort-based lookup in ODE solver)
           2009 Thomas Treichl
License: GPL-3+

Files: inst/linprog.m
Copyright: 2009 Luca Favatella
License: GPL-2+

Files: inst/private/__null_optim__.m
Copyright: 1994-2011 John W. Eaton
License: GPL-3+

Files: inst/test_min_2.m inst/optimset_compat.m inst/test_nelder_mead_min_2.m
 inst/test_d2_min_3.m inst/test_d2_min_1.m inst/d2_min.m inst/poly_2_ex.m
 inst/test_min_1.m inst/test_min_4.m inst/cdiff.m
 inst/test_nelder_mead_min_1.m inst/test_fminunc_1.m inst/minimize.m
 inst/test_d2_min_2.m inst/test_min_3.m inst/test_minimize_1.m
 inst/fminunc_compat.m
Copyright: 2002 Etienne Grossmann
License: GPL-2+

Files: inst/fmin.m
Copyright: 2001 Paul Kienzle
License: GPL-2+

Files: inst/private/__covd_wls__.m inst/private/__residmin_stat__.m
 inst/curvefit_stat.m inst/residmin_stat.m inst/private/__covp_corp_wls__.m
Copyright: 2011 Olaf Till
License: GPL-3+

Files: inst/battery.m inst/samin_example.m inst/rosenbrock.m
Copyright: 2004 Michael Creel
License: GPL-2+

Files: inst/dcdp.m inst/dfpdp.m inst/gjp.m inst/cpiv_bard.m inst/dfxpdp.m
Copyright: 2010, 2011 Olaf Till
License: GPL-2+

Files: inst/bfgsmin_example.m
Copyright: 2004,2005,2006 Michael Creel
License: GPL-2+

Files: inst/private/__lm_svd__.m inst/private/__dfdp__.m inst/leasqr.m inst/dfdp.m
Copyright: 1992-1994 Richard Shrager
           1992-1994 Arthur Jutan
           1992-1994 Ray Muzic
           2010, 2011 Olaf Till
License: GPL-2+

Files: inst/fmins.m
Copyright: 2003 Andy Adler
License: GPL-2+

Files: inst/jacobs.m
Copyright: 2011 Fotios Kasolis
License: GPL-3+

Files: inst/LinearRegression.m
Copyright: 2007 Andreas Stahel
License: GPL-2+

Files: inst/bfgsmin.m
Copyright: 2006 Michael Creel
License: GPL-2+

Files: inst/expfit.m
Copyright: 2000 Gert Van den Eynde
License:

Files: inst/private/__nonlin_residmin__.m inst/nonlin_residmin.m
 inst/private/__collect_constraints__.m inst/private/__plot_cmds__.m
 inst/nonlin_curvefit.m
Copyright: 2010, 2011 Olaf Till
License: GPL-3+

Files: inst/polyfitinf.m
Copyright: 1998-2011 Andrew V. Knyazev
           1998-2011 Andrew V. Knyazev
License:

Files: inst/wrap_f_dfdp.m
Copyright: 2010 Olaf Till
License: GPL-3+

Files: inst/fminsearch.m
Copyright: 2006 Sylvain Pelissier
License: GPL-2+

Files: src/__bfgsmin.cc
Copyright: 2004,2005,2006,2007,2010 Michael Creel
License: GPL-2+

Files: src/__disna_optim__.cc
Copyright: 2011 Olaf Till
License: GPL-3+

Files: src/numhessian.cc src/numgradient.cc src/samin.cc
Copyright: 2004, 2006 Michael Creel
License: GPL-2+


Reply to: