public inbox for gentoo-java@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-java] Running java-pkg_ensure-no-bundled-jars automatically with JAVA_PKG_STRICT
@ 2007-01-02 16:13 Petteri Räty
  2007-01-03  1:53 ` Joshua Nichols
  0 siblings, 1 reply; 4+ messages in thread
From: Petteri Räty @ 2007-01-02 16:13 UTC (permalink / raw
  To: gentoo-java


[-- Attachment #1.1: Type: text/plain, Size: 165 bytes --]

Any objections to the attached patch? It will probably find some false
positives but in those cases one can just use JAVA_PKG_STRICT= emerge.

Regards,
Petteri

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: no-bundled-jars.patch --]
[-- Type: text/x-patch; name="no-bundled-jars.patch", Size: 450 bytes --]

Index: java-pkg-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v
retrieving revision 1.8
diff -u -r1.8 java-pkg-2.eclass
--- java-pkg-2.eclass	18 Dec 2006 10:18:56 -0000	1.8
+++ java-pkg-2.eclass	2 Jan 2007 16:11:41 -0000
@@ -84,6 +84,7 @@
 }
 
 pre_src_compile() {
+	is-java-strict && java-pkg_ensure-no-bundled-jars
 	java-pkg-2_pkg_setup
 }
 

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-java] Running java-pkg_ensure-no-bundled-jars automatically with JAVA_PKG_STRICT
  2007-01-02 16:13 [gentoo-java] Running java-pkg_ensure-no-bundled-jars automatically with JAVA_PKG_STRICT Petteri Räty
@ 2007-01-03  1:53 ` Joshua Nichols
  2007-01-06 13:09   ` Petteri Räty
  0 siblings, 1 reply; 4+ messages in thread
From: Joshua Nichols @ 2007-01-03  1:53 UTC (permalink / raw
  To: gentoo-java

Petteri Räty wrote:
> Any objections to the attached patch? It will probably find some false
> positives but in those cases one can just use JAVA_PKG_STRICT= emerge.
>
> Regards,
> Petteri
>   
> ------------------------------------------------------------------------
>
> Index: java-pkg-2.eclass
> ===================================================================
> RCS file: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v
> retrieving revision 1.8
> diff -u -r1.8 java-pkg-2.eclass
> --- java-pkg-2.eclass	18 Dec 2006 10:18:56 -0000	1.8
> +++ java-pkg-2.eclass	2 Jan 2007 16:11:41 -0000
> @@ -84,6 +84,7 @@
>  }
>  
>  pre_src_compile() {
> +	is-java-strict && java-pkg_ensure-no-bundled-jars
>  	java-pkg-2_pkg_setup
>  }
>  
>   
I'm not sure if we should add this quite yet. Any idea how many packages 
this would affect?

Some problem areas I expect:

* Some packages are weird, and jar up their sources inside of their 
upstream distfile, which we then unpack. So, we'd either need to remove 
those jars after unpacking, or perhaps add some checks to ensure the 
bundled jars don't contain class files
* Some packages have jars for like tests, or examples, or whatnot. Maybe 
we need a variable to say what jars are ok?
* In some cases, we may be only replacing some jars with jar-from... but 
perhaps not all of them, or maybe they are meant to replace a jar, but 
the jar changed names, so both the symlink from jar-from and the 
original are around.

Whitelisting jars should take care of the first two points, and for the 
latter, well, I suppose those are the type of things this is intended to 
catch.

-- 
Joshua Nichols
Gentoo/Java Project Lead
-- 
gentoo-java@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-java] Running java-pkg_ensure-no-bundled-jars automatically with JAVA_PKG_STRICT
  2007-01-03  1:53 ` Joshua Nichols
@ 2007-01-06 13:09   ` Petteri Räty
  2007-01-09 16:13     ` Petteri Räty
  0 siblings, 1 reply; 4+ messages in thread
From: Petteri Räty @ 2007-01-06 13:09 UTC (permalink / raw
  To: gentoo-java


[-- Attachment #1.1: Type: text/plain, Size: 728 bytes --]

Joshua Nichols kirjoitti:
> 
> * Some packages are weird, and jar up their sources inside of their
> upstream distfile, which we then unpack. So, we'd either need to remove
> those jars after unpacking, or perhaps add some checks to ensure the
> bundled jars don't contain class files
> * Some packages have jars for like tests, or examples, or whatnot. Maybe
> we need a variable to say what jars are ok?
> * In some cases, we may be only replacing some jars with jar-from... but
> perhaps not all of them, or maybe they are meant to replace a jar, but
> the jar changed names, so both the symlink from jar-from and the
> original are around.
> 

Probably best to go with the attached then.

Regards,
Petteri

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: no-bundled-jars.patch --]
[-- Type: text/x-patch; name="no-bundled-jars.patch", Size: 1323 bytes --]

Index: java-pkg-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v
retrieving revision 1.8
diff -u -r1.8 java-pkg-2.eclass
--- java-pkg-2.eclass	18 Dec 2006 10:18:56 -0000	1.8
+++ java-pkg-2.eclass	6 Jan 2007 13:08:20 -0000
@@ -84,6 +84,7 @@
 }
 
 pre_src_compile() {
+	is-java-strict && java-pkg_ensure-no-bundled-jars --warn
 	java-pkg-2_pkg_setup
 }
 
Index: java-utils-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v
retrieving revision 1.39
diff -u -r1.39 java-utils-2.eclass
--- java-utils-2.eclass	3 Jan 2007 09:18:20 -0000	1.39
+++ java-utils-2.eclass	6 Jan 2007 13:08:21 -0000
@@ -1017,6 +1017,10 @@
 	debug-print-function ${FUNCNAME} $*
 	pushd ${WORKDIR} >/dev/null 2>/dev/null
 
+	if [[ "${1}" == "--warn" ]]; then
+		local warn="true"
+	fi
+
 	local bundled_jars=$(find . -name "*.jar" -type f)
 	if [[ -n ${bundled_jars} ]]; then
 		echo "Bundled jars found:"
@@ -1024,8 +1028,9 @@
 		for jar in ${bundled_jars}; do
 			echo $(pwd)${jar/./}
 		done
-		die "Bundled jars found!"
-
+		if [[ -z "${warn}" ]]; then
+			die "Bundled jars found!"
+		fi
 	fi
 	popd >/dev/null 2>/dev/null
 }

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-java] Running java-pkg_ensure-no-bundled-jars automatically with JAVA_PKG_STRICT
  2007-01-06 13:09   ` Petteri Räty
@ 2007-01-09 16:13     ` Petteri Räty
  0 siblings, 0 replies; 4+ messages in thread
From: Petteri Räty @ 2007-01-09 16:13 UTC (permalink / raw
  To: gentoo-java


[-- Attachment #1.1: Type: text/plain, Size: 869 bytes --]

Petteri Räty kirjoitti:
> Joshua Nichols kirjoitti:
>> * Some packages are weird, and jar up their sources inside of their
>> upstream distfile, which we then unpack. So, we'd either need to remove
>> those jars after unpacking, or perhaps add some checks to ensure the
>> bundled jars don't contain class files
>> * Some packages have jars for like tests, or examples, or whatnot. Maybe
>> we need a variable to say what jars are ok?
>> * In some cases, we may be only replacing some jars with jar-from... but
>> perhaps not all of them, or maybe they are meant to replace a jar, but
>> the jar changed names, so both the symlink from jar-from and the
>> original are around.
>>
> 
> Probably best to go with the attached then.
> 
> Regards,
> Petteri
> 

Ok. The attached is probably what I am going to commit this week unless
someone objects.

[-- Attachment #1.2: warn-about-bundled-jars.patch --]
[-- Type: text/plain, Size: 2505 bytes --]

Index: java-utils-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v
retrieving revision 1.39
diff -u -r1.39 java-utils-2.eclass
--- java-utils-2.eclass	3 Jan 2007 09:18:20 -0000	1.39
+++ java-utils-2.eclass	9 Jan 2007 16:12:19 -0000
@@ -1011,13 +1011,36 @@
 #	export RDEPEND="${RDEPEND} ${depstr}"
 #}
 
-# This should be used after S has been populated with symlinks to jars
-# TODO document
+# ------------------------------------------------------------------------------
+# @ebuild-function java-pkg_find-normal-jars
+#
+# Find the files with suffix .jar file in the given directory or $WORKDIR
+#
+# @param $1 - The directory to search for jar files (default: ${WORKDIR})
+# ------------------------------------------------------------------------------
+java-pkg_find-normal-jars() {
+	local dir=$1
+	[[ "${dir}" ]] || dir="${WORKDIR}"
+	local found
+	for jar in $(find "${dir}" -name "*.jar" -type f); do
+		echo "${jar}"
+		found="true"
+	done
+	[[ "${found}" ]]
+	return $?
+}
+
+# ------------------------------------------------------------------------------
+# @ebuild-function java-pkg_ensure-no-bundled-jars
+#
+# Try to locate bundled jar files in ${WORKDIR} and die if found.
+# This function should be called after WORKDIR has been populated with symlink
+# to system jar files or bundled jars removed.
+# ------------------------------------------------------------------------------
 java-pkg_ensure-no-bundled-jars() {
 	debug-print-function ${FUNCNAME} $*
-	pushd ${WORKDIR} >/dev/null 2>/dev/null
 
-	local bundled_jars=$(find . -name "*.jar" -type f)
+	local bundled_jars=$(java-pkg_find-normal-jars)
 	if [[ -n ${bundled_jars} ]]; then
 		echo "Bundled jars found:"
 		local jar
@@ -1025,9 +1048,7 @@
 			echo $(pwd)${jar/./}
 		done
 		die "Bundled jars found!"
-
 	fi
-	popd >/dev/null 2>/dev/null
 }
 
 # ------------------------------------------------------------------------------
Index: java-pkg-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v
retrieving revision 1.8
diff -u -r1.8 java-pkg-2.eclass
--- java-pkg-2.eclass	18 Dec 2006 10:18:56 -0000	1.8
+++ java-pkg-2.eclass	9 Jan 2007 16:12:19 -0000
@@ -84,6 +84,10 @@
 }
 
 pre_src_compile() {
+	if is-java-strict; then
+		echo "Searching for bundled jars:"
+		java-pkg_find-normal-jars || echo "None found."
+	fi
 	java-pkg-2_pkg_setup
 }
 

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-09 16:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-02 16:13 [gentoo-java] Running java-pkg_ensure-no-bundled-jars automatically with JAVA_PKG_STRICT Petteri Räty
2007-01-03  1:53 ` Joshua Nichols
2007-01-06 13:09   ` Petteri Räty
2007-01-09 16:13     ` Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox