[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36947] trunk/blender: Windows installer and Path changes, fixing various issues:

Brecht Van Lommel brechtvanlommel at pandora.be
Fri May 27 11:57:53 CEST 2011


Revision: 36947
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36947
Author:   blendix
Date:     2011-05-27 09:57:53 +0000 (Fri, 27 May 2011)
Log Message:
-----------
Windows installer and Path changes, fixing various issues:

* Windows installer not working for non-admin users and multiple users
* Addon scripts not installing next to user configuration
* Portable install not being taken into account in all places

The main problem was the windows installer was installing system scripts in
AppData next to the user configuration directory, which is not shared between
users. Now these are installed in ProgramFiles, and only addon scripts added
by the users go to AppData.

On all platforms, addon scripts were sometimes getting installed between
system scripts, because the scripts folder in the executable directory was
given precedence over the user configuration folder, that is no longer done
now. So addons now behave like user configuration, they are preserved even
if you download a newer build of the same blender version.

If you have an installation of 2.57 on windows, the addon install location
will not change until we do the version bump to 2.58, to avoid conflicts with
the existing the installed 2.57 version.

The old behavior of giving precedence to the local folder was done to support
portable install, where all configuration is written to the local folder. This
is now implemented differently: if and only if a "config" folder exists in the
local folder, portable install will be assumed, and files will only be written
to that local folder.

Modified Paths:
--------------
    trunk/blender/build_files/scons/tools/btools.py
    trunk/blender/release/scripts/startup/bl_operators/wm.py
    trunk/blender/release/windows/installer/00.sconsblender.nsi
    trunk/blender/source/blender/blenlib/BLI_path_util.h
    trunk/blender/source/blender/blenlib/intern/path_util.c
    trunk/blender/source/blender/editors/space_file/space_file.c
    trunk/blender/source/blender/python/intern/bpy.c
    trunk/blender/source/blender/python/intern/bpy_interface.c
    trunk/blender/source/blender/windowmanager/intern/wm_files.c
    trunk/blender/source/creator/creator.c
    trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp

Modified: trunk/blender/build_files/scons/tools/btools.py
===================================================================
--- trunk/blender/build_files/scons/tools/btools.py	2011-05-27 09:38:49 UTC (rev 36946)
+++ trunk/blender/build_files/scons/tools/btools.py	2011-05-27 09:57:53 UTC (rev 36947)
@@ -615,10 +615,7 @@
         else:
             if len(df)>0:
                 dp_tmp = dp[l:]
-                if dp_tmp.find('python\\lib') > -1:
-                    datafiles += "\n" +r'SetOutPath $INSTDIR'+dp[l:]+"\n\n"
-                else:
-                    datafiles += "\n"+r'SetOutPath $BLENDERHOME'+dp[l:]+"\n\n"
+                datafiles += "\n" +r'SetOutPath $INSTDIR'+dp[l:]+"\n\n"
 
                 for f in df:
                     outfile = os.path.join(dp,f)

Modified: trunk/blender/release/scripts/startup/bl_operators/wm.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/wm.py	2011-05-27 09:38:49 UTC (rev 36946)
+++ trunk/blender/release/scripts/startup/bl_operators/wm.py	2011-05-27 09:57:53 UTC (rev 36947)
@@ -940,6 +940,14 @@
             self.report({'ERROR'}, "Source path %r exists" % path_src)
         else:
             shutil.copytree(path_src, path_dst)
+
+            # in 2.57 and earlier windows installers, system scripts were copied
+            # into the configuration directory, don't want to copy those
+            system_script = os.path.join(path_dst, 'scripts/modules/bpy_types.py')
+            if os.path.isfile(system_script):
+                shutil.rmtree(os.path.join(path_dst, 'scripts'))
+                shutil.rmtree(os.path.join(path_dst, 'plugins'))
+
             # dont loose users work if they open the splash later.
             if bpy.data.is_saved is bpy.data.is_dirty is False:
                 bpy.ops.wm.read_homefile()

Modified: trunk/blender/release/windows/installer/00.sconsblender.nsi
===================================================================
--- trunk/blender/release/windows/installer/00.sconsblender.nsi	2011-05-27 09:38:49 UTC (rev 36946)
+++ trunk/blender/release/windows/installer/00.sconsblender.nsi	2011-05-27 09:57:53 UTC (rev 36947)
@@ -33,11 +33,11 @@
 !insertmacro MUI_PAGE_COMPONENTS
     
 !insertmacro MUI_PAGE_DIRECTORY
-Page custom DataLocation DataLocationOnLeave
 !insertmacro MUI_PAGE_INSTFILES
 !insertmacro MUI_PAGE_FINISH
   
 !insertmacro MUI_UNPAGE_WELCOME
+UninstPage custom un.OptionalRemoveConfig un.OptionalRemoveConfigOnLeave
 !insertmacro MUI_UNPAGE_CONFIRM
 !insertmacro MUI_UNPAGE_INSTFILES
 !insertmacro MUI_UNPAGE_FINISH
@@ -62,7 +62,6 @@
   LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)"
   LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop."
   LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc."
-  LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Specify User Data Location"
 ;--------------------------------
 ;Data
 
@@ -76,15 +75,15 @@
 
 SilentUnInstall normal
 
-Var BLENDERHOME
 Var SHORTVERSION ; This is blender_version_decimal() from path_util.c
+Var BLENDERCONFIG
+Var REMOVECONFIG
 
 ; Custom controls
 Var HWND
 
-Var HWND_APPDATA
-Var HWND_INSTDIR
-Var HWND_HOMEDIR
+Var HWND_KEEPCONFIG
+Var HWND_REMOVECONFIG
 
 Function .onInit
   ClearErrors
@@ -103,9 +102,12 @@
 FunctionEnd
 
 Function un.onInit
+  SetShellVarContext current
+  StrCpy $BLENDERCONFIG "$APPDATA\Blender Foundation\Blender"
+  SetShellVarContext all
 FunctionEnd
 
-Function DataLocation
+Function un.OptionalRemoveConfig
   nsDialogs::Create /NOUNLOAD 1018
   Pop $HWND
   
@@ -113,45 +115,27 @@
     Abort
   ${EndIf}
   
-  ${NSD_CreateLabel} 0 0 100% 24u "Please specify where you wish to install Blender's user data files. Be aware that if you choose to use your Application Data directory, your preferences and scripts will only be accessible by the current user account."
-  ${NSD_CreateRadioButton} 0 50 100% 12u "Use Application Data directory (recommended)"
-  Pop $HWND_APPDATA
-  ${NSD_CreateRadioButton} 0 80 100% 12u "Use installation directory"
-  Pop $HWND_INSTDIR
-  ${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there"
-  Pop $HWND_HOMEDIR
+  ${NSD_CreateRadioButton} 0 50 100% 12u "Keep configuration files, autosaved .blend files and installed addons (recommended)"
+  Pop $HWND_KEEPCONFIG
+  ${NSD_CreateRadioButton} 0 80 100% 12u "Remove all files, including configuration files, autosaved .blend files and installed addons"
+  Pop $HWND_REMOVECONFIG
+
+  SendMessage $HWND_KEEPCONFIG ${BM_SETCHECK} 1 0
   
-  ${If} ${AtMostWinME}
-    GetDlgItem $0 $HWND $HWND_APPDATA
-    EnableWindow $0 0
-    SendMessage $HWND_INSTDIR ${BM_SETCHECK} 1 0
-  ${Else}
-    SendMessage $HWND_APPDATA ${BM_SETCHECK} 1 0
-  ${EndIf}
-  
   nsDialogs::Show
   
 FunctionEnd
 
-Function DataLocationOnLeave
-  ${NSD_GetState} $HWND_APPDATA $R0
+Function un.OptionalRemoveConfigOnLeave
+  ${NSD_GetState} $HWND_REMOVECONFIG $R0
   ${If} $R0 == "1"
-    SetShellVarContext current
-    StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender"
-    SetShellVarContext all
+    StrCpy $REMOVECONFIG "1"
   ${Else}
-    ${NSD_GetState} $HWND_INSTDIR $R0
-    ${If} $R0 == "1"
-      StrCpy $BLENDERHOME $INSTDIR
-    ${Else}
-      ${NSD_GetState} $HWND_HOMEDIR $R0
-      ${If} $R0 == "1"
-        ReadEnvStr $BLENDERHOME "HOME"
-      ${EndIf}
-    ${EndIf}
+    StrCpy $REMOVECONFIG "0"
   ${EndIf}
 FunctionEnd
 
+
 Section "Blender [VERSION] (required)" InstallFiles
   SectionIn RO
 
@@ -160,7 +144,7 @@
   ; The contents of Blender installation root dir
   [ROOTDIRCONTS]
   
-  ; All datafiles (python, scripts, config)
+  ; All datafiles (python, scripts, datafiles)
   [DODATAFILES]
   
   SetOutPath $INSTDIR
@@ -169,7 +153,6 @@
   ${EndIf}
   ; Write the installation path into the registry
   WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "Install_Dir" "$INSTDIR"
-  WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" "$BLENDERHOME"
   WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]"
   ; Write the uninstall keys for Windows
   WriteRegStr   HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender"
@@ -204,7 +187,7 @@
   ExecWait '"$INSTDIR\blender.exe" -r'
 SectionEnd
 
-UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit 'Uninstall' to continue."
+UninstallText "This will uninstall Blender [VERSION], and all installed files. Hit 'Uninstall' to continue."
 
 Section "Uninstall"
   ; Remove registry keys
@@ -212,7 +195,6 @@
     SetRegView 64
   ${EndIf}
   
-  ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir"
   ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion"
   DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
   DeleteRegKey HKLM "SOFTWARE\BlenderFoundation"
@@ -226,21 +208,10 @@
 
   Delete "$INSTDIR\uninstall.exe"
 
-  MessageBox MB_YESNO "Recursively erase contents of $BLENDERHOME\$SHORTVERSION\scripts? NOTE: This includes all installed scripts and *any* file and directory you have manually created, installed later or copied. This also including .blend files." IDNO NextNoScriptRemove
-  RMDir /r "$BLENDERHOME\$SHORTVERSION\scripts"
-NextNoScriptRemove:
-  MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\config? NOTE: This includes your startup.blend, bookmarks and any other file and directory you may have created in that directory" IDNO NextNoConfigRemove
-  RMDir /r "$BLENDERHOME\$SHORTVERSION\config"
-NextNoConfigRemove:
-  MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\plugins? NOTE: This includes files and subdirectories in this directory" IDNO NextNoPluginRemove
-  RMDir /r "$BLENDERHOME\$SHORTVERSION\plugins"
-NextNoPluginRemove:
-  ; Try to remove dirs, but leave them if they contain anything
-  RMDir "$BLENDERHOME\$SHORTVERSION\plugins"
-  RMDir "$BLENDERHOME\$SHORTVERSION\config"
-  RMDir "$BLENDERHOME\$SHORTVERSION\scripts"
-  RMDir "$BLENDERHOME\$SHORTVERSION"
-  RMDir "$BLENDERHOME"
+  ${If} $REMOVECONFIG == "1"
+    RMDir /r "$BLENDERCONFIG\$SHORTVERSION"
+  ${Endif}
+
   ; Remove shortcuts
   Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
   Delete "$DESKTOP\Blender.lnk"

Modified: trunk/blender/source/blender/blenlib/BLI_path_util.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_path_util.h	2011-05-27 09:38:49 UTC (rev 36946)
+++ trunk/blender/source/blender/blenlib/BLI_path_util.h	2011-05-27 09:57:53 UTC (rev 36947)
@@ -50,11 +50,7 @@
 /* folder_id */
 
 /* general, will find based on user/local/system priority */
-#define BLENDER_CONFIG				1
 #define BLENDER_DATAFILES			2
-#define BLENDER_SCRIPTS				3
-#define BLENDER_PLUGINS				4
-#define BLENDER_PYTHON				5
 
 /* user-specific */
 #define BLENDER_USER_CONFIG			31
@@ -64,7 +60,6 @@
 #define BLENDER_USER_AUTOSAVE		35
 
 /* system */
-#define BLENDER_SYSTEM_CONFIG		51	/* optional */
 #define BLENDER_SYSTEM_DATAFILES	52
 #define BLENDER_SYSTEM_SCRIPTS		53
 #define BLENDER_SYSTEM_PLUGINS		54

Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c	2011-05-27 09:38:49 UTC (rev 36946)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c	2011-05-27 09:57:53 UTC (rev 36947)
@@ -902,10 +902,23 @@
 	return 0;
 }
 
+static int is_portable_install(void)
+{
+	/* detect portable install by the existance of config folder */
+	const int ver= BLENDER_VERSION;
+	char path[FILE_MAX];
+
+	return get_path_local(path, "config", NULL, ver);
+}
+
 static int get_path_user(char *targetpath, const char *folder_name, const char *subfolder_name, const char *envvar, const int ver)
 {
 	char user_path[FILE_MAX];
 	const char *user_base_path;
+
+	/* for portable install, user path is always local */
+	if (is_portable_install())
+		return get_path_local(targetpath, folder_name, subfolder_name, ver);
 	
 	user_path[0] = '\0';
 
@@ -1011,6 +1024,26 @@
 	}
 }

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list