From d1265ccd6f42503c0ba3e8e0f1c6d96073825295 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Mon, 11 Jun 2012 21:10:55 +0200 Subject: [PATCH] Implement experimental dependency checking --- maven-script-rpmbuild | 25 ++++++++++++++++++++++--- maven.spec | 6 +++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/maven-script-rpmbuild b/maven-script-rpmbuild index d44f74a..aabab06 100644 --- a/maven-script-rpmbuild +++ b/maven-script-rpmbuild @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/bash + if [ -f /usr/share/java-utils/java-functions ] ; then . /usr/share/java-utils/java-functions set_jvm @@ -32,6 +33,9 @@ function help() # add maven.repo.local if it's not defined already local_add="-Dmaven.repo.local=$(pwd)/.m2/" +log_file="$(umask 2 && mktemp -t mvn-rpmbuild.$$.XXXXXXXXXX)" +logfile_add="-Dmaven.resolver.logfile=$log_file" + function process_args() { while [ $# != 0 ]; do @@ -62,6 +66,21 @@ echo $JAVA_HOME export JAVA_HOME # can't put it on command line due to # http://jira.codehaus.org/browse/SUREFIRE-121 -export MAVEN_OPTS="$MAVEN_OPTS -Dmaven.local.mode ${local_add}" +export MAVEN_OPTS="$MAVEN_OPTS -Dmaven.local.mode ${local_add} ${logfile_add}" -$M2_HOME/bin/mvn -o "$@" +$M2_HOME/bin/mvn -o "$@" || exit $? + + +sanitize() { + for obj in $1; do + echo -n 'mvn-rpmbuild: possibly redundant dependency: ' + rpm -qf "$(readlink -f $obj)" | sed 's/-[^-]*-[^-]*$//' + done | sort -u +} + +installed=$(sanitize "$(rpm -ql `package-cleanup --all --leaves | xargs` | egrep '\.(jar|pom)$')") +used=$(sanitize "$(cat $log_file 2>/dev/null)") + +diff - /dev/fd/3 <<<"$installed" 3<<<"$used" | grep '^< ' | sed s/..// + +: diff --git a/maven.spec b/maven.spec index 92f2cc5..e140ad4 100644 --- a/maven.spec +++ b/maven.spec @@ -2,7 +2,7 @@ Name: maven Version: 3.0.4 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Java project management and project comprehension tool Group: Development/Tools @@ -97,6 +97,7 @@ Requires: sisu >= 2.1.1-2 Requires: sonatype-oss-parent Requires: xbean Requires: xerces-j2 +Requires: yum-utils # for noarch->arch change @@ -359,6 +360,9 @@ ln -sf `rpm --eval '%%{_jnidir}'` %{_datadir}/%{name}/repository-jni/JPP %changelog +* Mon Jun 11 2012 Mikolaj Izdebski - 3.0.4-7 +- Implement redundant dependency checks + * Thu May 24 2012 Krzysztof Daniel 3.0.4-6 - Bug 824789 -Use the version if it is possible.