panda.nsi 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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\python\lib
  88. File /nonfatal /r ${PSOURCE}\thirdparty\win-extras\*
  89. SetOutPath $INSTDIR
  90. WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/"
  91. WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/manual/"
  92. CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\ppython.exe" 0 "" "" "Panda Manual"
  93. CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\ppython.exe" 0 "" "" "Panda Website"
  94. SetOutPath $INSTDIR\samples\RubiksCube
  95. CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Test - Rubiks Cube.lnk" "$INSTDIR\bin\ppython.exe" "rubiksCube.py" "$INSTDIR\bin\ppython.exe" 0 SW_SHOWMINIMIZED "" "Panda Test"
  96. !endif
  97. SectionEnd
  98. !ifndef PPGAME
  99. Section "Sample Worlds" SecSamples
  100. SectionIn 1 2 3
  101. DetailPrint "Extracting models ..."
  102. SetDetailsPrint textonly
  103. SetOutPath $INSTDIR\models
  104. File /r /x CVS ${PANDA}\models\*
  105. DetailPrint "Extracting samples ..."
  106. SetDetailsPrint textonly
  107. SetOutPath $INSTDIR\samples
  108. File /r /x CVS ${PSOURCE}\samples\*
  109. SetDetailsPrint both
  110. SectionEnd
  111. !endif
  112. Section -post
  113. !ifndef PPGAME
  114. # Add the "bin" directory to the PATH.
  115. DetailPrint "Adding 'bin' directory to the PATH..."
  116. Push "$INSTDIR\bin"
  117. Call AddToPath
  118. !endif
  119. DetailPrint "Registering Helix Preferences..."
  120. WriteRegStr HKLM "Software\Helix\HelixSDK\10.0\Preferences\UseOverlay" "" "0"
  121. WriteRegStr HKLM "Software\Helix\HelixSDK\10.0\Preferences\UseWinDraw" "" "0"
  122. WriteRegStr HKCU "Software\Helix\HelixSDK\10.0\Preferences\UseOverlay" "" "0"
  123. WriteRegStr HKCU "Software\Helix\HelixSDK\10.0\Preferences\UseWinDraw" "" "0"
  124. DetailPrint "Adding the uninstaller ..."
  125. Delete "$INSTDIR\uninst.exe"
  126. WriteUninstaller "$INSTDIR\uninst.exe"
  127. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALLKEY}" "DisplayName" "${SMDIRECTORY}"
  128. WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALLKEY}" "UninstallString" '"$INSTDIR\uninst.exe"'
  129. CreateShortcut "$SMPROGRAMS\${SMDIRECTORY}\Uninstall ${FULLNAME}.lnk" "$INSTDIR\uninst.exe" ""
  130. SectionEnd
  131. !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  132. !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "The core files required to use ${FULLNAME}."
  133. !ifndef PPGAME
  134. !insertmacro MUI_DESCRIPTION_TEXT ${SecSamples} "Sample worlds, scripts, models and tutorials."
  135. !endif
  136. !insertmacro MUI_FUNCTION_DESCRIPTION_END
  137. Section Uninstall
  138. !ifndef PPGAME
  139. DetailPrint "Removing ${SMDIRECTORY} from PATH ..."
  140. Push "$INSTDIR\bin"
  141. Call un.RemoveFromPath
  142. !endif
  143. Delete "$INSTDIR\uninst.exe"
  144. DetailPrint "Removing Start Menu folder ..."
  145. RMDir /r "$SMPROGRAMS\${SMDIRECTORY}"
  146. DetailPrint "Completely removing the directory ($INSTDIR)..."
  147. RMDir /r "$INSTDIR"
  148. DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTALLKEY}"
  149. SectionEnd
  150. # --[ Utility Functions ]------------------------------------------------------
  151. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  152. Function IsNT
  153. Push $0
  154. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  155. StrCmp $0 "" 0 IsNT_yes
  156. ; we are not NT.
  157. Pop $0
  158. Push 0
  159. Return
  160. IsNT_yes:
  161. ; NT!!!
  162. Pop $0
  163. Push 1
  164. FunctionEnd
  165. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  166. Function un.IsNT
  167. Push $0
  168. ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
  169. StrCmp $0 "" 0 unIsNT_yes
  170. ; we are not NT.
  171. Pop $0
  172. Push 0
  173. Return
  174. unIsNT_yes:
  175. ; NT!!!
  176. Pop $0
  177. Push 1
  178. FunctionEnd
  179. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  180. Function un.StrStr
  181. Push $0
  182. Exch
  183. Pop $0 ; $0 now have the string to find
  184. Push $1
  185. Exch 2
  186. Pop $1 ; $1 now have the string to find in
  187. Exch
  188. Push $2
  189. Push $3
  190. Push $4
  191. Push $5
  192. StrCpy $2 -1
  193. StrLen $3 $0
  194. StrLen $4 $1
  195. IntOp $4 $4 - $3
  196. unStrStr_loop:
  197. IntOp $2 $2 + 1
  198. IntCmp $2 $4 0 0 unStrStrReturn_notFound
  199. StrCpy $5 $1 $3 $2
  200. StrCmp $5 $0 unStrStr_done unStrStr_loop
  201. unStrStrReturn_notFound:
  202. StrCpy $2 -1
  203. unStrStr_done:
  204. Pop $5
  205. Pop $4
  206. Pop $3
  207. Exch $2
  208. Exch 2
  209. Pop $0
  210. Pop $1
  211. FunctionEnd
  212. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  213. ; Commentary and smarter ';' checking by Jon Parise <[email protected]>
  214. Function AddToPath
  215. Exch $0
  216. Push $1
  217. Push $2
  218. Push $3
  219. Call IsNT
  220. Pop $1
  221. StrCmp $1 1 AddToPath_NT
  222. ; We're not on NT, so modify the AUTOEXEC.BAT file.
  223. StrCpy $1 $WINDIR 2
  224. FileOpen $1 "$1\autoexec.bat" a
  225. FileSeek $1 0 END
  226. GetFullPathName /SHORT $0 $0
  227. FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
  228. FileClose $1
  229. Goto AddToPath_done
  230. AddToPath_NT:
  231. ReadRegStr $1 HKCU "Environment" "PATH"
  232. Call IsUserAdmin
  233. Pop $3
  234. ; If this is an Admin user, use the System env. variable instead of the user's env. variable
  235. StrCmp $3 1 0 +2
  236. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  237. ; If the PATH string is empty, jump over the mangling routines.
  238. StrCmp $1 "" AddToPath_NTdoIt
  239. ; Pull off the last character of the PATH string. If it's a semicolon,
  240. ; we don't need to add another one, so jump to the section where we
  241. ; append the new PATH component(s).
  242. StrCpy $2 $1 1 -1
  243. StrCmp $2 ";" AddToPath_NTAddPath AddToPath_NTAddSemi
  244. AddToPath_NTAddSemi:
  245. StrCpy $1 "$1;"
  246. Goto AddToPath_NTAddPath
  247. AddToPath_NTAddPath:
  248. StrCpy $0 "$1$0"
  249. Goto AddToPath_NTdoIt
  250. AddToPath_NTdoIt:
  251. Call IsUserAdmin
  252. Pop $3
  253. StrCmp $3 1 0 NotAdmin
  254. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0
  255. Goto AddToPath_done
  256. NotAdmin:
  257. WriteRegExpandStr HKCU "Environment" "PATH" $0
  258. AddToPath_done:
  259. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  260. Pop $3
  261. Pop $2
  262. Pop $1
  263. Pop $0
  264. FunctionEnd
  265. ; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
  266. Function un.RemoveFromPath
  267. Exch $0
  268. Push $1
  269. Push $2
  270. Push $3
  271. Push $4
  272. Push $5
  273. Call un.IsNT
  274. Pop $1
  275. StrCmp $1 1 unRemoveFromPath_NT
  276. ; Not on NT
  277. StrCpy $1 $WINDIR 2
  278. FileOpen $1 "$1\autoexec.bat" r
  279. GetTempFileName $4
  280. FileOpen $2 $4 w
  281. GetFullPathName /SHORT $0 $0
  282. StrCpy $0 "SET PATH=%PATH%;$0"
  283. SetRebootFlag true
  284. Goto unRemoveFromPath_dosLoop
  285. unRemoveFromPath_dosLoop:
  286. FileRead $1 $3
  287. StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
  288. StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
  289. StrCmp $3 "$0" unRemoveFromPath_dosLoop
  290. StrCmp $3 "" unRemoveFromPath_dosLoopEnd
  291. FileWrite $2 $3
  292. Goto unRemoveFromPath_dosLoop
  293. unRemoveFromPath_dosLoopEnd:
  294. FileClose $2
  295. FileClose $1
  296. StrCpy $1 $WINDIR 2
  297. Delete "$1\autoexec.bat"
  298. CopyFiles /SILENT $4 "$1\autoexec.bat"
  299. Delete $4
  300. Goto unRemoveFromPath_done
  301. unRemoveFromPath_NT:
  302. StrLen $2 $0
  303. Call un.IsUserAdmin
  304. Pop $5
  305. StrCmp $5 1 0 NotAdmin
  306. ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
  307. Push $1
  308. Push $0
  309. Call un.StrStr ; Find $0 in $1
  310. Pop $0 ; pos of our dir
  311. IntCmp $0 -1 unRemoveFromPath_done
  312. ; else, it is in path
  313. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  314. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  315. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  316. StrLen $0 $1
  317. StrCpy $1 $1 $0 $2
  318. StrCpy $3 "$3$1"
  319. WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
  320. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  321. Goto unRemoveFromPath_done
  322. NotAdmin:
  323. ReadRegStr $1 HKCU "Environment" "PATH"
  324. Push $1
  325. Push $0
  326. Call un.StrStr ; Find $0 in $1
  327. Pop $0 ; pos of our dir
  328. IntCmp $0 -1 unRemoveFromPath_done
  329. ; else, it is in path
  330. StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
  331. IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
  332. IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
  333. StrLen $0 $1
  334. StrCpy $1 $1 $0 $2
  335. StrCpy $3 "$3$1"
  336. WriteRegExpandStr HKCU "Environment" "PATH" $3
  337. SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
  338. unRemoveFromPath_done:
  339. Pop $5
  340. Pop $4
  341. Pop $3
  342. Pop $2
  343. Pop $1
  344. Pop $0
  345. FunctionEnd
  346. ; From: http://nsis.sourceforge.net/archive/nsisweb.php?page=329&instances=0,11
  347. ; Localized by Ben Johnson ([email protected])
  348. Function IsUserAdmin
  349. Push $0
  350. Push $1
  351. Push $2
  352. Push $3
  353. Call IsNT
  354. Pop $1
  355. ClearErrors
  356. UserInfo::GetName
  357. ;IfErrors Win9x
  358. Pop $2
  359. UserInfo::GetAccountType
  360. Pop $3
  361. ; Compare results of IsNT with "1"
  362. StrCmp $1 1 0 NotNT
  363. ;This is NT
  364. StrCmp $3 "Admin" 0 NotAdmin
  365. ; Observation: I get here when running Win98SE. (Lilla)
  366. ; The functions UserInfo.dll looks for are there on Win98 too,
  367. ; but just don't work. So UserInfo.dll, knowing that admin isn't required
  368. ; on Win98, returns admin anyway. (per kichik)
  369. ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
  370. Pop $3
  371. Pop $2
  372. Pop $1
  373. Pop $0
  374. Push 1
  375. Return
  376. NOtAdmin:
  377. ; You should still check for an empty string because the functions
  378. ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
  379. #StrCmp $2 "" Win9x
  380. #StrCpy $0 0
  381. ;MessageBox MB_OK 'User "$2" is in the "$3" group'
  382. Pop $3
  383. Pop $2
  384. Pop $1
  385. Pop $0
  386. Push 0
  387. Return
  388. ;Because we use IsNT, this is redundant.
  389. #Win9x:
  390. # ; comment/message below is by UserInfo.nsi author:
  391. # ; This one means you don't need to care about admin or
  392. # ; not admin because Windows 9x doesn't either
  393. # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  394. # StrCpy $0 0
  395. NotNT:
  396. ;We are not NT
  397. ;Win9x doesn't have "admin" users.
  398. ;Let the user do whatever.
  399. Pop $3
  400. Pop $2
  401. Pop $1
  402. Pop $0
  403. Push 1
  404. FunctionEnd
  405. Function un.IsUserAdmin
  406. Push $0
  407. Push $1
  408. Push $2
  409. Push $3
  410. Call un.IsNT
  411. Pop $1
  412. ClearErrors
  413. UserInfo::GetName
  414. ;IfErrors Win9x
  415. Pop $2
  416. UserInfo::GetAccountType
  417. Pop $3
  418. ; Compare results of IsNT with "1"
  419. StrCmp $1 1 0 NotNT
  420. ;This is NT
  421. StrCmp $3 "Admin" 0 NotAdmin
  422. ; Observation: I get here when running Win98SE. (Lilla)
  423. ; The functions UserInfo.dll looks for are there on Win98 too,
  424. ; but just don't work. So UserInfo.dll, knowing that admin isn't required
  425. ; on Win98, returns admin anyway. (per kichik)
  426. ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
  427. Pop $3
  428. Pop $2
  429. Pop $1
  430. Pop $0
  431. Push 1
  432. Return
  433. NOtAdmin:
  434. ; You should still check for an empty string because the functions
  435. ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
  436. #StrCmp $2 "" Win9x
  437. #StrCpy $0 0
  438. ;MessageBox MB_OK 'User "$2" is in the "$3" group'
  439. Pop $3
  440. Pop $2
  441. Pop $1
  442. Pop $0
  443. Push 0
  444. Return
  445. ;Because we use IsNT, this is redundant.
  446. #Win9x:
  447. # ; comment/message below is by UserInfo.nsi author:
  448. # ; This one means you don't need to care about admin or
  449. # ; not admin because Windows 9x doesn't either
  450. # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  451. # StrCpy $0 0
  452. NotNT:
  453. ;We are not NT
  454. ;Win9x doesn't have "admin" users.
  455. ;Let the user do whatever.
  456. Pop $3
  457. Pop $2
  458. Pop $1
  459. Pop $0
  460. Push 1
  461. FunctionEnd