panda.nsi 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. ; Panda3D installation script for the Nullsoft Installation System (NSIS).
  2. ; Jon Parise <[email protected]>
  3. ; with Ben Johnson <[email protected]>
  4. ; with Jason Pratt <[email protected]>
  5. ; mangled by Josh Yelon <[email protected]>
  6. ; Caller needs to define these variables:
  7. ; COMPRESSOR - either zlib or lzma
  8. ; FULLNAME - full name of what we're building (ie, "Panda3D")
  9. ; SMDIRECTORY - where to put this in the start menu (ie, "Panda3D VERSION")
  10. ; UNINSTALLKEY - what registry key to use for uninstaller (ie, "Panda3D VERSION")
  11. ; INSTALLDIR - where to install the program (ie, "C:\Program Files\Panda3D-VERSION")
  12. ; PPGAME - only if making a prepackaged game. (ie, "Airblade")
  13. !define PANDA ..\built
  14. !define PSOURCE ..
  15. ; Use the Modern UI
  16. !include "MUI.nsh"
  17. ; Windows system messaging support
  18. !include "${NSISDIR}\Include\WinMessages.nsh"
  19. Name "${FULLNAME}"
  20. InstallDir "${INSTALLDIR}"
  21. OutFile "..\nsis-output.exe"
  22. SetCompress auto
  23. SetCompressor ${COMPRESSOR}
  24. !define MUI_ABORTWARNING
  25. !define MUI_FINISHPAGE_NOREBOOTSUPPORT
  26. !insertmacro MUI_PAGE_WELCOME
  27. !insertmacro MUI_PAGE_LICENSE "${PSOURCE}\doc\LICENSE"
  28. !insertmacro MUI_PAGE_DIRECTORY
  29. !insertmacro MUI_PAGE_INSTFILES
  30. !insertmacro MUI_PAGE_FINISH
  31. !insertmacro MUI_UNPAGE_WELCOME
  32. !insertmacro MUI_UNPAGE_CONFIRM
  33. !insertmacro MUI_UNPAGE_INSTFILES
  34. !insertmacro MUI_UNPAGE_FINISH
  35. !insertmacro MUI_LANGUAGE "Panda3DEnglish"
  36. ShowInstDetails show
  37. ShowUninstDetails show
  38. LicenseData ${PSOURCE}\doc\LICENSE
  39. InstType "Typical"
  40. !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
  41. Section "${SMDIRECTORY}" SecCore
  42. SectionIn 1 2 3 RO
  43. SetOutPath $INSTDIR
  44. SetOverwrite try
  45. SetOutPath $INSTDIR
  46. File ${PSOURCE}\doc\LICENSE
  47. SetOutPath $INSTDIR\bin
  48. File /r ${PANDA}\bin\*.dll
  49. SetOutPath $INSTDIR\etc
  50. File /r ${PANDA}\etc\*
  51. SetOutPath $INSTDIR\direct
  52. File /r /x CVS /x Opt?-Win32 ${PSOURCE}\direct\*.py
  53. File ${PANDA}\direct\__init__.py
  54. SetOutPath $INSTDIR\pandac
  55. File /r ${PANDA}\pandac\*.py
  56. File /r ${PANDA}\pandac\*.pyz
  57. SetOutPath $INSTDIR\python
  58. File /r /x CVS /x *.pyc ${PANDA}\python\*
  59. RMDir /r "$SMPROGRAMS\${SMDIRECTORY}"
  60. CreateDirectory "$SMPROGRAMS\${SMDIRECTORY}"
  61. !ifdef PPGAME
  62. SetOutPath $INSTDIR\bin
  63. File /r ${PANDA}\bin\ppython.exe
  64. SetOutpath $INSTDIR\${PPGAME}
  65. File /r ${PSOURCE}\${PPGAME}\*
  66. SetOutPath $INSTDIR\${PPGAME}
  67. CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Play ${FULLNAME}.lnk" "$INSTDIR\bin\ppython.exe" "${PPGAME}.py" "$INSTDIR\bin\ppython.exe" 0 SW_SHOWMINIMIZED "" "Play ${FULLNAME}"
  68. !else
  69. SetOutPath $INSTDIR\bin
  70. File /nonfatal /r ${PANDA}\bin\*.dle
  71. File /nonfatal /r ${PANDA}\bin\*.dlo
  72. File /nonfatal /r ${PANDA}\bin\*.dlm
  73. SetOutPath $INSTDIR\pandac\input
  74. File /r ${PANDA}\pandac\input\*
  75. SetOutPath $INSTDIR\bin
  76. File /r ${PANDA}\bin\*.exe
  77. SetOutPath $INSTDIR\lib
  78. File /r /x *.exp ${PANDA}\lib\*
  79. SetOutPath $INSTDIR\include
  80. File /r /x *.exp ${PANDA}\include\*
  81. SetOutPath $INSTDIR\SceneEditor
  82. File /r /x CVS ${PSOURCE}\SceneEditor\*.*
  83. SetOutPath $INSTDIR\Pmw
  84. File /r /x CVS ${PANDA}\Pmw\*.*
  85. SetOutPath $INSTDIR
  86. File /r /x CVS ${PSOURCE}\doc\ReleaseNotes
  87. SetOutPath $INSTDIR
  88. WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/"
  89. WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/manual/"
  90. CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\ppython.exe" 0 "" "" "Panda Manual"
  91. CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\ppython.exe" 0 "" "" "Panda Website"
  92. SetOutPath $INSTDIR\samples\RubiksCube
  93. CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Test - Rubiks Cube.lnk" "$INSTDIR\bin\ppython.exe" "rubiksCube.py" "$INSTDIR\bin\ppython.exe" 0 SW_SHOWMINIMIZED "" "Panda Test"
  94. !endif
  95. SectionEnd
  96. !ifndef PPGAME
  97. Section "Sample Worlds" SecSamples
  98. SectionIn 1 2 3
  99. DetailPrint "Extracting models ..."
  100. SetDetailsPrint textonly
  101. SetOutPath $INSTDIR\models
  102. File /r /x CVS ${PANDA}\models\*
  103. DetailPrint "Extracting samples ..."
  104. SetDetailsPrint textonly
  105. SetOutPath $INSTDIR\samples
  106. File /r /x CVS ${PSOURCE}\samples\*
  107. SetDetailsPrint both
  108. SectionEnd
  109. !endif
  110. Section -post
  111. !ifndef PPGAME
  112. # Add the "bin" directory to the PATH.
  113. DetailPrint "Adding 'bin' directory to the PATH..."
  114. Push "$INSTDIR\bin"
  115. Call AddToPath
  116. !endif
  117. DetailPrint "Registering Helix Preferences..."
  118. WriteRegStr HKLM "Software\Helix\HelixSDK\10.0\Preferences\UseOverlay" "" "0"
  119. WriteRegStr HKLM "Software\Helix\HelixSDK\10.0\Preferences\UseWinDraw" "" "0"
  120. WriteRegStr HKCU "Software\Helix\HelixSDK\10.0\Preferences\UseOverlay" "" "0"
  121. WriteRegStr HKCU "Software\Helix\HelixSDK\10.0\Preferences\UseWinDraw" "" "0"
  122. DetailPrint "Adding the uninstaller ..."
  123. Delete "$INSTDIR\uninst.exe"
  124. WriteUninstaller "$INSTDIR\uninst.exe"
  125. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALLKEY}" "DisplayName" "${SMDIRECTORY}"
  126. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALLKEY}" "UninstallString" '"$INSTDIR\uninst.exe"'
  127. CreateShortcut "$SMPROGRAMS\${SMDIRECTORY}\Uninstall ${FULLNAME}.lnk" "$INSTDIR\uninst.exe" ""
  128. SectionEnd
  129. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  130. !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "The core files required to use ${FULLNAME}."
  131. !ifndef PPGAME
  132. !insertmacro MUI_DESCRIPTION_TEXT ${SecSamples} "Sample worlds, scripts, models and tutorials."
  133. !endif
  134. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  135. Section Uninstall
  136. !ifndef PPGAME
  137. DetailPrint "Removing ${SMDIRECTORY} from PATH ..."
  138. Push "$INSTDIR\bin"
  139. Call un.RemoveFromPath
  140. !endif
  141. Delete "$INSTDIR\uninst.exe"
  142. DetailPrint "Removing Start Menu folder ..."
  143. RMDir /r "$SMPROGRAMS\${SMDIRECTORY}"
  144. DetailPrint "Completely removing the directory ($INSTDIR)..."
  145. RMDir /r "$INSTDIR"
  146. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALLKEY}"
  147. SectionEnd
  148. # --[ Utility Functions ]------------------------------------------------------
  149. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  150. Function IsNT
  151. Push $0
  152. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  153. StrCmp $0 "" 0 IsNT_yes
  154. ; we are not NT.
  155. Pop $0
  156. Push 0
  157. Return
  158. IsNT_yes:
  159. ; NT!!!
  160. Pop $0
  161. Push 1
  162. FunctionEnd
  163. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  164. Function un.IsNT
  165. Push $0
  166. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  167. StrCmp $0 "" 0 unIsNT_yes
  168. ; we are not NT.
  169. Pop $0
  170. Push 0
  171. Return
  172. unIsNT_yes:
  173. ; NT!!!
  174. Pop $0
  175. Push 1
  176. FunctionEnd
  177. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  178. Function un.StrStr
  179. Push $0
  180. Exch
  181. Pop $0 ; $0 now have the string to find
  182. Push $1
  183. Exch 2
  184. Pop $1 ; $1 now have the string to find in
  185. Exch
  186. Push $2
  187. Push $3
  188. Push $4
  189. Push $5
  190. StrCpy $2 -1
  191. StrLen $3 $0
  192. StrLen $4 $1
  193. IntOp $4 $4 - $3
  194. unStrStr_loop:
  195. IntOp $2 $2 + 1
  196. IntCmp $2 $4 0 0 unStrStrReturn_notFound
  197. StrCpy $5 $1 $3 $2
  198. StrCmp $5 $0 unStrStr_done unStrStr_loop
  199. unStrStrReturn_notFound:
  200. StrCpy $2 -1
  201. unStrStr_done:
  202. Pop $5
  203. Pop $4
  204. Pop $3
  205. Exch $2
  206. Exch 2
  207. Pop $0
  208. Pop $1
  209. FunctionEnd
  210. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  211. ; Commentary and smarter ';' checking by Jon Parise <[email protected]>
  212. Function AddToPath
  213. Exch $0
  214. Push $1
  215. Push $2
  216. Push $3
  217. Call IsNT
  218. Pop $1
  219. StrCmp $1 1 AddToPath_NT
  220. ; We're not on NT, so modify the AUTOEXEC.BAT file.
  221. StrCpy $1 $WINDIR 2
  222. FileOpen $1 "$1\autoexec.bat" a
  223. FileSeek $1 0 END
  224. GetFullPathName /SHORT $0 $0
  225. FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
  226. FileClose $1
  227. Goto AddToPath_done
  228. AddToPath_NT:
  229. ReadRegStr $1 HKCU "Environment" "PATH"
  230. Call IsUserAdmin
  231. Pop $3
  232. ; If this is an Admin user, use the System env. variable instead of the user's env. variable
  233. StrCmp $3 1 0 +2
  234. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  235. ; If the PATH string is empty, jump over the mangling routines.
  236. StrCmp $1 "" AddToPath_NTdoIt
  237. ; Pull off the last character of the PATH string. If it's a semicolon,
  238. ; we don't need to add another one, so jump to the section where we
  239. ; append the new PATH component(s).
  240. StrCpy $2 $1 1 -1
  241. StrCmp $2 ";" AddToPath_NTAddPath AddToPath_NTAddSemi
  242. AddToPath_NTAddSemi:
  243. StrCpy $1 "$1;"
  244. Goto AddToPath_NTAddPath
  245. AddToPath_NTAddPath:
  246. StrCpy $0 "$1$0"
  247. Goto AddToPath_NTdoIt
  248. AddToPath_NTdoIt:
  249. Call IsUserAdmin
  250. Pop $3
  251. StrCmp $3 1 0 NotAdmin
  252. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0
  253. Goto AddToPath_done
  254. NotAdmin:
  255. WriteRegExpandStr HKCU "Environment" "PATH" $0
  256. AddToPath_done:
  257. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  258. Pop $3
  259. Pop $2
  260. Pop $1
  261. Pop $0
  262. FunctionEnd
  263. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  264. Function un.RemoveFromPath
  265. Exch $0
  266. Push $1
  267. Push $2
  268. Push $3
  269. Push $4
  270. Push $5
  271. Call un.IsNT
  272. Pop $1
  273. StrCmp $1 1 unRemoveFromPath_NT
  274. ; Not on NT
  275. StrCpy $1 $WINDIR 2
  276. FileOpen $1 "$1\autoexec.bat" r
  277. GetTempFileName $4
  278. FileOpen $2 $4 w
  279. GetFullPathName /SHORT $0 $0
  280. StrCpy $0 "SET PATH=%PATH%;$0"
  281. SetRebootFlag true
  282. Goto unRemoveFromPath_dosLoop
  283. unRemoveFromPath_dosLoop:
  284. FileRead $1 $3
  285. StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
  286. StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
  287. StrCmp $3 "$0" unRemoveFromPath_dosLoop
  288. StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  289. FileWrite $2 $3
  290. Goto unRemoveFromPath_dosLoop
  291. unRemoveFromPath_dosLoopEnd:
  292. FileClose $2
  293. FileClose $1
  294. StrCpy $1 $WINDIR 2
  295. Delete "$1\autoexec.bat"
  296. CopyFiles /SILENT $4 "$1\autoexec.bat"
  297. Delete $4
  298. Goto unRemoveFromPath_done
  299. unRemoveFromPath_NT:
  300. StrLen $2 $0
  301. Call un.IsUserAdmin
  302. Pop $5
  303. StrCmp $5 1 0 NotAdmin
  304. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  305. Push $1
  306. Push $0
  307. Call un.StrStr ; Find $0 in $1
  308. Pop $0 ; pos of our dir
  309. IntCmp $0 -1 unRemoveFromPath_done
  310. ; else, it is in path
  311. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  312. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  313. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  314. StrLen $0 $1
  315. StrCpy $1 $1 $0 $2
  316. StrCpy $3 "$3$1"
  317. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
  318. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  319. Goto unRemoveFromPath_done
  320. NotAdmin:
  321. ReadRegStr $1 HKCU "Environment" "PATH"
  322. Push $1
  323. Push $0
  324. Call un.StrStr ; Find $0 in $1
  325. Pop $0 ; pos of our dir
  326. IntCmp $0 -1 unRemoveFromPath_done
  327. ; else, it is in path
  328. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  329. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  330. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  331. StrLen $0 $1
  332. StrCpy $1 $1 $0 $2
  333. StrCpy $3 "$3$1"
  334. WriteRegExpandStr HKCU "Environment" "PATH" $3
  335. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  336. unRemoveFromPath_done:
  337. Pop $5
  338. Pop $4
  339. Pop $3
  340. Pop $2
  341. Pop $1
  342. Pop $0
  343. FunctionEnd
  344. ; From: http://nsis.sourceforge.net/archive/nsisweb.php?page=329&instances=0,11
  345. ; Localized by Ben Johnson ([email protected])
  346. Function IsUserAdmin
  347. Push $0
  348. Push $1
  349. Push $2
  350. Push $3
  351. Call IsNT
  352. Pop $1
  353. ClearErrors
  354. UserInfo::GetName
  355. ;IfErrors Win9x
  356. Pop $2
  357. UserInfo::GetAccountType
  358. Pop $3
  359. ; Compare results of IsNT with "1"
  360. StrCmp $1 1 0 NotNT
  361. ;This is NT
  362. StrCmp $3 "Admin" 0 NotAdmin
  363. ; Observation: I get here when running Win98SE. (Lilla)
  364. ; The functions UserInfo.dll looks for are there on Win98 too,
  365. ; but just don't work. So UserInfo.dll, knowing that admin isn't required
  366. ; on Win98, returns admin anyway. (per kichik)
  367. ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
  368. Pop $3
  369. Pop $2
  370. Pop $1
  371. Pop $0
  372. Push 1
  373. Return
  374. NOtAdmin:
  375. ; You should still check for an empty string because the functions
  376. ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
  377. #StrCmp $2 "" Win9x
  378. #StrCpy $0 0
  379. ;MessageBox MB_OK 'User "$2" is in the "$3" group'
  380. Pop $3
  381. Pop $2
  382. Pop $1
  383. Pop $0
  384. Push 0
  385. Return
  386. ;Because we use IsNT, this is redundant.
  387. #Win9x:
  388. # ; comment/message below is by UserInfo.nsi author:
  389. # ; This one means you don't need to care about admin or
  390. # ; not admin because Windows 9x doesn't either
  391. # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  392. # StrCpy $0 0
  393. NotNT:
  394. ;We are not NT
  395. ;Win9x doesn't have "admin" users.
  396. ;Let the user do whatever.
  397. Pop $3
  398. Pop $2
  399. Pop $1
  400. Pop $0
  401. Push 1
  402. FunctionEnd
  403. Function un.IsUserAdmin
  404. Push $0
  405. Push $1
  406. Push $2
  407. Push $3
  408. Call un.IsNT
  409. Pop $1
  410. ClearErrors
  411. UserInfo::GetName
  412. ;IfErrors Win9x
  413. Pop $2
  414. UserInfo::GetAccountType
  415. Pop $3
  416. ; Compare results of IsNT with "1"
  417. StrCmp $1 1 0 NotNT
  418. ;This is NT
  419. StrCmp $3 "Admin" 0 NotAdmin
  420. ; Observation: I get here when running Win98SE. (Lilla)
  421. ; The functions UserInfo.dll looks for are there on Win98 too,
  422. ; but just don't work. So UserInfo.dll, knowing that admin isn't required
  423. ; on Win98, returns admin anyway. (per kichik)
  424. ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
  425. Pop $3
  426. Pop $2
  427. Pop $1
  428. Pop $0
  429. Push 1
  430. Return
  431. NOtAdmin:
  432. ; You should still check for an empty string because the functions
  433. ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
  434. #StrCmp $2 "" Win9x
  435. #StrCpy $0 0
  436. ;MessageBox MB_OK 'User "$2" is in the "$3" group'
  437. Pop $3
  438. Pop $2
  439. Pop $1
  440. Pop $0
  441. Push 0
  442. Return
  443. ;Because we use IsNT, this is redundant.
  444. #Win9x:
  445. # ; comment/message below is by UserInfo.nsi author:
  446. # ; This one means you don't need to care about admin or
  447. # ; not admin because Windows 9x doesn't either
  448. # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  449. # StrCpy $0 0
  450. NotNT:
  451. ;We are not NT
  452. ;Win9x doesn't have "admin" users.
  453. ;Let the user do whatever.
  454. Pop $3
  455. Pop $2
  456. Pop $1
  457. Pop $0
  458. Push 1
  459. FunctionEnd