changeset 2888:f5504d3e6a80

PR2799: Files are missing from resources.jar 2016-07-26 Andrew John Hughes <gnu.andrew@redhat.com> PR2799: Files are missing from resources.jar * Makefile.am: (MIME_TYPE_CHECK_BUILD_DIR): Add build directory for mime type check. (MIME_TYPE_CHECK_SRCS): Specify sources for mime type check. (EXTRA_DIST): Distribute mime type check sources. (check-local): Depend on check-mimetype. (clean-tests): Depend on clean-check-mimetype. (clean-local): Depend on clean-mimetypecheck. (.PHONY): Depend on clean-check-mimetype, clean-mimetypecheck, clean-add-mime-types-file, clean-add-mime-types-file-debug and clean-add-mime-types-file-boot. (add-mime-types-file): Add a symlink to the system mime.types file if found. (clean-add-mime-types-file): Remove symlink to the system mime types file. (add-mime-types-file-debug): Add a symlink to the system mime.types file, if found, in the debug build. (clean-add-mime-types-file-debug): Remove symlink to the system mime types file in the debug build. (icedtea-stage2): Depend on add-mime-types-file. (clean-icedtea-stage2): Depend on clean-add-mime-types-file. (icedtea-debug-stage2): Depend on add-mime-types-file-debug. (clean-icedtea-debug-stage2): Depend on clean-add-mime-types-file-debug. (add-mime-types-file-boot): Add a symlink to the system mime.types file, if found, in the bootstrap build. (clean-add-mime-types-file-boot): Remove symlink to the system mime types file in the bootstrap build. (icedtea-stage1): Depend on add-mime-types-file-boot. (clean-icedtea-stage1): Depend on clean-add-mime-types-file-boot. (check-mimetype): Check that we can recognise a HTML file and (if system mime.types is available) a Java file. (clean-check-mimetype): Cleanup after check-mimetype. (mimetypecheck): Build the MIME type check. (clean-mimetypecheck): Remove MIME type check build. (install-data-local): Install the mime.types symlink. * acinclude.m4: (IT_CHECK_FOR_MIME_TYPES): Check for a system mime.types file and define MIME_TYPES_FILE_FOUND if located. * configure.ac: Invoke IT_CHECK_FOR_MIME_TYPES. * test/RH1195203.java: Testcase to get Java to print the MIME type of a file.
author Andrew John Hughes <gnu_andrew@member.fsf.org>
date Wed, 27 Jul 2016 05:29:59 +0100
parents cafef061b9d4
children 101843a7ca92
files ChangeLog Makefile.am acinclude.m4 configure.ac test/RH1195203.java
diffstat 5 files changed, 217 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jul 28 16:04:20 2016 +0100
+++ b/ChangeLog	Wed Jul 27 05:29:59 2016 +0100
@@ -1,3 +1,51 @@
+2016-07-26  Andrew John Hughes  <gnu.andrew@redhat.com>
+
+	PR2799: Files are missing from resources.jar
+	* Makefile.am:
+	(MIME_TYPE_CHECK_BUILD_DIR): Add build directory
+	for mime type check.
+	(MIME_TYPE_CHECK_SRCS): Specify sources for
+	mime type check.
+	(EXTRA_DIST): Distribute mime type check sources.
+	(check-local): Depend on check-mimetype.
+	(clean-tests): Depend on clean-check-mimetype.
+	(clean-local): Depend on clean-mimetypecheck.
+	(.PHONY): Depend on clean-check-mimetype,
+	clean-mimetypecheck, clean-add-mime-types-file,
+	clean-add-mime-types-file-debug and
+	clean-add-mime-types-file-boot.
+	(add-mime-types-file): Add a symlink to the
+	system mime.types file if found.
+	(clean-add-mime-types-file): Remove symlink
+	to the system mime types file.
+	(add-mime-types-file-debug): Add a symlink to the
+	system mime.types file, if found, in the debug build.
+	(clean-add-mime-types-file-debug): Remove symlink
+	to the system mime types file in the debug build.
+	(icedtea-stage2): Depend on add-mime-types-file.
+	(clean-icedtea-stage2): Depend on clean-add-mime-types-file.
+	(icedtea-debug-stage2): Depend on add-mime-types-file-debug.
+	(clean-icedtea-debug-stage2): Depend on clean-add-mime-types-file-debug.
+	(add-mime-types-file-boot): Add a symlink to the
+	system mime.types file, if found, in the bootstrap build.
+	(clean-add-mime-types-file-boot): Remove symlink
+	to the system mime types file in the bootstrap build.
+	(icedtea-stage1): Depend on add-mime-types-file-boot.
+	(clean-icedtea-stage1): Depend on clean-add-mime-types-file-boot.
+	(check-mimetype): Check that we can recognise a HTML
+	file and (if system mime.types is available) a Java file.
+	(clean-check-mimetype): Cleanup after check-mimetype.
+	(mimetypecheck): Build the MIME type check.
+	(clean-mimetypecheck): Remove MIME type check build.
+	(install-data-local): Install the mime.types symlink.
+	* acinclude.m4:
+	(IT_CHECK_FOR_MIME_TYPES): Check for a system mime.types
+	file and define MIME_TYPES_FILE_FOUND if located.
+	* configure.ac:
+	Invoke IT_CHECK_FOR_MIME_TYPES.
+	* test/RH1195203.java: Testcase to get Java to print
+	the MIME type of a file.
+
 2016-07-28  Andrew John Hughes  <gnu.andrew@member.fsf.org>
 
 	S7175845, PR1437, RH1207129: 'jar uf' changes file
--- a/Makefile.am	Thu Jul 28 16:04:20 2016 +0100
+++ b/Makefile.am	Wed Jul 27 05:29:59 2016 +0100
@@ -70,6 +70,7 @@
 STAGE2_BOOT_DIR = $(abs_top_builddir)/bootstrap/icedtea
 JAMVM_IMPORT_PATH = $(abs_top_builddir)/jamvm/install/hotspot
 CRYPTO_CHECK_BUILD_DIR = $(abs_top_builddir)/test/cryptocheck.build
+MIME_TYPE_CHECK_BUILD_DIR = $(abs_top_builddir)/test/mimetypecheck.build
 STAGE1_BOOT_RUNTIME = $(STAGE1_BOOT_DIR)/jre/lib/rt.jar
 STAGE2_BOOT_RUNTIME = $(STAGE2_BOOT_DIR)/jre/lib/rt.jar
 FONTCONFIG_PATH = openjdk/jdk/src/solaris/classes/sun/awt/fontconfigs
@@ -367,6 +368,7 @@
 
 REWRITER_SRCS = $(top_srcdir)/rewriter/com/redhat/rewriter/ClassRewriter.java
 CRYPTO_CHECK_SRCS = $(top_srcdir)/TestCryptoLevel.java
+MIME_TYPE_CHECK_SRCS = $(top_srcdir)/test/RH1195203.java
 
 # Patch list
 
@@ -917,16 +919,18 @@
 	rewriter/agpl-3.0.txt \
 	$(REWRITER_SRCS) \
 	test/tapset \
-	$(CRYPTO_CHECK_SRCS)
+	$(CRYPTO_CHECK_SRCS) \
+	$(MIME_TYPE_CHECK_SRCS)
 
 # Top-Level Targets
 # =================
 
 all-local: icedtea-stage2 $(DESKTOP_FILES)
 
-check-local: jtregcheck check-tapset
-
-clean-tests: clean-jtreg clean-tapset-report clean-jtreg-reports
+check-local: jtregcheck check-tapset check-mimetype
+
+clean-tests: clean-jtreg clean-tapset-report clean-jtreg-reports \
+  clean-check-mimetype
 	if [ $(abs_top_srcdir) != $(abs_top_builddir) ] ; then \
 	  if [ -e test ] ; then \
 	    rmdir test ; \
@@ -942,7 +946,7 @@
  clean-add-cacao clean-add-cacao-debug clean-rt clean-rewrite-rhino clean-rewriter \
  clean-add-systemtap clean-add-systemtap-debug clean-add-nss clean-add-tzdata-support \
  clean-add-tzdata-support-debug clean-cryptocheck clean-policytool-@JAVA_VER@.desktop \
- clean-jconsole-@JAVA_VER@.desktop
+ clean-jconsole-@JAVA_VER@.desktop clean-mimetypecheck
 	if [ -e bootstrap ]; then \
 	  rmdir bootstrap ; \
 	fi
@@ -973,7 +977,7 @@
 	clean-tests clean-tapset-report clean-add-systemtap \
 	clean-add-systemtap-debug clean-add-systemtap-boot \
 	clean-add-nss clean-add-tzdata-support clean-add-tzdata-support-debug \
-	clean-add-tzdata-support-boot \
+	clean-add-tzdata-support-boot clean-check-mimetype clean-mimetypecheck \
 	clean-check-crypto clean-check-crypto-debug clean-check-crypto-boot \
 	clean-add-archive clean-add-archive-debug clean-add-archive-boot clean-cryptocheck \
 	clean-download-hotspot clean-download-corba clean-download-jaxp \
@@ -981,7 +985,7 @@
 	clean-extract-corba clean-extract-jaxp clean-extract-jaxws clean-extract-jdk \
 	clean-extract-langtools clean-split-debuginfo clean-split-debuginfo-debug \
 	clean-split-debuginfo-boot clean-policytool-@JAVA_VER@.desktop clean-jconsole-@JAVA_VER@.desktop \
-	clean-fonts
+	clean-fonts clean-add-mime-types-file clean-add-mime-types-file-debug clean-add-mime-types-file-boot
 
 env:
 	@echo 'unset JAVA_HOME'
@@ -2148,6 +2152,20 @@
 	rm -rvf $(BUILD_DEBUGINFO_DIR)
 	rm -f stamps/split-debuginfo.stamp
 
+stamps/add-mime-types-file.stamp: stamps/icedtea.stamp
+if MIME_TYPES_FILE_FOUND
+	if [ -e $(BUILD_SDK_DIR)/jre/lib ] ; then \
+	  ln -sf $(MIME_TYPES_FILE) $(BUILD_SDK_DIR)/jre/lib/mime.types ; \
+	fi
+endif
+	touch $@
+
+clean-add-mime-types-file:
+	if [ -e $(BUILD_SDK_DIR)/jre/lib/mime.types ] ; then \
+	  rm -vf $(BUILD_SDK_DIR)/jre/lib/mime.types ; \
+	fi
+	rm -f stamps/add-mime-types-file.stamp
+
 stamps/icedtea-debug.stamp: stamps/bootstrap-directory-symlink-stage2.stamp \
  stamps/download.stamp stamps/extract.stamp $(OPENJDK_TREE) \
  stamps/cacao.stamp stamps/rewrite-rhino.stamp stamps/jamvm.stamp
@@ -2282,25 +2300,41 @@
 	rm -rvf $(BUILD_DEBUG_DEBUGINFO_DIR)
 	rm -f stamps/split-debuginfo-debug.stamp
 
+stamps/add-mime-types-file-debug.stamp: stamps/icedtea-debug.stamp
+if MIME_TYPES_FILE_FOUND
+	if [ -e $(BUILD_DEBUG_SDK_DIR)/jre/lib ] ; then \
+	  ln -sf $(MIME_TYPES_FILE) $(BUILD_DEBUG_SDK_DIR)/jre/lib/mime.types ; \
+	fi
+endif
+	touch $@
+
+clean-add-mime-types-file-debug:
+	if [ -e $(BUILD_DEBUG_SDK_DIR)/jre/lib/mime.types ] ; then \
+	  rm -vf $(BUILD_DEBUG_SDK_DIR)/jre/lib/mime.types ; \
+	fi
+	rm -f stamps/add-mime-types-file-debug.stamp
+
 stamps/icedtea-stage2.stamp: stamps/icedtea.stamp stamps/add-cacao.stamp \
  stamps/add-zero.stamp stamps/add-jamvm.stamp stamps/add-systemtap.stamp \
  stamps/add-tzdata-support.stamp stamps/check-crypto.stamp stamps/add-archive.stamp \
- stamps/split-debuginfo.stamp
+ stamps/split-debuginfo.stamp stamps/add-mime-types-file.stamp
 	mkdir -p stamps
 	touch $@
 
-clean-icedtea-stage2: clean-add-jamvm clean-check-crypto clean-add-archive clean-split-debuginfo
+clean-icedtea-stage2: clean-add-jamvm clean-check-crypto clean-add-archive clean-split-debuginfo \
+ clean-add-mime-types-file
 	rm -f stamps/icedtea-stage2.stamp
 
 stamps/icedtea-debug-stage2.stamp: stamps/icedtea-debug.stamp \
  stamps/add-cacao-debug.stamp stamps/add-zero-debug.stamp stamps/add-jamvm-debug.stamp \
  stamps/add-systemtap-debug.stamp stamps/add/tzdata-support-debug.stamp \
- stamps/check-crypto-debug.stamp stamps/add-archive-debug.stamp stamps/split-debuginfo-debug.stamp
+ stamps/check-crypto-debug.stamp stamps/add-archive-debug.stamp stamps/split-debuginfo-debug.stamp \
+ stamps/add-mime-types-file-debug.stamp
 	mkdir -p stamps
 	touch $@
 
 clean-icedtea-debug-stage2: clean-add-jamvm-debug clean-check-crypto-debug \
- clean-add-archive-debug clean-split-debuginfo-debug
+ clean-add-archive-debug clean-split-debuginfo-debug clean-add-mime-types-file-debug
 	rm -f stamps/icedtea-debug-stage2.stamp
 
 # OpenJDK boot Targets
@@ -2424,15 +2458,30 @@
 	rm -rvf $(BUILD_BOOT_DEBUGINFO_DIR)
 	rm -f stamps/split-debuginfo-boot.stamp
 
+stamps/add-mime-types-file-boot.stamp: stamps/icedtea-boot.stamp
+if MIME_TYPES_FILE_FOUND
+	if [ -e $(BUILD_BOOT_SDK_DIR)/jre/lib ] ; then \
+	  ln -sf $(MIME_TYPES_FILE) $(BUILD_BOOT_SDK_DIR)/jre/lib/mime.types ; \
+	fi
+endif
+	touch $@
+
+clean-add-mime-types-file-boot:
+	if [ -e $(BUILD_BOOT_SDK_DIR)/jre/lib/mime.types ] ; then \
+	  rm -vf $(BUILD_BOOT_SDK_DIR)/jre/lib/mime.types ; \
+	fi
+	rm -f stamps/add-mime-types-file-boot.stamp
+
 stamps/icedtea-stage1.stamp: stamps/icedtea-boot.stamp \
  stamps/add-systemtap-boot.stamp stamps/add-tzdata-support-boot.stamp \
  stamps/check-crypto-boot.stamp stamps/add-archive-boot.stamp \
- stamps/split-debuginfo-boot.stamp
+ stamps/split-debuginfo-boot.stamp stamps/add-mime-types-file-boot.stamp
 	mkdir -p stamps
 	touch $@
 
 clean-icedtea-stage1: clean-add-systemtap-boot clean-add-tzdata-support-boot \
- clean-check-crypto-boot clean-add-archive-boot clean-split-debuginfo-boot
+ clean-check-crypto-boot clean-add-archive-boot clean-split-debuginfo-boot \
+ clean-add-mime-types-file-boot
 	rm -f stamps/icedtea-stage1.stamp
 
 # Rebuild targets
@@ -2763,7 +2812,7 @@
 
 # end additional VMs
 
-# jtreg
+# Test cases
 
 stamps/jtreg.stamp: stamps/icedtea-stage2.stamp
 	rm -rf test/jtreg/classes
@@ -2904,6 +2953,35 @@
 	rm -f test/check-stap.log
 endif
 
+stamps/check-mimetype.stamp: stamps/mimetypecheck.stamp stamps/icedtea.stamp
+	if [ -e $(BUILD_SDK_DIR)/bin/java ] ; then \
+	  echo "<html><head/><body/></html>" > $(MIME_TYPE_CHECK_BUILD_DIR)/test.html ; \
+	  expected="text/html" ; \
+	  html=$$($(BUILD_SDK_DIR)/bin/java -cp $(MIME_TYPE_CHECK_BUILD_DIR) RH1195203 \
+	    $(MIME_TYPE_CHECK_BUILD_DIR)/test.html) ; \
+	  if test "x$${html}" != "x$${expected}" ; then \
+	    echo "MIME type test failed; expected $${expected}, got $${html}" ; \
+	    exit -1; \
+	  fi ; \
+	fi
+if MIME_TYPES_FILE_FOUND
+	if [ -e $(BUILD_SDK_DIR)/bin/java ] ; then \
+	  expected="text/x-java-source" ; \
+	  java=$$($(BUILD_SDK_DIR)/bin/java -cp $(MIME_TYPE_CHECK_BUILD_DIR) RH1195203 \
+	    $(MIME_TYPE_CHECK_SRCS)) ; \
+	  if test "x$${java}" != "x$${expected}"; then \
+	    echo "MIME type test failed; expected $${expected}, got $${java}" ; \
+	    exit -1; \
+	  fi ; \
+	fi
+endif
+	mkdir -p stamps
+	touch $@
+
+clean-check-mimetype:
+	rm -f $(MIME_TYPE_CHECK_BUILD_DIR)/test.html
+	rm -f stamps/check-mimetype.stamp
+
 # Support classes for non-OpenJDK bootstraps
 
 rt-source-files.txt: $(OPENJDK_BOOT_TREE)
@@ -2964,6 +3042,19 @@
 	rm -rf $(CRYPTO_CHECK_BUILD_DIR)
 	rm -f stamps/cryptocheck.stamp
 
+# Mime Type Check
+
+stamps/mimetypecheck.stamp: $(INITIAL_BOOTSTRAP_LINK_STAMP)
+	mkdir -p $(MIME_TYPE_CHECK_BUILD_DIR)
+	$(BOOT_DIR)/bin/javac $(IT_JAVACFLAGS) \
+	  -d $(MIME_TYPE_CHECK_BUILD_DIR) $(MIME_TYPE_CHECK_SRCS)
+	mkdir -p stamps
+	touch $@
+
+clean-mimetypecheck:
+	rm -rf $(MIME_TYPE_CHECK_BUILD_DIR)
+	rm -f stamps/mimetypecheck.stamp
+
 # File substitution
 
 policytool-@JAVA_VER@.desktop: policytool.desktop
@@ -3120,6 +3211,9 @@
 	$(INSTALL_DATA) $(BUILD_SDK_DIR)/jre/lib/currency.data $(DESTDIR)${prefix}/jre/lib
 	$(INSTALL_DATA) $(BUILD_SDK_DIR)/jre/lib/jvm.hprof.txt $(DESTDIR)${prefix}/jre/lib
 	$(INSTALL_DATA) $(BUILD_SDK_DIR)/jre/lib/meta-index $(DESTDIR)${prefix}/jre/lib
+if MIME_TYPES_FILE_FOUND
+	$(call install_file,$(BUILD_SDK_DIR)/jre/lib/mime.types,$(DESTDIR)${prefix}/jre/lib,$(INSTALL_DATA))
+endif
 	$(INSTALL_DATA) $(BUILD_SDK_DIR)/jre/lib/psfont.properties.ja $(DESTDIR)${prefix}/jre/lib
 	$(INSTALL_DATA) $(BUILD_SDK_DIR)/jre/lib/$(INSTALL_ARCH_DIR)/jvm.cfg \
 	  $(DESTDIR)${prefix}/jre/lib/$(INSTALL_ARCH_DIR)
@@ -3221,6 +3315,12 @@
 
 add-jamvm-debug: stamps/add-jamvm-debug.stamp
 
+add-mime-types-file: stamps/add-mime-types-file.stamp
+
+add-mime-types-file-debug: stamps/add-mime-types-file-debug.stamp
+
+add-mime-types-file-boot: stamps/add-mime-types-file-boot.stamp
+
 add-nss: stamps/add-nss.stamp
 
 add-nss-debug: stamps/add-nss-debug.stamp
@@ -3257,6 +3357,8 @@
 
 check-crypto-debug: stamps/check-crypto-debug.stamp
 
+check-mimetype: stamps/check-mimetype.stamp
+
 clone-boot: stamps/clone-boot.stamp
 
 cryptocheck: stamps/cryptocheck.stamp
@@ -3321,6 +3423,8 @@
 
 jtreg: stamps/jtreg.stamp
 
+mimetypecheck: stamps/mimetypecheck.stamp
+
 native-ecj: stamps/native-ecj.stamp
 
 overlay: stamps/overlay.stamp
--- a/acinclude.m4	Thu Jul 28 16:04:20 2016 +0100
+++ b/acinclude.m4	Wed Jul 27 05:29:59 2016 +0100
@@ -3399,3 +3399,20 @@
   AC_SUBST(FREETYPE2_CFLAGS)
   AC_SUBST(FREETYPE2_LIBS)
 ])
+
+AC_DEFUN_ONCE([IT_CHECK_FOR_MIME_TYPES],
+[
+  MIME_TYPES_FILE="/etc/mime.types"
+  AC_MSG_CHECKING([for ${MIME_TYPES_FILE}])
+  if test -f ${MIME_TYPES_FILE}; then
+     mime_types_file_found=yes
+  else
+     mime_types_file_found=no
+  fi
+  AC_MSG_RESULT([$mime_types_file_found])
+  if test "x${mime_types_file_found}" = "xno"; then
+    AC_MSG_WARN([No system MIME types file found.])
+  fi
+  AC_SUBST([MIME_TYPES_FILE])
+  AM_CONDITIONAL(MIME_TYPES_FILE_FOUND, test "x${mime_types_file_found}" = "xyes")
+])
--- a/configure.ac	Thu Jul 28 16:04:20 2016 +0100
+++ b/configure.ac	Wed Jul 27 05:29:59 2016 +0100
@@ -45,6 +45,8 @@
 IT_CHECK_FOR_MERCURIAL
 IT_OBTAIN_HG_REVISIONS
 AC_PATH_TOOL([LSB_RELEASE],[lsb_release])
+IT_CHECK_FOR_MIME_TYPES
+
 IT_WITH_HOTSPOT_BUILD
 AC_PATH_TOOL([LINUX32],[linux32])
 IT_CHECK_GCC_VERSION
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/RH1195203.java	Wed Jul 27 05:29:59 2016 +0100
@@ -0,0 +1,32 @@
+/* RH1195203 -- Check correct recognition of mime types.
+   Copyright (C) 2015 Red Hat, Inc.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+import javax.activation.MimetypesFileTypeMap;
+
+public class RH1195203
+{
+    public static void main(String[] args)
+    {
+        if (args.length == 0)
+        {
+	    System.err.println("No file specified.");
+	    System.exit(-1);
+	}
+
+        System.out.println(MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(args[0]));
+    }
+}