home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / xbmc-9.11.exe / system / python / spyce / spyce.nsi < prev    next >
Encoding:
Text File  |  2009-12-23  |  6.9 KB  |  209 lines

  1. ; spyce.nsi
  2. ; Spyce Installer (NSIS script)
  3.  
  4. ;#####################################
  5. ;VERSION
  6.  
  7. !define VERSION 1.3.13
  8. !define RELEASE 1
  9.  
  10. ;#####################################
  11. ;DEFINES
  12.  
  13. !define NAME Spyce
  14. !define NAME_SMALL spyce
  15. !define Desc "Spyce - Python Server Pages"
  16. !define REG_PROG "SOFTWARE\${NAME}"
  17. !define REG_UNINST "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
  18. !define PYTHON "python.exe"
  19. !define REG_PYTHONLOC "${REG_PROG}"
  20.  
  21. !define COMPILE 1
  22.  
  23. ;#####################################
  24. ;OPTIONS
  25.  
  26. OutFile "${NAME_SMALL}-${VERSION}.exe"
  27. InstallDir $PROGRAMFILES\${NAME_SMALL}
  28. InstallDirRegKey HKLM ${REG_PROG} "location"
  29.  
  30. Name "${NAME}"
  31. Caption "${NAME} Windows Installer"
  32. UninstallCaption "${NAME} Windows Uninstaller"
  33. DirText "${NAME} Windows Installer"
  34. ComponentText  "${NAME} Windows Installer"
  35. CompletedText "${NAME} Windows Installer is finished"
  36. UninstallText "${NAME} Windows Uninstaller"
  37. BrandingText " "
  38.  
  39. CRCCheck on
  40. AutoCloseWindow true
  41. EnabledBitmap  misc/one-check.bmp
  42. DisabledBitmap  misc/one-nocheck.bmp
  43. ShowInstDetails show
  44. ShowUninstDetails show
  45. ;BGGradient 
  46. SilentUnInstall silent
  47. Icon misc\pics\spyce-border.ico ; MUST contain a 32x32x16 color icon
  48. UninstallIcon misc\pics\spyce-border.ico
  49. WindowIcon on
  50. SetOverwrite on
  51. SetCompress auto
  52. SetDatablockOptimize on
  53. SetDateSave off
  54.  
  55. ;#####################################
  56. ;SECTIONS
  57.  
  58. Section "${NAME} engine"
  59.   ReadRegStr $9 HKLM ${REG_PYTHONLOC} "python"
  60.   SetOutPath $INSTDIR
  61.   ; create and register uninstaller
  62.   WriteUninstaller "uninstall.exe"
  63.   WriteRegStr HKLM ${REG_PROG} "location" "$INSTDIR"
  64.   WriteRegStr HKLM "${REG_UNINST}" "DisplayName" "${NAME}: ${DESC} (remove only)"
  65.   WriteRegStr HKLM "${REG_UNINST}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  66.  
  67.   ; copy spyce engine files
  68.   File *.py
  69.   File CHANGES LICENCE README THANKS spyceApache.conf spyce.conf.eg misc\pics\spyce.ico spyce.mime
  70.   SetOutPath "$INSTDIR\modules"
  71.   File modules\*.py
  72.   SetOutPath "$INSTDIR\tags"
  73.   File tags\*.py
  74.   SetOutPath -
  75.   ; pre-compile the sources
  76.   !ifdef COMPILE
  77.     DetailPrint "Compile Spyce sources."
  78.     ExecWait `"$9" "$INSTDIR\spyceParser.py"`
  79.     ExecWait `"$9" "$INSTDIR\installHelper.py" "--py=$INSTDIR"`
  80.     ;ExecWait `"$9" -OO "$INSTDIR\installHelper.py" "--py=$INSTDIR"`
  81.     ExecWait `"$9" "$INSTDIR\installHelper.py" "--py=$INSTDIR\modules"`
  82.     ;ExecWait `"$9" -OO "$INSTDIR\installHelper.py" "--py=$INSTDIR\modules"`
  83.     ExecWait `"$9" "$INSTDIR\installHelper.py" "--py=$INSTDIR\tags"`
  84.     ;ExecWait `"$9" -OO "$INSTDIR\installHelper.py" "--py=$INSTDIR\tags"`
  85.   !endif
  86. SectionEnd
  87.  
  88. Section "${NAME} documentation"
  89.   SectionIn RO
  90.   ReadRegStr $9 HKLM ${REG_PYTHONLOC} "python"
  91.   ; copy Spyce documentation files
  92.   SetOutPath "$INSTDIR\docs"
  93.   File docs\*.spy docs\*.gif
  94.   SetOutPath "$INSTDIR\docs\examples"
  95.   File docs\examples\*.spy docs\examples\*.spi docs\examples\*.tmpl docs\examples\*.py docs\examples\*.gif
  96.   SetOutPath "$INSTDIR\docs\inc"
  97.   File docs\inc\*.spi
  98.   SetOutPath -
  99.   ; compile documentation
  100.   !ifdef COMPILE
  101.     DetailPrint "Compile Spyce documentation."
  102.     ExecWait `"$9" "$INSTDIR\run_spyceCmd.py" "-O" "$INSTDIR\docs\*.spy"`
  103.   !endif
  104. SectionEnd
  105.  
  106. SectionDivider "Options"
  107.  
  108. Section "Create start menu shortcuts"
  109.   CreateDirectory "$SMPROGRAMS\${NAME}"
  110.   CreateShortCut "$SMPROGRAMS\${NAME}\Spyce Documentation.lnk" "$INSTDIR\docs\index.html" "" "$INSTDIR\spyce.ico"
  111.   CreateShortCut "$SMPROGRAMS\${NAME}\Spyce Documentation -- localhost.lnk" "http://localhost/spyce/" "" ""
  112.   CreateShortCut "$SMPROGRAMS\${NAME}\Spyce Online.lnk" "http://spyce.sf.net/" "" ""
  113.   CreateShortCut "$SMPROGRAMS\${NAME}\Spyce Examples.lnk" "$INSTDIR\docs\examples" "" "$INSTDIR\spyce.ico"
  114.   CreateShortCut "$SMPROGRAMS\${NAME}\Uninstall Spyce.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  115. SectionEnd
  116.  
  117. Section "Create shell extensions"
  118.   WriteRegStr HKCR ".spy" "" "SpyceFile"
  119.   WriteRegStr HKCR "SpyceFile" "" "Spyce dynamic HTML file"
  120.   WriteRegStr HKCR "SpyceFile\DefaultIcon" "" $INSTDIR\spyce.ico,0
  121.   WriteRegStr HKCR "SpyceFile\shell\open\command" "" 'notepad.exe "%1"'
  122.   WriteRegStr HKCR "SpyceFile\shell\compile" "" "Compile Spyce"
  123.   WriteRegStr HKCR "SpyceFile\shell\compile\command" "" '"$9" "$INSTDIR\run_spyceCmd.py" -O "%1"'
  124.   WriteRegStr HKCR "SpyceFile\shell" "" "compile"
  125. SectionEnd
  126.  
  127. Section "Configure Apache"
  128.   DetailPrint "Configuring Apache..."
  129.   ExecWait `"$9" "$INSTDIR\installHelper.py" "--apache=$INSTDIR"`
  130.   ExecWait `"$9" "$INSTDIR\installHelper.py" "--apacheRestart"`
  131.   MessageBox MB_OK|MB_ICONEXCLAMATION "$\nApache reconfigured and restarted.$\nIf everything is ok, you should be able to browse to: http://localhost/spyce/$\nIf not, please check your httpd.conf file and/or restart Apache."
  132.  
  133. SectionEnd
  134.  
  135.  
  136. Section "Uninstall"
  137.   ReadRegStr $9 HKLM ${REG_PYTHONLOC} "python"
  138.   DetailPrint "Unconfiguring Apache..."
  139.   ExecWait `"$9" "$INSTDIR\installHelper.py" "--apacheUN"`
  140.   ExecWait `"$9" "$INSTDIR\installHelper.py" "--apacheRestart"`
  141.   RMDir /r "$INSTDIR"
  142.   RMDir /r "$SMPROGRAMS\${NAME}"
  143.   DeleteRegKey HKLM ${REG_UNINST}
  144.   DeleteRegKey HKLM ${REG_PROG}
  145.   DeleteRegKey HKCR ".spy"
  146.   DeleteRegKey HKCR "SpyceFile"
  147. SectionEnd
  148.  
  149. ;#####################################
  150. ;FUNCTIONS
  151.  
  152. Function detectPython
  153.   ; see if there is any python interpreter
  154.   ClearErrors
  155.   ExecShell "open" "${PYTHON}" `-c "print 'Python is alive!'"` SW_SHOWMINIMIZED
  156.   IfErrors 0 NoAbort
  157.     MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to find Python interpreter. Please install Python first."
  158.     Abort
  159.   NoAbort:
  160.   ; find out where it is
  161.   GetTempFileName $9
  162.   GetTempFileName $8
  163.   FileOpen $7 $9 w
  164.   FileWrite $7 'import sys$\n'
  165.   FileWrite $7 "f=open(r'$8', 'w')$\n"
  166.   FileWrite $7 'f.write(sys.executable)$\n'
  167.   FileWrite $7 'f.close()$\n'
  168.   FileClose $7
  169.   ExecShell "open" "${PYTHON}" `"$9"` SW_SHOWMINIMIZED
  170.   IntOp $0 0 + 0
  171.   Loop:
  172.     FileOpen $7 $8 r
  173.     FileRead $7 $6
  174.     FileClose $7
  175.     StrCmp $6 "" 0 EndLoop
  176.     Sleep 100
  177.     IntOp $0 $0 + 1
  178.     IntCmp $0 50 EndLoop
  179.     Goto Loop
  180.   EndLoop:
  181.   Delete $9
  182.   StrCpy $9 "$6"  ; put the python path in $9 -- GLOBAL
  183.   StrCmp $9 "" 0 NoAbort2
  184.     MessageBox MB_OK|MB_ICONEXCLAMATION "Mechanism for discovering Python path via sys.executable did not work.$\nSorry, but automatic installation is unable to proceed. Please contact the author."
  185.     Abort
  186.   NoAbort2:
  187.   WriteRegStr HKLM ${REG_PYTHONLOC} "python" "$9"
  188. FunctionEnd
  189.  
  190. Function .onInit
  191.   Call detectPython
  192. FunctionEnd
  193.  
  194. Function .onInstSuccess
  195.   DetailPrint "Spyce successfully installed."
  196.   MessageBox MB_OK "Spyce successfully installed."
  197.   ExecShell "open" "$INSTDIR\docs\index.html" SW_SHOWMAXIMIZED
  198. FunctionEnd
  199.  
  200. Function un.onInit
  201.   MessageBox MB_YESNO|MB_ICONQUESTION "Are you sure that you want to uninstall Spyce?" IDYES NoAbort
  202.     Abort
  203.   NoAbort:
  204. FunctionEnd
  205.  
  206. Function un.onUninstSuccess
  207.   MessageBox MB_OK "Spyce successfully uninstalled."
  208. FunctionEnd
  209.