r19204 - gnucash/trunk - Bug #618646 - Should be able to run gnucash-bin.exe directly, rather than gnucash.cmd

Geert Janssens gjanssens at code.gnucash.org
Tue May 25 16:20:52 EDT 2010


Author: gjanssens
Date: 2010-05-25 16:20:52 -0400 (Tue, 25 May 2010)
New Revision: 19204
Trac: http://svn.gnucash.org/trac/changeset/19204

Modified:
   gnucash/trunk/packaging/win32/dist-impl.sh
   gnucash/trunk/packaging/win32/gnucash.iss.in
   gnucash/trunk/packaging/win32/install-impl.sh
   gnucash/trunk/src/bin/environment-win32.in
   gnucash/trunk/src/bin/gnucash-bin.c
   gnucash/trunk/src/core-utils/gnc-path.c
   gnucash/trunk/src/gnc-module/gnc-module.c
   gnucash/trunk/src/gnc-module/gnc-module.h
Log:
Bug #618646 - Should be able to run gnucash-bin.exe directly, rather than gnucash.cmd
Patch by Tao Wang.

Modified: gnucash/trunk/packaging/win32/dist-impl.sh
===================================================================
--- gnucash/trunk/packaging/win32/dist-impl.sh	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/packaging/win32/dist-impl.sh	2010-05-25 20:20:52 UTC (rev 19204)
@@ -223,8 +223,6 @@
     cp -a $_INSTALL_UDIR/etc/gconf/schemas/* $DIST_UDIR/etc/gconf/schemas
     mkdir -p $DIST_UDIR/lib
     cp -a $_INSTALL_UDIR/lib/lib*.la $DIST_UDIR/lib
-    mkdir -p $DIST_UDIR/lib/gnucash
-    cp -a $_INSTALL_UDIR/lib/gnucash/lib*.dll $DIST_UDIR/lib/gnucash
     cp -a $_INSTALL_UDIR/libexec $DIST_UDIR
     mkdir -p $DIST_UDIR/share
     cp -a $_INSTALL_UDIR/share/{gnucash,locale} $DIST_UDIR/share

Modified: gnucash/trunk/packaging/win32/gnucash.iss.in
===================================================================
--- gnucash/trunk/packaging/win32/gnucash.iss.in	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/packaging/win32/gnucash.iss.in	2010-05-25 20:20:52 UTC (rev 19204)
@@ -41,17 +41,17 @@
 Name: menuicon; Description: "{cm:CreateMenuLink}"; GroupDescription: "{cm:AdditionalIcons}"
 
 [Icons]
-Name: "{group}\GnuCash"; Filename: "{app}\bin\gnucash.cmd"; WorkingDir: "{app}\bin"; Comment: "{cm:IconComment_GnuCash}"; IconFilename: "{app}\share\gnucash\pixmaps\gnucash-icon.ico"; Tasks: menuicon; Flags: runminimized
+Name: "{group}\GnuCash"; Filename: "{app}\bin\gnucash-bin.exe"; WorkingDir: "{app}\bin"; Comment: "{cm:IconComment_GnuCash}"; IconFilename: "{app}\share\gnucash\pixmaps\gnucash-icon.ico"; Tasks: menuicon; Flags: runminimized
 Name: "{group}\{cm:IconName_README}"; Filename: "{app}\doc\gnucash\{cm:IconFilename_README}"; Comment: "{cm:IconComment_README}"; Tasks: menuicon
 Name: "{group}\{cm:IconName_FAQ}"; Filename: "http://wiki.gnucash.org/wiki/FAQ"; Tasks: menuicon
 Name: "{group}\{cm:IconName_Bugzilla}"; Filename: "http://bugzilla.gnome.org/enter_bug.cgi?product=GnuCash"; Tasks: menuicon
 Name: "{group}\{cm:IconName_InstallFQ}"; Filename: "{app}\bin\install-fq-mods.cmd"; WorkingDir: "{app}\bin"; Comment: "{cm:IconComment_InstallFQ}"; Tasks: menuicon
 Name: "{group}\{cm:IconName_Uninstall}"; Filename: "{uninstallexe}"; Comment: "{cm:IconComment_Uninstall}"; Tasks: menuicon
 
-Name: "{commondesktop}\GnuCash"; Filename: "{app}\bin\gnucash.cmd"; WorkingDir: "{app}\bin"; Comment: "{cm:IconComment_GnuCash}"; IconFilename: "{app}\share\gnucash\pixmaps\gnucash-icon.ico"; Tasks: desktopicon; Flags: runminimized
+Name: "{commondesktop}\GnuCash"; Filename: "{app}\bin\gnucash-bin.exe"; WorkingDir: "{app}\bin"; Comment: "{cm:IconComment_GnuCash}"; IconFilename: "{app}\share\gnucash\pixmaps\gnucash-icon.ico"; Tasks: desktopicon; Flags: runminimized
 
 [Run]
-Filename: "{app}\bin\gnucash.cmd"; Description: "{cm:RunPrg}"; WorkingDir: "{app}\bin"; OnlyBelowVersion: 0,6; Flags: postinstall skipifsilent runhidden
+Filename: "{app}\bin\gnucash-bin.exe"; Description: "{cm:RunPrg}"; WorkingDir: "{app}\bin"; OnlyBelowVersion: 0,6; Flags: postinstall skipifsilent runhidden
 Filename: "{app}\bin\guile.cmd"; Parameters: "-c ""(use-modules (ice-9 slib)) (require 'printf)"""; Flags: runhidden
 ;; The Windows firewall exceptions, see http://www.vincenzo.net/isxkb/index.php?title=Adding_a_rule_to_the_Windows_firewall
 Filename: "{sys}\netsh.exe"; Parameters: "firewall add allowedprogram ""{app}\bin\gnucash-bin.exe"" ""GnuCash Free Finance Manager"" ENABLE ALL"; StatusMsg: "{cm:StatusMsgFirewall}"; Flags: runhidden; MinVersion: 0,5.01.2600sp2;
@@ -72,7 +72,7 @@
 ; Note: The above AfterInstall function will create the 
 ; gnucash.cmd file on-the-fly by the Pascal script below.
 
-Source: "@prefix@\..\dist\etc\*"; DestDir: "{app}\etc"; Flags: recursesubdirs; Components: main
+Source: "@prefix@\..\dist\etc\*"; DestDir: "{app}\etc"; Flags: recursesubdirs; Components: main; AfterInstall: MyAfterInstallEtc()
 Source: "@prefix@\..\dist\lib\*"; DestDir: "{app}\lib"; Flags: recursesubdirs; Components: main
 Source: "@prefix@\..\dist\libexec\*"; DestDir: "{app}\libexec"; Flags: recursesubdirs; Components: main
 Source: "@prefix@\..\dist\share\*"; DestDir: "{app}\share"; Flags: recursesubdirs; Components: main
@@ -114,7 +114,7 @@
 Root: HKCR; Subkey: ".gnucash"; ValueType: string; ValueName: "Content Type"; ValueData: "application/x-gnucash"; Flags: uninsdeletevalue
 Root: HKCR; Subkey: "GnuCash.Financial.Data"; ValueType: string; ValueName: ""; ValueData: "GnuCash Financial Data"; Flags: uninsdeletevalue
 Root: HKCR; Subkey: "GnuCash.Financial.Data\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\share\gnucash\pixmaps\gnucash-icon.ico,0" 
-Root: HKCR; Subkey: "GnuCash.Financial.Data\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\bin\gnucash.cmd"" ""%1""" 
+Root: HKCR; Subkey: "GnuCash.Financial.Data\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\bin\gnucash-bin.exe"" ""%1""" 
 
 Root: HKLM; Subkey: "Software\GnuCash"; ValueType: none; Flags: uninsdeletekeyifempty
 Root: HKLM; Subkey: "Software\GnuCash\Paths"; ValueType: none; Flags: uninsdeletekeyifempty
@@ -154,9 +154,11 @@
 [UninstallDelete]
 Type: files; Name: "{app}\bin\gnucash.cmd"
 Type: files; Name: "{app}\bin\guile.cmd"
+Type: files; Name: "{app}\etc\gnucash\environment"
 Type: files; Name: "{app}\share\guile\1.6\slibcat"
 Type: filesandordirs; Name: "{app}\share\guile"
 Type: filesandordirs; Name: "{app}\etc\gconf"
+Type: dirifempty; Name: "{app}\etc\gnucash"
 Type: dirifempty; Name: "{app}\etc"
 
 ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -224,6 +226,62 @@
 end;
 
 
+function BackslashPath(const S: String): String;
+begin
+	{ Convert c:\soft to c:/soft }
+	Result := S;
+	StringChange(Result, '\', '/');
+end;
+
+procedure MyAfterInstallEtc();
+var
+  FileName, FileString, appdir, libdir, pkglibdir, pkgdatadir: String;
+  Res: Boolean;
+begin
+
+  { Get the installation-specific paths }
+  appdir := BackslashPath( ExpandConstant('{app}') );
+  libdir := BackslashPath( appdir + '/lib' );
+  pkglibdir := BackslashPath( appdir + '/bin' );
+  pkgdatadir := BackslashPath( appdir + '/share/gnucash' );
+
+  { Create the etc/gnucash/environment file; #10 is the linefeed character and #13 CR }
+
+  { If you make any changes here, you should probably also change the equivalent sections }
+  { in packaging/win32/install.sh, src/bin/environment*.in and src/bin/gnucash-setup-env-osx.in }
+  FileName := appdir + '\etc\gnucash\environment' ;
+  
+
+  FileString := '# environment'#13#10 ;
+  FileString := FileString + '#'#13#10 ;
+  FileString := FileString + '# This configuration file can be used to change/add'#13#10 ;
+  FileString := FileString + '# environment variables during GnuCash startup.'#13#10 ;
+  FileString := FileString + '#'#13#10 ;
+
+  FileString := FileString + '[Variables]'#13#10 ;
+  FileString := FileString + 'PATH=' + appdir + '/bin;' + libdir + ';' + pkglibdir + ';{PATH}'#13#10 ;
+  FileString := FileString + 'SCHEME_LIBRARY_PATH='#13#10 ;
+  FileString := FileString + 'GNC_MODULE_PATH=' + pkglibdir + ''#13#10 ;
+  FileString := FileString + 'GUILE_LOAD_PATH=' + pkgdatadir + '/guile-modules;' + pkgdatadir + '/scm;' + appdir + '/share/guile/1.6;{GUILE_LOAD_PATH}'#13#10 ;
+  FileString := FileString + 'EXTRA_LIBS={GNC_MODULE_PATH}'#13#10 ;
+  FileString := FileString + 'LD_LIBRARY_PATH={EXTRA_LIBS};{LD_LIBRARY_PATH}'#13#10 ;
+  FileString := FileString + 'DYLD_LIBRARY_PATH={EXTRA_LIBS};{DYLD_LIBRARY_PATH}'#13#10 ;
+  FileString := FileString + 'LTDL_LIBRARY_PATH=' + libdir + ''#13#10 ;
+  FileString := FileString + 'QOF_LIB_DIR=' + pkglibdir + ''#13#10 ;
+  FileString := FileString + 'GNC_DBD_DIR=' + libdir + '/dbd'#13#10 ;
+  FileString := FileString + 'GNC_STANDARD_REPORTS_DIR=' + pkgdatadir + '/guile-modules/gnucash/report/standard-reports'#13#10 ;
+  FileString := FileString + 'GUILE_WARN_DEPRECATED=no'#13#10 ;
+
+  { Save the final file }
+  Res := ForceDirectories(appdir + '\etc\gnucash');
+  if Res = False then
+    MsgBox('Error on creating '+appdir+'\etc\gnucash for completing the installation', mbInformation, MB_OK);
+	
+  Res := SaveStringToFile(FileName, FileString, False);
+  if Res = False then
+    MsgBox('Error on saving '+FileName+' for completing the installation', mbInformation, MB_OK);
+end;  
+
 [Languages]
 Name: "en"; MessagesFile: "compiler:Default.isl"
 Name: "de"; MessagesFile: "compiler:Languages\German.isl"; InfoAfterFile: "@prefix@\share\@PACKAGE@\doc\README-de.win32-bin.txt"
@@ -445,27 +503,27 @@
 ;; ;;;;;;;;;;;;;;;;;
 ;; Simplified Chinese translation
 
-zh_CN.FullInstall=ÍêÈ«°²×°
-zh_CN.CustomInstall=×Ô¶¨Òå°²×°
-zh_CN.CreateDesktopIcon=´´½¨×ÀÃæͼ±ê
-zh_CN.CreateMenuLink=´´½¨¿ªÊ¼²Ëµ¥Á´½Ó
-zh_CN.RunPrg=ÏÖÔÚ¿ªÊ¼ÔËÐÐ GnuCash
-zh_CN.AdditionalIcons=´´½¨ÕâЩͼ±ê
-zh_CN.StatusMsgFirewall=ÕýÔÚ°²×° Windows ·À»ðǽ¹æÔò...
+zh_CN.FullInstall=��ȫ��װ
+zh_CN.CustomInstall=�Զ��尲װ
+zh_CN.CreateDesktopIcon=��������ͼ��
+zh_CN.CreateMenuLink=������ʼ�˵�����
+zh_CN.RunPrg=���ڿ�ʼ���� GnuCash
+zh_CN.AdditionalIcons=������Щͼ��
+zh_CN.StatusMsgFirewall=���ڰ�װ Windows ����ǽ����...
 
-zh_CN.MainFiles=GnuCash ³ÌÐò
-zh_CN.TranslFiles=·­ÒëÎļþ
-zh_CN.TemplFiles=»á¼Æ¿ÆÄ¿Ä£°åÎļþ
+zh_CN.MainFiles=GnuCash ����
+zh_CN.TranslFiles=�����ļ�
+zh_CN.TemplFiles=��ƿ�Ŀģ���ļ�
 
-zh_CN.IconComment_GnuCash=GnuCash Ãâ·Ñ²ÆÎñ¹ÜÀí
-zh_CN.IconName_README=ÏÔʾ×ÔÊöÎļþ
-zh_CN.IconComment_README=ÏÔʾ×ÔÊöÎļþ
+zh_CN.IconComment_GnuCash=GnuCash ��Ѳ������
+zh_CN.IconName_README=��ʾ�����ļ�
+zh_CN.IconComment_README=��ʾ�����ļ�
 zh_CN.IconFilename_README=README-zh_CN.win32-bin.txt
-zh_CN.IconName_FAQ=³£¼ûÎÊÌâ (ÔÚÏß)
-zh_CN.IconName_Bugzilla=±¨¸æÈí¼þ Bug (ÔÚÏß)
-zh_CN.IconName_InstallFQ=°²×°ÔÚÏß¼Û¸ñ¼ìË÷¹¦ÄÜ
-zh_CN.IconComment_InstallFQ=°²×°ÔÚÏß¼Û¸ñ¼ìË÷Ëù±ØÐèµÄ Perl Finance-QuoteÄ£¿é¡£ÐèÒª ActivePerl 5.8 »ò 5.10
-zh_CN.IconName_Uninstall=жÔØ GnuCash
-zh_CN.IconComment_Uninstall=жÔزÆÎñ¹ÜÀíÈí¼þ GnuCash
+zh_CN.IconName_FAQ=�������� (����)
+zh_CN.IconName_Bugzilla=������� Bug (����)
+zh_CN.IconName_InstallFQ=��װ���߼۸��������
+zh_CN.IconComment_InstallFQ=��װ���߼۸���������� Perl Finance-Quoteģ�顣��Ҫ ActivePerl 5.8 �� 5.10
+zh_CN.IconName_Uninstall=� GnuCash
+zh_CN.IconComment_Uninstall=ж�ز��������� GnuCash
 
 ;; ;;;;;;;;;;;;;;;;;;;;

Modified: gnucash/trunk/packaging/win32/install-impl.sh
===================================================================
--- gnucash/trunk/packaging/win32/install-impl.sh	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/packaging/win32/install-impl.sh	2010-05-25 20:20:52 UTC (rev 19204)
@@ -1377,7 +1377,7 @@
         # correct the 'dlname' in the libtool archives. We do not use these
         # files to dlopen the modules, so actually this is unneeded.
         # Also, in all installed .la files, remove the dependency_libs line
-        mv bin/*.dll gnucash 2>/dev/null || true
+        mv bin/*.dll gnucash/*.dll $_INSTALL_UDIR/bin 2>/dev/null || true
         for A in gnucash/*.la; do
             sed '/dependency_libs/d;s#../bin/##' $A > tmp ; mv tmp $A
         done

Modified: gnucash/trunk/src/bin/environment-win32.in
===================================================================
--- gnucash/trunk/src/bin/environment-win32.in	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/src/bin/environment-win32.in	2010-05-25 20:20:52 UTC (rev 19204)
@@ -16,7 +16,7 @@
 PATH=@-BIN_DIR-@;{PATH}
 
 SCHEME_LIBRARY_PATH=
-GNC_MODULE_PATH=@-GNC_PKGLIB_INSTALLDIR-@;{GNC_MODULE_PATH}
+GNC_MODULE_PATH=@-BIN_DIR-@;{GNC_MODULE_PATH}
 
 EXTRA_PATH={EXTRA_PATH};@-GNC_GUILE_MODULE_DIR-@;@-GNC_SCM_INSTALL_DIR-@
 GUILE_LOAD_PATH={EXTRA_PATH};{GUILE_LOAD_PATH}

Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/src/bin/gnucash-bin.c	2010-05-25 20:20:52 UTC (rev 19204)
@@ -177,6 +177,12 @@
     gint i;
     gboolean got_keyfile;
 
+#ifdef G_OS_WIN32
+	config_path = gnc_path_get_pkgsysconfdir();
+	share_path = gnc_path_get_pkgdatadir();
+	help_path = g_path_get_dirname(share_path);
+#endif /* G_OS_WIN32 */
+
     if ((path = g_getenv("GNC_CONFIG_PATH")))
         config_path = g_strdup(path);
     if ((path = g_getenv("GNC_SHARE_PATH")))
@@ -726,7 +732,7 @@
      */
     environment_override();
 
-    #ifdef HAVE_GETTEXT
+#ifdef HAVE_GETTEXT
     {
         gchar *localedir = gnc_path_get_localedir();
         /* setlocale(LC_ALL, ""); is already called by gtk_set_locale()

Modified: gnucash/trunk/src/core-utils/gnc-path.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-path.c	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/src/core-utils/gnc-path.c	2010-05-25 20:20:52 UTC (rev 19204)
@@ -75,7 +75,12 @@
 gchar *gnc_path_get_pkglibdir()
 {
     gchar *libdir = gnc_path_get_libdir ();
+#ifdef G_OS_WIN32
+	/* Workaround for Bug 618646, {pkglibdir} will be bin/ on Windows */
+	gchar *result = gnc_gbr_find_bin_dir(libdir);
+#else
     gchar *result = g_build_filename (libdir, "gnucash", (char*)NULL);
+#endif
     g_free (libdir);
     //printf("Returning pkglibdir %s\n", result);
     return result;

Modified: gnucash/trunk/src/gnc-module/gnc-module.c
===================================================================
--- gnucash/trunk/src/gnc-module/gnc-module.c	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/src/gnc-module/gnc-module.c	2010-05-25 20:20:52 UTC (rev 19204)
@@ -209,9 +209,14 @@
 
             /* Gotcha: On MacOS, G_MODULE_SUFFIX is defined as "so", but if we do
              * not build clean libtool modules with "-module", we get dynamic
-             * libraries ending on .dylib */
-            if (g_str_has_suffix(dent, "." G_MODULE_SUFFIX) ||
-                    g_str_has_suffix(dent, ".dylib"))
+             * libraries ending on .dylib
+             * On Windows, all modules will move to bin/, so they will be mixed with
+             * other libraries, such as gtk+. Adding a prefix "libgncmod" filter will prevent 
+             * module loader load other libraries. And the filter should works on other platform.
+             */
+            if ((g_str_has_suffix(dent, "." G_MODULE_SUFFIX)
+					|| g_str_has_suffix(dent, ".dylib"))
+					&& g_str_has_prefix(dent, GNC_MODULE_PREFIX))
             {
                 /* get the full path name, then dlopen the library and see
                  * if it has the appropriate symbols to be a gnc_module */

Modified: gnucash/trunk/src/gnc-module/gnc-module.h
===================================================================
--- gnucash/trunk/src/gnc-module/gnc-module.h	2010-05-25 19:26:50 UTC (rev 19203)
+++ gnucash/trunk/src/gnc-module/gnc-module.h	2010-05-25 20:20:52 UTC (rev 19204)
@@ -11,6 +11,7 @@
 typedef void * GNCModule;
 
 #define DEFAULT_MODULE_PATH "/usr/local/gnucash/lib/modules"
+#define GNC_MODULE_PREFIX "libgncmod"
 
 /* the basics: initialize the module system, refresh its module
  * database, and get a list of all known modules */



More information about the gnucash-changes mailing list