diff options
Diffstat (limited to 'windows_installer')
-rw-r--r-- | windows_installer/build.bat | 111 | ||||
-rw-r--r-- | windows_installer/installer.directory.ini | 56 | ||||
-rw-r--r-- | windows_installer/installer.nsi | 651 | ||||
-rw-r--r-- | windows_installer/installer.upgrade.ini | 28 | ||||
-rw-r--r-- | windows_installer/installer.warning.rtf | 8 | ||||
-rw-r--r-- | windows_installer/template.nlf | 189 | ||||
-rw-r--r-- | windows_installer/template.nsh | 12 | ||||
-rw-r--r-- | windows_installer/winmakei18n.py | 37 | ||||
-rw-r--r-- | windows_installer/winprepnsi.py | 98 | ||||
-rw-r--r-- | windows_installer/winsetup.py | 111 |
10 files changed, 1301 insertions, 0 deletions
diff --git a/windows_installer/build.bat b/windows_installer/build.bat new file mode 100644 index 0000000..b7dc671 --- /dev/null +++ b/windows_installer/build.bat @@ -0,0 +1,111 @@ +@rem The contents of this file are subject to the BitTorrent Open Source License +@rem Version 1.0 (the License). You may not copy or use this file, in either +@rem code or executable form, except in compliance with the License. You +@rem may obtain a copy of the License at http://www.bittorrent.com/license/. +@rem +@rem Software distributed under the License is distributed on an AS IS basis, +@rem WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +@rem for the specific language governing rights and limitations under the +@rem License. + +@rem For Python 2.3: +@rem set PYTHON=python23 +@rem For Python 2.4: +set PYTHON=Python24 + +@rem For GTK 2.4: +@rem set WIMP_DIR_NAME=wimp +@rem For GTK 2.6 and 2.8: +set WIMP_DIR_NAME=MS-Windows + +@rem copy the important files to the root, so we don't have to hardcode paths +@rem all over the place + +@if exist "windows_installer\build.bat" goto continue +@echo You must run build.bat from within the root directory +:continue + +cd windows_installer + +copy winsetup.py .. +copy winmakei18n.py .. +copy installer.directory.ini .. +copy installer.upgrade.ini .. +copy installer.warning.rtf .. + +cd .. + +del /F /S /Q build dist +c:\%PYTHON%\python.exe winmakei18n.py +@if errorlevel 1 goto error +c:\%PYTHON%\python.exe winsetup.py py2exe +@if errorlevel 1 goto error + +copy %GTK_BASEPATH%\bin\libpng12.dll dist\ +@if errorlevel 1 goto error +copy %GTK_BASEPATH%\bin\zlib1.dll dist\ +@if errorlevel 1 goto error +copy %GTK_BASEPATH%\bin\libpangoft2-1.0-0.dll dist\ +@if errorlevel 1 goto error +@rem I don't think this is needed: +@rem copy %GTK_BASEPATH%\bin\libxml2.dll dist\ + +mkdir dist\etc\pango +copy %GTK_BASEPATH%\etc\pango dist\etc\pango +@if errorlevel 1 goto error + +mkdir dist\etc\gtk-2.0\ +copy %GTK_BASEPATH%\etc\gtk-2.0\gdk-pixbuf.loaders dist\etc\gtk-2.0 +@if errorlevel 1 goto error + +mkdir dist\lib\gtk-2.0\2.4.0\loaders +copy %GTK_BASEPATH%\lib\gtk-2.0\2.4.0\loaders\libpixbufloader-png.dll dist\lib\gtk-2.0\2.4.0\loaders +@if errorlevel 1 goto error +copy %GTK_BASEPATH%\lib\gtk-2.0\2.4.0\loaders\libpixbufloader-xpm.dll dist\lib\gtk-2.0\2.4.0\loaders +@if errorlevel 1 goto error +copy %GTK_BASEPATH%\lib\gtk-2.0\2.4.0\loaders\libpixbufloader-ico.dll dist\lib\gtk-2.0\2.4.0\loaders +@if errorlevel 1 goto error + +mkdir dist\lib\pango\1.4.0\modules +copy %GTK_BASEPATH%\lib\pango\1.4.0\modules\pango-basic-win32.dll dist\lib\pango\1.4.0\modules\ +@if errorlevel 1 goto error +copy %GTK_BASEPATH%\lib\pango\1.4.0\modules\pango-basic-fc.dll dist\lib\pango\1.4.0\modules\ +@if errorlevel 1 goto error + +@rem This never could have been working. 'copy' does not recurse subdirectories +@rem I think the task this is supposed to accomplish is in winsetup.py +@rem copy %GTK_BASEPATH%\lib\locale dist\lib\ +@rem @if errorlevel 1 goto error + +copy %GTK_BASEPATH%\etc\gtk-2.0\gtkrc dist\etc\gtk-2.0 +@if errorlevel 1 goto error +mkdir dist\lib\gtk-2.0\2.4.0\engines +copy %GTK_BASEPATH%\lib\gtk-2.0\2.4.0\engines\libwimp.dll dist\lib\gtk-2.0\2.4.0\engines +@if errorlevel 1 goto error + +mkdir dist\share\themes\%WIMP_DIR_NAME%\gtk-2.0 +copy %GTK_BASEPATH%\share\themes\%WIMP_DIR_NAME%\gtk-2.0\gtkrc dist\share\themes\%WIMP_DIR_NAME%\gtk-2.0 +@if errorlevel 1 goto error + +c:\%PYTHON%\python.exe windows_installer\winprepnsi.py windows_installer\installer.nsi installer.temp.nsi +@if errorlevel 1 goto error +"C:\Program Files\NSIS\makensis.exe" installer.temp.nsi +@if errorlevel 1 goto error +del installer.temp.nsi +@if errorlevel 1 goto error + +@rem cleanup +del winsetup.py +del winmakei18n.py +del installer.directory.ini +del installer.upgrade.ini +del installer.warning.rtf + + +@goto done + +:error +@echo ------------------------------------------------------------------------------- +@echo Build failed. + +:done
\ No newline at end of file diff --git a/windows_installer/installer.directory.ini b/windows_installer/installer.directory.ini new file mode 100644 index 0000000..d56f2c2 --- /dev/null +++ b/windows_installer/installer.directory.ini @@ -0,0 +1,56 @@ +[Field 1]
+Type=Label
+Text=Setup will install $5 in the following folder. To install in a different folder, click Browse and select another folder. Click Next to continue.
+Left=0
+Right=-1
+Top=0
+Bottom=30
+
+[Field 2]
+Type=Label
+Text=Select the install type:
+Left=0
+Right=80
+Top=40
+Bottom=56
+
+[Field 3]
+Type=DropList
+ListItems=Default Install|Custom Location
+State=Default Install
+Notify=ONSELCHANGE
+Left=80
+Right=-80
+Top=38
+Bottom=94
+
+[Field 4]
+Type=GroupBox
+Text=Destination Folder
+Left=0
+Right=-1
+Top=70
+Bottom=105
+
+[Field 5]
+Type=Text
+State=$4
+Left=10
+Right=-75
+Top=85
+Bottom=97
+
+[Field 6]
+Type=Button
+Flags=DIRREQUEST
+Text=B&rowse...
+Notfy=ONCLICK
+ListItems=Select the folder to install $5 in:
+RefFields=5
+Notify=ONCLICK
+State=$4
+Left=-67
+Right=-12
+Top=83
+Bottom=98
+
diff --git a/windows_installer/installer.nsi b/windows_installer/installer.nsi new file mode 100644 index 0000000..92bc282 --- /dev/null +++ b/windows_installer/installer.nsi @@ -0,0 +1,651 @@ +# The contents of this file are subject to the BitTorrent Open Source License +# Version 1.0 (the License). You may not copy or use this file, in either +# source code or executable form, except in compliance with the License. You +# may obtain a copy of the License at http://www.bittorrent.com/license/. +# +# Software distributed under the License is distributed on an AS IS basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. + +# Written by Bram Cohen, Matt Chisholm and Greg Hazel + + +;-------------------------------- +;Include Modern UI + +!include "MUI.nsh" + + +; replaced by winprepnsi.py +!define VERSION "%VERSION%" +!define APPNAME "%APP_NAME%" + +Outfile ${APPNAME}-${VERSION}.exe +Name "${APPNAME}" + +;SilentInstall silent + +; automatically close the installer when done. +;AutoCloseWindow true + +CRCCheck on + +SetCompressor /SOLID lzma + +; adds xp style support +XPStyle on + +InstProgressFlags smooth +InstallDir "$PROGRAMFILES\${APPNAME}\" +; " this fixes syntax highlighting in xemacs :) + +!define EXENAME "bittorrent.exe" +VAR KILLEXENAME +VAR UPGRADE + +!define MUI_ICON "images\bittorrent.ico" +;!define MUI_UNICON "images\bittorrent.ico" + +!define MUI_LANGDLL_ALWAYSSHOW +!define MUI_LANGDLL_REGISTRY_ROOT HKCU +!define MUI_LANGDLL_REGISTRY_KEY "Software\BitTorrent" +!define MUI_LANGDLL_REGISTRY_VALUENAME "Language" + +;-------------------------------- +;Pages + + Page custom installer.upgrade + Page custom uninstall + +!define MUI_PAGE_CUSTOMFUNCTION_SHOW disableBackButton +!define MUI_PAGE_HEADER_TEXT "Warning" +!define MUI_PAGE_HEADER_SUBTEXT "From ${APPNAME}" +!define MUI_LICENSEPAGE_TEXT_TOP "${APPNAME} is 100% FREE, and it always will be." +!define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)" +!define MUI_LICENSEPAGE_TEXT_BOTTOM " " + !insertmacro MUI_PAGE_LICENSE "installer.warning.rtf" + + Page custom installer.directory installer.directory.leave + + !define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "${APPNAME} has been successfully installed!" + !insertmacro MUI_PAGE_INSTFILES + +!define MUI_FINISHPAGE_TITLE "${APPNAME} Setup Complete" +!define MUI_FINISHPAGE_RUN "$INSTDIR\bittorrent.exe" +; this is an opt-in url, we want to make it opt-out +;!define MUI_FINISHPAGE_LINK "http://search.bittorrent.com" +;!define MUI_FINISHPAGE_LINK_LOCATION http://search.bittorrent.com +; so we hi-jack the readme option +!define MUI_FINISHPAGE_SHOWREADME_TEXT "&Visit http://search.bittorrent.com to search for torrents!" +!define MUI_FINISHPAGE_SHOWREADME http://search.bittorrent.com + +!define MUI_FINISHPAGE_NOREBOOTSUPPORT + !insertmacro MUI_PAGE_FINISH + + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Languages +%LANG_MACROS% + +; example: +;LangString TEXT_FOO ${LANG_ENGLISH} "Foo thing in English" + + +;-------------------------------- +;Reserve Files + + ;Things that need to be extracted on first (keep these lines before any File command!) + ;Only for BZIP2 compression + + ReserveFile "installer.upgrade.ini" + ReserveFile "installer.directory.ini" + !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS + +Var HWND +Var DLGITEM + +Function uninstall + + ;; IMPORTANT: We cannot ever run any old installers, because they might delete the + ;; old installation directory, including any data the user might have stored there. + ;; Newer uninstallers play nice, but we cannot tell them apart. + + ; check here too, since this page is run either way + ;Call GetUninstallString + ;Pop $R0 + + ;StrCmp $R0 "" nextuninst + + ;;Run the uninstaller + ;;Do not copy the uninstaller to a temp file + ;ExecWait '$R0 /S' + ;IfErrors 0 nextuninst + ;ExecWait '$R0 /S' + ;Sleep 2000 + ;IfErrors no_remove_uninstaller + ;Goto nextuninst + ;no_remove_uninstaller: + ; Call MagicUninstall + + nextuninst: + Call QuitIt + ClearErrors + Delete $INSTDIR\btdownloadgui.exe + IfErrors deleteerror + Delete $INSTDIR\btmaketorrentgui.exe + IfErrors deleteerror + Delete $INSTDIR\bittorrent.exe + IfErrors deleteerror + Delete $INSTDIR\maketorrent.exe + IfErrors deleteerror + Delete $INSTDIR\choose_language.exe + IfErrors deleteerror + goto endofdelete + deleteerror: + MessageBox MB_OK "Removing old BitTorrent exe files failed. You must quit BitTorrent and uninstall it before installing this version." + Abort + endofdelete: + + Call MagicUninstall + + endofuninst: +FunctionEnd + +Function installer.upgrade + !insertmacro MUI_HEADER_TEXT "Upgrade" "${APPNAME} ${VERSION}" + + !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "installer.upgrade.ini" + Pop $HWND ;HWND of dialog + + GetDlgItem $DLGITEM $HWND 1200 ;1200 + Field number - 1 + SendMessage $DLGITEM ${WM_SETTEXT} 0 "STR:A version of ${APPNAME} is already installed." + + GetDlgItem $DLGITEM $HWND 1201 ;1200 + Field number - 1 + SendMessage $DLGITEM ${WM_SETTEXT} 0 "STR:This installer will upgrade to ${APPNAME} ${VERSION}." + + !insertmacro MUI_INSTALLOPTIONS_SHOW +FunctionEnd + +Function installer.directory + + StrCmp $UPGRADE "no" OK + Abort + + OK: + + !insertmacro MUI_HEADER_TEXT "Choose Install Location" "Choose the folder in which to install ${APPNAME}" + + StrCpy $4 $INSTDIR + StrCpy $5 ${APPNAME} + + InstallOptionsEx::initDialog /NOUNLOAD "$PLUGINSDIR\installer.directory.ini" + + Pop $hwnd ;HWND of dialog + + !insertmacro MUI_INSTALLOPTIONS_READ $0 "installer.directory.ini" "Field 3" "State" + StrCmp $0 "Default Install" 0 show + GetDlgItem $DLGITEM $hwnd 1204 + EnableWindow $DLGITEM 0 + GetDlgItem $DLGITEM $hwnd 1205 + EnableWindow $DLGITEM 0 + + show: + InstallOptionsEx::show + Pop $R0 +FunctionEnd + +Function installer.directory.leave + ; At this point the user has either pressed Next or one of our custom buttons + ; We find out which by reading from the INI file + !insertmacro MUI_INSTALLOPTIONS_READ $0 "installer.directory.ini" "Settings" "State" + StrCmp $0 0 page + StrCmp $0 3 droplist + Abort ; Return to the page + +droplist: + ; Make the DirRequest field depend on the droplist + !insertmacro MUI_INSTALLOPTIONS_READ $0 "installer.directory.ini" "Field 3" "State" + StrCmp $0 "Custom Location" +3 + StrCpy $0 0 + Goto +2 + StrCpy $0 1 + GetDlgItem $1 $hwnd 1204 ; DirRequest control + EnableWindow $1 $0 + GetDlgItem $1 $hwnd 1205 ; button (the following control) + EnableWindow $1 $0 + Abort ; Return to the page + +page: + !insertmacro MUI_INSTALLOPTIONS_READ $0 "installer.directory.ini" "Settings" "Notify" + StrCmp $0 "ONNEXT" save + Abort + +save: + ; At this point we know the Next button was pressed, so perform any validation and reading + !insertmacro MUI_INSTALLOPTIONS_READ $INSTDIR "installer.directory.ini" "Field 5" "State" + +FunctionEnd + +Function disableBackButton + FindWindow $0 "#32770" "" $HWNDPARENT + GetDlgItem $1 $HWNDPARENT 3 ; back button + ShowWindow $1 ${SW_HIDE} +FunctionEnd + +; This function ensures that you have administrator privileges +; it is copied from: +;http://nsis.sourceforge.net/archive/viewpage.php?pageid=275 +Function IsUserAdmin + Push $R0 + Push $R1 + Push $R2 + + ClearErrors + UserInfo::GetName + IfErrors Win9x + Pop $R1 + UserInfo::GetAccountType + Pop $R2 + + StrCmp $R2 "Admin" 0 Continue + StrCpy $R0 "true" + Goto Done + + Continue: + StrCmp $R2 "" Win9x + StrCpy $R0 "false" + Goto Done + + Win9x: + StrCpy $R0 "true" + + Done: + + Pop $R2 + Pop $R1 + Exch $R0 +FunctionEnd + +!macro GetUninstallString UN +Function ${UN}GetUninstallString + ReadRegStr $R0 HKLM \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \ + "UninstallString" + Push $R0 +FunctionEnd +!macroend + +!macro GetOldPath UN +Function ${UN}GetOldPath + Call ${UN}GetUninstallString + + Pop $0 + + StrCpy $1 $0 1 0 ; get firstchar + StrCmp $1 '"' "" getparent + ; if first char is ", let's remove "s first. + StrCpy $0 $0 "" 1 + StrCpy $1 0 + rqloop: + StrCpy $2 $0 1 $1 + StrCmp $2 '"' rqdone + StrCmp $2 "" rqdone + IntOp $1 $1 + 1 + Goto rqloop + rqdone: + StrCpy $0 $0 $1 + getparent: + ; the uninstall string goes to an EXE, lets get the directory. + StrCpy $1 -1 + gploop: + StrCpy $2 $0 1 $1 + StrCmp $2 "" gpexit + StrCmp $2 "\" gpexit + #"emacs + IntOp $1 $1 - 1 + Goto gploop + gpexit: + StrCpy $0 $0 $1 + + Push $0 + +FunctionEnd +!macroend + +!macro CheckForIt UN +Function ${UN}CheckForIt + + Processes::FindProcess $KILLEXENAME + StrCmp $R0 "1" foundit didntfindit + + foundit: + MessageBox MB_OKCANCEL "You must quit ${APPNAME} ($KILLEXENAME) \ + before installing this version.$\r$\nPlease quit it and press \ + OK to continue." IDOK tryagain + Abort + + tryagain: + + Sleep 2000 + Processes::FindProcess $KILLEXENAME + StrCmp $R0 "1" stillthere didntfindit + + stillthere: + MessageBox MB_OKCANCEL "There is still a copy of ${APPNAME} \ + ($KILLEXENAME) running.$\r$\nPress OK to force-quit the application, \ + or Cancel to exit." IDOK killit + Abort + + killit: + KillProcDLL::KillProc $KILLEXENAME + Sleep 1000 + + didntfindit: + +FunctionEnd +!macroend + +!macro QuitIt UN +Function ${UN}QuitIt + StrCpy $KILLEXENAME "btdownloadgui.exe" + Call ${UN}CheckForIt + StrCpy $KILLEXENAME "bittorrent.exe" + Call ${UN}CheckForIt + StrCpy $KILLEXENAME "btmaketorrentgui.exe" + Call ${UN}CheckForIt + StrCpy $KILLEXENAME "maketorrent.exe" + Call ${UN}CheckForIt + StrCpy $KILLEXENAME "choose_language.exe" + Call ${UN}CheckForIt + StrCpy $KILLEXENAME "" +FunctionEnd +!macroend + +!macro MagicUninstall UN +Function ${UN}MagicUninstall + ;; this would remove other associations / context menu items too + ; DeleteRegKey HKCR .torrent + ; DeleteRegKey HKCR "MIME\Database\Content Type\application/x-bittorrent" + + ;; disassociate our missing Application manually, windows takes care of the rest + DeleteRegKey HKCR "Applications\${EXENAME}.exe"
+ DeleteRegKey HKLM "Software\Classes\Applications\${EXENAME}.exe" + ; just in case + DeleteRegKey HKCR "Applications\btdownloadgui.exe"
+ DeleteRegKey HKLM "Software\Classes\Applications\btdownloadgui.exe"
+
+ ;; be nice and put back what we removed + ReadRegStr $R1 HKCR "bittorrent\shell\open\command" "backup" + StrCmp $R1 "" delete restore + restore: + WriteRegStr HKCR "bittorrent\shell\open\command" "" $R1 + goto continue + delete: + DeleteRegKey HKCR bittorrent + continue: + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" + + ;; we do not currently restore backups on torrent:// stuff + DeleteRegKey HKCR torrent + + Call ${UN}GetOldPath + Pop $R0 + StrCmp $R0 "" 0 remove + StrCpy $R0 $INSTDIR + remove: + + + ; some users like to store important data in our directory + ; be nice to them + ;RMDir /r "$R0" + + Delete "$R0\*.exe" + Delete "$R0\*.pyd" + Delete "$R0\*.dll" + Delete "$R0\library.zip" + RMDir /r "$R0\images" + RMDir /r "$R0\lib" + RMDir /r "$R0\etc" + RMDir /r "$R0\share" + RMDir /r "$R0\locale" + Delete "$R0\redirdonate.html" + Delete "$R0\credits.txt" + Delete "$R0\credits-l10n.txt" + Delete "$R0\LICENSE.txt" + Delete "$R0\README.txt" + Delete "$R0\TRACKERLESS.txt" + Delete "$R0\public.key" + + ClearErrors + RMDir "$R0" + + IfErrors 0 dontwarn + MessageBox MB_OK "Not deleting $R0,$\r$\nbecause there are extra files or directories in it, or it is in use." + dontwarn: + + SetShellVarContext current + Delete "$SMSTARTUP\${APPNAME}.lnk" + + SetShellVarContext all + Delete "$DESKTOP\${APPNAME}.lnk" + RMDir /r "$SMPROGRAMS\${APPNAME}" + +FunctionEnd +!macroend + +;awesome voodoo +!insertmacro CheckForIt "" +!insertmacro CheckForIt "un." + +!insertmacro QuitIt "" +!insertmacro QuitIt "un." + +!insertmacro GetUninstallString "" +!insertmacro GetUninstallString "un." + +!insertmacro GetOldPath "" +!insertmacro GetOldPath "un." + +!insertmacro MagicUninstall "" +!insertmacro MagicUninstall "un." + +Function .onInit + BringToFront + + ;Language selection dialog + !insertmacro MUI_LANGDLL_DISPLAY + + Call QuitIt + ClearErrors + + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer.directory.ini" + + ; check for an installed copy, and add the upgrade page if needed + Call GetOldPath + Pop $R0 + StrCmp $R0 "" notupgrading + StrCpy $UPGRADE "yes" + StrCpy $INSTDIR $R0 + + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer.upgrade.ini" + + Goto done + notupgrading: + StrCpy $UPGRADE "no" + done: +FunctionEnd + +Section "Install" SecInstall + SectionIn 1 2 + + Call IsUserAdmin + Pop $R0 + StrCmp $R0 "false" abortinstall continueinstall + + abortinstall: + MessageBox MB_OK "You must have Administrator privileges to install ${APPNAME}." + Goto endofinstall + + continueinstall: + + SetOverwrite try + + SetOutPath $INSTDIR + WriteUninstaller "$INSTDIR\uninstall.exe" + + IntFmt $0 "%u" 0 + + goto skip + files: + IntOp $0 $0 + 1 + IntCmp $0 30 ohcrap + Sleep 1000 + skip: + + File dist\*.exe + IfErrors files + File dist\*.pyd + IfErrors files + File dist\*.dll + IfErrors files + File dist\library.zip + IfErrors files + File /r dist\images + IfErrors files + File /r dist\lib + IfErrors files + File /r dist\etc + IfErrors files + File /r dist\share + IfErrors files + File /r dist\locale + IfErrors files + File redirdonate.html + IfErrors files + File credits.txt + IfErrors files + File credits-l10n.txt + IfErrors files + File LICENSE.txt + IfErrors files + File README.txt + IfErrors files + File TRACKERLESS.txt + IfErrors files + File public.key + IfErrors files + + goto success + ohcrap: + MessageBox MB_OK "While installing BitTorrent, a critical timeout occured. Please reboot, and retry the installer." + Abort + success: + + ; registry entries + + ; in super old versions of BitTorrent (2.x) some Bad Things were done. + ; if we don not clean them up before installing, users get "Invalid Menu Handle" + ; after upgrading. + DeleteRegKey HKCR "torrent_auto_file" + DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.torrent\" "ProgId"
+
+ ; this guards against a reinstallation to a different directory (like d:\...) causing Invalid Menu Handle
+ DeleteRegKey HKCR "Applications\btdownloadgui.exe"
+ DeleteRegKey HKCR "Applications\bittorrent.exe"
+ DeleteRegKey HKCR "Applications\${EXENAME}" + DeleteRegKey HKLM "Software\Classes\Applications\btdownloadgui.exe"
+ DeleteRegKey HKLM "Software\Classes\Applications\bittorrent.exe"
+ DeleteRegKey HKLM "Software\Classes\Applications\${EXENAME}" + + ;; make us the default handler for BT files + WriteRegStr HKCR .torrent "" bittorrent + DeleteRegKey HKCR ".torrent\Content Type" + ;; This line maks it so that BT sticks around as an option + ;; after installing some other default handler for torrent files + WriteRegStr HKCR ".torrent\OpenWithProgids" "bittorrent" "" + + ; this prevents user-preference from generating "Invalid Menu Handle" by looking for an app + ; that no longer exists, and instead points it at us. + WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.torrent\" Application "${EXENAME}"
+ WriteRegStr HKCR "Applications\${EXENAME}\shell" "" open
+ WriteRegStr HKCR "Applications\${EXENAME}\shell\open\command" "" `"$INSTDIR\${EXENAME}" --responsefile "%1"` + + ;; Add a mime type + WriteRegStr HKCR "MIME\Database\Content Type\application/x-bittorrent" Extension .torrent + + ;; Add a shell command to match the 'bittorrent' handler described above + WriteRegStr HKCR bittorrent "" "TORRENT File" + WriteRegBin HKCR bittorrent EditFlags 00000100 + ;; make us the default handler for bittorrent:// + WriteRegBin HKCR bittorrent "URL Protocol" 0 + WriteRegStr HKCR "bittorrent\Content Type" "" "application/x-bittorrent" + WriteRegStr HKCR "bittorrent\DefaultIcon" "" "$INSTDIR\${EXENAME},0" + WriteRegStr HKCR "bittorrent\shell" "" open + + ReadRegStr $R1 HKCR "bittorrent\shell\open\command" "" + StrCmp $R1 "" continue + + WriteRegStr HKCR "bittorrent\shell\open\command" "backup" $R1 + +continue: + WriteRegStr HKCR "bittorrent\shell\open\command" "" `"$INSTDIR\${EXENAME}" --responsefile "%1"` + + ;; Add a shell command to handle torrent:// stuff + WriteRegStr HKCR torrent "" "TORRENT File" + WriteRegBin HKCR torrent EditFlags 00000100 + ;; make us the default handler for torrent:// + WriteRegBin HKCR torrent "URL Protocol" 0 + WriteRegStr HKCR "torrent\Content Type" "" "application/x-bittorrent" + WriteRegStr HKCR "torrent\DefaultIcon" "" "$INSTDIR\${EXENAME},0" + WriteRegStr HKCR "torrent\shell" "" open + + ReadRegStr $R1 HKCR "torrent\shell\open\command" "" + WriteRegStr HKCR "torrent\shell\open\command" "backup" $R1 + + WriteRegStr HKCR "torrent\shell\open\command" "" `"$INSTDIR\${EXENAME}" --responsefile "%1"` + + ;; Automagically register with the Windows Firewall + WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List" "$INSTDIR\${EXENAME}" `$INSTDIR\${EXENAME}:*:Enabled:${APPNAME}` + + ;; Info about install/uninstall + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME} ${VERSION}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" '"$INSTDIR\uninstall.exe"' + + ; Add items to start menu + SetShellVarContext current + CreateShortCut "$SMSTARTUP\${APPNAME}.lnk" "$INSTDIR\${EXENAME}" + + ; Create desktop link + SetShellVarContext all + CreateShortCut "$DESKTOP\${APPNAME}.lnk" "$INSTDIR\${EXENAME}" + + CreateDirectory "$SMPROGRAMS\${APPNAME}" + CreateShortCut "$SMPROGRAMS\${APPNAME}\Downloader.lnk" "$INSTDIR\${EXENAME}" + CreateShortCut "$SMPROGRAMS\${APPNAME}\Make Torrent.lnk" "$INSTDIR\maketorrent.exe" + CreateShortCut "$SMPROGRAMS\${APPNAME}\Donate.lnk" "$INSTDIR\redirdonate.html" + CreateShortCut "$SMPROGRAMS\${APPNAME}\Choose Language.lnk" "$INSTDIR\choose_language.exe" + + IfSilent launch_anyway not_silent + launch_anyway: + ExecShell open "$INSTDIR\${EXENAME}" + not_silent: + + BringToFront + endofinstall: +SectionEnd + +Function un.onInit + ;; gets the stored language from install + !insertmacro MUI_UNGETLANGUAGE +FunctionEnd + +Section "Uninstall" + Call un.QuitIt + ; this should not go in MagicUninstall + ; because we want to keep the preference between upgrades + DeleteRegKey HKCU "Software\BitTorrent\Language" + Call un.MagicUninstall +SectionEnd diff --git a/windows_installer/installer.upgrade.ini b/windows_installer/installer.upgrade.ini new file mode 100644 index 0000000..f247dd1 --- /dev/null +++ b/windows_installer/installer.upgrade.ini @@ -0,0 +1,28 @@ +[Settings]
+NumFields=2
+NextButtonText=Upgrade
+
+[Field 1]
+Type=label
+Text="A version of BitTorrent is already installed."
+Left=0
+Right=-1
+Top=0
+Bottom=15
+
+[Field 2]
+Type=label
+Text="This installer will upgrade your version."
+Left=0
+Right=-1
+Top=15
+Bottom=25
+
+[Field 3]
+Type=Radiobutton
+Text=Upgrade
+Left=0
+Right=-1
+Top=60
+Bottom=70
+State=1
\ No newline at end of file diff --git a/windows_installer/installer.warning.rtf b/windows_installer/installer.warning.rtf new file mode 100644 index 0000000..e816cff --- /dev/null +++ b/windows_installer/installer.warning.rtf @@ -0,0 +1,8 @@ +{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Tahoma;}{\f1\froman\fprq2\fcharset2 Symbol;}}
+{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs16 Some malicious websites are charging money for BitTorrent, committing credit card fraud, and infecting computers with malicious software. If you did not download this copy of BitTorrent from http://www.bittorrent.com/ PROTECT YOURSELF NOW!\par
+\par
+\pard\fi-360\li1080\tx1080\f1\'b7\tab\f0 Check your computer for malicious software.\par
+\f1\'b7\tab\f0 Check your credit card bill for unauthorized charges\par
+\f1\'b7\tab\f0 Cancel the installation NOW and download BitTorrent for free from http://www.bittorrent.com/ \par
+}
+
\ No newline at end of file diff --git a/windows_installer/template.nlf b/windows_installer/template.nlf new file mode 100644 index 0000000..6564e56 --- /dev/null +++ b/windows_installer/template.nlf @@ -0,0 +1,189 @@ +# Header, don't edit
+NLF v6
+# Language ID
+%(id)s
+# Font and size - dash (-) means default
+-
+-
+# Codepage - dash (-) means ANSI code page
+-
+# RTL - anything else than RTL means LTR
+-
+# ^Branding
+Nullsoft Install System %%s
+# ^SetupCaption
+$(^Name) Setup
+# ^UninstallCaption
+$(^Name) Uninstall
+# ^LicenseSubCaption
+: License Agreement
+# ^ComponentsSubCaption
+: Installation Options
+# ^DirSubCaption
+: Installation Folder
+# ^InstallingSubCaption
+: Installing
+# ^CompletedSubCaption
+: Completed
+# ^UnComponentsSubCaption
+: Uninstallation Options
+# ^UnDirSubCaption
+: Uninstallation Folder
+# ^ConfirmSubCaption
+: Confirmation
+# ^UninstallingSubCaption
+: Uninstalling
+# ^UnCompletedSubCaption
+: Completed
+# ^BackBtn
+< &Back
+# ^NextBtn
+&Next >
+# ^AgreeBtn
+I &Agree
+# ^AcceptBtn
+I &accept the terms in the License Agreement
+# ^DontAcceptBtn
+I &do not accept the terms in the License Agreement
+# ^InstallBtn
+&Install
+# ^UninstallBtn
+&Uninstall
+# ^CancelBtn
+Cancel
+# ^CloseBtn
+&Close
+# ^BrowseBtn
+B&rowse...
+# ^ShowDetailsBtn
+Show &details
+# ^ClickNext
+Click Next to continue.
+# ^ClickInstall
+Click Install to start the installation.
+# ^ClickUninstall
+Click Uninstall to start the uninstallation.
+# ^Name
+Name
+# ^Completed
+Completed
+# ^LicenseText
+Please review the license agreement before installing $(^NameDA). If you accept all terms of the agreement, click I Agree.
+# ^LicenseTextCB
+Please review the license agreement before installing $(^NameDA). If you accept all terms of the agreement, click the check box below. $_CLICK
+# ^LicenseTextRB
+Please review the license agreement before installing $(^NameDA). If you accept all terms of the agreement, select the first option below. $_CLICK
+# ^UnLicenseText
+Please review the license agreement before uninstalling $(^NameDA). If you accept all terms of the agreement, click I Agree.
+# ^UnLicenseTextCB
+Please review the license agreement before uninstalling $(^NameDA). If you accept all terms of the agreement, click the check box below. $_CLICK
+# ^UnLicenseTextRB
+Please review the license agreement before uninstalling $(^NameDA). If you accept all terms of the agreement, select the first option below. $_CLICK
+# ^Custom
+Custom
+# ^ComponentsText
+Check the components you want to install and uncheck the components you don't want to install. $_CLICK
+# ^ComponentsSubText1
+Select the type of install:
+# ^ComponentsSubText2_NoInstTypes
+Select components to install:
+# ^ComponentsSubText2
+Or, select the optional components you wish to install:
+# ^UnComponentsText
+Check the components you want to uninstall and uncheck the components you don't want to uninstall. $_CLICK
+# ^UnComponentsSubText1
+Select the type of uninstall:
+# ^UnComponentsSubText2_NoInstTypes
+Select components to uninstall:
+# ^UnComponentsSubText2
+Or, select the optional components you wish to uninstall:
+# ^DirText
+Setup will install $(^NameDA) in the following folder. To install in a different folder, click Browse and select another folder. $_CLICK
+# ^DirSubText
+Destination Folder
+# ^DirBrowseText
+Select the folder to install $(^NameDA) in:
+# ^UnDirText
+Setup will uninstall $(^NameDA) from the following folder. To uninstall from a different folder, click Browse and select another folder. $_CLICK
+# ^UnDirSubText
+""
+# ^UnDirBrowseText
+Select the folder to uninstall $(^NameDA) from:
+# ^SpaceAvailable
+"Space available: "
+# ^SpaceRequired
+"Space required: "
+# ^UninstallingText
+$(^NameDA) will be uninstalled from the following folder. $_CLICK
+# ^UninstallingSubText
+Uninstalling from:
+# ^FileError
+Error opening file for writing: \r\n\r\n$0\r\n\r\nClick Abort to stop the installation,\r\nRetry to try again, or\r\nIgnore to skip this file.
+# ^FileError_NoIgnore
+Error opening file for writing: \r\n\r\n$0\r\n\r\nClick Retry to try again, or\r\nCancel to stop the installation.
+# ^CantWrite
+"Can't write: "
+# ^CopyFailed
+Copy failed
+# ^CopyTo
+"Copy to "
+# ^Registering
+"Registering: "
+# ^Unregistering
+"Unregistering: "
+# ^SymbolNotFound
+"Could not find symbol: "
+# ^CouldNotLoad
+"Could not load: "
+# ^CreateFolder
+"Create folder: "
+# ^CreateShortcut
+"Create shortcut: "
+# ^CreatedUninstaller
+"Created uninstaller: "
+# ^Delete
+"Delete file: "
+# ^DeleteOnReboot
+"Delete on reboot: "
+# ^ErrorCreatingShortcut
+"Error creating shortcut: "
+# ^ErrorCreating
+"Error creating: "
+# ^ErrorDecompressing
+Error decompressing data! Corrupted installer?
+# ^ErrorRegistering
+Error registering DLL
+# ^ExecShell
+"ExecShell: "
+# ^Exec
+"Execute: "
+# ^Extract
+"Extract: "
+# ^ErrorWriting
+"Extract: error writing to file "
+# ^InvalidOpcode
+Installer corrupted: invalid opcode
+# ^NoOLE
+"No OLE for: "
+# ^OutputFolder
+"Output folder: "
+# ^RemoveFolder
+"Remove folder: "
+# ^RenameOnReboot
+"Rename on reboot: "
+# ^Rename
+"Rename: "
+# ^Skipped
+"Skipped: "
+# ^CopyDetails
+Copy Details To Clipboard
+# ^LogInstall
+Log install process
+# ^Byte
+B
+# ^Kilo
+K
+# ^Mega
+M
+# ^Giga
+G
diff --git a/windows_installer/template.nsh b/windows_installer/template.nsh new file mode 100644 index 0000000..a2e54da --- /dev/null +++ b/windows_installer/template.nsh @@ -0,0 +1,12 @@ +;NSIS Modern User Interface - Language File
+;Compatible with Modern UI 1.68
+
+;Language: %(name)s (%(id)s)
+
+;--------------------------------
+
+!insertmacro MUI_LANGUAGEFILE_BEGIN "%(name)s"
+
+ !define MUI_LANGNAME "%(name)s" ;Use only ASCII characters (if this is not possible, use the English name)
+
+!insertmacro MUI_LANGUAGEFILE_END
diff --git a/windows_installer/winmakei18n.py b/windows_installer/winmakei18n.py new file mode 100644 index 0000000..5bfe298 --- /dev/null +++ b/windows_installer/winmakei18n.py @@ -0,0 +1,37 @@ +# The contents of this file are subject to the BitTorrent Open Source License +# Version 1.0 (the License). You may not copy or use this file, in either +# source code or executable form, except in compliance with the License. You +# may obtain a copy of the License at http://www.bittorrent.com/license/. +# +# Software distributed under the License is distributed on an AS IS basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. + +# Written by Matt Chisholm + +import os +import sys +from BitTorrent import languages, language_names +GNUWIN_BIN = r'C:\Program Files\GnuWin32\bin' + +if os.name != 'nt': + print "This script is only for use on Win32. Use makei18n.sh to regenerate locales on a Unix OS." + sys.exit() + +for l in languages: + print l + #os.system(r'"%s\msgmerge.exe" --no-fuzzy-matching po\%s.po messages.po > locale\%s\LC_MESSAGES\messages.po' % (GNUWIN_BIN,l,l)) + path = 'locale\%s\LC_MESSAGES' % l + if not os.access(path, os.F_OK): + os.system('mkdir %s' % path) + if not os.path.exists(r'po\%s.po' % (l)): + print r'Warning: po\%s.po does not exist.' % (l) + else: + os.system(r'copy po\%s.po %s\bittorrent.po' %(l,path)) + os.system(r'"%s\msgfmt.exe" -o %s\bittorrent.mo %s\bittorrent.po' % (GNUWIN_BIN, path, path)) + + + + + diff --git a/windows_installer/winprepnsi.py b/windows_installer/winprepnsi.py new file mode 100644 index 0000000..b620c00 --- /dev/null +++ b/windows_installer/winprepnsi.py @@ -0,0 +1,98 @@ +import sys +import os +from BitTorrent import version, app_name, languages, language_names +from BitTorrent.language import locale_sucks + +NSIS_DIR = "C:\\Program Files\\NSIS" + +if not os.path.exists(NSIS_DIR): + raise Exception("Please set NSIS_DIR in winprepnsi.py!") + +version_str = version +if int(version_str[2]) % 2: + version_str = version_str + '-Beta' + +nsis_language_names = { + 'af' :'Afrikaans', + 'bg' :'Bulgarian', + 'ca' :'Catalan', + 'cs' :'Czech', + 'da' :'Danish', + 'de' :'German', + 'en' :'English', + 'es' :'Spanish', + 'es_MX' :'SpanishMX', + 'fr' :'French', + 'el' :'Greek', + 'hu' :'Hungarian', + 'he' :'Hebrew', + 'it' :'Italian', + 'is' :'Icelandic', + 'ja' :'Japanese', + 'ko' :'Korean', + 'nb_NO' :'Norwegian', + 'nl' :'Dutch', + 'pl' :'Polish', + 'pt' :'Portuguese', + 'pt_BR' :'PortugueseBR', + 'ro' :'Romanian', + 'ru' :'Russian', + 'sk' :'Slovak', + 'sl' :'Slovenian', + 'sv' :'Swedish', + 'tr' :'Turkish', + 'vi' :'Vietnamese', + 'zh_CN' :'TradChinese', + 'zh_TW' :'SimpChinese', + } + + + +f = open(sys.argv[1]) +b = f.read() +f.close() +b = b.replace("%VERSION%", version_str) +b = b.replace("%APP_NAME%", app_name) + +found_langs = {} +lang_macros = "" +for l in languages: + lang = nsis_language_names[l] + nlf = os.path.join(NSIS_DIR, "Contrib\\Language files\\%s.nlf" % lang) + nsh = os.path.join(NSIS_DIR, "Contrib\\Modern UI\\Language files\\%s.nsh" % lang) + if os.path.exists(nlf) and os.path.exists(nsh): + lang_macros += (' !insertmacro MUI_LANGUAGE "%s"\r\n' % lang) + found_langs[l] = lang + else: + lcid = None + for id, code in locale_sucks.iteritems(): + if code.lower() == l.lower(): + lcid = id + + print "Creating a template for", lang, lcid + f = open(nlf, 'w') + template = open("windows_installer\\template.nlf", 'r') + template_str = template.read() + template.close() + t = (template_str % {'id':lcid}) + f.write(t) + f.close() + + f = open(nsh, 'w') + template = open("windows_installer\\template.nsh", 'r') + template_str = template.read() + template.close() + t = (template_str % {'name':lang, 'id':lcid}) + f.write(t) + f.close() + + + lang_macros += (' !insertmacro MUI_LANGUAGE "%s"\r\n' % lang) + found_langs[l] = lang + +b = b.replace("%LANG_MACROS%", lang_macros) + +f = open(sys.argv[2], "w") +f.write(b) +f.close() + diff --git a/windows_installer/winsetup.py b/windows_installer/winsetup.py new file mode 100644 index 0000000..4d6f380 --- /dev/null +++ b/windows_installer/winsetup.py @@ -0,0 +1,111 @@ +# The contents of this file are subject to the BitTorrent Open Source License +# Version 1.0 (the License). You may not copy or use this file, in either +# source code or executable form, except in compliance with the License. You +# may obtain a copy of the License at http://www.bittorrent.com/license/. +# +# Software distributed under the License is distributed on an AS IS basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. + +# Written by Bram Cohen and Matt Chisholm + +import os +import sys +from distutils.core import setup +import py2exe +import glob +from BitTorrent import languages
+ +if os.name != 'nt': + print "This script is only for use on Win32. Use setup.py to install on a Unix OS." + sys.exit() + +from BitTorrent.platform import get_shell_dir, shellcon
+ +opts = { + "py2exe": { + "includes":"pango,atk,gobject" + ",encodings,encodings.*" +# ",cjkcodecs,cjkcodecs.*" +# ",dns,dns.rdtypes.ANY.*,dns.rdtypes.IN.*" + , + +# Uncomment the following lines if you want a dist\ directory build by +# py2exe that works under Win32 with a GTK runtime installed +# separately: +## "dll_excludes":["iconv.dll", "intl.dll", "libatk-1-1.0-0.dll", +## "libgdk_pixbuf-2.0-0.dll", "libgdk-win32-2.0-0.dll", +## "libglib-2.0-0.dll", "libgmodule-2.0-0.dll", +## "libgobject-2.0-0.dll", "libgthread-2.0-0.dll", +## "libgtk-win32-2.0-0.dll", "libpango-1.0-0.dll", +## "libpangowin32-1.0-0.dll", +## ], + } +} + +# needed for py2exe to find win32com.shell; from http://starship.python.net/crew/theller/moin.cgi/WinShell +if 1: + try: + import modulefinder, sys + import win32com + for p in win32com.__path__[1:]: + modulefinder.AddPackagePath("win32com", p) + for extra in ["win32com.shell"]: #,"win32com.mapi" + __import__(extra) + m = sys.modules[extra] + for p in m.__path__[1:]: + modulefinder.AddPackagePath(extra, p) + except ImportError: + # no build path setup, no worries. + pass +
+mfc = os.path.join(get_shell_dir(shellcon.CSIDL_SYSTEM), "mfc71.dll")
+ms = [mfc, ]
+ +translations = [] +for l in languages: + path = os.path.join('locale', l, 'LC_MESSAGES', 'bittorrent.mo') + if os.access(path, os.F_OK): + translations.append(("locale\\%s\\LC_MESSAGES" % l, + ["locale\\%s\\LC_MESSAGES\\bittorrent.mo" % l, + #"locale\\%s\\LC_MESSAGES\\bittorrent.po" % l, + ])) + gtk_mo = [] + + gtk_path = "" + + import gtk + + if (gtk.gtk_version[1] == 4): + gtk_path = os.path.join(os.environ["GTK_BASEPATH"], "lib\\locale\\%s\\LC_MESSAGES" % l) + elif ((gtk.gtk_version[1] == 6) or (gtk.gtk_version[1] == 8)): + gtk_path = os.path.join(os.environ["GTK_BASEPATH"], "share\\locale\\%s\\LC_MESSAGES" % l) + else: + gtk_path = os.path.join(os.environ["GTK_BASEPATH"], "share\\locale\\%s\\LC_MESSAGES" % l) + if not os.path.exists(gtk_path): + raise Exception("Unknown gtk version, please locate gtk20.mo etc, and modify this script") + + for fn in ("glib20.mo", "gtk20.mo", "gtk20-properties.mo"): + moname = os.path.join(gtk_path, fn) + if os.access(moname, os.F_OK): + gtk_mo.append(moname) + translations.append(("share\\locale\\%s\\LC_MESSAGES" % l, gtk_mo)) + +setup(windows=[{'script': 'bittorrent.py' , + "icon_resources": [(1, "images\\bittorrent.ico")]}, + {'script': 'maketorrent.py', + "icon_resources": [(1, "images\\bittorrent.ico")]}, + {'script': 'choose_language.py', + "icon_resources": [(1, "images\\bittorrent.ico")]}, + ], + options=opts, + data_files=[('',["credits.txt", "LICENSE.txt", + "README.txt", "redirdonate.html", + "TRACKERLESS.txt","public.key", + ]), + ("images", ["images\\bittorrent.ico"]), + ("images\\icons\\default", glob.glob("images\\icons\\default\\*png")), + ("images\\logo", glob.glob("images\\logo\\*png")), + ] + ms + translations, + ) |