[RFC]: make IcedTea-web to be compatible with RHEL5 libraries

Deepak Bhole dbhole at redhat.com
Mon Aug 22 13:55:04 PDT 2011


* Jiri Vanek <jvanek at redhat.com> [2011-08-22 09:21]:
> On 07/21/2011 03:21 PM, Dr Andrew John Hughes wrote:
> >On 12:08 Thu 21 Jul     , Jiri Vanek wrote:
> >>
> >>Hi!
> >>
> >>This patch is another attempt o make icedtea-web buildable on rhel 5 with older libraries. Before build of plugin itself is started, then testing c++ program is tried to be linked with same options. If this compilation fails, then original IcedTeaNPPlugin.cc is backuped,  glibBuildable.patch is applied to IcedTeaNPPlugin.cc and then plugin is linked.
> >>During clean-plugin original IcedTeaNPPlugin.cc is restored from backup (and when test application is compiled, then this binary is deleted, also backup is delete)
> >>
> >>Please, when you will ask me to include this "solution" more to configure (or autotools or anywhere) then I will need a little bit of help.
> >>
> >
> >I suggest taking a look at the autoconf manual and function detection:
> >
> >http://www.gnu.org/software/autoconf/manual/autoconf.html#Library-Functions
> >
> >Then, rather than patching, I'd add a header file with #ifdefs to handle both cases.
> >
> 
> 2011-08-22  Jiri Vanek <jvanek at redhat.com>
> 	Added functionality to allow icedtea web to be buildable with
> 	 rhel5 libraries
> 	* testGlibs.cc: testing file. If not compiled, then Rhel5Compatible
> 	 macro is defined for compiling IcedTeaNPPlugin.cc.
> 	* plugin/icedteanp/IcedTeaNPPlugin.cc: added replacements for incompatible
> 	 functions, added #define sections for use this function instead of glib ones
> 	*Makefile.am: (stamps/patch-for-glib): new target, compiling testGlibs.cc
> 	($(PLUGIN_DIR)/%.o): now depends on stamps/patch-for-glib and define
> 	 Rhel5Compatible if  testGlibs.cc was compiled successfully
> 	($(PLUGIN_DIR)/IcedTeaPlugin.so): same as ^
> 	(clean-IcedTeaPlugin): removes compiled testGlibs if exists
> 

Is this RHEL 5 specific or glib version specific? It looks to be the
latter. In which case no test program should be needed -- just a check
for glib version and conditional compilation accordingly.

Cheers,
Deepak

> 
> Regards J.

> diff -r 68756a4f8cc0 Makefile.am
> --- a/Makefile.am	Thu Aug 11 14:11:41 2011 -0400
> +++ b/Makefile.am	Mon Aug 22 14:57:32 2011 +0200
> @@ -76,6 +76,11 @@
>  LIVECONNECT_DIR = netscape sun/applet
>  PLUGIN_DIR=$(abs_top_builddir)/plugin/icedteanp
>  PLUGIN_SRCDIR=$(abs_top_srcdir)/plugin/icedteanp
> +
> +TESTGLIBS_NAME=testGlibs
> +TESTGLIBS_SRC=$(abs_top_srcdir)/$(TESTGLIBS_NAME).cc
> +TESTGLIBS=$(abs_top_builddir)/$(TESTGLIBS_NAME)
> +
>  LIVECONNECT_SRCS = $(PLUGIN_SRCDIR)/java
>  ICEDTEAPLUGIN_TARGET = $(PLUGIN_DIR)/IcedTeaPlugin.so stamps/liveconnect-dist.stamp
>  PLUGIN_PKGS = sun.applet netscape.security netscape.javascript
> @@ -199,6 +204,13 @@
>  # is listed before -l options.  See:
>  # http://developer.mozilla.org/en/docs/XPCOM_Glue
>  
> +
> +stamps/patch-for-glib:
> +	mkdir -p stamps
> +	-$(CXX) $(CXXFLAGS) $(GLIB_CFLAGS) $(GLIB_LIBS) \
> +	  $(TESTGLIBS_SRC) -o $(TESTGLIBS)
> +	touch $@
> +
>  PLUGIN_SRC=IcedTeaNPPlugin.cc IcedTeaScriptablePluginObject.cc \
>          IcedTeaJavaRequestProcessor.cc IcedTeaPluginRequestProcessor.cc \
>  		IcedTeaPluginUtils.cc
> @@ -207,10 +219,17 @@
>          IcedTeaJavaRequestProcessor.o IcedTeaPluginRequestProcessor.o \
>  		IcedTeaPluginUtils.o
>  
> -$(PLUGIN_DIR)/%.o: $(PLUGIN_SRCDIR)/%.cc
> +$(PLUGIN_DIR)/%.o: $(PLUGIN_SRCDIR)/%.cc stamps/patch-for-glib
> +	if [ ! -e $(TESTGLIBS) ] ; then \
> +	  RHEL5COMPATIBLE="-DRhel5Compatible" ;\
> +	else \
> +	  RHEL5COMPATIBLE="" ;\
> +	fi; \
> +	echo "rhel5comaptible="$$RHEL5COMPATIBLE ;\
>  	mkdir -p $(PLUGIN_DIR) && \
>  	cd $(PLUGIN_DIR) && \
>  	$(CXX) $(CXXFLAGS) \
> +	   $$RHEL5COMPATIBLE \
>  	  -DJDK_UPDATE_VERSION="\"$(JDK_UPDATE_VERSION)\"" \
>  	  -DPLUGIN_NAME="\"IcedTea-Web Plugin\"" \
>  	  -DPLUGIN_VERSION="\"$(PLUGIN_VERSION)\"" \
> @@ -223,9 +242,16 @@
>  	  $(MOZILLA_CFLAGS) \
>  	  -fPIC -o $@ -c $<
>  
> -$(PLUGIN_DIR)/IcedTeaPlugin.so: $(addprefix $(PLUGIN_DIR)/,$(PLUGIN_OBJECTS))
> +$(PLUGIN_DIR)/IcedTeaPlugin.so: $(addprefix $(PLUGIN_DIR)/,$(PLUGIN_OBJECTS)) stamps/patch-for-glib
> +	if [ ! -e $(TESTGLIBS) ] ; then \
> +	  RHEL5COMPATIBLE="-DRhel5Compatible";\
> +	else \
> +	  RHEL5COMPATIBLE=""; \
> +	fi; \
> +	echo "rhel5comaptible="$$RHEL5COMPATIBLE ;\
>  	cd $(PLUGIN_DIR) && \
>  	$(CXX) $(CXXFLAGS) \
> +	  $$RHEL5COMPATIBLE \
>  	  $(PLUGIN_OBJECTS) \
>  	  $(GLIB_LIBS) \
>  	  $(GTK_LIBS) \
> @@ -233,6 +259,9 @@
>  	  -shared -o $@
>  
>  clean-IcedTeaPlugin:
> +	if [ -e $(TESTGLIBS) ] ; then \
> +	  rm $(TESTGLIBS) ; \
> +	fi
>  	rm -f $(PLUGIN_DIR)/*.o
>  	rm -f $(PLUGIN_DIR)/IcedTeaPlugin.so
>  	if [ $(abs_top_srcdir) != $(abs_top_builddir) ]; then \
> @@ -241,9 +270,10 @@
>  	    rmdir $(abs_top_builddir)/plugin ; \
>  	  fi ; \
>  	fi
> +	rm -f stamps/patch-for-glib
>  endif
>  
> -stamps/plugin.stamp: $(ICEDTEAPLUGIN_TARGET)
> +stamps/plugin.stamp: stamps/patch-for-glib $(ICEDTEAPLUGIN_TARGET)
>  	mkdir -p stamps
>  	touch stamps/plugin.stamp
>  
> diff -r 68756a4f8cc0 plugin/icedteanp/IcedTeaNPPlugin.cc
> --- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Thu Aug 11 14:11:41 2011 -0400
> +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Mon Aug 22 14:57:32 2011 +0200
> @@ -47,6 +47,10 @@
>  #include <sys/types.h>
>  #include <unistd.h>
>  
> +#ifdef Rhel5Compatible
> +#include <glib.h>
> +#endif
> +
>  // Liveconnect extension
>  #include "IcedTeaScriptablePluginObject.h"
>  #include "IcedTeaNPPlugin.h"
> @@ -869,6 +873,16 @@
>    PLUGIN_DEBUG ("ITNP_URLNotify return\n");
>  }
>  
> +#ifdef Rhel5Compatible
> +// Returns key from first item stored in hashtable
> +gboolean
> +find_first_item_in_hash_table(gpointer key, gpointer value, gpointer user_data)
> +{
> +    user_data = key;
> +    return (gboolean)TRUE;
> +}
> +#endif
> +
>  NPError
>  get_cookie_info(const char* siteAddr, char** cookieString, uint32_t* len)
>  {
> @@ -913,19 +927,33 @@
>    // valid. So we just pick the first valid one and use it. Proxy/Cookie
>    // information is not instance specific anyway, it is URL specific.
>  
> +#ifdef Rhel5Compatible
>    if (browser_functions.getvalueforurl)
>    {
> -      GHashTableIter iter;
>        gpointer id, instance;
>  
> -      g_hash_table_iter_init (&iter, instance_to_id_map);
> -      g_hash_table_iter_next (&iter, &instance, &id);
> +      g_hash_table_find(instance_to_id_map, (GHRFunc)find_first_item_in_hash_table, &instance);
>  
>        return browser_functions.getvalueforurl((NPP) instance, NPNURLVCookie, siteAddr, cookieString, len);
>    } else
>    {
>        return NPERR_GENERIC_ERROR;
>    }
> +#else
> +  if (browser_functions.getvalueforurl)
> +  {
> +      GHashTableIter iter;
> +      gpointer id, instance;
> +
> +      g_hash_table_iter_init (&iter, instance_to_id_map);
> +      g_hash_table_iter_next (&iter, &instance, &id);
> +
> +      return browser_functions.getvalueforurl((NPP) instance, NPNURLVCookie, siteAddr, cookieString, len);
> +  } else
> +  {
> +      return NPERR_GENERIC_ERROR;
> +  }
> +#endif
>  
>  #endif
>  
> @@ -1363,21 +1391,38 @@
>  
>  #else
>  
> +#ifdef Rhel5Compatible
>    if (browser_functions.getvalueforurl)
>    {
>  
>        // As in get_cookie_info, we use the first active instance
> -      GHashTableIter iter;
>        gpointer id, instance;
>  
> -      g_hash_table_iter_init (&iter, instance_to_id_map);
> -      g_hash_table_iter_next (&iter, &instance, &id);
> +      g_hash_table_find(instance_to_id_map, (GHRFunc)find_first_item_in_hash_table, &instance);
>  
>        browser_functions.getvalueforurl((NPP) instance, NPNURLVProxy, siteAddr, proxy, len);
>    } else
>    {
>        return NPERR_GENERIC_ERROR;
>    }
> +#else
> +  if (browser_functions.getvalueforurl)
> +  {
> +
> +      // As in get_cookie_info, we use the first active instance
> +      GHashTableIter iter;
> +      gpointer id, instance;
> +
> +      g_hash_table_iter_init (&iter, instance_to_id_map);
> +      g_hash_table_iter_next (&iter, &instance, &id);
> +
> +      browser_functions.getvalueforurl((NPP) instance, NPNURLVProxy, siteAddr, proxy, len);
> +  } else
> +  {
> +      return NPERR_GENERIC_ERROR;
> +  }
> +#endif
> +
>  #endif
>  
>    return NPERR_NO_ERROR;
> @@ -1403,6 +1448,17 @@
>    return FALSE;
>  }
>  
> +#ifdef Rhel5Compatible
> +int
> +strcmp0(char *str1, char *str2)
> +{
> +   if (str1 != NULL)
> +     return str2 != NULL ? strcmp(str1, str2) : 1;
> +   else // str1 == NULL
> +     return str2 != NULL ? 1 : 0;
> +}
> +#endif
> +
>  // remove all components from LD_LIBRARY_PATH, which start with
>  // MOZILLA_FIVE_HOME; firefox has its own NSS based security provider,
>  // which conflicts with the one configured in nss.cfg.
> @@ -1424,7 +1480,11 @@
>    components = g_strsplit (path_old, ":", -1);
>    for (i1 = 0, i2 = 0; components[i1] != NULL; i1++)
>      {
> +#ifdef Rhel5Compatible
> +      if (strcmp0 (components[i1], moz_home) == 0
> +#else
>        if (g_strcmp0 (components[i1], moz_home) == 0
> +#endif
>  	  || g_str_has_prefix (components[i1], moz_home))
>  	components[i2] = components[i1];
>        else
> diff -r 68756a4f8cc0 testGlibs.cc
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/testGlibs.cc	Mon Aug 22 14:57:32 2011 +0200
> @@ -0,0 +1,23 @@
> +#include <glib.h>
> +#include <iostream>
> +
> +
> +int testLibs()
> +{
> +      GHashTable* instance_to_id_map = g_hash_table_new(NULL, NULL);
> +
> +      GHashTableIter iter;
> +      gpointer id, instance;
> +
> +      g_hash_table_iter_init (&iter, instance_to_id_map);
> +      g_hash_table_iter_next (&iter, &instance, &id);
> +      return g_strcmp0 ("hell", "hello");
> +     
> +}
> +
> +int main(void){
> +int a=testLibs();
> +   std::cout << a;/* << "\n";*/
> +return a;
> +}
> +




More information about the distro-pkg-dev mailing list