[libmarpa-r2-perl] 01/14: add cp_libmarpa.sh utility: t+

Jonas Smedegaard dr at jones.dk
Sat May 17 21:24:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag Marpa-R2-2.085_003
in repository libmarpa-r2-perl.

commit d63f738541c02bb7bdf77d10b0f05c4980d8c5ad
Author: Jeffrey Kegler <JKEGL at cpan.org>
Date:   Wed Apr 16 10:00:40 2014 -0700

    add cp_libmarpa.sh utility: t+
---
 cpan/MANIFEST                |  1 +
 cpan/cp_libmarpa.sh          | 55 ++++++++++++++++++++++++++++++++++++++++++++
 cpan/inc/Marpa/R2/License.pm | 34 +++++++++++++++++++++++++++
 3 files changed, 90 insertions(+)

diff --git a/cpan/MANIFEST b/cpan/MANIFEST
index 4b82594..8d6b5c6 100644
--- a/cpan/MANIFEST
+++ b/cpan/MANIFEST
@@ -42,6 +42,7 @@ author.t/spelling_exceptions.list
 author.t/tidy.t
 author.t/tidy1
 c_to_dist.sh
+cp_libmarpa.sh
 etc/.gitignore
 etc/Makefile
 etc/check_license.pl
diff --git a/cpan/cp_libmarpa.sh b/cpan/cp_libmarpa.sh
new file mode 100644
index 0000000..9c79f2c
--- /dev/null
+++ b/cpan/cp_libmarpa.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+# Copyright 2014 Jeffrey Kegler
+# This file is part of Marpa::R2.  Marpa::R2 is free software: you can
+# redistribute it and/or modify it under the terms of the GNU Lesser
+# General Public License as published by the Free Software Foundation,
+# either version 3 of the License, or (at your option) any later version.
+#
+# Marpa::R2 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser
+# General Public License along with Marpa::R2.  If not, see
+# http://www.gnu.org/licenses/.
+
+# Copy the libmarpa distribution to a directory
+# Note: This script needs to be portable
+
+if [ $# != 1 ] 
+then
+	echo "usage: $0 target-directory" 1>&2
+	exit 1
+fi
+todir="$1"
+fromdir=libmarpa_dist
+if [ ! -e "$fromdir" ]
+then
+    echo "cannot find directory $fromdir -- you need to be in a CPAN distribution directory to run this command" 1>&2
+    exit 1
+fi
+if [ ! -d "$fromdir" ]
+then
+    echo "$fromdir is not a directory -- you need to be in a CPAN distribution directory to run this command" 1>&2
+    exit 1
+fi
+checkfile="$fromdir/configure.ac"
+if [ ! -e "$checkfile" ]
+then
+    echo "$fromdir does not contain a configure.ac file -- you need to be in a CPAN distribution directory to run this command" 1>&2
+    exit 1
+fi
+if [ ! -r "$checkfile" ]
+then
+    echo "You not have the sufficient permissions to copy $checkfile" 1>&2
+    exit 1
+fi
+if [ -e "$todir" ]
+then
+    echo "cannot create directory $todir -- something with that name already exists" 1>&2
+    exit 1
+fi
+mkdir "$todir" || exit 1
+# Copy using copying user's permissions and new modification times
+(cd "$fromdir"; tar cf - . ) | (cd "$todir"; tar xfom -)
diff --git a/cpan/inc/Marpa/R2/License.pm b/cpan/inc/Marpa/R2/License.pm
index ba8cf01..8e1b507 100644
--- a/cpan/inc/Marpa/R2/License.pm
+++ b/cpan/inc/Marpa/R2/License.pm
@@ -380,6 +380,8 @@ sub file_type {
         if $filepart =~ /[.] (xs|c|h) \z /xms;
     return \&license_problems_in_xsh_file
         if $filepart =~ /[.] (xsh) \z /xms;
+    return \&license_problems_in_sh_file
+        if $filepart =~ /[.] (sh) \z /xms;
     return \&license_problems_in_c_file
         if $filepart =~ /[.] (xs|c|h) [.] in \z /xms;
     return \&license_problems_in_tex_file
@@ -524,6 +526,38 @@ sub license_problems_in_xsh_file {
     return @problems;
 } ## end sub license_problems_in_xsh_file
 
+sub license_problems_in_sh_file {
+    my ( $filename, $verbose ) = @_;
+    if ($verbose) {
+        say {*STDERR} "Checking $filename as sh hash style file"
+            or die "say failed: $ERRNO";
+    }
+    my @problems = ();
+    $DB::single = 1;
+    my $ref_text = slurp_top( $filename, 256 + length $r2_hash_license );
+    my $text = ${$ref_text};
+    $text =~ s/ \A [#][!] [^\n]* \n//xms;
+    $text = substr $text, 0, length $r2_hash_license;
+    if ( $r2_hash_license ne $text ) {
+        my $problem = "No license language in $filename (sh hash style)\n";
+        if ($verbose) {
+            $problem
+                .= "=== Differences ===\n"
+                . Text::Diff::diff( \$text, \$r2_hash_license )
+                . ( q{=} x 30 );
+        } ## end if ($verbose)
+        push @problems, $problem;
+    }
+    if ( scalar @problems and $verbose >= 2 ) {
+        my $problem =
+              "=== license for $filename should be as follows:\n"
+            . $r2_hash_license
+            . ( q{=} x 30 );
+        push @problems, $problem;
+    } ## end if ( scalar @problems and $verbose >= 2 )
+    return @problems;
+}
+
 sub license_problems_in_perl_file {
     my ( $filename, $type, $verbose ) = @_;
     if ($verbose) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmarpa-r2-perl.git



More information about the Pkg-perl-cvs-commits mailing list