[pkg-java] r8179 - in trunk/maven-repo-helper: debian src/main/bin src/main/java/org/debian/maven/repo src/main/share
ludovicc-guest at alioth.debian.org
ludovicc-guest at alioth.debian.org
Sat Apr 4 11:16:59 UTC 2009
Author: ludovicc-guest
Date: 2009-04-04 11:16:59 +0000 (Sat, 04 Apr 2009)
New Revision: 8179
Added:
trunk/maven-repo-helper/src/main/share/mh_lib.sh
Modified:
trunk/maven-repo-helper/debian/changelog
trunk/maven-repo-helper/debian/control
trunk/maven-repo-helper/debian/rules
trunk/maven-repo-helper/src/main/bin/mh_cleanpom
trunk/maven-repo-helper/src/main/bin/mh_genrules
trunk/maven-repo-helper/src/main/bin/mh_installjar
trunk/maven-repo-helper/src/main/bin/mh_installpom
trunk/maven-repo-helper/src/main/bin/mh_installpoms
trunk/maven-repo-helper/src/main/bin/mh_lspoms
trunk/maven-repo-helper/src/main/bin/mvn-repo
trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java
Log:
* Add doc and man pages,
* Use a library to parse shell script args
Modified: trunk/maven-repo-helper/debian/changelog
===================================================================
--- trunk/maven-repo-helper/debian/changelog 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/debian/changelog 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,4 +1,4 @@
-maven-repo-helper (0.1) unstable; urgency=low
+maven-repo-helper (0.1-0ubuntu1~ppa19) jaunty; urgency=low
* Initial release. (Closes: #521947)
Modified: trunk/maven-repo-helper/debian/control
===================================================================
--- trunk/maven-repo-helper/debian/control 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/debian/control 2009-04-04 11:16:59 UTC (rev 8179)
@@ -3,7 +3,7 @@
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
Uploaders: Ludovic Claude <ludovic.claude at laposte.net>
-Build-Depends: debhelper (>= 5), cdbs, default-jdk, ant, maven-ant-helper
+Build-Depends: debhelper (>= 5), cdbs, default-jdk, ant, maven-ant-helper, help2man
Standards-Version: 3.8.1
Vcs-Bzr: lp:~ludovicc/maven-packaging-support/maven-repo-helper
Vcs-Browser: http://bazaar.launchpad.net/~ludovicc/maven-packaging-support/maven-repo-helper/files
Modified: trunk/maven-repo-helper/debian/rules
===================================================================
--- trunk/maven-repo-helper/debian/rules 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/debian/rules 2009-04-04 11:16:59 UTC (rev 8179)
@@ -11,6 +11,24 @@
DEB_ANT_BUILDFILE := ./debian/build.xml
DEB_ANT_ARGS := -Dpackage=$(PACKAGE) -Dversion=$(VERSION)
+# Generation of man pages
+SCRIPTS := $(wildcard src/main/bin/mh_*)
+MAN_PAGES := $(addprefix debian/tmp/doc/,$(addsuffix .1, $(notdir $(SCRIPTS))))
+debian/tmp/mh_lib.sh : src/main/share/mh_lib.sh
+ mkdir -p debian/tmp
+ cp src/main/share/mh_lib.sh debian/tmp/mh_lib.sh
+debian/tmp/mh_% : src/main/bin/mh_% debian/tmp/mh_lib.sh
+ mkdir -p debian/tmp
+ cp $< $@
+ perl -i -pe 's,\. /usr/share/maven-repo-helper/mh_lib.sh,\. debian/tmp/mh_lib.sh,' $@
+ chmod +x $@
+debian/tmp/doc/mh_%.1 : debian/tmp/mh_%
+ mkdir -p debian/tmp/doc
+ -grep -q '^#!/bin/bash' $< && help2man -N -o $@ $<
+ -grep -q '^#!/usr/bin/perl' $< && pod2man $< > $@
+man-pages: $(MAN_PAGES)
+build/$(PACKAGE):: man-pages
+
binary-post-install/$(PACKAGE)::
dh_install -p$(PACKAGE) build/$(PACKAGE)-$(VERSION).jar /usr/share/java
dh_install -p$(PACKAGE) src/main/bin /usr
@@ -18,5 +36,8 @@
dh_link -p$(PACKAGE) /usr/share/java/$(PACKAGE)-$(VERSION).jar /usr/share/java/$(PACKAGE).jar
dh_link -p$(PACKAGE) /usr/share/$(PACKAGE)/postinst.tmpl /usr/share/debhelper/autoscripts/postinst-maven-repo
dh_link -p$(PACKAGE) /usr/share/$(PACKAGE)/postrm.tmpl /usr/share/debhelper/autoscripts/postrm-maven-repo
+ dh_installman $(MAN_PAGES)
-
+$(SCRIPTS):
+ help2man $(basename )
+
Modified: trunk/maven-repo-helper/src/main/bin/mh_cleanpom
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_cleanpom 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/bin/mh_cleanpom 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,19 +1,51 @@
-#!/bin/bash
+#!/bin/bash --
-CLEAN_ARGS=''
-if [ "$1" = "-d" ]; then
- CLEAN_ARGS=$1
- shift
+. /usr/share/maven-repo-helper/mh_lib.sh
+
+syntax()
+{
+ echo -e "Usage: mh_cleanpom [option]... [pom] [target] [pom-props] [versions-props]"
+ echo -e "Cleans the POM and prepare it for inclusion in the Maven repository."
+ echo -e "Also extracts some information from the POM."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t[pom] is the location of the POM file to clean."
+ echo -e "\t Default to pom.xml or debian/pom.xml"
+ echo -e "\t[target] is where the cleaned POM is written to."
+ echo -e "\t Default to debian/tmp/pom.xml"
+ echo -e "\t[pom-props] is where the POM properties file will be written."
+ echo -e "\t Default to debian/tmp/pom.properties"
+ echo -e "\t[versions-props] is where the versions properties file will be written."
+ echo -e "\t Default to debian/tmp/versions.properties"
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-d --debian-parent: force the cleaned POM to inherit from"
+ echo -e "\t org.debian:debian-parent:1.0-SNAPSHOT"
+ echo -e "\t-s<spec> --spec=<spec>: gives the location of the Maven spec file for"
+ echo -e "\t special properties. Optional, the default location is"
+ echo -e "\t debian/maven.spec"
+ echo -e "\t-v --verbose: show more information while running"
+ echo -e "\t-n --no-act: don't actually do anything, just print the results"
+ exit 1
+}
+
+ARGS="d debian-parent s spec v verbose n no-act" parseargs "$@"
+
+if [ "$ARGC" -lt "1" ]; then
+ syntax
fi
-if [ "$1" = "--debian-parent" ]; then
- CLEAN_ARGS=$1
- shift
-fi
-POM=$1
-TARGET=$2
-POM_PROPS=$3
-VERSIONS_PROPS=$4
-SPEC=$5
+
+DEBIANPARENT=$(getarg d debian-parent)
+SPEC=$(getarg s spec)
+SPEC=${SPEC:-debian/maven.spec}
+VERBOSE=$(getarg v verbose)
+NOACT=$(getarg n no-act)
+POM="${ARGV[0]}"
+TARGET="${ARGV[1]:-debian/tmp/pom.xml}"
+POM_PROPS="${ARGV[2]:-debian/tmp/pom.properties}"
+VERSIONS_PROPS="${ARGV[3]:-debian/tmp/versions.properties}"
+
if [ -z "$POM" ]; then
if [ -f debian/pom.xml ]; then
POM="debian/pom.xml"
@@ -21,19 +53,10 @@
POM="pom.xml"
fi
fi
-if [ -z "$TARGET" ]; then
- TARGET="debian/tmp/pom.xml"
+
+CLEAN_ARGS="${VERBOSE:+--verbose} ${DEBIANPARENT:+--debian-parent}"
+
+if [ -z "$NOACT" ]; then
+ java -cp /usr/share/java/maven-repo-helper.jar org.debian.maven.repo.POMCleaner $CLEAN_ARGS $POM $TARGET $POM_PROPS $VERSIONS_PROPS $SPEC
fi
-if [ -z "$POM_PROPS" ]; then
- POM_PROPS="debian/tmp/pom.properties"
-fi
-if [ -z "$VERSIONS_PROPS" ]; then
- VERSIONS_PROPS="debian/tmp/versions.properties"
-fi
-if [ -z "$SPEC" ]; then
- if [ -f debian/maven.spec ]; then
- SPEC="debian/maven.spec"
- fi
-fi
-java -cp /usr/share/java/maven-repo-helper.jar org.debian.maven.repo.POMCleaner $CLEAN_ARGS $POM $TARGET $POM_PROPS $VERSIONS_PROPS $SPEC
Modified: trunk/maven-repo-helper/src/main/bin/mh_genrules
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_genrules 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/bin/mh_genrules 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,28 +1,31 @@
-#!/bin/bash
-# Generate some of the build and installation scripts
+#!/bin/bash --
-USE_ANT=false
-if [ "$1" = "-a" ]; then
- USE_ANT=true
- shift
-fi
-if [ "$1" = "--use-ant" ]; then
- USE_ANT=true
- shift
-fi
+. /usr/share/maven-repo-helper/mh_lib.sh
-PACKAGE=$1
+syntax()
+{
+ echo -e "Usage: mh_genrules [option]... [package]"
+ echo -e "Generate the rules file, at least partially."
+ echo -e "Also extracts some information from the POM."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t[package] is the name of the binary package,"
+ echo -e "\t e.g. libcommons-lang-java"
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-a --use-ant: add code to use Ant to build the sources"
+ exit 1
+}
-if [ -z "$PACKAGE" ]; then
- echo "Syntax:"
- echo "mh_genrules <binary package>"
- exit 1
-fi
+ARGS="a use-ant" parseargs "$@"
-if [ ! -z "${PACKAGE##-p}" ]; then
- PACKAGE=${PACKAGE##-p}
+if [ "$ARGC" -lt "1" ]; then
+ syntax
fi
+PACKAGE="${ARGV[0]}"
+
VERSION_PROPERTIES_FILE="debian/tmp/versions.properties"
mh_lspoms $PACKAGE > /dev/null
@@ -73,13 +76,13 @@
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"
+ echo -e "\tmh_installjar -p$BIN_PACKAGE -l $POM build/\$(PACKAGE)-\$(VERSION).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"
+ echo -e "\tmh_installjar -p$BIN_PACKAGE -l $POM $BASENAME/build/$BASENAME-\$(VERSION).jar"
fi
fi
done
Modified: trunk/maven-repo-helper/src/main/bin/mh_installjar
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_installjar 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/bin/mh_installjar 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,56 +1,92 @@
-#!/bin/bash
+#!/bin/bash --
set -e
-CLEAN_ARGS=''
-SPEC=''
+. /usr/share/maven-repo-helper/mh_lib.sh
-if [ "$1" = "-d" ]; then
- CLEAN_ARGS=$1
- shift
-fi
-if [ "$1" = "--debian-parent" ]; then
- CLEAN_ARGS=$1
- shift
-fi
-if [ "$1" = "-s" ]; then
- shift
- SPEC=$1
- shift
-fi
-if [ "$1" = "--spec" ]; then
- shift
- SPEC=$1
- shift
-fi
+syntax()
+{
+ echo -e "Usage: mh_installjar [option]... [pom] [jar] [link]..."
+ echo -e "Installs the jar file in /usr/share/maven-repo, at the correct location for"
+ echo -e "Maven."
+ echo -e "It can also create additional links to the jar, usually placed in"
+ echo -e "/usr/share/java."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t[pom] is the location of the POM associated with the jar to install."
+ echo -e "\t GroupId, artifactId and version will be extracted from this file."
+ echo -e "\t[jar] is the path to the jar to install, usually located in the build"
+ echo -e "\t folder."
+ echo -e "\t[link] is an additional link to the jar to install, usually there should"
+ echo -e "\t be a link to usr/share/java/$jar.jar and"
+ echo -e "\t usr/share/java/$jar-$version.jar to comply with the Java packaging"
+ echo -e "\t guidelines. Note that there is no need to specify those particular"
+ echo -e "\t links if the --java-lib option is used."
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-p<package> --package=<package>: package to act on "
+ echo -e "\t-s<spec> --spec=<spec>: gives the location of the Maven spec file for"
+ echo -e "\t special properties. Optional, the default location is"
+ echo -e "\t debian/maven.spec"
+ echo -e "\t-l --java-lib: Optional, if given it will create additional links into "
+ echo -e "\t /usr/share/java to comply with the Java specification. More precisely,"
+ echo -e "\t the links created will be /usr/share/java/$name-$version.jar and"
+ echo -e "\t /usr/share/java/$name.jar"
+ echo -e "\t-n<name> --name=<name>: Optional, the name to use when installing the"
+ echo -e "\t library in /usr/share/java when --java-lib is used."
+ echo -e "\t Defaults to the artifact id found in the POM."
+ echo -e "\t-r<version> --version=<version>: Optional, the version to use when"
+ echo -e "\t installing the library in /usr/share/java when --java-lib is used."
+ echo -e "\t Defaults to the version found in the POM."
+ echo -e "\t-v --verbose: show more information while running"
+ echo -e "\t-n --no-act: don't actually do anything, just print the results"
+ exit 1
+}
-PACKAGE=$1
+ARGS="s spec l java-lib n name r version v verbose n no-act" parseargs "$@"
-if [ ! -z "${PACKAGE##-p}" ]; then
- PACKAGE=${PACKAGE##-p}
+if [ "$ARGC" -lt "2" ]; then
+ syntax
fi
-POM=$2
-JAR=$3
+SPEC=$(getarg s spec)
+SPEC=${SPEC:-debian/maven.spec}
+PACKAGE=$(getarg p package)
+PACKAGE=${PACKAGE:?"Package parameter (-p) is mandatory"}
+JAVALIB=$(getarg l java-lib)
+NAME=$(getarg l java-lib)
+VERBOSE=$(getarg v verbose)
+NOACT=$(getarg n no-act)
+POM="${ARGV[0]}"
+JAR="${ARGV[1]}"
-if [ -z "$SPEC" ]; then
- if [ -f debian/maven.spec ]; then
- SPEC="debian/maven.spec"
- fi
-fi
+DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
mkdir -p debian/tmp 2> /dev/null
mh_cleanpom $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties debian/tmp/notused.properties $SPEC
source debian/tmp/pom.properties
GROUP_PATH=$(echo $GROUP_ID | tr . / )
+
+# Install the jar in the Maven repository
cp $JAR debian/tmp/${ARTIFACT_ID}-${VERSION}.jar
-dh_install -p${PACKAGE} --sourcedir=debian/tmp ${ARTIFACT_ID}-${VERSION}.jar \
+dh_install $DH_OPTS -p${PACKAGE} --sourcedir=debian/tmp ${ARTIFACT_ID}-${VERSION}.jar \
usr/share/maven-repo/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}
-while [ ! -z "$4" ]; do
- LINK_JAR=$4
- shift
- dh_link -p${PACKAGE} usr/share/maven-repo/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.jar \
+# Create the additional links
+for (( i=2; i < $ARGC; i++ )); do
+ LINK_JAR="${ARGV[i]}"
+ dh_link $DH_OPTS -p${PACKAGE} usr/share/maven-repo/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.jar \
$LINK_JAR;
done
+if [ -n "$JAVALIB" ]; then
+ JAR_NAME=$(getarg n name)
+ JAR_NAME=${JAR_NAME:-$ARTIFACT_ID}
+ JAR_VERSION=$(getarg r version)
+ JAR_VERSION=${JAR_VERSION:-$VERSION}
+ dh_link $DH_OPTS -p${PACKAGE} usr/share/maven-repo/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.jar \
+ usr/share/java/$JAR_NAME.jar;
+ dh_link $DH_OPTS -p${PACKAGE} usr/share/maven-repo/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.jar \
+ usr/share/java/$JAR_NAME-$JAR_VERSION.jar;
+fi
Modified: trunk/maven-repo-helper/src/main/bin/mh_installpom
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_installpom 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/bin/mh_installpom 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,54 +1,62 @@
-#!/bin/bash
+#!/bin/bash --
set -e
-CLEAN_ARGS=''
-SPEC=''
+. /usr/share/maven-repo-helper/mh_lib.sh
-if [ "$1" = "-d" ]; then
- CLEAN_ARGS=$1
- shift
-fi
-if [ "$1" = "--debian-parent" ]; then
- CLEAN_ARGS=$1
- shift
-fi
-if [ "$1" = "-s" ]; then
- shift
- SPEC=$1
- shift
-fi
-if [ "$1" = "--spec" ]; then
- shift
- SPEC=$1
- shift
-fi
+syntax()
+{
+ echo -e "Usage: mh_installpom [option]... [pom]"
+ echo -e "Installs the POM file in /usr/share/maven-repo, at the correct location for"
+ echo -e "Maven."
+ echo -e "Before installing the POM, it prepares it with mh_cleanpom."
+ echo -e ""
+ echo -e "debian/maven.spec is used to alter the version properties for the library and"
+ echo -e "its dependencies."
+ echo -e ""
+ echo -e "Prefer to use mh_installpoms as it reuses the information in"
+ echo -e "debian/\$package.poms and avoids repetition."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t[pom] is the location of the POM associated with the jar to install."
+ echo -e "\t GroupId, artifactId and version will be extracted from this file."
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-p<package> --package=<package>: package to act on "
+ echo -e "\t-d --debian-parent: force the cleaned POM to inherit from"
+ echo -e "\t org.debian:debian-parent:1.0-SNAPSHOT"
+ echo -e "\t-s<spec> --spec=<spec>: gives the location of the Maven spec file for"
+ echo -e "\t special properties. Optional, the default location is"
+ echo -e "\t debian/maven.spec"
+ echo -e "\t-v --verbose: show more information while running"
+ echo -e "\t-n --no-act: don't actually do anything, just print the results"
+ exit 1
+}
-PACKAGE=$1
+ARGS="p package d debian-parent s spec v verbose n no-act" parseargs "$@"
-if [ ! -z "${PACKAGE##-p}" ]; then
- PACKAGE=${PACKAGE##-p}
+if [ "$ARGC" -lt "1" ]; then
+ syntax
fi
-POM=$2
-INSTALLED_JAR=$3
+DEBIANPARENT=$(getarg d debian-parent)
+SPEC=$(getarg s spec)
+SPEC=${SPEC:-debian/maven.spec}
+PACKAGE=$(getarg p package)
+PACKAGE=${PACKAGE:?"Package parameter (-p) is mandatory"}
+VERBOSE=$(getarg v verbose)
+NOACT=$(getarg n no-act)
+POM="${ARGV[0]}"
-if [ -z "$SPEC" ]; then
- if [ -f debian/maven.spec ]; then
- SPEC="debian/maven.spec"
- fi
-fi
+CLEAN_ARGS="${DEBIANPARENT:+--debian-parent}"
+DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
mkdir -p debian/tmp 2> /dev/null
-mh_cleanpom $CLEAN_ARGS $POM debian/tmp/pom.xml debian/tmp/pom.properties debian/tmp/versions.properties $SPEC
+mh_cleanpom $DH_OPTS $CLEAN_ARGS --spec=$SPEC $POM debian/tmp/pom.xml debian/tmp/pom.properties debian/tmp/versions.properties
source debian/tmp/pom.properties
GROUP_PATH=$(echo $GROUP_ID | tr . / )
mv debian/tmp/pom.xml debian/tmp/${ARTIFACT_ID}-${VERSION}.pom
-dh_install -p${PACKAGE} --sourcedir=debian/tmp ${ARTIFACT_ID}-${VERSION}.pom \
+dh_install $DH_OPTS -p${PACKAGE} --sourcedir=debian/tmp ${ARTIFACT_ID}-${VERSION}.pom \
usr/share/maven-repo/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}
-
-if [ ! -z "$INSTALLED_JAR" ]; then
- dh_link -p${PACKAGE} $INSTALLED_JAR \
- usr/share/maven-repo/${GROUP_PATH}/${ARTIFACT_ID}/${VERSION}/${ARTIFACT_ID}-${VERSION}.jar;
-fi
Modified: trunk/maven-repo-helper/src/main/bin/mh_installpoms
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_installpoms 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/bin/mh_installpoms 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,15 +1,40 @@
-#!/bin/bash
+#!/bin/bash --
set -e
-PACKAGE=$1
+. /usr/share/maven-repo-helper/mh_lib.sh
-if [ ! -z "${PACKAGE##-p}" ]; then
- PACKAGE=${PACKAGE##-p}
-fi
+syntax()
+{
+ echo -e "Usage: mh_installpoms [option]..."
+ echo -e "Reads the file debian/\$package.poms and installs each POM file"
+ echo -e "listed in the .poms file."
+ echo -e ""
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e "\t-p<package> --package=<package>: package to act on "
+ echo -e "\t-s<spec> --spec=<spec>: gives the location of the Maven spec file for"
+ echo -e "\t special properties. Optional, the default location is"
+ echo -e "\t debian/maven.spec"
+ echo -e "\t-v --verbose: show more information while running"
+ echo -e "\t-n --no-act: don't actually do anything, just print the results"
+ exit 1
+}
+ARGS="p package s spec v verbose n no-act" parseargs "$@"
+
+SPEC=$(getarg s spec)
+SPEC=${SPEC:-debian/maven.spec}
+PACKAGE=$(getarg p package)
+PACKAGE=${PACKAGE:?"Package parameter (-p) is mandatory"}
+VERBOSE=$(getarg v verbose)
+NOACT=$(getarg n no-act)
+
+DH_OPTS="${VERBOSE:+-v} ${NOACT:+-n}"
+
cat debian/$PACKAGE.poms | while read POM OPTS; do
if [ ! -z "$POM" ]; then
- mh_installpom $OPTS -p$BIN_PACKAGE $POM
+ mh_installpom $DH_OPTS $OPTS -p$PACKAGE --spec=$SPEC $POM
fi
done
Modified: trunk/maven-repo-helper/src/main/bin/mh_lspoms
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mh_lspoms 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/bin/mh_lspoms 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,32 +1,48 @@
-#!/bin/bash
+#!/bin/bash --
-VERBOSE=true
-if [ "$1" = "-q" ]; then
- VERBOSE=false
- shift
-fi
+. /usr/share/maven-repo-helper/mh_lib.sh
-PACKAGE=$1
+syntax()
+{
+ echo -e "Usage: mh_lspoms [option]... [package]"
+ echo -e "Looks for all POM files defined in the source of the project."
+ echo -e ""
+ echo -e "Where"
+ echo -e "\t[package] is the name of the binary package,"
+ echo -e "\t e.g. libcommons-lang-java"
+ echo -e "Options:"
+ echo -e "\t-h --help: show this text"
+ echo -e "\t-V --version: show the version"
+ echo -e ""
+ echo -e "You need to execute it on the unpacked origianl source tree, merged with the"
+ echo -e "debian/ folder. It will create the file debian/<binary package>.poms which"
+ echo -e "contains all the POMs to deploy to the Maven repository and is used by"
+ echo -e "mh_mavenrepo and mh_installpoms."
+ echo -e ""
+ echo -e "The contents of debian/<binary package>.poms should be:"
+ echo -e "\t* one POM file location per line,"
+ echo -e "\t* optionaly, the location is followed by the option --debian-parent"
+ echo -e "\t to indicate that this POM should inherit directly from the Debian"
+ echo -e "\t parent POM."
+ echo -e ""
+ echo -e "All POMs which are installed in the Maven repository should inherit either"
+ echo -e "directly or indirectly from org.debian:debian-parent:1.0-SNAPSHOT"
+ exit 1
+}
-if [ -z "$PACKAGE" ]; then
- echo "Syntax:"
- echo "mh_lspoms <binary package>"
- exit 1
-fi
+ARGS="" parseargs "$@"
-if [ ! -z "${PACKAGE##-p}" ]; then
- PACKAGE=${PACKAGE##-p}
+if [ "$ARGC" -lt "1" ]; then
+ syntax
fi
+PACKAGE="${ARGV[0]}"
+
if [ -e debian/$PACKAGE.poms ]; then
- if $VERBOSE ; then
- echo debian/$PACKAGE.poms already exist. Please delete it if you want to regenerate it.
- fi
+ echo debian/$PACKAGE.poms already exist. Please delete it if you want to regenerate it.
else
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
+ echo The list of POM files is now in debian/$PACKAGE.poms
fi
Modified: trunk/maven-repo-helper/src/main/bin/mvn-repo
===================================================================
--- trunk/maven-repo-helper/src/main/bin/mvn-repo 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/bin/mvn-repo 2009-04-04 11:16:59 UTC (rev 8179)
@@ -1,2 +1,2 @@
-#!/bin/sh
+#!/bin/sh --
java -cp /usr/share/java/maven-repo-helper.jar org.debian.maven.repo.DebianPOM "$@"
Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java
===================================================================
--- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java 2009-04-02 00:35:50 UTC (rev 8178)
+++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/POMCleaner.java 2009-04-04 11:16:59 UTC (rev 8179)
@@ -393,6 +393,7 @@
System.out.println("Usage: [option] original-pom target-file versions-properties [special-dependencies]");
System.out.println("");
System.out.println("Options:");
+ System.out.println(" -v, --verbose: be extra verbose");
System.out.println(" -d, --debian-parent: target POM will inherit directly from the Debian parent POM");
System.out.println("");
System.out.println("Arguments:");
@@ -435,6 +436,11 @@
POMCleaner cleaner = new POMCleaner();
Collection specialCases = new ArrayList();
int i = inc(-1, args);
+ boolean verbose = false;
+ if ("--verbose".equals(args[0]) || "-v".equals(args[0])) {
+ verbose = true;
+ i = inc(i, args);
+ }
boolean inheritFromDebian = false;
if ("--debian-parent".equals(args[0]) || "-d".equals(args[0])) {
inheritFromDebian = true;
@@ -448,7 +454,9 @@
String specialDependencies = args[i++];
File sdFile = new File(specialDependencies);
if (!sdFile.exists()) {
- System.err.println("Cannot find file: " + sdFile);
+ if (verbose) {
+ System.err.println("Cannot find file: " + sdFile);
+ }
} else {
try {
LineNumberReader lnr = new LineNumberReader(new FileReader(sdFile));
Added: trunk/maven-repo-helper/src/main/share/mh_lib.sh
===================================================================
--- trunk/maven-repo-helper/src/main/share/mh_lib.sh (rev 0)
+++ trunk/maven-repo-helper/src/main/share/mh_lib.sh 2009-04-04 11:16:59 UTC (rev 8179)
@@ -0,0 +1,64 @@
+# This is included by mh_* and contains common functions
+#
+# - argument parsing
+# - package selection
+#
+
+VERSION=0.2
+
+parseargs()
+{
+ ARGC=0
+ ARGV=()
+ while [ -n "$1" ]; do
+ if [ "-V" = "$1" ] || [ "--version" = "$1" ]; then
+ echo "Maven Repo Helper version $VERSION"
+ exit 0
+ elif [ "-h" = "$1" ] || [ "--help" = "$1" ]; then
+ syntax
+ elif [ "-" = "${1:1:1}" ]; then
+ # long opt
+ optn=$(echo $1 | sed -n 's/^--\([^=]*\)\(=.*\)*$/\1/p' | sed 's/-/_/g')
+ if [ -z "$optn" ] || ! echo $ARGS | sed 's/-/_/g' | grep $optn >/dev/null; then
+ echo "Invalid option: $optn"
+ syntax
+ fi
+ optv=$(echo $1 | sed -n 's/^[^=]*=\(.*\)$/\1/p')
+ if [ -z "$optv" ]; then
+ optv=true
+ fi
+ export opt_$optn="$optv"
+ elif [ "-" = "${1:0:1}" ]; then
+ # short opt
+ optn="${1:1:1}"
+ if [ -z "$optn" ] || ! echo $ARGS | sed 's/-/_/g' | grep $optn >/dev/null; then
+ echo "Invalid option: $optn"
+ syntax
+ fi
+ optv="${1:2}"
+ if [ -z "$optv" ]; then
+ optv=true
+ fi
+ export opt_$optn="$optv"
+ else
+ # not-opt arg
+ ARGV[$ARGC]="$1"
+ ARGC=$(( $ARGC + 1 ))
+ fi
+ shift
+ done
+ export ARGC
+ export ARGV
+}
+
+getarg()
+{
+ while [ -n "$1" ]; do
+ optn=$(echo "opt_$1" | sed 's/-/_/g')
+ if [ -n "${!optn}" ]; then
+ echo ${!optn}
+ return
+ fi
+ shift
+ done
+}
\ No newline at end of file
More information about the pkg-java-commits
mailing list