Detection of useless dependencies

Petteri Räty <[email protected]> Sat, 19 Jul 2008 02:05:30 +0300
Newsgroups gmane.linux.gentoo.java
Message-ID <[email protected]>
If you are using JAVA_PKG_STRICT and install dev-java/java-dep-check, 
you will start to see messages like the following:
 >>> Merging dev-java/xstream-1.2-r2 to /
  * Possibly unneeded dependencies found in package.env:
  *      commons-cli-1

This means that xstream is recording a dependency on commons-cli-1 to 
package.env but the class files installed by xstream don't reference any 
classes from commons-cli in the constant pool. For most packages this 
means that you just remove the usage from the ebuild but the tool will 
also give you false positives if the dependency is only needed at 
runtime and is loaded a provider framework for example. These false 
positives will eventually be hidden by mandating the use of 
java-pkg_register-dependency for these dependencies and then we can use 
the values given to that function to filter those out from the results 
of java-dep-check.

Regards,
Petteri
java-dep-check.patch (text/plain, 1.2 KB)
Index: java-pkg-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v
retrieving revision 1.28
diff -u -r1.28 java-pkg-2.eclass
--- java-pkg-2.eclass	7 Jul 2008 16:54:56 -0000	1.28
+++ java-pkg-2.eclass	18 Jul 2008 22:13:44 -0000
@@ -49,7 +49,7 @@
 	SRC_URI="mirror://apache/${PN/-///}/source/${P}-src.tar.gz"
 fi
 
-EXPORT_FUNCTIONS pkg_setup src_compile
+EXPORT_FUNCTIONS pkg_setup src_compile pkg_preinst
 
 # ------------------------------------------------------------------------------
 # @eclass-pkg_setup
@@ -93,6 +93,23 @@
 	fi
 }
 
+
+java-pkg-2_pkg_preinst() {
+	if is-java-strict; then
+		if has_version dev-java/java-dep-check; then
+			local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
+			if [[ ${output} ]]; then
+				ewarn "Possibly unneeded dependencies found in package.env:"
+				for dep in ${output}; do
+					ewarn "\t${dep}"
+				done
+			fi
+		else
+			eerror "Install dev-java/java-dep-check for dependency checking"
+		fi
+	fi
+}
+
 # ------------------------------------------------------------------------------
 # @eclass-end
 # ------------------------------------------------------------------------------
signature.asc (application/pgp-signature, 260 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiBIboACgkQcxLzpIGCsLRzSgCdGzZcUkCKdpcStvHhFRcsgpuE
tAsAn160NuaIW3uwgU7WEfqJp32y9A+e
=yKAY
-----END PGP SIGNATURE-----