]> git.lyx.org Git - features.git/blob - development/Win32/packaging/AltInstaller/ConfigLyX.nsh
535ff17ae772e39b93556d442f0518127eca57aa
[features.git] / development / Win32 / packaging / AltInstaller / ConfigLyX.nsh
1 Function ConfigureLyX
2  # configures LyX
3
4   # create the PathPrefix
5   StrCpy $PathPrefix "$INSTDIR\bin"
6   ${if} $PythonPath != ""
7     StrCpy $PathPrefix "$PathPrefix;$PythonPath"
8   ${endif}
9   ${if} $LatexPath != ""
10     StrCpy $PathPrefix "$PathPrefix;$LatexPath"
11   ${endif}
12   ${if} $GhostscriptPath != ""
13     StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
14   ${endif}
15   ${if} $ImageMagickPath != ""
16     StrCpy $PathPrefix "$PathPrefix;$ImageMagickPath"
17   ${endif}
18   ${if} $PSVPath != ""
19     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
20   ${endif}
21   ${if} $EditorPath != ""
22     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
23   ${endif}
24   ${if} $ImageEditorPath != ""
25     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
26   ${endif}
27   
28   # Set a path prefix in lyxrc.dist
29   ClearErrors
30   ${if} "$PathPrefix" != ""
31    Delete "$INSTDIR\Resources\lyxrc.dist"
32    FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
33    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
34    FileClose $R1
35    IfErrors 0 +2
36     MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
37   ${endif}
38
39   # Create a batch file to start LyX with the environment variables set
40   ClearErrors
41   Delete "${PRODUCT_BAT}"
42   FileOpen $R1 "${PRODUCT_BAT}" w
43   FileWrite $R1 '@echo off$\r$\n\
44                  SET LANG=$LangCode$\r$\n\
45                  SET AIK_DATA_DIR=${AiksaurusDir}$\r$\n\
46                  start "${PRODUCT_NAME}" "${LAUNCHER_EXE}" %*$\r$\n'
47   FileClose $R1
48   IfErrors 0 +2
49    MessageBox MB_OK|MB_ICONEXCLAMATION "$(CreateCmdFilesFailed)"
50
51   # set the preferences file
52   # (having one preferences file that is modified to fit the needs is possible but not easy to maintain
53   # therefore simply delete the file that shouldn't be used)
54   # if not Acrobat or Adobe Reader is used
55   ${if} $Acrobat == "None" # no special PDF viewer is used
56    Rename "$INSTDIR\Resources\preferencesGSview" "$INSTDIR\Resources\preferences"
57    Delete "$INSTDIR\Resources\preferencesAcro"
58   ${endif}
59   # if Acrobat or Adobe Reader is used
60   ${if} $Acrobat == "Yes" # used for Acrobat / Adobe Reader
61    Rename "$INSTDIR\Resources\preferencesAcro" "$INSTDIR\Resources\preferences"
62    Delete "$INSTDIR\Resources\preferencesGSview"
63   ${endif}
64
65   # register LyX
66   ${if} $CreateFileAssociations == "true"
67    WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
68   ${endif}
69   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "RootKey" "$ProductRootKey"
70   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
71   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "${PRODUCT_UNINSTALL_EXE}"
72   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
73   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
74   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
75   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_INFO_URL}"
76   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_ABOUT_URL}"
77   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "LyX Team"
78   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "HelpLink" "${PRODUCT_HELP_LINK}"
79   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
80   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
81
82   # create start menu entry
83   SetOutPath "$INSTDIR\bin"
84   CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
85   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
86   SetOutPath "$INSTDIR"
87   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "${PRODUCT_UNINSTALL_EXE}"
88
89   # create desktop icon
90   ${if} $CreateDesktopIcon == "true"
91    SetOutPath "$INSTDIR\bin"
92    CreateShortCut "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
93   ${endif}
94
95   # register the extension .lyx
96   ${if} $CreateFileAssociations == "true"
97    # write informations about file type
98    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Document"
99    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE}"
100    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_BAT}" "%1"'
101    # write informations about file extensions
102    WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
103    WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "Content Type" "${PRODUCT_MIME_TYPE}"  
104    # refresh shell
105    System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
106   ${endif}
107
108   # create the LyX Application Data folder for all users
109   # this folder is automatically created by LyX when it is first started but we want to start LyX with a specific session file,
110   # so we create this folder before LyX starts and copy there the session file
111   Call CreateAppPathSub # function from LyXUtils.nsh
112   
113   # delete unnecessary files
114   ${if} $DelPythonFiles == "True"
115    Delete $INSTDIR\bin\python.exe
116    Delete $INSTDIR\bin\python25.dll
117    Delete $INSTDIR\bin\Python-License.txt
118    RMDir /r $INSTDIR\bin\Lib
119    RMDir /r $INSTDIR\bin\DLLs
120   ${endif}
121   RMDir /r $INSTDIR\external
122
123   # create a bat-file to start configure in a console window so that the user see the progress
124   # of the configuration and to have a signal when the configuration is ready to start LyX
125   # this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
126   # time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
127   # a batch file is needed because simply calling
128   # ExecWait '"$PythonPath\python.exe" "$INSTDIR\Resources\configure.py"'
129   # creates the config files in $PythonPath
130   ${if} $PythonPath == ""
131    StrCpy $PythonPath "$INSTDIR\bin"
132   ${endif}
133   StrCpy $1 $INSTDIR 2 # get drive letter
134   FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
135   FileWrite $R1 '$1$\r$\n\
136                  cd $INSTDIR\Resources\$\r$\n\
137                  "$PythonPath\python.exe" configure.py'
138   FileClose $R1
139
140 FunctionEnd
141