Make GnuCash more runtime relocatable by using dynamic paths in the environment file.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19518 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2010-08-31 14:31:35 +00:00
parent 85f067604f
commit 3ba2c90396
7 changed files with 123 additions and 97 deletions

View File

@ -227,7 +227,6 @@ AC_SUBST(SED)
# Set some defaults, they may be overridden below
REGEX_LIBS=""
GNUCASH_ENVIRONMENT="environment"
AC_MSG_CHECKING(operating system)
case $host_os in
@ -255,7 +254,6 @@ update to latest darwin])
AC_MSG_RESULT(${_ige_mac})
AC_SUBST(IGE_MAC_LIBS)
AC_SUBST(IGE_MAC_CFLAGS)
GNUCASH_ENVIRONMENT="environment-osx"
else
AC_MSG_RESULT(no)
fi
@ -263,7 +261,6 @@ update to latest darwin])
mingw*|cygwin*)
platform=win32
AC_MSG_RESULT($platform)
GNUCASH_ENVIRONMENT="environment-win32"
LT_PROG_RC
AC_MSG_CHECKING(for native win32)
@ -306,7 +303,6 @@ update to latest darwin])
;;
esac
AC_SUBST(REGEX_LIBS)
AC_SUBST(GNUCASH_ENVIRONMENT)
AM_CONDITIONAL(PLATFORM_LINUX, test "x$platform" = "xlinux/other")
AM_CONDITIONAL(PLATFORM_OSX, test "x$platform" = "xdarwin")

View File

@ -238,6 +238,8 @@ function dist_gnucash() {
cp -a $_INSTALL_UDIR/bin/* $DIST_UDIR/bin
mkdir -p $DIST_UDIR/etc/gconf/schemas
cp -a $_INSTALL_UDIR/etc/gconf/schemas/* $DIST_UDIR/etc/gconf/schemas
mkdir -p $DIST_UDIR/etc/gnucash
cp -a $_INSTALL_UDIR/etc/gnucash/* $DIST_UDIR/etc/gnucash
cp -a $_INSTALL_UDIR/lib/lib*.la $DIST_UDIR/bin
mkdir -p $DIST_UDIR/share
cp -a $_INSTALL_UDIR/share/{gnucash,locale} $DIST_UDIR/share

View File

@ -1,4 +1,4 @@
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Input configuration for the Inno Setup Compiler
; Copyright (c) 2004-2005 Christian Stimming <stimming@tuhh.de>
;
@ -60,7 +60,7 @@ Filename: "{sys}\netsh.exe"; Parameters: "firewall add allowedprogram ""{app}\bi
[UninstallRun]
Filename: "{app}\bin\gconftool-2.exe"; Parameters: "--shutdown"; Flags: runhidden
Filename: "{sys}\netsh.exe"; Parameters: "firewall delete allowedprogram program=""{app}\bin\gnucash.exe"""; Flags: runhidden; MinVersion: 0,5.01.2600sp2
Filename: "{sys}\netsh.exe"; Parameters: "firewall delete allowedprogram program=""{app}\bin\@PACKAGE@.exe"""; Flags: runhidden; MinVersion: 0,5.01.2600sp2
Filename: "{sys}\netsh.exe"; Parameters: "firewall delete allowedprogram program=""{app}\bin\gconfd-2.exe"""; Flags: runhidden; MinVersion: 0,5.01.2600sp2
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -70,8 +70,9 @@ Filename: "{sys}\netsh.exe"; Parameters: "firewall delete allowedprogram program
[Files]
; The main executables and DLLs
Source: "@prefix@\..\dist\bin\*"; DestDir: "{app}\bin"; Flags: recursesubdirs ignoreversion; Components: main
Source: "@prefix@\..\dist\etc\*"; DestDir: "{app}\etc"; Flags: recursesubdirs; Components: main; AfterInstall: MyAfterInstallEtc()
; Note: The above AfterInstall function will create the
Source: "@prefix@\..\dist\etc\*"; DestDir: "{app}\etc"; Flags: recursesubdirs; Components: main
Source: "@prefix@\..\dist\etc\@PACKAGE@\environment"; DestDir: "{app}\etc\@PACKAGE@"; Components: main; AfterInstall: MyAfterInstallEnvironment()
; Note: The above AfterInstall function will adapt the
; environment config file on-the-fly by the Pascal script below.
Source: "@prefix@\..\dist\lib\*"; DestDir: "{app}\lib"; Flags: recursesubdirs; Components: main
Source: "@prefix@\..\dist\libexec\*"; DestDir: "{app}\libexec"; Flags: recursesubdirs; Components: main
@ -203,58 +204,54 @@ begin
end;
function BackslashPath(const S: String): String;
begin
{ Convert c:\soft to c:/soft }
Result := S;
StringChange(Result, '\', '/');
{ Convert c:\soft to c:/soft }
Result := S;
StringChange(Result, '\', '/');
end;
procedure MyAfterInstallEtc();
procedure MyAfterInstallEnvironment();
var
FileName, FileString, appdir, libdir, pkglibdir, pkgdatadir: String;
EnvFile, EtcDir: String;
iLineCounter, iSize : Integer;
EnvStringList: TArrayOfString;
Res: Boolean;
begin
{ Make some Windows-only changes to the etc/@PACKAGE@/environment file }
{ If you make any changes here, you should probably also change the equivalent sections }
{ in packaging/win32/install.sh }
{ A new line is stared with #13#10 - #10 is the linefeed character and #13 CR }
{ Get the installation-specific paths }
appdir := BackslashPath( ExpandConstant('{app}') );
libdir := BackslashPath( appdir + '/lib' );
pkglibdir := BackslashPath( appdir + '/bin' );
pkgdatadir := BackslashPath( appdir + '/share/gnucash' );
EnvFile := ExpandConstant(CurrentFileName);
EtcDir := ExtractFileDir(EnvFile);
{ Create the etc/gnucash/environment file; #10 is the linefeed character and #13 CR }
{ Load the current contents of the environment file }
Res := LoadStringsFromFile(EnvFile, EnvStringList);
if Res = False then
MsgBox('Error on reading ' + EnvFile + ' for completing the installation', mbInformation, MB_OK);
{ 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=' + pkglibdir + ';{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 + 'GNC_DBD_DIR=' + libdir + '/dbd'#13#10 ;
FileString := FileString + 'GUILE_WARN_DEPRECATED=no'#13#10 ;
iSize := GetArrayLength(EnvStringList);
for iLineCounter := 0 to iSize-1 do
begin
{ Adapt GUILE_LOAD_PATH parameter }
if (Pos('GUILE_LOAD_PATH', EnvStringList[iLineCounter]) = 1) then
StringChangeEx(EnvStringList[iLineCounter], '{GUILE_LOAD_PATH}', '{GNC_HOME}/share/guile/1.6;{GUILE_LOAD_PATH}', True);
{ Adapt GNC_DBD_DIR parameter }
if (Pos('GNC_DBD_DIR', EnvStringList[iLineCounter]) > 0) then
EnvStringList[iLineCounter] := 'GNC_DBD_DIR={GNC_HOME}/lib/dbd';
end;
{ Save the final file }
Res := ForceDirectories(appdir + '\etc\gnucash');
Res := ForceDirectories(EtcDir);
if Res = False then
MsgBox('Error on creating '+appdir+'\etc\gnucash for completing the installation', mbInformation, MB_OK);
Res := SaveStringToFile(FileName, FileString, False);
MsgBox('Error on creating ' + EtcDir + ' for completing the installation', mbInformation, MB_OK);
Res := SaveStringsToFile(EnvFile, EnvStringList, False);
if Res = False then
MsgBox('Error on saving '+FileName+' for completing the installation', mbInformation, MB_OK);
end;
MsgBox('Error on saving ' + EnvFile + ' for completing the installation', mbInformation, MB_OK);
end;
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"

View File

@ -111,21 +111,14 @@ gnucash-setup-env: gnucash-setup-env-osx.in ${top_builddir}/config.status Makefi
mv $@.tmp $@
chmod u+x $@
environment: ${GNUCASH_ENVIRONMENT}.in ${top_builddir}/config.status Makefile
environment: environment.in ${top_builddir}/config.status Makefile
rm -f $@.tmp
sed < $< > $@.tmp \
-e 's#@-BIN_DIR-@#${bindir}#g' \
-e 's#@-GNC_GUILE_MODULE_DIR-@#${GNC_SHAREDIR}/guile-modules#g' \
-e 's#@-GNC_SCM_INSTALL_DIR-@#${GNC_SCM_INSTALL_DIR}#g' \
-e 's#@-GNC_LIB_INSTALLDIR-@#${libdir}#' \
-e 's#@-GNC_PKGLIB_INSTALLDIR-@#${pkglibdir}#g' \
-e "s#@-TOP_SRC_DIR-@#`pwd`/${top_srcdir}#g" \
-e 's#@-PREFIX-@#${prefix}#g'
-e '/@-NOTE.*-@/ D'
if CUSTOM_GNC_DBD_DIR
echo 'GNC_DBD_DIR=@GNC_DBD_DIR@' >> $@.tmp
endif
mv $@.tmp $@
chmod u+x $@
CLEANFILES = $(BUILT_SOURCES) ${config_DATA} ${PLATFORM_FILES}

View File

@ -1,28 +0,0 @@
# environment
#
# This configuration file can be used to change/add
# environment variables during GnuCash startup.
#
# If you make any changes here, you should probably
# also change the equivalent sections in:
# - src/bin/environment.in
# - src/bin/environment-osx.in
# - packaging/win32/gnucash.iss.in
# - packaging/win32/install.sh
[Variables]
GUILE_WARN_DEPRECATED=no
PATH=@-BIN_DIR-@;{PATH}
SCHEME_LIBRARY_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}
EXTRA_LIBS={GNC_MODULE_PATH};@-GNC_LIB_INSTALLDIR-@;@-GNC_PKGLIB_INSTALLDIR-@
LD_LIBRARY_PATH={EXTRA_LIBS};{LD_LIBRARY_PATH}
DYLD_LIBRARY_PATH={EXTRA_LIBS};{DYLD_LIBRARY_PATH}
GNC_STANDARD_REPORTS_DIR=@-GNC_STANDARD_REPORTS_DIR-@

View File

@ -1,24 +1,63 @@
@-NOTE If you make any changes here, you should probably -@
@-NOTE also change the equivalent sections in: -@
@-NOTE - src/bin/gnucash-launcher.in -@
@-NOTE - packaging/win32/gnucash.iss.in -@
@-NOTE - packaging/win32/install.sh -@
# environment
#
# This configuration file can be used to change/add
# environment variables during GnuCash startup.
# This configuration file can be used to change/add environment variables
# during GnuCash startup.
#
# If you make any changes here, you should probably
# also change the equivalent sections in:
# - src/bin/environment-osx.in
# - src/bin/environment-win32.in
# - packaging/win32/gnucash.iss.in
# - packaging/win32/install.sh
# It uses a very simple syntax for this:
# <variable_name>=<variable_value>
#
# You can refer to existing environment variables in the new value by
# enclosing it in {}, for example
# NEW_VARIABLE={OLD_VARIABLE}_something
#
# When adding variables that hold a collection of directories (path variables),
# always use ';' to separate the directories. GnuCash will replace these with
# the proper separator for your operating system. For example:
# PATH=/some/extra/path;{PATH}
#
# Finally, GnuCash exports a number of environment variables itself you can use
# here as you see fit. They are read only. GnuCash will ignore any changes you
# make to them. These variables are:
# GNC_HOME the directory where GnuCash was installed. This is the base
# directory of all the other directories below
# GNC_BIN the directory where the GnuCash executable resides. This is
# equivalent to {GNUCASH_HOME}/bin
# GNC_LIB the directory where the GnuCash private libraries reside. This is
# equivalent to {GNUCASH_HOME}/lib/gnucash
# GNC_DATA the directory where GnuCash specific additional data is stored,
# equivalent to {GNUCASH_HOME}/share/gnucash
# GNC_CONF the directory where GnuCash configuration files are stored,
# equivalent to {GNUCASH_HOME}/etc/gnucash
# SYS_LIB the directory where the GnuCash public libraries reside. This is
# equivalent to {GNUCASH_HOME}/lib
[Variables]
# PATH is used to find the finance::quote utility functions
PATH={GNC_BIN};{PATH}
# Tell GnuCash where to look for GnuCash modules
GNC_MODULE_PATH={GNC_LIB};{GNC_MODULE_PATH}
# Prevent embedded guile from issuing deprecation warnings
GUILE_WARN_DEPRECATED=no
PATH=@-BIN_DIR-@;{PATH}
GNC_MODULE_PATH=@-GNC_PKGLIB_INSTALLDIR-@;{GNC_MODULE_PATH}
# Tell Guile where to find GnuCash specific guile modules
# GUILE_LIBS can be used to override the path to Guile's own modules
# GUILE_LIBS=
GUILE_LOAD_PATH={GNC_DATA}/guile-modules;{GNC_DATA}/scm;{GUILE_LIBS};{GUILE_LOAD_PATH}
EXTRA_PATH={EXTRA_PATH};@-GNC_GUILE_MODULE_DIR-@;@-GNC_SCM_INSTALL_DIR-@
GUILE_LOAD_PATH={EXTRA_PATH};{GUILE_LOAD_PATH}
# Tell Guile where to find GnuCash specific shared libraries
GNC_LIBRARY_PATH={SYS_LIB};{GNC_MODULE_PATH}
LD_LIBRARY_PATH={GNC_LIBRARY_PATH};{LD_LIBRARY_PATH}
# The same, but for GnuCash on OS X
DYLD_LIBRARY_PATH={GNC_LIBRARY_PATH};{DYLD_LIBRARY_PATH}
EXTRA_LIBS={GNC_MODULE_PATH};@-GNC_LIB_INSTALLDIR-@;@-GNC_PKGLIB_INSTALLDIR-@
LD_LIBRARY_PATH={EXTRA_LIBS};{LD_LIBRARY_PATH}
DYLD_LIBRARY_PATH={EXTRA_LIBS};{DYLD_LIBRARY_PATH}
# If you wish GnuCash to use a different language, uncomment the two parameters
# below and set LANG to your preferred locale
# LANG=nl_BE
# LANGUAGE={LANG}

View File

@ -171,6 +171,33 @@ environment_override()
gsize param_count;
gint i;
gboolean got_keyfile;
gchar *env_parm, *bin_parm;
/* Export default parameters to the environment */
env_parm = gnc_path_get_prefix();
if (!g_setenv("GNC_HOME", env_parm, FALSE))
g_warning ("Couldn't set/override environment variable GNC_HOME.");
bin_parm = g_build_filename(env_parm, "bin", NULL);
if (!g_setenv("GNC_BIN", bin_parm, FALSE))
g_warning ("Couldn't set/override environment variable GNC_BIN.");
g_free (env_parm);
g_free (bin_parm);
env_parm = gnc_path_get_pkglibdir();
if (!g_setenv("GNC_LIB", env_parm, FALSE))
g_warning ("Couldn't set/override environment variable GNC_LIB.");
g_free (env_parm);
env_parm = gnc_path_get_pkgdatadir();
if (!g_setenv("GNC_DATA", env_parm, FALSE))
g_warning ("Couldn't set/override environment variable GNC_DATA.");
g_free (env_parm);
env_parm = gnc_path_get_pkgsysconfdir();
if (!g_setenv("GNC_CONF", env_parm, FALSE))
g_warning ("Couldn't set/override environment variable GNC_CONF.");
g_free (env_parm);
env_parm = gnc_path_get_libdir();
if (!g_setenv("SYS_LIB", env_parm, FALSE))
g_warning ("Couldn't set/override environment variable SYS_LIB.");
g_free (env_parm);
config_path = gnc_path_get_pkgsysconfdir();
#ifdef G_OS_WIN32