community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1733857 - in /comdev/tools/licensing: ./ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/committers/ src/perl/ src/python/
Date Mon, 07 Mar 2016 01:34:23 GMT
Author: rvs
Date: Mon Mar  7 01:34:23 2016
New Revision: 1733857

URL: http://svn.apache.org/viewvc?rev=1733857&view=rev
Log:
Merge remote-tracking branch 'refs/remotes/git-svn' into HEAD

Added:
    comdev/tools/licensing/README.txt
    comdev/tools/licensing/build.xml
    comdev/tools/licensing/license.txt
    comdev/tools/licensing/neo-license-no-box.txt
    comdev/tools/licensing/src/
    comdev/tools/licensing/src/java/
    comdev/tools/licensing/src/java/org/
    comdev/tools/licensing/src/java/org/apache/
    comdev/tools/licensing/src/java/org/apache/committers/
    comdev/tools/licensing/src/java/org/apache/committers/ReplaceLicense.java
    comdev/tools/licensing/src/perl/
    comdev/tools/licensing/src/perl/README.txt
    comdev/tools/licensing/src/perl/cocoon21-avoid.txt
    comdev/tools/licensing/src/perl/insert_license.pl   (with props)
    comdev/tools/licensing/src/perl/insert_license.txt
    comdev/tools/licensing/src/perl/iou_license.pl   (with props)
    comdev/tools/licensing/src/perl/update-AL20.pl   (with props)
    comdev/tools/licensing/src/perl/verify-diff.sed   (with props)
    comdev/tools/licensing/src/perl/verify-diff.sh   (with props)
    comdev/tools/licensing/src/python/
    comdev/tools/licensing/src/python/relicense.py   (with props)

Added: comdev/tools/licensing/README.txt
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/README.txt?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/README.txt (added)
+++ comdev/tools/licensing/README.txt Mon Mar  7 01:34:23 2016
@@ -0,0 +1,63 @@
+This is a work in progress.  BE CAREFUL WHEN USING THESE SCRIPTS!
+
+Please enhance these tools.
+See also some other tools in ../tools/
+For more information, see: http://www.apache.org/dev/apply-license.html
+
+------------------------------------------------------------------------
+Notes:
+* This is a growing set of tools, developed as each project ensures
+that we have proper licenses.
+
+* The tools address various purposes. Some tools only replace existing
+licenses, some only do *.java files, some do *.xml as well, some only
+insert a new license, some report statistics about all files.
+
+* See the particular notes in the head portion of each script.
+
+* Please enhance these tools and add new ones. The job is not complete.
+
+------------------------------------------------------------------------
+Java:
+ ReplaceLicense.java
+
+Python:
+ relicense.py
+
+Perl:
+ insert_license.pl
+ update-AL20.pl
+
+------------------------------------------------------------------------
+The following notes are from previous versions of this README.
+(FIXME: Not sure if the notes are only relevant to ReplaceLicense.java
+or relicense.py as well. Perhaps should move to their script header.)
+------------------------------------------------------------------------
+
+---
+It'll do a decent enough job of preserving the original copyright dates.
+
+The biggest current flaw is that it is overaggressive in three ways:
+
+- It will relicense files not under the old ASL 1.1 license
+- It will relicense files under the old ASL 1.1 license, but have an
+  addendum after the ==== block that needs to be preserved.
+- It will change an existing:
+	Copyright 2004 The Apache Software Foundation.
+  Into:
+    Copyright 2004-2004 The Apache Software Foundation.
+
+YOU MUST USE THE FULL license.txt IN THIS DIRECTORY.
+
+For more information, see: http://www.apache.org/dev/apply-license.html
+
+---
+2004.02.16
+
+Added a Java version of a program to replace the license from 
+1.1 to 2.0 (sorry could not hack the python version).
+
+2004.02.18 - Gary Gregory
+
+Created src directory tree and packaged ReplaceLicense.java to
+org.apache.committers.

Added: comdev/tools/licensing/build.xml
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/build.xml?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/build.xml (added)
+++ comdev/tools/licensing/build.xml Mon Mar  7 01:34:23 2016
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="relicense" default="build" basedir=".">
+
+    <!-- Load local and user build preferences -->
+    <property file="build.properties"/>
+    <property file="../build.properties"/>
+    <property file="${user.home}/build.properties"/>
+
+    <!--
+        These property values may optionally be overridden with property
+        settings from an "ant" command line, the "build.properties" file
+        in this directory, the "build.properties" file in your home
+        directory, or from settings in a superior build.xml script.
+    -->
+    <!-- Output directory name for all files generated by the build process -->
+    <property name="build.home" value="${basedir}/build"/>
+    
+    <!-- The base directory for distribution targets -->
+    <property name="dist.home" value="${basedir}/dist" />
+
+    <!-- Name of the project -->
+    <property name="jar.name" value="relicense"/>
+
+    <!-- Should Java compilations set the debug compiler option? -->
+    <property name="compile.debug" value="true" />
+
+    <!-- Should Java compilations set the deprecation compiler option? -->
+    <property name="compile.deprecation" value="true" />
+
+    <!-- Should Java compilations set the optimize compiler option? -->
+    <property name="compile.optimize" value="true" />    
+
+    <target name="build-prepare">
+        <mkdir dir="${build.home}"/>
+        <mkdir dir="${build.home}/classes"/>
+    </target>
+
+    <target name="build" depends="build-prepare">
+        <javac srcdir="src"
+            destdir="${build.home}/classes"
+            debug="${compile.debug}"
+            optimize="${compile.optimize}"
+            deprecation="${compile.deprecation}">
+        </javac>
+    </target>
+
+    <target name="dist-prepare">
+        <mkdir dir="${dist.home}"/>
+    </target>
+
+     <target name="dist" depends="build, dist-prepare">
+        <jar basedir="${build.home}/classes" compress="true" jarfile="${dist.home}/${jar.name}.jar"/>
+    </target>
+
+    <target name="all" depends="dist" description="Build everything."/>
+
+    <target name="clean">
+        <delete dir="${build.home}"/>
+        <delete dir="${dist.home}"/>
+    </target>
+
+</project>

Added: comdev/tools/licensing/license.txt
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/license.txt?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/license.txt (added)
+++ comdev/tools/licensing/license.txt Mon Mar  7 01:34:23 2016
@@ -0,0 +1,15 @@
+/* Copyright [yyyy] [name of copyright owner] or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

Added: comdev/tools/licensing/neo-license-no-box.txt
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/neo-license-no-box.txt?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/neo-license-no-box.txt (added)
+++ comdev/tools/licensing/neo-license-no-box.txt Mon Mar  7 01:34:23 2016
@@ -0,0 +1,16 @@
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *

Added: comdev/tools/licensing/src/java/org/apache/committers/ReplaceLicense.java
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/java/org/apache/committers/ReplaceLicense.java?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/java/org/apache/committers/ReplaceLicense.java (added)
+++ comdev/tools/licensing/src/java/org/apache/committers/ReplaceLicense.java Mon Mar  7 01:34:23 2016
@@ -0,0 +1,357 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.committers;
+
+import java.util.regex.*;
+import java.io.*;
+
+/*
+ * This program is used to replace
+ * the Apache License version 1.1 with the new
+ * Apache License version 2.0.
+ *
+ * See:
+ *   http://www.apache.org/dev/apply-license.html
+ *   http://www.apache.org/licenses
+ *
+ * Program can process a specific file, or recursively process
+ * all the files within a specific directory.
+ *
+ * Orginally written to handle license conversion in
+ * jakarta-taglibs (Pierre Delisle). Should also work with other projects.
+ * Please hack according to own needs.
+ *
+ * Usage: (requires J2SE 1.4.x minimum)
+ *   java -cp <path>/relicense.jar org.apache.committers.ReplaceLicense [options] path
+ *
+ * where
+ *   path: path to directory or file
+ *   options:
+ *     -n: test mode (no output saved)
+ *     -r: recursively process directories
+ *         By default, directories are ignored.
+ *     -s: Replacement output is saved in the same file
+ *         By default, output is saved in a new file with extension "_ALV20" added.
+ *     -a: add license (Java/C style) if file does not have it.
+ *
+ * The program preserves copyright dates, and updates them to 2004
+ * if necessary in the following way, where first match is applied:
+ *    2004 --> no modification
+ *    -2003 --> 2003 replaced with 2004
+ *    2003 --> 2003 replaced with 2003-2004
+ *         --> add ,2004
+ *
+ * Configuration:
+ *   EXCLUDED_DIRS
+ *     Array of directory names to be excluded
+ *   EXCLUDED_SUFFIXES
+ *     Array of file suffixes to be excluded
+ *   EXCLUDED_PREFIXES
+ *     Array of file prefixes to be excluded
+ */
+
+public class ReplaceLicense {
+    
+    // Suffix added with option -n
+    private static String SuffixNewFile = "_ALV20";
+    
+    // Line separator
+    private static String lsep = System.getProperty("line.separator");
+    
+    private static String[] EXCLUDED_DIRS = {
+        "CVS",".svn",
+    };
+    
+    private static String[] EXCLUDED_PREFIXES = {
+        "LICENSE",
+        "NOTICE",
+    };
+    
+    private static String[] EXCLUDED_SUFFIXES = {
+        SuffixNewFile,
+        ".class",
+        ".gif",
+        ".jpg",
+        ".jpeg",
+        ".jar",
+        ".zip",
+        ".war",
+        "~",
+    };
+    
+    // The new Apache License version 2.0
+    private static String ALV20 =
+    "/*" + lsep +
+    " * Copyright @DATES@ The Apache Software Foundation." + lsep +
+    " * " + lsep +
+    " * Licensed under the Apache License, Version 2.0 (the \"License\");" + lsep +
+    " * you may not use this file except in compliance with the License." + lsep +
+    " * You may obtain a copy of the License at" + lsep +
+    " * " + lsep +
+    " *      http://www.apache.org/licenses/LICENSE-2.0" + lsep +
+    " * " + lsep +
+    " * Unless required by applicable law or agreed to in writing, software" + lsep +
+    " * distributed under the License is distributed on an \"AS IS\" BASIS," + lsep +
+    " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." + lsep +
+    " * See the License for the specific language governing permissions and" + lsep +
+    " * limitations under the License." + lsep +
+    " */";
+    
+    // Regexp to match Apache License version 1.1,
+    //   /* ...  The Apache Software License ... */
+    private static final String ALV11_REGEXP =
+    "/\\*.*?The Apache Software License.*?\\*/";
+    
+    // Regexp to match copyright dates in Apache License version 1.1,
+    private static final String ALV11DATES_REGEXP =
+    "Copyright \\([cC]\\).*?The Apache";
+
+    // Regexp to match Apache License version 2.0,
+    //   /* ...  http://www.apache.org/licenses/LICENSE-2.0 ... */
+    private static final String ALV20_REGEXP =
+    "/\\*.*?http://www.apache.org/licenses/LICENSE-2.0.*?\\*/";
+  
+    // Pattern to match Apache License version 1.1
+    private static Pattern patternALV11 =
+    Pattern.compile(ALV11_REGEXP, Pattern.DOTALL);
+    
+    // Pattern to match Apache License version 2.0
+    private static Pattern patternALV20 =
+    Pattern.compile(ALV20_REGEXP, Pattern.DOTALL);
+  
+    // Pattern to match the copyright dates in Apache License version 1.1
+    private static Pattern patternDates =
+    Pattern.compile(ALV11DATES_REGEXP);
+    
+    // options
+    private boolean save;
+    private boolean recurseOnDirs;
+    private boolean copyToNewFile;
+    private boolean addLicense;
+    
+    // stats
+    private int filesProcessedCount = 0;
+    
+    //**********************************************************************
+    // Main
+    
+    public static void main(String[] args) throws Exception {
+        int optind;
+        boolean save = true;
+        boolean recurseOnDirs = false;
+        boolean copyToNewFile = true;
+        boolean addLicense = false;
+        for (optind=0; optind<args.length; optind++) {
+            if (args[optind].equals("-n")) {
+                System.out.println("test mode (no output saved)");
+                save = false;
+            } else if (args[optind].equals("-r")) {
+                System.out.println("recursively process directories");
+                recurseOnDirs = true;
+            } else if (args[optind].equals("-s")) {
+                System.out.println("replacement output saved in the same file");
+                copyToNewFile = false;
+            } else if (args[optind].equals("-a")) {
+                System.out.println("license will be added if file does not have it yet");
+                addLicense = true;
+            } else if (args[optind].startsWith("-")) {
+                System.out.println("Invalid option: " + args[optind]);
+                usage();
+            } else {
+                break;
+            }
+        }
+        
+        //System.out.println("optind=" + optind + " args.length=" + args.length);
+        if (optind == args.length) {
+            System.out.println("Specify at least one file or directory to process.");
+            usage();
+        }
+        
+        System.out.println("");
+        ReplaceLicense rl = new ReplaceLicense( save, recurseOnDirs, copyToNewFile,
+                                               addLicense );
+        for (; optind<args.length; optind++) {
+            String path = args[optind];
+            rl.process(new File(path));
+            System.out.println(rl.filesProcessedCount + " files processed.");
+        }
+        System.out.println("\nDone!");
+    }
+    
+    private static void usage() {
+        System.out.println(
+        "Usage: java ReplaceLicense [options] path\n" +
+        "options:\n" +
+        "  -n: test mode (no output saved)\n" +
+        "  -r: recursively process directories\n" +
+        "  -s: replacement output is saved in the same file\n" +
+        "  -a: add license (Java/C style) if file does not have it." );
+        System.exit(1);
+    }
+    
+    //**********************************************************************
+    // Constructor
+    
+    public ReplaceLicense( boolean save, boolean recurseOnDirs, boolean copyToNewFile,
+                           boolean addLicense ) {
+        this.save = save;
+        this.recurseOnDirs = recurseOnDirs;
+        this.copyToNewFile = copyToNewFile;
+        this.addLicense = addLicense;
+    }
+    
+    //**********************************************************************
+    // Process
+    
+    private void process(File file) throws Exception {
+        System.out.println(file.getPath());
+        if (!file.exists()) {
+            System.out.println("  ERROR: '" + file.getPath() + "' does not exist");
+            return;
+        }
+        String fileName = file.getName();
+        if (excluded(fileName)) {
+            System.out.println("  Excluded file");
+            return;
+        }
+        
+        if (file.isDirectory()) {
+            if (!this.recurseOnDirs) {
+                System.out.println("  directory ignored");
+                return;
+            }
+            System.out.println("  directory");
+            if (excludedDir(fileName)) {
+                System.out.println("  Excluded directory");
+                return;
+            }
+            File[] children = file.listFiles();
+            for (int i=0; i<children.length; i++) {
+                process(children[i]);
+            }
+            return;
+        }
+        
+        // process a file
+        String data = fileAsString(file);
+        Matcher matcher = patternALV11.matcher(data);
+        String datesMatch = null;
+        String datesNew = null;
+        if (matcher.find()) {
+            System.out.println("  license replaced");
+            // System.out.println("start: " + matcher.start() + " end: " + matcher.end());
+            Matcher matcherDates = patternDates.matcher(data);
+            if (matcherDates.find()) {
+                // System.out.println("matched the copyright dates: " + datesMatcher.group());
+                // System.out.println("start: " + datesMatcher.start() + " end: " + datesMatcher.end());
+                // the dates for the copyright:
+                datesMatch = matcherDates.group();
+                datesMatch = datesMatch.substring(14, datesMatch.length()-11);
+                datesNew = datesMatch;
+                // System.out.println("the date: [" + datesMatch + "]");
+                if (datesMatch.indexOf("-2004") != -1) {
+                    // nothing to do
+                } else if (datesMatch.indexOf("-2003") != -1) {
+                    datesNew = datesMatch.replaceFirst("-2003", "-2004");
+                } else if (datesMatch.indexOf(",2003") != -1) {
+                    datesNew = datesMatch.replaceFirst(",2003", ",2003-2004");
+                } else {
+                    datesNew = datesMatch + ",2004";
+                }
+                System.out.println("  " + datesMatch + " -> " + datesNew);
+            } else {
+                System.out.println("no match found for copyright dates using pattern " + matcherDates.pattern().pattern());
+            }
+            // put new dates in the license
+            if (this.save) {
+                if(datesNew==null) {
+                    throw new Exception("Null datesNew replacement string, cannot replace dates");
+                }
+                String newLicense = ALV20.replaceFirst("@DATES@", datesNew);
+                String data2 = matcher.replaceFirst(newLicense);
+                stringToFile(file, data2);
+            }
+            this.filesProcessedCount++;
+        } else {
+          // didn't find license 1.1 - now checkes for 2.0
+          matcher = patternALV20.matcher(data);
+          if ( matcher.find() ) {
+            System.out.println("  found new license");
+          } else {
+            if ( addLicense ) {
+              if ( this.save ) {
+                String newLicense = ALV20.replaceFirst("@DATES@", "2004");
+                String data2 = newLicense + "\n" + data;
+                stringToFile(file, data2);
+              }
+              this.filesProcessedCount++;
+              System.out.println( "  license added" );
+            } else {
+              System.out.println("  no license found");
+            } // if addLicense              
+          } // second if matcher.find (new license)
+        } // first if matcher.find (old license)
+    } // method
+    
+    //**********************************************************************
+    // Support methods
+    
+    private String fileAsString(File file) throws Exception {
+        StringBuffer sb = new StringBuffer();
+        FileReader reader = new FileReader(file);
+        int size = 4*1024;
+        char[] buf = new char[size];
+        int count;
+        while ((count = reader.read(buf, 0, size)) != -1) {
+            sb.append(buf, 0, count);
+        }
+        reader.close();
+        return sb.toString();
+    }
+    
+    private void stringToFile(File file, String data) throws Exception {
+        if (this.copyToNewFile) {
+            file = new File(file.getPath() + SuffixNewFile);
+        }
+        FileWriter fw = new FileWriter(file);
+        fw.write(data);
+        fw.close();
+    }
+    
+    private boolean excluded(String fileName) {
+        for (int i=0; i<EXCLUDED_PREFIXES.length; i++) {
+            if (fileName.startsWith(EXCLUDED_PREFIXES[i])) {
+                return true;
+            }
+        }
+        for (int i=0; i<EXCLUDED_SUFFIXES.length; i++) {
+            if (fileName.endsWith(EXCLUDED_SUFFIXES[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    private boolean excludedDir(String fileName) {
+        for (int i=0; i<EXCLUDED_DIRS.length; i++) {
+            if (fileName.equals(EXCLUDED_DIRS[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

Added: comdev/tools/licensing/src/perl/README.txt
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/README.txt?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/README.txt (added)
+++ comdev/tools/licensing/src/perl/README.txt Mon Mar  7 01:34:23 2016
@@ -0,0 +1,5 @@
+These are some Perl tools for assessing and fixing license headers.
+
+See also other tools at
+https://svn.apache.org/repos/private/committers/tools
+and see Apache RAT (currently in Incubator) 

Added: comdev/tools/licensing/src/perl/cocoon21-avoid.txt
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/cocoon21-avoid.txt?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/cocoon21-avoid.txt (added)
+++ comdev/tools/licensing/src/perl/cocoon21-avoid.txt Mon Mar  7 01:34:23 2016
@@ -0,0 +1,25 @@
+KEYS
+LICENSE.txt
+legal/
+misc/credits/
+src/blocks/chaperon/samples/grammars/java.grm
+src/blocks/forms/samples/resources/htmlarea/
+src/blocks/forms/samples/resources/mattkruse-lib/
+src/blocks/forms/samples/resources/mattkruse-lib.js
+src/blocks/midi/test/org/apache/cocoon/generation/XMidi.dtd
+src/blocks/ojb/conf/repository.dtd
+src/blocks/woody/samples/resources/htmlarea/
+src/blocks/woody/samples/resources/mattkruse-lib/
+src/blocks/woody/samples/resources/mattkruse-lib.js
+src/webapp/WEB-INF/entities/any.rng
+src/webapp/WEB-INF/entities/characters.ent
+src/webapp/WEB-INF/entities/datatypes.dtd
+src/webapp/WEB-INF/entities/ISO
+src/webapp/WEB-INF/entities/open-office/
+src/webapp/WEB-INF/entities/w3c/
+src/webapp/WEB-INF/entities/web-app_2_3.dtd
+src/webapp/WEB-INF/entities/xslt-20020523.rng
+src/webapp/WEB-INF/entities/XMLSchema.dtd
+tools/jetty/
+tools/src/schematron/
+/package-list

Added: comdev/tools/licensing/src/perl/insert_license.pl
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/insert_license.pl?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/insert_license.pl (added)
+++ comdev/tools/licensing/src/perl/insert_license.pl Mon Mar  7 01:34:23 2016
@@ -0,0 +1,530 @@
+#!/usr/bin/perl -w
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#=========================================================
+#
+# For files that do not yet have an Apache License, insert the 2.0 license.
+# Adds comment markers for the relevant file type.
+#
+# This can also be used to provide a summary of the current situation.
+# It will detect the presence of various different license headers.
+# Use the -p option for practice mode.
+#
+# Limitations:
+# - Only developed and tested for certain file types. Others will be
+# reported and skipped.
+# Needs tweaks for other types (see "configuration" section below).
+# - Only inserts missing licenses and detects and reports other license types.
+#  See ./update-AL20.pl to update to the current license style.
+#
+# Caveats:
+# - As usual, make a backup of your tree first or be prepared to 'svn revert -R'
+# your working copy if the script stuffs up.
+#
+# WARNING: Be sure to look at the output of this script for warnings.
+# WARNING: Be sure to do the normal 'svn diff' and review.
+# Attend to the warning in tools/copy2license.pl about "collective copyright".
+#
+# Developed only for UNIX, YMMV.
+#
+# Procedure:
+# See ./relicense.txt for an example procedure.
+# Use -p for practise mode.
+# Run the script. It will descend the directory tree.
+# Run with no parameters or -h to show usage.
+#
+#=========================================================
+
+use strict;
+use vars qw($opt_h $opt_p);
+use Getopt::Std;
+use File::Basename;
+use File::Find;
+
+#--------------------------------------------------
+# ensure proper usage
+getopts("hp");
+if ((scalar @ARGV < 1) || defined($opt_h)) {
+  ShowUsage();
+  exit;
+}
+
+my $startDir = shift;
+my $avoidList = shift;
+if (!-e $startDir) {
+  print STDERR qq!
+The start directory '$startDir' does not exist.
+!;
+  ShowUsage();
+  exit;
+}
+if (defined($avoidList) && !-e $avoidList) {
+  print STDERR qq!
+The list of files to avoid '$avoidList' does not exist.
+!;
+  ShowUsage();
+  exit;
+}
+if ($opt_p) { print STDERR "\nDoing practice run. No files will be written\n"; }
+print qq!
+AL-20 = Apache License 2.0 with original Copyright line.
+AL-20a = Apache License 2.0 with original Copyright line and "or its licensors".
+AL-20b = Apache License 2.0 with no Copyright line, i.e. the current style.
+----------------------
+
+!;
+
+#--------------------------------------------------
+# do some configuration
+my $license = qq!Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+!;
+my @license = split(/\n/, $license);
+
+# build a hash of filename extensions to be processed
+# together with the particular style of comment marker to use.
+my @xmlFileTypes = (
+  ".xml", ".xsl", ".xslt", ".xmap", ".xcat",
+  ".xconf", ".xroles", ".roles", ".xsp", ".rss",
+  ".xinfo", ".xprofile", ".xsamples", ".xtest", ".xweb", ".xwelcome",
+  ".samplesxconf", ".samplesxpipe", ".svg", ".xhtml", ".xhtml2", ".gt", ".jx", ".jmx",
+  ".jdo", ".orm", ".jdoquery", ".jelly",
+  ".jxt", ".meta", ".pagesheet", ".stx", ".xegrm", ".xgrm", ".xlex", ".xmi",
+  ".xsd", ".rng", ".rdf", ".rdfs", ".xul", ".tld", ".xxe", ".ft", ".fv",
+  ".wsdd", ".wsdl", ".xlog", ".pom",
+);
+my @sgmlFileTypes = (
+  ".dtd", ".mod", ".sgml", ".sgm",
+);
+my @htmlFileTypes = (
+  ".html", ".htm", ".jsp", ".ihtml",
+);
+my @cFileTypes = (
+  ".java", ".js", ".c", ".h", ".cpp", ".cc", ".cs", ".css", ".egrm", ".grm",
+  ".javascript", ".jj", ".gy", ".g",
+);
+my @shFileTypes = (
+  ".sh", ".ccf", ".pl", ".py", ".sed", ".awk",
+);
+my @propertiesFileTypes = (
+  ".properties", ".rnc", ".rnx", ".prefs", ".rb", ".handlers", ".schemas",
+);
+my @dosFileTypes = (
+  ".bat", ".cmd",
+);
+my @sqlFileTypes = (
+  ".script", ".sql",
+);
+my @vmFileTypes = (
+  ".vm",
+);
+my @ignoreFileTypes = (
+  ".txt", ".dcl", ".ent", ".pen", ".project"
+);
+my (%fileTypes, $fileType);
+foreach $fileType (@xmlFileTypes) {
+  $fileTypes{$fileType}{type} = "xml";
+  $fileTypes{$fileType}{openComment} = "<!--\n";
+  $fileTypes{$fileType}{leaderComment} = "  ";
+  $fileTypes{$fileType}{closeComment} = "-->\n";
+  # insert after line 1 which must be the xml declaration
+  $fileTypes{$fileType}{insertionPoint} = "1";
+}
+foreach $fileType (@sgmlFileTypes) {
+  $fileTypes{$fileType}{type} = "sgml";
+  $fileTypes{$fileType}{openComment} = "<!--\n";
+  $fileTypes{$fileType}{leaderComment} = "  ";
+  $fileTypes{$fileType}{closeComment} = "-->\n";
+  # insert at very top of file
+  $fileTypes{$fileType}{insertionPoint} = "0";
+}
+foreach $fileType (@htmlFileTypes) {
+  $fileTypes{$fileType}{type} = "html";
+  $fileTypes{$fileType}{openComment} = "<!--\n";
+  $fileTypes{$fileType}{leaderComment} = "  ";
+  $fileTypes{$fileType}{closeComment} = "-->\n";
+  # insert at very top of file
+  $fileTypes{$fileType}{insertionPoint} = "0";
+}
+foreach $fileType (@cFileTypes) {
+  $fileTypes{$fileType}{type} = "C";
+  $fileTypes{$fileType}{openComment} = "/*\n";
+  $fileTypes{$fileType}{leaderComment} = " * ";
+  $fileTypes{$fileType}{closeComment} = " */\n";
+  # insert at very top of file
+  $fileTypes{$fileType}{insertionPoint} = "0";
+}
+foreach $fileType (@shFileTypes) {
+  $fileTypes{$fileType}{type} = "sh";
+  $fileTypes{$fileType}{openComment} = "\n";
+  $fileTypes{$fileType}{leaderComment} = "# ";
+  $fileTypes{$fileType}{closeComment} = "\n";
+  # insert after line 1 which must be #! script invocation
+  $fileTypes{$fileType}{insertionPoint} = "1";
+}
+foreach $fileType (@propertiesFileTypes) {
+  $fileTypes{$fileType}{type} = "properties";
+  $fileTypes{$fileType}{openComment} = "";
+  $fileTypes{$fileType}{leaderComment} = "# ";
+  $fileTypes{$fileType}{closeComment} = "\n";
+  # insert at very top of file
+  $fileTypes{$fileType}{insertionPoint} = "0";
+}
+foreach $fileType (@dosFileTypes) {
+  $fileTypes{$fileType}{type} = "dos";
+  $fileTypes{$fileType}{openComment} = "\@echo off\n";
+  $fileTypes{$fileType}{leaderComment} = "rem ";
+  $fileTypes{$fileType}{closeComment} = "\n";
+  # insert at very top of file
+  $fileTypes{$fileType}{insertionPoint} = "0";
+}
+foreach $fileType (@sqlFileTypes) {
+  $fileTypes{$fileType}{type} = "sql";
+  $fileTypes{$fileType}{openComment} = "";
+  $fileTypes{$fileType}{leaderComment} = "-- ";
+  $fileTypes{$fileType}{closeComment} = "\n";
+  # insert at very top of file
+  $fileTypes{$fileType}{insertionPoint} = "0";
+}
+foreach $fileType (@vmFileTypes) {
+  $fileTypes{$fileType}{type} = "vm";
+  $fileTypes{$fileType}{openComment} = "#*\n";
+  $fileTypes{$fileType}{leaderComment} = "  ";
+  $fileTypes{$fileType}{closeComment} = "*#\n";
+  # insert after line 1 which must be the xml declaration
+  $fileTypes{$fileType}{insertionPoint} = "1";
+}
+
+my ($countTotal, $countUnknownType, $countIgnoreType) = (0, 0, 0);
+my ($countXmlDeclMissing, $countInserted, $countAvoid) = (0, 0, 0);
+my ($countLicense, $countLicense10, $countLicense11, $countLicense12) = (0, 0, 0, 0);
+my ($countLicensePD, $countLicenseOther) = (0, 0);
+my ($countLicense20, $countLicense20a, $countLicense20b) = (0, 0, 0);
+
+# 3rdParty users of an Apache License
+my ($countLicenseF20, $countLicenseF11, $countLicenseF12) = (0, 0, 0);
+
+my $dualLicensesDetected = 0;
+my %uniqueSuffixes;
+my @avoidList;
+
+# read the avoidList
+if (defined($avoidList)) {
+  open(INPUT, "<$avoidList") or die "Could not open input file '$avoidList': $!";
+  while (<INPUT>) {
+    next if (/^#/);
+    chomp;
+    push(@avoidList, $_);
+  }
+  close INPUT;
+}
+
+#--------------------------------------------------
+sub process_file {
+  return unless -f && -T; # process only text files
+  my $fileName = $File::Find::name;
+  my ($file, $dir, $ext) = fileparse($fileName, qr/\.[^.]*/);
+  return if ($dir =~ /\/CVS\//); # skip CVS directories
+  return if ($dir =~ /\/\.svn\//); # skip SVN directories
+  return if ($fileName =~ /.cvsignore/); # skip 
+  return if ($file =~ /^\./); # skip hidden files
+  foreach my $avoidFn (@avoidList) {
+    if ($fileName =~ /$avoidFn/) {
+      $countAvoid++;
+      return;
+    }
+  }
+  $countTotal++;
+  if ($ext eq "") { $ext = "NoExtension"; }
+  $uniqueSuffixes{$ext}++;
+  print "$fileName, ";
+  my $tmpFile = $fileName . ".tmp";
+  open(INPUT, "<$fileName") or die "Could not open input file '$fileName': $!";
+
+  # First do some tests on the file to ensure it does not already have a license
+  # and ensure that XML files have an xml declaration.
+  my ($existsLicense, $warnDualLicense, $existsXmlDecl) = (0, 0, 0);
+  my ($warnAL20OldLicense) = 0;
+  my ($warnAL20aOldLicense) = 0;
+  my $licenseType = "";
+  undef $/;  # slurp the whole file
+  my $content = <INPUT>;
+  # we want our matches to happen only in the top part of the file
+# NOTE: You may want to relax this from time-to-time to find
+# all possible dual-license issues.
+  my $headContent = substr($content, 0, 1500);
+  $headContent =~ s/[ \t]+/ /g;
+
+  # detect various existing licenses
+  LICENSE_CASE: {
+    if ($headContent =~ /Licensed to the Apache Software Foundation \(ASF\) under/) {
+      $existsLicense = 1; $countLicense++;
+      $countLicense20b++; $licenseType = "AL-20b";
+      last LICENSE_CASE;
+    }
+    if ($headContent =~ /Licensed under the Apache License.*Version 2.0/) {
+      $existsLicense = 1; $countLicense++;
+      if ($headContent =~ /Apache Software Foundation or its licensors/) {
+        $countLicense20a++; $licenseType = "AL-20a";
+        $warnAL20aOldLicense = 1;
+      }
+      else {
+        if ($headContent =~ /Copyright.*Apache Software Foundation/) {
+          $countLicense20++; $licenseType = "AL-20";
+          $warnAL20OldLicense = 1;
+        }
+        else {
+          $countLicenseF20++; $licenseType = "F-AL-20";
+        }
+      }
+      last LICENSE_CASE;
+    }
+    if ($headContent =~ /The Apache Software License.*Version 1.2/) {
+      $existsLicense = 1; $countLicense++;
+      if ($headContent =~ /Copyright.*Apache Software Foundation/) {
+        $countLicense12++; $licenseType = "AL-12";
+      }
+      else {
+        $countLicenseF12++; $licenseType = "F-AL-12";
+      }
+      last LICENSE_CASE;
+    }
+    if ($headContent =~ /The Apache Software License.*Version 1.1/) {
+      $existsLicense = 1; $countLicense++;
+      if ($headContent =~ /Copyright.*Apache Software Foundation/) {
+        $countLicense11++; $licenseType = "AL-11";
+      }
+      else {
+        $countLicenseF11++; $licenseType = "F-AL-11";
+      }
+      last LICENSE_CASE;
+    }
+    if ($headContent =~ /Copyright.*The Apache Group/) {
+      $countLicense10++; $licenseType = "AL-10";
+      $existsLicense = 1; $countLicense++;
+      last LICENSE_CASE;
+    }
+    if ($headContent =~ /Public Domain.*/i) {
+      $countLicensePD++; $licenseType = "PublicDomain";
+      $existsLicense = 1; $countLicense++;
+      last LICENSE_CASE;
+    }
+    # catchall
+    if ($headContent =~ /Copyright|\(c\)/i) {
+      # do process xml files that have a copyright attribute
+      last LICENSE_CASE if ($headContent =~ /copyright=/i);
+      # do process DTD files that have a copyright attribute
+      last LICENSE_CASE if ($headContent =~ /copyright CDATA/i);
+      # do process css files that have a .copyright section
+      last LICENSE_CASE if ($headContent =~ /\.copyright/i);
+      # do process files that just talk about copyright
+      last LICENSE_CASE if ($headContent =~ /copyright statement/i);
+      $countLicenseOther++; $licenseType = "Other";
+      $existsLicense = 1; $countLicense++;
+      last LICENSE_CASE;
+    }
+    # catchall
+    if ($headContent =~ /re[ -]*distribut/i) {
+      $countLicenseOther++; $licenseType = "Other";
+      $existsLicense = 1; $countLicense++;
+      last LICENSE_CASE;
+    }
+  }
+
+  # Try to detect if a new AL-20 license has been accidently inserted
+  # as well as having some other license.
+  # FIXME: If a practice run reveals more types of Foregin copyright
+  # then add patterns here.
+  if ($licenseType =~ /AL-20/) {
+    if (($headContent =~ /Rights Reserved/i) ||
+        ($headContent =~ /Public Domain/i) ||
+        ($headContent =~ /Copyright.*Copyright/i)) {
+      $warnDualLicense = 1; $dualLicensesDetected++;
+    }
+  }
+
+  # ensure that xml files have an xml declaration
+  if ($headContent =~ /^<\?xml/) { $existsXmlDecl = 1; }
+
+  $/ = "\n"; # reset input record separator
+
+  my $recognisedFileType = 0; my $thisFileType = "unknown";
+  foreach $fileType (keys %fileTypes) {
+    if ($fileType eq $ext) {
+      $recognisedFileType = 1;
+      $thisFileType = $fileTypes{$fileType}{type};
+      last;
+    }
+  }
+  print "extension=$ext, fileType=$thisFileType, ";
+  if (!$existsXmlDecl && ($thisFileType eq "xml")) {
+    print "XML file does not have XML Declaration so skipping\n";
+    $countXmlDeclMissing++;
+    return;
+  }
+  if ($existsLicense) {
+    if ($licenseType !~ /^AL/) { print "WARN: "; }
+    print "Found existing license (licenseType=$licenseType) so skipping";
+    if ($warnAL20OldLicense) { print ", WARN: old AL-20 copyright notice"; }
+    if ($warnAL20aOldLicense) { print ", WARN: old AL-20a copyright notice"; }
+    if ($warnDualLicense) { print ", WARN: dual license"; }
+    print "\n";
+    return;
+  }
+  foreach $fileType (@ignoreFileTypes) {
+    if ($fileType eq $ext) {
+      $countIgnoreType++;
+      print "ignored, ";
+    }
+  }
+  if (!$recognisedFileType) {
+    print "File type '$ext' is not recognised so skipping\n";
+    $countUnknownType++;
+    return;
+  }
+
+  # Now process the file.
+  my $insertionDone = 0; my ($line, $thisLine);
+  if (!$opt_p) {
+    open(OUTPUT, ">$tmpFile")
+      or die "Could not open output file '$tmpFile': $!";
+  }
+  $countInserted++;
+  if ($fileTypes{$ext}{insertionPoint} == 0) {
+    print "Insert new license\n";
+    if (!$opt_p) {
+      print OUTPUT $fileTypes{$ext}{openComment};
+      foreach $line (@license) {
+        $thisLine = $fileTypes{$ext}{leaderComment} . $line;
+        $thisLine =~ s/\s+$//;
+        print OUTPUT $thisLine, "\n";
+      }
+      print OUTPUT $fileTypes{$ext}{closeComment};
+    }
+    $insertionDone = 1;
+  }
+  seek(INPUT, 0, 0); $. = 0; # rewind to top of file
+  while (<INPUT>) {
+    if (!$opt_p) {
+      print OUTPUT $_ or die "Could not write output file '$fileName': $!";
+    }
+    if (!$insertionDone) {
+      if ($. == $fileTypes{$ext}{insertionPoint}) {
+        print "Insert new license\n";
+        if (!$opt_p) {
+          print OUTPUT $fileTypes{$ext}{openComment};
+          foreach $line (@license) {
+            $thisLine = $fileTypes{$ext}{leaderComment} . $line;
+            $thisLine =~ s/\s+$//;
+            print OUTPUT $thisLine, "\n";
+          }
+          print OUTPUT $fileTypes{$ext}{closeComment};
+        }
+        $insertionDone = 1;
+      }
+    }
+  }
+  close INPUT or die "Could not close input file '$fileName': $!";
+  if (!$opt_p) {
+    close OUTPUT or die "Could not close output file '$tmpFile': $!";
+    rename($tmpFile, $fileName);
+  }
+}
+find(\&process_file, $startDir);
+
+#--------------------------------------------------
+# Report some statistics
+my $statsMsg = "were";
+if ($opt_p) { $statsMsg = "would be"; }
+$countUnknownType -= $countIgnoreType;
+print STDERR qq!
+Total $countTotal text files were investigated.
+New licenses $statsMsg inserted in $countInserted files.
+Skipped $countLicense files with an existing license:
+ (Apache v2.0=$countLicense20, v2.0a=$countLicense20a, v2.0b=$countLicense20b)
+ (Apache v1.2=$countLicense12, v1.1=$countLicense11, v1.0=$countLicense10)
+ (Other=$countLicenseOther, PublicDomain=$countLicensePD)
+ (3rdParty using AL v2.0=$countLicenseF20, v1.2=$countLicenseF12, v1.1=$countLicenseF11)
+Skipped $countXmlDeclMissing XML files with missing XML Declaration.
+!;
+if (defined($avoidList)) {
+  print STDERR "Avoided $countAvoid files as specified in the avoidList\n";
+}
+print STDERR qq!
+Ignored $countIgnoreType files of specified type (@ignoreFileTypes)
+Skipped $countUnknownType files of unknown type.
+!;
+if ($dualLicensesDetected) {
+  print STDERR qq!
+WARNING: $dualLicensesDetected files had another license as well as the new
+Apache v2.0 license. (Scan the log output for lines with "WARN: dual".)
+!;
+}
+my $suffix;
+if ($countUnknownType > 0) {
+  print STDERR qq!
+List of unknown filename extensions and ignored filename extensions:
+(Add new fileTypes to this script if you want them to be catered for.)
+!;
+  foreach $suffix ( sort keys %uniqueSuffixes) {
+    my $suffixKnown = 0;
+    foreach $fileType (keys %fileTypes) {
+      if ($suffix eq $fileType) { $suffixKnown = 1; }
+    }
+    if (!$suffixKnown) {
+      print STDERR "$suffix=$uniqueSuffixes{$suffix} ";
+    }
+  }
+  print STDERR "\n\n";
+}
+print STDERR "List of all unique filename extensions:\n";
+foreach $suffix ( sort keys %uniqueSuffixes) {
+  print STDERR "$suffix=$uniqueSuffixes{$suffix} ";
+}
+print STDERR "\n\n";
+if ($opt_p) { print STDERR "Finished practice run.\n"; }
+
+#==================================================
+# ShowUsage
+#==================================================
+
+sub ShowUsage {
+  print STDERR qq!
+Usage: $0 [-h] [-p] startDir [avoidList] > logfile
+                                                                                
+  where:
+  startDir = The SVN directory (pathname) to start processing. Will descend.
+  avoidList = List of files and directories to avoid, one per line.
+
+  option:
+  h = Show this help message.
+  p = Do a practice run. Do not write any files.
+
+!;
+}

Propchange: comdev/tools/licensing/src/perl/insert_license.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: comdev/tools/licensing/src/perl/insert_license.txt
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/insert_license.txt?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/insert_license.txt (added)
+++ comdev/tools/licensing/src/perl/insert_license.txt Mon Mar  7 01:34:23 2016
@@ -0,0 +1,44 @@
+This is an example procedure for the Apache Forrest project.
+Others may find it useful.
+
+------------------------------------------------------------------------
+The relicense task is described at
+http://forrest.apache.org/tasks.html#legal-monitoring
+
+The "avoid" file is used to skip known situations, e.g. some files should not
+be touched. See Forrest's at
+http://svn.apache.org/repos/asf/forrest/trunk/etc/relicense-avoid.txt
+
+Before commencing, do 'tree -d > relicense-tree.txt' which will form
+a listing of what sections have already been done and the issues that remain.
+Or perhaps you are brave enough to do the whole trunk at once.
+
+------------------------------------------------------------------------
+* Do the whole tree, a section at a time, using insert_license.pl script.
+* cd to a directory as high as you dare, e.g. "site-author" or "main"
+* Ensure no local svn edits pending.
+* In another window, do a practice run:
+insert_license.pl -p \
+/path/to/svn/forrest/main relicense-avoid.txt > relicense.log
+* Review the summary output and grep the relicence.log file.
+* Investigate the files that are listed as having problems.
+* grep for special patterns like "WARN" and "dual license", etc.
+* grep "Insert new license" to see which files would have a license inserted.
+* You may need to add more filename patterns to your *-avoid.txt file.
+* Do more practice runs.
+
+* When happy, do a production run by ommitting the -p practice mode.
+* Again review the summary output and grep the relicence.log file.
+* Some files may need to be fixed by hand.
+* Note sections that are finished and remaining issues in relicense-tree.txt
+* Do a 'svn diff' and make sure that it is what you expected:
+  See ./verify-diff.sh which removes expected patterns from a diff listing.
+  If some text remains, then you might have a problem.
+* Then 'svn commit'.
+
+* If the log reveals that there are old Apache licenses headers, then use the
+  script ./update_AL20.pl
+
+* Tweak the insert_license.pl script to address new issues.
+
+------------------------------------------------------------------------

Added: comdev/tools/licensing/src/perl/iou_license.pl
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/iou_license.pl?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/iou_license.pl (added)
+++ comdev/tools/licensing/src/perl/iou_license.pl Mon Mar  7 01:34:23 2016
@@ -0,0 +1,411 @@
+
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+# 
+#      http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#*/
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Insert or update (iou) the license in a given file.  The license is
+# assumed to be located in a comment block that contains a particular
+# license string ($licenseString) somewhere inside it, and that the 
+# comment contains nothing but that license.  The entire comment including
+# that line will be removed, and a new comment consisting solely of the
+# new license will be inserted.
+#
+# The license is read from "iou_license.txt", either in the local
+# directory where this script is invoked or from the dirctory where the
+# script itself lives (should be an option someday).  This is the text
+# that will go *inside* the comment.  It does not contain any
+# comment-related characters, so that the comment could be added to
+# files with different comment styles.
+#
+# The license in "iou_license.txt" can contain an optional license
+# version line that assigns a version string to that specific license
+# content (eg, LicenseVersion v1.0 ).  When the text changes, this version
+# string should change.  If the script encounters a file whose
+# license has the same version (if versioning was used) as the current 
+# one, the file will remain unchanged.
+#
+# Comments are understood on a per-file-type basis.
+#
+# Without arguments, this script will process all files within the 
+# current directory and its sub-directories.  Alternatively, one or
+# more files and/or directories can be specified as arguments.
+#
+#   Usage: iou_license.pl [item ...]
+#
+#          item: One or more files and/or directories to be processed
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+#
+# The following lines are designed to run perl on this script, no
+# matter which shell the script is accidentally run under.  The point
+# here is this: The normal way to invoke perl on a script is to put
+# a line starting with #! at the begging of the script that invokes
+# perl, as in "#!/usr/bin/perl".  The problem with this is that the
+# script then hard codes the location of perl into itself, and when
+# that changes the script breaks (and rather mysteriously at that).
+# So this script purposefully specifies *no* interpreter at the top,
+# and then adapts to whatever shell is running to get to perl.  (I
+# tried putting #!/bin/sh at the top to guarantee the shell, but perl
+# is too clever by half -- when the shell script executes perl, perl
+# looks at the #! line and says "this is a shell script" and invokes
+# the shell.)
+#
+# Yes this is ugly, but it is an Officially Certified Hack(TM), so
+# no purist, anti-hacker, ivory tower kvetching.
+#
+
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+    & eval 'exec perl -S $0 $argv:q'
+	    if 0;
+
+$scriptDir = $0;
+$scriptDir =~ s,/[^/]+$,,;
+push( @INC, $scriptDir );
+
+$Verbose = 1;				# someday make this turn-off-able
+
+$LicenseTextFileName = "iou_license.txt";
+$LicenseTextFile       = "$scriptDir/$LicenseTextFileName"; # make this an option someday
+
+@args = ( $#ARGV < 0 ? '.' : @ARGV );	# by default, use all source
+
+#
+# Set licenseString to a unique identifying string within the license text.
+# This string will be used to determine whether we've found the license comment.
+# It would be more desirable and less maintenance if this string were changed
+# to a unique tag that could remain constant (eg, license_comment_start).  Till
+# then, however, we'll have to live with what we have.
+#
+# It may also be useful to allow this string to be set on the command-line
+# since source files can contain a wide variety of licenses.  For example,
+# let's say we're importing a set of sources from The Foobar Software Depot,
+# and those sources contain the "Common Foobar License" (CFL), we could use the
+# a command line option to replace the CFL by executing a command like the
+# following to override the default licenseString definition:
+#
+#	iou_license.pl -s "Common Foobar License"
+#
+
+$licenseString = "Licensed to the Apache Software Foundation";
+
+# The ':'-separated pre, mid, and end comment strings for each file type
+
+# Optional fourth and fifth elements are regular expressions for pre and end
+# (otherwise a simple substring match is done).  If the fourth and/or fifth
+# elements exist, they will override the simple pre and end elements.
+
+$java  = '/*: *: */';
+$shell = '#/*:#:#*/';
+$bat   = '@rem /*:@rem:@rem */';
+$html  = '<!--: !: !-->:\<\!(\n|\s|\-\-):.*(\-\-\s*)?\>';
+
+$mapping{'.bat'}		= $bat;
+
+$mapping{'.c'}			= $java;
+$mapping{'.h'}			= $java;
+$mapping{'.java'}		= $java;
+$mapping{'.policy'}		= $java;
+
+$mapping{'.html'}		= $html;
+$mapping{'.jsp'}		= $html;
+$mapping{'.jspfragment'}	= $html;
+$mapping{'.xml'}		= $html;
+
+$mapping{'.nmk'}		= $shell;
+$mapping{'.jmk'}		= $shell;
+$mapping{'.sh'}			= $shell;
+$mapping{'.csh'}		= $shell;
+$mapping{'.ksh'}		= $shell;
+$mapping{'.pl'}			= $shell;
+$mapping{'.properties'}		= $shell;
+$mapping{'makefile'}		= $shell;
+$mapping{'Makefile'}		= $shell;
+$mapping{'GNUmakefile'}		= $shell;
+
+# technically all you need is "<!--" and "-->" but we use the !s to draw
+# a cutesy box.
+
+&createGetPats();
+
+#
+# Process the arguments.  If the arg is a directory, recurse looking for
+# known file types
+#
+
+foreach $arg ( @args )
+{
+    if ( -T $arg )	# text file
+    {	
+	push( @files, $arg );
+    }
+    elsif ( -d $arg )	# directory -- run find
+    {		
+	push( @files, split(/\s+/, $files = `find $arg \\( $names \\) -print`) );
+    }
+    else
+    {
+	print STDERR "unknown file type for $arg: ignoring\n";
+    }
+}
+
+&getCurrentLicense();			# read the current license
+
+$error = 0;				# process each file
+foreach $file ( @files )
+{
+    $error |= &process_file( $file );
+}
+
+exit( $error );
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# process_file:
+#	Process a single file.  Figure out from its suffix what kind of
+#	comment to use (currently only .java, .c, and .h are understood).
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+sub process_file
+{
+    local ( $file ) = @_;
+
+    if ( -l $file )
+    {
+	print "link: $file: skipping\n" if ( $Verbose );
+	return;
+    }
+
+    local ( $pre, $mid, $end, $prePat, $endPat ) = &getPats( $file );
+
+    if ( $pre eq 'UNDEF' )
+    {
+	print "unknown file type: $file: skipping\n" if ( $Verbose );
+	return;
+    }
+
+    local ( $found_license );			# did we find the license comment?
+    local ( $comment_start );			# current comment starting position
+    local ( $in_comment );			# boolean stating whether we're inside a comment block
+    local ( $license_start, $license_end );	# license comment start/end positions
+    local ( $license_version );			# license version in file
+
+    open( FILE, $file ) || die( "$file: $!" );
+
+    $prePat = &pat( $pre ) unless ( defined($prePat) && $prePat ne '' );
+    $endPat = &pat( $end ) unless ( defined($endPat) && $endPat ne '' );
+
+
+
+    while ( <FILE> )				# search for existing license
+    {				
+	if ( $. == 1 && /^[#%]!/ )
+	{					# skip over initial #! or %!
+	    $license_start    = tell( FILE );	# overwritten if comment is...
+	    $license_end      = tell( FILE );	# overwritten if comment is...
+	    next;				# ...present later in file
+	}
+
+	##
+	## If the prePat is closed by the endPat on the same line, a license
+	## is probably not there:
+	##
+
+	if ( /$prePat.*$endPat/ )
+	{
+	    next;
+	}
+	elsif ( /$prePat/ )
+	{
+	    $in_comment = 1;
+
+	    $comment_start = tell( FILE ) - length;
+	}
+	elsif ( /.*$licenseString/ && $in_comment )
+	{
+		$found_license++;
+		$license_start = $comment_start;
+	}
+	elsif ( /LicenseVersion ([^\s]+)/ )
+	{
+	    $license_version = $1;
+	}
+	elsif ( /$endPat/ )
+	{
+	    $in_comment = 0;
+
+	    ##
+	    ## When the file is a script with a special first line (eg, #!/bin/sh), license_end will
+	    ## be set to some number of characters greater than zero (ie, the length of that first line)
+	    ## and license_start will be equal to license_end.  Otherwise, license_end will have
+	    ## been set to zero, so we need to account for this special case:
+	    ##
+
+	    if ( $found_license && (!$license_end || ($license_start==$license_end)) )
+	    {
+		$license_end = tell( FILE );
+	    }
+	}
+    }
+    $found_license = 0 if ( $found_license && (!$license_end || ($license_start==$license_end)) );
+
+    if ( $Verbose )
+    {
+	print "$file: ";
+
+	if ( !$found_license )
+	{
+	    print "adding";
+	}
+	else
+	{
+	    print "replacing license ";
+	    print ( $license_version ? $license_version: "(unversioned)" );
+	}
+	print "\n";
+    }
+
+    local ( $tmp ) = "$file.cr";			# create tmp file with new stuff
+
+    open( NEW, ">$tmp" ) || die( "$tmp: $!" );
+    seek( FILE, 0, 0 );
+    read( FILE, $buf, $license_start );		# copy pre-comment stuff
+
+    print NEW $buf;
+    print NEW "$pre\n";
+
+    foreach $l ( @License )			# put in license
+    {
+	print NEW $mid, ' ', $l;
+    }
+
+    print NEW "$end\n";
+
+    seek( FILE, $license_end, 0 );		# copy post-comment stuff
+
+    while ( read(FILE, $buf,4096) )
+    {
+	print NEW $buf;
+    }
+
+    close( NEW );				# rename tmp to cur
+    close( FILE );
+
+    if ( !rename($tmp, $file) )
+    {
+	print "couldn't rename files for $file: $!";
+	return 1;
+    }
+
+    return 0;
+}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# getCurrentLicense
+#	Read current license and optional version.
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+sub getCurrentLicense
+{
+    open( LICENSE, "$LicenseTextFileName" ) || open( LICENSE, $LicenseTextFile )
+	|| die( "$LicenseTextFile: $!" );
+
+    @License = <LICENSE>;
+    close( LICENSE );
+
+    foreach $_ ( @License )
+    {
+	if ( /LicenseVersion ([^\s]+)/ )
+	{
+	    $CurrentLicenseVersion = $1;
+	    last;
+	}
+    }
+
+    print "License version $CurrentLicenseVersion\n" if ( $Verbose && $CurrentLicenseVersion );
+}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# createGetPats
+#	Build up the maps from file name to pre, mid, and end comment
+#	strings by creating the getPats method.  Also define $name
+#	for the find comment to find such things (if necessary).
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+sub createGetPats
+{
+    push( @matchList, 'sub getPats {' );
+    push( @matchList, '    local ($_) = @_;' );
+
+    foreach $type ( keys(%mapping) )
+    {
+	$map = $mapping{$type};
+	( $pre, $mid, $end ) = ( $map =~ /^([^:]*)\:([^:]*)\:(.*)$/ );
+
+	# Optional args
+	$prePat = $endPat = undef;
+
+	if ( $end =~ /^([^:]*)\:([^:]*)\:(.*)$/ )
+	{
+	    $prePat = $2;
+	    $endPat = $3;
+	    $end = $1;
+	}
+	if ( $type =~ /^\./ )
+	{
+	    push( @findArgs, "-name '*$type'" );
+	    $pat = "m,\\$type\$,";
+	}
+	else
+	{
+	    push( @findArgs, "-name '$type*'" );
+	    $pat = "(m,^$type, || m,/$type,)";
+	}
+	push( @matchList, "    $pat && return ( '$pre', '$mid', '$end', " .
+	    (defined($prePat) ? "'$prePat', " : "undef, ") .
+	    (defined($endPat) ? "'$endPat');" : "undef);") );
+    }
+
+    $names = join( ' -o ', @findArgs );
+
+    push( @matchList, "    return ('UNDEF', 'UNDEF', 'UNDEF', undef, undef);" );
+    push( @matchList, "}" );
+    $getPats = join( "\n", @matchList, '' );
+    eval $getPats;
+}
+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# pat
+#	Turn a simple string into something usable in a pattern by
+#	escaping the special characters
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+sub pat
+{
+    local ( $_ ) = @_;
+
+    s/(\W)/\\$1/g;
+    return $_;
+}
+

Propchange: comdev/tools/licensing/src/perl/iou_license.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: comdev/tools/licensing/src/perl/update-AL20.pl
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/update-AL20.pl?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/update-AL20.pl (added)
+++ comdev/tools/licensing/src/perl/update-AL20.pl Mon Mar  7 01:34:23 2016
@@ -0,0 +1,260 @@
+#!/usr/bin/perl -w
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#=========================================================
+#
+# Purpose:
+# Update the license header for files that have an existing
+# Apache License 2.0 which used the old style copyright line.
+#
+# Investigates every text file and detects various different versions
+# of the ASF license header.
+#
+# Developed only for UNIX, YMMV.
+#
+# Procedure:
+# Run the script. It will descend the directory tree.
+# Run with no parameters or -h to show usage.
+# Use practice mode (-p) to see what existing license headers are detected.
+# Use verbose practise mode (-v -p) to scan for WARN and ERROR. 
+# Add patterns to an avoidList to skip certain files or directories.
+#
+# Note:
+# You might prefer the tools/copy2license.pl which operates on a specific set of
+# files. Whereas update-AL20.pl investigates all text files found, so useful
+# for xml-related projects which tend to many different filename extensions.
+# Note:
+# Attend to the warning in tools/copy2license.pl about "collective copyright".
+#=========================================================
+
+use strict;
+use vars qw($opt_p $opt_h $opt_v);
+use Getopt::Std;
+use File::Basename;
+use File::Find;
+
+my ($countTotal, $countLicenseMissing, $countAvoid) = (0, 0, 0);
+my ($countLicense20, $countLicense20a, $countLicense20b) = (0, 0, 0);
+my $countLicenseF20 = 0;
+my $countLicense20x = 0;
+
+#--------------------------------------------------
+# ensure proper usage
+getopts("phv");
+if ((scalar @ARGV < 1) || defined($opt_h)) {
+  ShowUsage();
+  exit;
+}
+
+my $startDir = shift;
+if (!-e $startDir) {
+  print "\nThe start directory '$startDir' does not exist.\n";
+  ShowUsage();
+  exit;
+}
+my $avoidList = shift;
+if (defined($avoidList) && !-e $avoidList) {
+  print qq!
+The list of files to avoid '$avoidList' does not exist.
+!;
+  ShowUsage();
+  exit;
+}
+my @avoidList;
+# read the avoidList
+if (defined($avoidList)) {
+  open(INPUT, "<$avoidList") or die "Could not open input file '$avoidList': $!";
+  while (<INPUT>) {
+    next if (/^#/);
+    chomp;
+    push(@avoidList, $_);
+  }
+  close INPUT;
+}
+
+#--------------------------------------------------
+# Do the work
+
+chdir "$startDir" or die "Cannot cd to '$startDir': $!\n";
+
+if ($opt_p) { print "\nDoing practice run. No files will be written\n"; }
+print qq!
+AL-20 = Apache License 2.0 with original Copyright line.
+AL-20a = Apache License 2.0 with original Copyright line and "or its licensors".
+AL-20b = Apache License 2.0 with no Copyright line, i.e. the current style.
+AL-20x = same as AL-20b but missing the word "contributor".
+----------------------
+
+!;
+
+my $newLicenseHeader = <<"EOT";
+Licensed to the Apache Software Foundation (ASF) under one or more
+LEADERcontributor license agreements.  See the NOTICE file distributed with
+LEADERthis work for additional information regarding copyright ownership.
+LEADERThe ASF licenses this file to You under the Apache License, Version 2.0
+LEADER(the "License"); you may not use this file except in compliance with
+LEADERthe License.  You may obtain a copy of the License at
+EOT
+chomp($newLicenseHeader);
+
+#--------------------------------------------------
+sub process_file {
+  return unless -f && -T; # process only text files
+  my $fileName = $File::Find::name;
+  my ($file, $dir, $ext) = fileparse($fileName, qr/\.[^.]*/);
+  return if ($dir =~ /\/\.svn\//); # skip SVN directories
+  return if ($dir =~ /\/CVS\//); # skip CVS directories
+  return if ($dir =~ /\/build\//); # skip build directories
+  return if ($file =~ /^\./); # skip hidden files
+  $fileName =~ s/^\.\///; # strip leading ./
+  my $pathName = $startDir . "/" . $fileName;
+  foreach my $avoidFn (@avoidList) {
+    if ($pathName =~ /$avoidFn/) {
+      $countAvoid++;
+      return;
+    }
+  }
+  $countTotal++;
+  if ($opt_v) { print "$fileName : "; }
+  my $licenseType = "";
+  my $updatedLicenseHeader = "";
+  my $commentLeader = "";
+  open(INPUT, "<$pathName") or die "Could not open input file '$pathName': $!";
+  undef $/;  # slurp the whole file
+  my $content = <INPUT>;
+  close INPUT;
+  $/ = "\n"; # reset input record separator
+  # we want our matches to happen only in the top part of the file
+  my $headContent = substr($content, 0, 1200);
+  my $tailContent = "";
+  if (length($content) > 1200) {
+    $tailContent = substr($content, 1200);
+  }
+  # detect various existing licenses and the comment leader
+  LICENSE_CASE: {
+    if ($headContent =~ /Apache Software Foundation \(ASF\) under one/) {
+      if ($headContent !~ /contributor license agreements\.[ ]+See the NOTICE/) {
+        # detect an error with a previous version of this script
+        $countLicense20x++; $licenseType = "AL-20x";
+      }
+      else {
+        $countLicense20b++; $licenseType = "AL-20b";
+      }
+      last LICENSE_CASE;
+    }
+    if ($headContent =~ /Licensed *under *the *Apache *License.*Version 2.0/) {
+      if ($headContent =~ /Apache Software Foundation or its licensors/) {
+        $countLicense20a++; $licenseType = "AL-20a";
+      }
+      else {
+        if ($headContent =~ /Copyright.*Apache Software Foundation/) {
+          $countLicense20++; $licenseType = "AL-20";
+        }
+        else {
+          $countLicenseF20++; $licenseType = "F-AL-20";
+        }
+      }
+      if ($headContent =~ /(.*)Copyright ([0-9-, ]+) ?T?h?e? Apache Software Foundation/) {
+        $commentLeader = $1;
+      }
+      last LICENSE_CASE;
+    }
+    # catchall
+    $countLicenseMissing++;
+    if ($opt_v) { print "WARN: not Apache License"; }
+  }
+  if ($opt_v && $licenseType) { print "found $licenseType"; }
+
+  if (!$licenseType || $licenseType eq "AL-20b" || $licenseType =~/^F-/) {
+    if ($opt_v) { print ", skipping\n"; }
+    else { print "License Type not determined for: $pathName\n" unless $licenseType }
+    return;
+  }
+  $updatedLicenseHeader = $newLicenseHeader;
+  # deal with a special case where comment leader gets confused
+  if ($commentLeader eq '/* ')
+  {
+    $updatedLicenseHeader = "\n * ".$updatedLicenseHeader;
+    $commentLeader = ' * ';
+  }
+  # insert the comment leader
+  $updatedLicenseHeader =~ s/^LEADER/$commentLeader/gosm;
+  my $headerUpdated = 0;
+  if ($opt_v) { print "\n"; }
+  UPDATE_CASE: {
+    if ($headContent =~ s#Copyright ([0-9-, ]+) ?T?h?e? Apache Software Foundation.*You may obtain a copy of the License at *$#$updatedLicenseHeader#osm) {
+      $headerUpdated = 1;
+      last UPDATE_CASE;
+    }
+    if ($licenseType eq "AL-20x") {
+      if ($headContent =~ s#(license agreements\.[ ]+See the NOTICE)#contributor $1#) {
+        $headerUpdated = 1;
+        last UPDATE_CASE;
+      }
+    }
+    # catchall
+    print "ERROR: Could not replace license header pattern ($licenseType) in $pathName\n";
+  }
+  if (!$opt_p && $headerUpdated) {
+    open(OUTPUT, ">$pathName") or die ("Could not open output file '$pathName': $!\n");
+    print OUTPUT $headContent . $tailContent;
+    close OUTPUT;
+  }
+}
+find(\&process_file, ".");
+
+#--------------------------------------------------
+# report some statistics
+print qq!
+----------------------
+Processed $countTotal text files:
+$countLicense20b files already had AL-20b and were skipped.
+$countLicense20x files had AL-20x and were updated.
+$countLicense20a files had AL-20a and were updated.
+$countLicense20 files had the original AL-20 and were updated.
+$countLicenseF20 files were 3rdParty users of AL-20 and were skipped.
+$countLicenseMissing files were not Apache License 2.0 (or had no license) and were skipped.
+!;
+if (defined($avoidList)) {
+  print "Avoided $countAvoid files as specified in the avoidList\n";
+}
+print "\n";
+
+if ($opt_p) { print "Finished practice run.\n"; }
+
+#==================================================
+# ShowUsage
+#==================================================
+
+sub ShowUsage {
+  print qq!
+Usage: $0 [-h] [-p] [-v] startDir [avoidList] > logfile
+                                                                                
+  where:
+  startDir = The directory (pathname) to start processing. Will descend.
+  avoidList = List of files or directories to avoid, one per line.
+
+  option:
+  h = Show this help message.
+  v = Be verbose.
+  p = Do a practice run. Do not write any files.
+
+Note: It will skip directories with name /build/
+Add other patterns to the avoidList.
+
+!;
+}

Propchange: comdev/tools/licensing/src/perl/update-AL20.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: comdev/tools/licensing/src/perl/verify-diff.sed
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/verify-diff.sed?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/verify-diff.sed (added)
+++ comdev/tools/licensing/src/perl/verify-diff.sed Mon Mar  7 01:34:23 2016
@@ -0,0 +1,30 @@
+/^-.*Copyright.*Apache Software Foundation/d
+/^-.*Licensed *under *the *Apache *License,/d
+/ may *not *use *this *file *except/d
+/ may obtain a copy of the License at/d
+/^-.*as applicable/d
+/^\+.*Licensed to the Apache Software Foundation/d
+/^\+.*contributor license agreements/d
+/^\+.*this work for additional information/d
+/^\+.*The ASF licenses this file to You/d
+/^\+.*http:\/\/www.apache.org\/licenses\/LICENSE/d
+/^\+.*Unless required by applicable law/d
+/^\+.*distributed under the License/d
+/^\+.*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,/d
+/^\+.*See the License for the specific/d
+/^\+.*limitations under the License/d
+/\$Id.*\$/d
+/^[-+]$/d
+/^[-+]#$/d
+/^[-+]# $/d
+/^[-+] *\* *$/d
+/^[-+]\/\* *$/d
+/^[-+]\*\/ *$/d
+/^[-+][Rr][Ee][Mm]$/d
+/@echo off/d
+/^[-+] *$/d
+/^\+<\?xml/d
+/<!--/d
+/-->/d
+/^---/d
+/^\+\+\+/d

Propchange: comdev/tools/licensing/src/perl/verify-diff.sed
------------------------------------------------------------------------------
    svn:executable = *

Added: comdev/tools/licensing/src/perl/verify-diff.sh
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/perl/verify-diff.sh?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/perl/verify-diff.sh (added)
+++ comdev/tools/licensing/src/perl/verify-diff.sh Mon Mar  7 01:34:23 2016
@@ -0,0 +1 @@
+cat diff.txt | grep "^[-+]" | sed -f verify-diff.sed

Propchange: comdev/tools/licensing/src/perl/verify-diff.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: comdev/tools/licensing/src/python/relicense.py
URL: http://svn.apache.org/viewvc/comdev/tools/licensing/src/python/relicense.py?rev=1733857&view=auto
==============================================================================
--- comdev/tools/licensing/src/python/relicense.py (added)
+++ comdev/tools/licensing/src/python/relicense.py Mon Mar  7 01:34:23 2016
@@ -0,0 +1,290 @@
+#!/usr/bin/python
+
+################################################################
+#
+#	Author 	:	ajack@apache.org
+#	Version	:	0.1
+#
+################################################################
+#	CHANGE HISTORY:
+#
+#	Hack away folks...
+#
+################################################################
+# This code traverses a source tree replacing the top /* ... */
+# (over multiple lines) with the contents of a text file, i.e.
+# removing an old license and inserting a new one.
+#
+#	Usage	python relicense.py [source root] [license file]
+#
+# NOTE #1: Currently this does not preserver copyright dates,
+# and such. This flaw (until resolved) might make this script 
+# useless for all practical purposes.
+#
+# NOTE #2:
+#
+# THIS CODE MAY NOT WORK, DON'T RUN IT UNLESS YOU CAN
+# HANDLE THAT.
+#
+# DO NOT UNDER ANY CIRCUMSTANCES RUN THIS WITHOUT A FULL
+# BACKUP OF YOUR SOURCE TREE.
+#
+# DO A DIRECTORY COMPARISON, AFTER AN APPARENT RUN, TO
+# ENSURE NOTHING UNEXPECTED OCCURED.
+#
+################################################################
+#http://article.gmane.org/gmane.comp.jakarta.ant.devel/26477/match=copyright+years
+#This is from my "Taligent Guide to Designing Programs"
+#
+#"If you significantly modify a file, list the year of modification. 
+#The years correspond to publication, not creation dates. Separate 
+#consecutive years with a dash, but off-years with a comma"
+#
+#This was published in 1994, for C++ programs. How much of the above 
+#is required and how much is merely convention, I'm not sure. Regardless,
+#the dates not listed do not imply there is no copyright asserted for 
+#those years.
+#
+#Conor
+################################################################
+# 
+#  * Added support for alternative copyright owner passed in on 
+#    command line
+#  * Improved exception reporting
+#
+# Robert
+################################################################
+import os.path
+import os
+import sys
+import re
+import string
+import traceback
+from time import gmtime, strftime
+class FileType:
+    def __init__(self, startcomment, continuecomment, endcomment, endspec):
+         self.start = startcomment
+         self.cont = continuecomment
+         self.end = endcomment
+         self.endspec = endspec
+
+def printcopyright(licenseFile, copyrightOwner, copyrightyearsbefore,
+                   separator, lastcopyrightyear, currentyear, tmpStream,
+                   mytype, javatype, openHeader, closeHeader):
+#prints the copyright statement
+    """licenseFile           : path of the file containing the license file
+       copyrightOwner        : name of the new owner of the copyright
+       copyrightyearsbefore  : a string representing all the copyright years before the last
+       separator             : the character before the last original copyright year
+       lastcopyrightyear     : int the last copyright year from the original
+       currentyear           : int the current year
+       tmpStream             : the stream to write to
+       mytype                : information about the type of file
+       javatype              : information about java files (because the template is for java)
+       openHeader            : should we open the current header?
+       closeHeader           : should we close the current header?
+       """
+######################################################################
+# last copyright year is
+# < currentyear - 1                                   # add ,current
+# = currentyear - 1
+#            and is introduced by a comma or nothing  # add -current
+#            and is introduced by a dash              # replace with current
+# = currentyear                                       # do nothing
+###################################################################
+    licenseStream = None
+    templateregex = re.compile('Copyright (\[yyyy\]) (\[name of copyright owner\])')
+    try:
+      try:
+        # Transfer license header
+        licenseStream = open(licenseFile, 'r')
+
+        # Attach license at top of new file...
+        line = licenseStream.readline()
+        seenLicenseEnd = False
+        while line:
+          # Did we have some preamble lines?
+          if line.startswith(javatype.start) and not openHeader and mytype.endspec:
+            line = string.replace(line, javatype.start, '', 1)
+          # Check to see if we've reached the end of the license block.
+          if line.strip().startswith(javatype.end):
+            seenLicenseEnd = True
+
+          # first adjust the line to the conventions of the particular language
+          if mytype.start != javatype.start and line.startswith(javatype.start):
+            line = string.replace(line, javatype.start, mytype.start, 1)
+          elif mytype.end != javatype.end and line.strip().startswith(javatype.end):
+            line = string.replace(line, javatype.end, mytype.end, 1)
+          elif mytype.cont != javatype.cont:
+            line = string.replace(line, javatype.cont, mytype.cont, 1)
+
+          match = templateregex.search(line)
+          if match:
+            if lastcopyrightyear < (int(currentyear) - 1):
+              line = line.replace('[yyyy]', copyrightyearsbefore + separator + str(lastcopyrightyear) + "," + str(currentyear))
+            elif lastcopyrightyear == (int(currentyear) - 1):
+              if separator == "-":
+                line = line.replace('[yyyy]', copyrightyearsbefore + separator + str(currentyear))
+              else:
+                line = line.replace('[yyyy]', copyrightyearsbefore + separator + str(lastcopyrightyear) + "-" + str(currentyear))
+            else:
+              line = line.replace('[yyyy]', copyrightyearsbefore + separator + str(lastcopyrightyear))
+            line = line.replace( '[name of copyright owner]', copyrightOwner)
+          # We may not want to close the header, so check for that first!
+          if seenLicenseEnd and not closeHeader:
+            line = None
+            seenLicenseEnd = False
+          else:
+            tmpStream.write(line)
+          line = licenseStream.readline()
+      except Exception, details:
+        print "Failed on: "  + str(details)
+        traceback.print_exc()
+    finally:
+      if licenseStream: licenseStream.close()
+      return
+
+# Default values
+sourceTreeRoot='.'
+licenseFile = './license.txt'
+copyrightOwner = 'The Apache Software Foundation'
+mymap = {'xsl' : FileType("<!--","", "-->", True),
+         'xml' : FileType("<!--","", "-->", True),
+         'sh'  : FileType("#", "#", "#", False),
+         'in'  : FileType("#", "#", "#", False),
+         'cmd' : FileType("REM", "REM", "REM", False),
+         'bat' : FileType("REM", "REM", "REM", False),
+         'c'   : FileType("/*"," *", "*/", True),
+         'h'   : FileType("/*"," *", "*/", True),
+         'java' : FileType("/*"," *", "*/", True)}
+
+javatype = mymap['java']    
+usage="python relicense.py [source root] [license file] [copyright owner]"
+#
+if len(sys.argv) > 1:
+    sourceTreeRoot=sys.argv[1]
+if len(sys.argv) > 2:
+    licenseFile=sys.argv[2]
+if len(sys.argv) > 3:
+    copyrightOwner=sys.argv[3]
+if len(sys.argv) > 4:
+    print usage
+    sys.exit(1)
+    
+copyrightregex = re.compile('Copyright (?P<copyrightyearsbefore>[-,0-9]*)(?P<separator>[ ,-])?(?P<lastcopyrightyear>\d\d\d\d)?.+' + copyrightOwner)
+copyrightend = re.compile(' limitations under the License.')
+extregexp=re.compile('.*\.([a-zA-Z]*)')
+
+if not os.path.exists(licenseFile):
+    print 'License file [' + licenseFile + '] not found.'
+    sys.exit(1)
+
+#
+# Traverse a tree
+#
+print 'Traverse [' + sourceTreeRoot + '] attaching license [' + licenseFile + ']'
+currentyear=strftime("%Y", gmtime())
+for root, dirs, files in os.walk(sourceTreeRoot):
+    for file in files:
+        result = extregexp.match(file)
+        if result and mymap.get(result.group(1)):
+            #
+            # get the file type information from the map
+            #
+            mytype = mymap[result.group(1)]
+            sourceFile=os.path.join(root,file)
+            tmpFile=os.path.join(root,file+'.tmp')
+
+            print 'Convert [' + sourceFile + '] via [' + tmpFile + ']'
+
+            # The java stream is the source file
+            # The tmp stream is where things get written to (during transer)
+            # The license stream is the new header
+            fileStream=None
+            tmpStream=None
+
+            try:
+                try:
+                    # Open tmp for writing...
+                    tmpStream=open(tmpFile,'w')
+                    # Open Java source file for reading...
+                    fileStream=open(sourceFile, 'r')
+
+                    # Transfer source, skipping first comment.
+                    line = fileStream.readline()
+                    inHeader = False
+                    pastHeader = False
+                    seenCopyright = False
+                    seenPreamble = False
+                    # default for first copyright year
+                    lastcopyrightyear = currentyear
+                    copyrightyearsbefore = ""
+                    separator = " "
+
+                    while line:
+                      if not inHeader and line.strip().startswith(mytype.start):
+                        inHeader = True
+                        seenPreamble = False
+                      if inHeader:
+                        while line:
+                          mymatch = copyrightregex.search(line)
+                          if mymatch:
+                            copyrightyearsbefore = mymatch.group('copyrightyearsbefore')
+                            separator = mymatch.group('separator')
+                            lastcopyrightyear = mymatch.group('lastcopyrightyear')
+                            if lastcopyrightyear == None:
+                                lastcopyrightyear = currentyear
+                            else:
+                                lastcopyrightyear = int(lastcopyrightyear)
+                            seenCopyright = True
+                          elif not seenCopyright:
+                            # this line doesn't concern us yet.  skip it.
+                            # It could be a necessary preamble.
+                            tmpStream.write(line)
+                            seenPreamble = True
+                          if mytype.endspec and \
+                              line.strip().endswith(mytype.end.strip()) or \
+                             not mytype.endspec and not \
+                              line.strip().startswith(mytype.cont.strip()):
+                             line = fileStream.readline()
+                             inHeader = False
+                             break
+                          if seenCopyright and copyrightend.search(line):
+                             # Skip to the next line
+                             break
+                          # Read the next line
+                          line = fileStream.readline()
+                      if seenCopyright:
+                        printcopyright(licenseFile, copyrightOwner,
+                                       copyrightyearsbefore, separator,
+                                       lastcopyrightyear, currentyear,
+                                       tmpStream, mytype, javatype,
+                                       not seenPreamble, not inHeader)
+                        seenCopyright = False
+                      # do not go past EOF
+                      if not line:
+                        break
+                      elif not inHeader:
+                        tmpStream.write(line)
+                      #else:
+                      #    print 'Skip ' + line
+
+                      line = fileStream.readline()
+
+                finally:
+                  if fileStream: fileStream.close()
+                  if tmpStream: tmpStream.close()
+
+                # Remove the original
+                os.remove(sourceFile)
+
+                # Replace with temporary (enhanced)
+                os.rename(tmpFile,sourceFile)
+
+            except Exception, details:
+              print "Failed on: " + sourceFile + ':' + str(details)
+              traceback.print_exc()
+
+              # Cleanup if failed..
+              if os.path.exists(tmpFile):
+                  os.remove(tmpFile)

Propchange: comdev/tools/licensing/src/python/relicense.py
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message