]> git.sesse.net Git - vlc/blobdiff - vlc.win32.nsi.in
Cosmetics
[vlc] / vlc.win32.nsi.in
index 033a9c63a5badbc0de8e29f4f5dd71e60a586552..59aaedd3c05f57fc2692f04675c05b2a28cb817c 100644 (file)
@@ -13,6 +13,8 @@
 !define PRODUCT_UNINST_ROOT_KEY "HKLM"\r
 !define PRODUCT_ID "{ea92ef52-afe4-4212-bacb-dfe9fca94cd6}"\r
 \r
+@FILE_LIBVLC_DLL@\r
+\r
 ;;;;;;;;;;;;;;;;;;;;;;;;;\r
 ; General configuration ;\r
 ;;;;;;;;;;;;;;;;;;;;;;;;;\r
@@ -31,7 +33,8 @@ SetCompressor /SOLID lzma
 SetOverwrite ifnewer\r
 CRCCheck on\r
 \r
-InstType "Normal"\r
+InstType "Recommended"\r
+InstType "Minimum"\r
 InstType "Full"\r
 \r
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
@@ -194,7 +197,7 @@ FunctionEnd
 \r
 !macro RegisterExtensionSection EXT\r
   Section /o ${EXT}\r
-    SectionIn 2 3\r
+    SectionIn 1 3\r
     Push $R0\r
     StrCpy $R0 ${EXT}\r
     Call RegisterExtension\r
@@ -235,7 +238,7 @@ FunctionEnd
 ;;;;;;;;;;;;;;;;;;;;;;;;;;\r
 \r
 !macro delprefs\r
-  SectionIn 2 3\r
+  SectionIn 1 3\r
   StrCpy $0 0\r
   !define Index 'Line${__LINE__}'\r
   "${Index}-Loop:"\r
@@ -254,6 +257,65 @@ FunctionEnd
   !undef Index\r
 !macroend\r
 \r
+Var UninstallLog\r
+\r
+!macro OpenUninstallLog\r
+  FileOpen $UninstallLog "$INSTDIR\uninstall.log" a\r
+  FileSeek $UninstallLog 0 END\r
+!macroend\r
+\r
+!macro CloseUninstallLog\r
+  FileClose $UninstallLog\r
+  SetFileAttributes "$INSTDIR\uninstall.log" HIDDEN\r
+!macroend\r
+\r
+!macro InstallFile FILEREGEX\r
+  File "${FILEREGEX}"\r
+  !define Index 'Line${__LINE__}'\r
+  FindFirst $0 $1 "$INSTDIR\${FILEREGEX}"\r
+  StrCmp $0 "" "${Index}-End"\r
+  "${Index}-Loop:"\r
+    StrCmp $1 "" "${Index}-End"\r
+    FileWrite $UninstallLog "$1$\r$\n"\r
+    FindNext $0 $1\r
+    Goto "${Index}-Loop"\r
+  "${Index}-End:"\r
+  !undef Index\r
+!macroend\r
+\r
+!macro InstallFolder FOLDER\r
+  File /r "${FOLDER}"\r
+  Push "${FOLDER}"\r
+  Call InstallFolderInternal\r
+!macroend\r
+\r
+Function InstallFolderInternal\r
+  Pop $9\r
+  !define Index 'Line${__LINE__}'\r
+  FindFirst $0 $1 "$INSTDIR\$9\*"\r
+  StrCmp $0 "" "${Index}-End"\r
+  "${Index}-Loop:"\r
+    StrCmp $1 "" "${Index}-End"\r
+    StrCmp $1 "." "${Index}-Next"\r
+    StrCmp $1 ".." "${Index}-Next"\r
+    IfFileExists "$9\$1\*" 0 "${Index}-Write"\r
+      Push $0\r
+      Push $9\r
+      Push "$9\$1"\r
+      Call InstallFolderInternal\r
+      Pop $9\r
+      Pop $0\r
+      Goto "${Index}-Next"\r
+    "${Index}-Write:"\r
+    FileWrite $UninstallLog "$9\$1$\r$\n"\r
+    "${Index}-Next:"\r
+    FindNext $0 $1\r
+    Goto "${Index}-Loop"\r
+  "${Index}-End:"\r
+  !undef Index\r
+FunctionEnd\r
+\r
+\r
 ;;;;;;;;;;;;;;;;;;;;;;\r
 ; Installer sections ;\r
 ;;;;;;;;;;;;;;;;;;;;;;\r
@@ -263,16 +325,29 @@ Section "Media player (required)" SEC01
   SetShellVarContext all\r
   SetOutPath "$INSTDIR"\r
 \r
-  File  vlc.exe\r
-  File  vlc.exe.manifest\r
-  @FILE_LIBVLC_DLL@\r
-  File  *.txt\r
+  !insertmacro OpenUninstallLog\r
 \r
-  File  /r plugins\r
-  File  /r locale\r
-  File  /r osdmenu\r
-  File  /r skins\r
-  File  /r http\r
+  !insertmacro InstallFile vlc.exe\r
+  !insertmacro InstallFile vlc.exe.manifest\r
+  !ifdef LIBVLC_DLL\r
+  !insertmacro InstallFile ${LIBVLC_DLL}\r
+  !endif\r
+  !insertmacro InstallFile *.txt\r
+\r
+  !insertmacro InstallFolder plugins\r
+  !insertmacro InstallFolder locale\r
+  !insertmacro InstallFolder osdmenu\r
+  !insertmacro InstallFolder skins\r
+  !insertmacro InstallFolder http\r
+\r
+  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" \\r
+    "${PRODUCT_WEB_SITE}"\r
+  FileWrite $UninstallLog "${PRODUCT_NAME}.url$\r$\n"\r
+  WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" \\r
+    "${PRODUCT_WEB_SITE}/doc/"\r
+  FileWrite $UninstallLog "Documentation.url$\r$\n"\r
+\r
+  !insertmacro CloseUninstallLog\r
 \r
   ; Add VLC to "recomended programs" for the following extensions\r
   WriteRegStr HKCR Applications\vlc.exe "" ""\r
@@ -326,12 +401,8 @@ Section "Start Menu Shortcut" SEC02a
     "$INSTDIR\vlc.exe" "--intf skins"\r
   CreateShortCut "$SMPROGRAMS\VideoLAN\Reset VLC defaults and quit.lnk" \\r
     "$INSTDIR\vlc.exe" "--reset-config --reset-plugins-cache --save-config vlc:quit "\r
-  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" \\r
-    "${PRODUCT_WEB_SITE}"\r
   CreateShortCut "$SMPROGRAMS\VideoLAN\${PRODUCT_NAME} Website.lnk" \\r
     "$INSTDIR\${PRODUCT_NAME}.url"\r
-  WriteIniStr "$INSTDIR\Documentation.url" "InternetShortcut" "URL" \\r
-    "${PRODUCT_WEB_SITE}/doc/"\r
   CreateShortCut "$SMPROGRAMS\VideoLAN\Documentation.lnk" \\r
     "$INSTDIR\Documentation.url"\r
 SectionEnd\r
@@ -339,12 +410,15 @@ SectionEnd
 Section "Desktop Shortcut" SEC02b\r
   SectionIn 1 2 3\r
   CreateShortCut "$DESKTOP\VLC media player.lnk" \\r
-    "$INSTDIR\vlc.exe" "--intf wx"\r
+    "$INSTDIR\vlc.exe" ""\r
 SectionEnd\r
 \r
 Section /o "Mozilla plugin" SEC03\r
-  SectionIn 2 3\r
-  File /r mozilla\r
+  SectionIn 1 3\r
+\r
+  !insertmacro OpenUninstallLog\r
+  !insertmacro InstallFolder mozilla\r
+  !insertmacro CloseUninstallLog\r
 \r
   ; doesn't work. bug in mozilla/mozilla firefox or moz documentation (xpt file isn't loaded)\r
   ; see mozilla bugs 184506 and 159445\r
@@ -373,6 +447,9 @@ Section /o "Mozilla plugin" SEC03
     StrCmp $R2 "" "${Index}-Loop" ""\r
 \r
     CopyFiles "$INSTDIR\mozilla\*" "$R2"\r
+    !ifdef LIBVLC_DLL\r
+    CopyFiles ${LIBVLC_DLL} "$R2"\r
+    !endif\r
     Goto "${Index}-Loop"\r
 \r
   "${Index}-End:"\r
@@ -380,15 +457,17 @@ Section /o "Mozilla plugin" SEC03
 \r
 SectionEnd\r
 \r
-Section "ActiveX plugin" SEC04\r
-  SectionIn 2 3\r
+Section /o "ActiveX plugin" SEC04\r
+  SectionIn 1 3\r
   SetOutPath "$INSTDIR"\r
-  File activex\axvlc.dll\r
+  !insertmacro OpenUninstallLog\r
+  !insertmacro InstallFile activex\axvlc.dll\r
+  !insertmacro CloseUninstallLog\r
   RegDLL "$INSTDIR\axvlc.dll"\r
 SectionEnd\r
 \r
-Section "Context Menus" SEC05\r
-  SectionIn 3\r
+Section /o "Context Menus" SEC05\r
+  SectionIn 3\r
   !insertmacro MacroAllExtensions AddContextMenu\r
   !insertmacro AddContextMenu "Directory"\r
 SectionEnd\r
@@ -471,6 +550,59 @@ SectionEnd
 ; Uninstaller sections ;\r
 ;;;;;;;;;;;;;;;;;;;;;;;;\r
 \r
+; TrimNewlines (copied from NSIS documentation)\r
+; input, top of stack  (e.g. whatever$\r$\n)\r
+; output, top of stack (replaces, with e.g. whatever)\r
+; modifies no other variables.\r
+\r
+Function un.TrimNewlines\r
+ Exch $R0\r
+ Push $R1\r
+ Push $R2\r
+ StrCpy $R1 0\r
\r
+ loop:\r
+   IntOp $R1 $R1 - 1\r
+   StrCpy $R2 $R0 1 $R1\r
+   StrCmp $R2 "$\r" loop\r
+   StrCmp $R2 "$\n" loop\r
+   IntOp $R1 $R1 + 1\r
+   IntCmp $R1 0 no_trim_needed\r
+   StrCpy $R0 $R0 $R1\r
\r
+ no_trim_needed:\r
+   Pop $R2\r
+   Pop $R1\r
+   Exch $R0\r
+FunctionEnd\r
+\r
+Function un.RemoveEmptyDirs\r
+  Pop $9\r
+  !define Index 'Line${__LINE__}'\r
+  FindFirst $0 $1 "$INSTDIR$9*"\r
+  StrCmp $0 "" "${Index}-End"\r
+  "${Index}-Loop:"\r
+    StrCmp $1 "" "${Index}-End"\r
+    StrCmp $1 "." "${Index}-Next"\r
+    StrCmp $1 ".." "${Index}-Next"\r
+      Push $0\r
+      Push $1\r
+      Push $9\r
+      Push "$9$1\"\r
+      Call un.RemoveEmptyDirs\r
+      Pop $9\r
+      Pop $1\r
+      Pop $0\r
+    "${Index}-Remove:"\r
+    RMDir "$INSTDIR$9$1"\r
+    "${Index}-Next:"\r
+    FindNext $0 $1\r
+    Goto "${Index}-Loop"\r
+  "${Index}-End:"\r
+  FindClose $0\r
+  !undef Index\r
+FunctionEnd\r
+\r
 Section "Uninstall" SEC91\r
   SectionIn 1 2 3 RO\r
   SetShellVarContext all\r
@@ -508,7 +640,25 @@ Section "Uninstall" SEC91
 \r
   RMDir "$SMPROGRAMS\VideoLAN"\r
   RMDir /r $SMPROGRAMS\VideoLAN\r
-  RMDir /r $INSTDIR\r
+\r
+  FileOpen $UninstallLog "$INSTDIR\uninstall.log" r\r
+  UninstallLoop:\r
+    ClearErrors\r
+    FileRead $UninstallLog $R0\r
+    IfErrors UninstallEnd\r
+    Push $R0\r
+    Call un.TrimNewLines\r
+    Pop $R0\r
+    Delete "$INSTDIR\$R0"\r
+    Goto UninstallLoop\r
+  UninstallEnd:\r
+  FileClose $UninstallLog\r
+  Delete "$INSTDIR\uninstall.log"\r
+  Delete "$INSTDIR\uninstall.exe"\r
+  Push "\"\r
+  Call un.RemoveEmptyDirs\r
+  RMDir "$INSTDIR"\r
+\r
   DeleteRegKey HKLM Software\VideoLAN\r
 \r
   DeleteRegKey HKCR Applications\vlc.exe\r
@@ -534,6 +684,7 @@ Section "Uninstall" SEC91
 SectionEnd\r
 \r
 Section /o "un.Delete preferences and cache" SEC92\r
+  SectionIn 1 3\r
   !insertmacro delprefs\r
 SectionEnd\r
 \r