[pkg-java] r8164 - in trunk/maven-repo-helper: debian src/main/bin

ludovicc-guest at alioth.debian.org ludovicc-guest at alioth.debian.org
Wed Apr 1 20:06:30 UTC 2009


Author: ludovicc-guest
Date: 2009-04-01 20:06:30 +0000 (Wed, 01 Apr 2009)
New Revision: 8164

Added:
   trunk/maven-repo-helper/src/main/bin/mh_genrules
   trunk/maven-repo-helper/src/main/bin/mh_installpoms
   trunk/maven-repo-helper/src/main/bin/mh_mavenrepo
Modified:
   trunk/maven-repo-helper/debian/changelog
   trunk/maven-repo-helper/src/main/bin/mh_lspoms
Log:
* all scripts are now functional

Modified: trunk/maven-repo-helper/debian/changelog
===================================================================
--- trunk/maven-repo-helper/debian/changelog	2009-04-01 12:15:03 UTC (rev 8163)
+++ trunk/maven-repo-helper/debian/changelog	2009-04-01 20:06:30 UTC (rev 8164)
@@ -1,4 +1,4 @@
-maven-repo-helper (0.1-0ubuntu1~ppa11) jaunty; urgency=low
+maven-repo-helper (0.1-0ubuntu1~ppa18) jaunty; urgency=low
 
   * Initial release. (Closes: #521947)
 

Added: trunk/maven-repo-helper/src/main/bin/mh_genrules
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_genrules	                        (rev 0)
+++ trunk/maven-repo-helper/src/main/bin/mh_genrules	2009-04-01 20:06:30 UTC (rev 8164)
@@ -0,0 +1,100 @@
+#!/bin/bash
+# Generate some of the build and installation scripts
+
+USE_ANT=false
+if [ "$1" = "-a" ]; then
+    USE_ANT=true
+    shift
+fi
+if [ "$1" = "--use-ant" ]; then
+    USE_ANT=true
+    shift
+fi
+
+PACKAGE=$1
+
+if [ -z "$PACKAGE" ]; then
+    echo "Syntax:"
+    echo "mh_genrules <binary package>"
+    exit 1
+fi
+
+if [ ! -z "${PACKAGE##-p}" ]; then
+    PACKAGE=${PACKAGE##-p}
+fi
+
+VERSION_PROPERTIES_FILE="debian/tmp/versions.properties"
+
+mh_lspoms $PACKAGE > /dev/null
+
+# Automatic execution of mh_cleanpom to fill versions.properties
+if [ ! -f "$VERSION_PROPERTIES_FILE" ]; then
+    cat debian/$PACKAGE.poms | while read POM OPTS; do
+        echo "mh_cleanpom $POM"
+        mh_cleanpom $OPTS $POM
+    done
+fi
+
+BIN_PACKAGE="\$(PACKAGE)"
+SOURCE=$(dpkg-parsechangelog | egrep '^Source:' | cut -f2 -d' ')
+if [ "lib$SOURCE-java" = "$PACKAGE" ]; then
+    BIN_PACKAGE="lib\$(PACKAGE)-java"
+elif [ "$SOURCE-java" = "$PACKAGE" ]; then
+    BIN_PACKAGE="\$(PACKAGE)-java"
+fi
+
+gen_rules() {
+    echo "#!/usr/bin/make -f"
+    echo ""
+    echo "include /usr/share/cdbs/1/rules/debhelper.mk"
+    if $USE_ANT ; then
+        echo "include /usr/share/cdbs/1/class/ant.mk"
+    fi
+    echo ""
+    echo "PACKAGE			   := \$(DEB_SOURCE_PACKAGE)"
+    echo "VERSION			   := \$(DEB_UPSTREAM_VERSION)"
+    echo "JAVA_HOME            := /usr/lib/jvm/default-java"
+    if $USE_ANT ; then
+        echo "DEB_JARS             := # TODO - fill the list of jars"
+        echo "DEB_ANT_BUILD_TARGET := package"
+        echo "DEB_ANT_BUILDFILE    := debian/build.xml"
+        echo "DEB_ANT_ARGS         := -Dpackage=\$(PACKAGE) -DartifactId=\$(PACKAGE) -Dversion=\$(VERSION)"
+    fi
+    echo ""
+    echo "binary-post-install/$BIN_PACKAGE::"
+    echo -e "\tmh_installpoms -p$BIN_PACKAGE"
+
+    if [ -f debian/tmp/pom.properties ]; then
+        source debian/tmp/pom.properties
+    fi
+    cat debian/$PACKAGE.poms | while read POM OPTS; do
+        if [[ "$POM" = "pom.xml" || "$POM" = "debian/pom.xml" ]]; then
+            grep "<packaging>\s*pom" $POM > /dev/null
+            if [ $? != 0 ]; then
+                echo -e "\tmh_installjar -p$BIN_PACKAGE $POM build/\$(PACKAGE)-\$(VERSION).jar usr/share/java/\$(PACKAGE)-\$(VERSION).jar usr/share/java/\$(PACKAGE).jar"
+            fi
+        elif [ ! -z "$POM" ]; then
+            BASENAME=$(basename $(dirname $POM))
+            grep "<packaging>\s*pom" $POM > /dev/null
+            if [ $? != 0 ]; then
+                echo -e "\tmh_installjar -p$BIN_PACKAGE $POM $BASENAME/build/$BASENAME-\$(VERSION).jar usr/share/java/$BASENAME-\$(VERSION).jar usr/share/java/$BASENAME.jar"
+            fi
+        fi
+    done
+    echo ""
+    echo "binary-fixup/$BIN_PACKAGE::"
+    echo -e "\tmh_mavenrepo"
+    echo ""
+    echo "clean::"
+    echo -e "\t-rm -rf debian/tmp"
+}
+
+if [ -e debian/rules ]; then
+    gen_rules > debian/rules.new
+    echo "The new rules have been generated into debian/rules.new."
+    echo "You need to merge them manually into debian/rules"
+else
+    mkdir -p debian
+    gen_rules > debian/rules
+    echo "The new rules have been generated into debian/rules."
+fi

Added: trunk/maven-repo-helper/src/main/bin/mh_installpoms
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_installpoms	                        (rev 0)
+++ trunk/maven-repo-helper/src/main/bin/mh_installpoms	2009-04-01 20:06:30 UTC (rev 8164)
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+PACKAGE=$1
+
+if [ ! -z "${PACKAGE##-p}" ]; then
+    PACKAGE=${PACKAGE##-p}
+fi
+
+cat debian/$PACKAGE.poms | while read POM OPTS; do
+    if [ ! -z "$POM" ]; then
+        mh_installpom $OPTS -p$BIN_PACKAGE $POM
+    fi
+done

Modified: trunk/maven-repo-helper/src/main/bin/mh_lspoms
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_lspoms	2009-04-01 12:15:03 UTC (rev 8163)
+++ trunk/maven-repo-helper/src/main/bin/mh_lspoms	2009-04-01 20:06:30 UTC (rev 8164)
@@ -1,6 +1,8 @@
-QUIET=false
+#!/bin/bash
+
+VERBOSE=true
 if [ "$1" = "-q" ]; then
-    QUIET=true
+    VERBOSE=false
     shift
 fi
 
@@ -12,13 +14,18 @@
     exit 1
 fi
 
+if [ ! -z "${PACKAGE##-p}" ]; then
+    PACKAGE=${PACKAGE##-p}
+fi
+
 if [ -e debian/$PACKAGE.poms ]; then
-  if [ "$QUIET" = "false" ]; then
+  if $VERBOSE ; then
     echo debian/$PACKAGE.poms already exist. Please delete it if you want to regenerate it.
   fi
 else
-  find . -path '*/.*' -prune -o -type f -print | grep -e /pom\.xml$ | grep -v "debian/tmp" | sed s,./,, | sed -e's,^\(debian/pom\.xml\|pom\.xml\),\1 --debian-parent,' > debian/$PACKAGE.poms
-  if [ "$QUIET" = "false" ]; then
+  mkdir -p debian
+  find . -path '*/.*' -prune -o -path './debian/tmp' -prune -o -type f -name 'pom.xml' -print | sed s,./,, | sed -e's,^\(debian/pom\.xml\|pom\.xml\),\1 --debian-parent,' > debian/$PACKAGE.poms
+  if $VERBOSE ; then
     echo The list of POM files is now in debian/$PACKAGE.poms
   fi
 fi

Added: trunk/maven-repo-helper/src/main/bin/mh_mavenrepo
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_mavenrepo	                        (rev 0)
+++ trunk/maven-repo-helper/src/main/bin/mh_mavenrepo	2009-04-01 20:06:30 UTC (rev 8164)
@@ -0,0 +1,102 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+mh_mavenrepo - manage the Maven repository when installing Java libraries
+
+=cut
+
+use strict;
+use File::Find;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<mh_mavenrepo> [S<I<debhelper options>>] [B<-n>]
+
+=head1 DESCRIPTION
+
+mh_mavenrepo is a debhelper program that will scan your package for Maven
+POM files and generate installation scripts to keep the Debian parent POM
+in the Maven repository updated with the current list of libraries and their
+versions.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-n>, B<--noscripts>
+
+Do not modify postinst/postrm scripts.
+
+=back
+
+=head1 CONFORMS TO
+
+Java policy, version TODO
+
+=cut
+
+init();
+
+my $versionPropertiesFile = "debian/tmp/versions.properties";
+
+if (! $dh{NOSCRIPTS}) {
+    foreach my $package (@{$dh{DOPACKAGES}}) {
+    	doit(("rm","-rf","debian/tmp"));
+        if ( -e "debian/$package.poms" ) {
+            cleanpoms("debian/$package.poms");
+            my $libraries = readLibraries();
+			autoscript($package,"postinst","postinst-maven-repo","s%#PACKAGE#%$package%;s%#LIBRARIES#%$libraries%");
+			autoscript($package,"postrm","postrm-maven-repo","s%#LIBRARIES#%$libraries%");
+        }
+    }
+}
+
+sub cleanpoms {
+    my $pomsFile = shift;
+	open(POMS, $pomsFile) ||
+	    error("Can't open $pomsFile: $!");
+	foreach my $line (<POMS>) {
+        chomp($line);
+		if ($line ne '') {
+            my $pom='';
+            my $opts='';
+            my @elems=split(' ',$line);
+            push(@elems, '');
+            ($pom,$opts)=@elems;
+			doit("mh_cleanpom $opts $pom");
+		}
+	}
+	close(POMS);
+}
+
+sub readLibraries {
+   	open(VERSIONS, $versionPropertiesFile) ||
+        error("Can't open $versionPropertiesFile: $!");
+    my $libraries = '';
+	foreach my $line (<VERSIONS>) {
+        chomp($line);
+        $_=$line;
+		if (! ($line eq '') && ! (substr($line,0,1) eq '#')) {
+            s/\.version=/ /g;
+            $libraries .= $_ . ",";
+        }
+    }
+    close(VERSIONS);
+    return $libraries;
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is a part of maven-repo-helper but is made to work with debhelper.
+
+=head1 AUTHORS
+
+Ludovic Claude <ludovic.claude at laposte.net>
+
+Also includes bits of the dh_pycentral written by Raphael Hertzog <hertzog at debian.org>.
+
+=cut
\ No newline at end of file


Property changes on: trunk/maven-repo-helper/src/main/bin/mh_mavenrepo
___________________________________________________________________
Name: svn:executable
   + *




More information about the pkg-java-commits mailing list