Update win32 build files

This commit is contained in:
Andrew Resch 2010-09-14 11:48:05 -07:00
parent 3e68733cfd
commit 6402634ec1
3 changed files with 479 additions and 322 deletions

View File

@ -1,19 +1,35 @@
build_version = "1.3.0-rc2"
python_path = "C:\\Python26\\"
import shutil
shutil.copy(python_path + "Scripts\deluge-script.py", python_path + "Scripts\deluge.py")
shutil.copy(python_path + "Scripts\deluged-script.py", python_path + "Scripts\deluged.py")
shutil.copy(python_path + "Scripts\deluge-web-script.py", python_path + "Scripts\deluge-web.py")
shutil.copy(python_path + "Scripts\deluge-gtk-script.py", python_path + "Scripts\deluge-gtk.py")
shutil.copy(python_path + "Scripts\deluge-console-script.py", python_path + "Scripts\deluge-console.py")
from bbfreeze import Freezer
f = Freezer("..\\build-win32\\deluge-bbfreeze-" + build_version, includes=("libtorrent", "gzip", "zipfile", "re", "socket", "struct", "cairo", "pangocairo", "atk", "pango", "wsgiref.handlers", "twisted.internet.utils", "gio", "gtk.glade"))
f.addScript(python_path + "Scripts\deluge.py", gui_only=False)
f.addScript(python_path + "Scripts\deluged.py", gui_only=False)
f.addScript(python_path + "Scripts\deluge-web.py", gui_only=False)
f.addScript(python_path + "Scripts\deluge-gtk.py", gui_only=False)
f.addScript(python_path + "Scripts\deluge-console.py", gui_only=False)
f() # starts the freezing process
build_version = "1.3.0"
python_path = "C:\\Python26\\"
import shutil
shutil.copy(python_path + "Scripts\deluge-script.py", python_path + "Scripts\deluge.py")
shutil.copy(python_path + "Scripts\deluge-script.py", python_path + "Scripts\deluge-debug.py")
shutil.copy(python_path + "Scripts\deluged-script.py", python_path + "Scripts\deluged.py")
shutil.copy(python_path + "Scripts\deluge-web-script.py", python_path + "Scripts\deluge-web.py")
shutil.copy(python_path + "Scripts\deluge-gtk-script.py", python_path + "Scripts\deluge-gtk.py")
shutil.copy(python_path + "Scripts\deluge-console-script.py", python_path + "Scripts\deluge-console.py")
includes=("libtorrent", "gzip", "zipfile", "re", "socket", "struct", "cairo", "pangocairo", "atk", "pango", "wsgiref.handlers", "twisted.internet.utils", "gio", "gtk.glade")
excludes=("numpy", "OpenGL", "psyco")
dst = "..\\build-win32\\deluge-bbfreeze-" + build_version
from bbfreeze import Freezer
f = Freezer(dst, includes=includes, excludes=excludes)
f.include_py = False
f.addScript(python_path + "Scripts\deluge.py", gui_only=True)
f.addScript(python_path + "Scripts\deluge-debug.py", gui_only=False)
f.addScript(python_path + "Scripts\deluged.py", gui_only=False)
f.addScript(python_path + "Scripts\deluge-web.py", gui_only=False)
f.addScript(python_path + "Scripts\deluge-gtk.py", gui_only=True)
f.addScript(python_path + "Scripts\deluge-console.py", gui_only=False)
f() # starts the freezing process
import icon
icon.CopyIcons(dst+"\\deluge.exe", "deluge.ico")
icon.CopyIcons(dst+"\\deluge-debug.exe", "deluge.ico")
icon.CopyIcons(dst+"\\deluged.exe", "deluge.ico")
icon.CopyIcons(dst+"\\deluge-web.exe", "deluge.ico")
icon.CopyIcons(dst+"\\deluge-gtk.exe", "deluge.ico")
icon.CopyIcons(dst+"\\deluge-console.exe", "deluge.ico")

View File

@ -1,303 +1,253 @@
# Deluge Windows installer script
# Version 0.4 28-Apr-2009
# Copyright (C) 2009 by
# Jesper Lund <mail@jesperlund.com>
# Andrew Resch <andrewresch@gmail.com>
# John Garland <johnnybg@gmail.com>
# Deluge is free software.
#
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# Deluge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with deluge. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
# Set default compressor
SetCompressor lzma
###
### --- The PROGRAM_VERSION !define need to be updated with new Deluge versions ---
###
# Script version; displayed when running the installer
!define DELUGE_INSTALLER_VERSION "0.4"
# Deluge program information
!define PROGRAM_NAME "Deluge"
!define PROGRAM_VERSION "1.3.0-rc2"
!define PROGRAM_WEB_SITE "http://deluge-torrent.org"
# Python files generated with bbfreeze (without DLLs from GTK+ runtime)
!define DELUGE_PYTHON_BBFREEZE_OUTPUT_DIR "..\build-win32\deluge-bbfreeze-${PROGRAM_VERSION}"
# Installer for GTK+ 2.12 runtime; will be downloaded from deluge-torrent.org
!define DELUGE_GTK_DEPENDENCY "gtk2-runtime-2.16.6-2010-05-12-ash.exe"
# --- Interface settings ---
# Modern User Interface 2
!include MUI2.nsh
# Installer
!define MUI_ICON "deluge.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "installer-top.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "installer-side.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_ABORTWARNING
# Uninstaller
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_HEADERIMAGE_UNBITMAP "installer-top.bmp"
!define MUI_WELCOMEFINISHPAGE_UNBITMAP "installer-side.bmp"
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
# --- Start of Modern User Interface ---
# Welcome page
!insertmacro MUI_PAGE_WELCOME
# License page
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
# Components page
!insertmacro MUI_PAGE_COMPONENTS
# Let the user select the installation directory
!insertmacro MUI_PAGE_DIRECTORY
# Run installation
!insertmacro MUI_PAGE_INSTFILES
# Display 'finished' page
!insertmacro MUI_PAGE_FINISH
# Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
# Language files
!insertmacro MUI_LANGUAGE "English"
# --- Functions ---
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
# --- Installation sections ---
# Compare versions
!include "WordFunc.nsh"
!define PROGRAM_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}"
!define PROGRAM_UNINST_ROOT_KEY "HKLM"
# Branding text
BrandingText "Deluge Windows Installer v${DELUGE_INSTALLER_VERSION}"
Name "${PROGRAM_NAME} ${PROGRAM_VERSION}"
OutFile "..\build-win32\deluge-${PROGRAM_VERSION}-win32-setup.exe"
# The Python bbfreeze files will be placed here
!define DELUGE_PYTHON_SUBDIR "$INSTDIR\Deluge-Python"
InstallDir "$PROGRAMFILES\Deluge"
ShowInstDetails show
ShowUnInstDetails show
# Install main application
Section "Deluge Bittorrent Client" Section1
SectionIn RO
Rmdir /r "${DELUGE_PYTHON_SUBDIR}"
SetOutPath "${DELUGE_PYTHON_SUBDIR}"
File /r "${DELUGE_PYTHON_BBFREEZE_OUTPUT_DIR}\*.*"
# Clean up previous confusion between Deluge.ico and deluge.ico (seems to matter on Vista registry settings?)
Delete "$INSTDIR\Deluge.ico"
SetOverwrite ifnewer
SetOutPath $INSTDIR
File "..\LICENSE"
File "StartX.exe"
File "deluge.ico"
# Create deluge.cmd file
fileOpen $0 "$INSTDIR\deluge.cmd" w
fileWrite $0 '@ECHO OFF$\r$\n'
fileWrite $0 'SET DELUGEFOLDER="$INSTDIR"$\r$\n'
fileWrite $0 'SET STARTX_APP="$INSTDIR\StartX.exe"$\r$\n'
fileWrite $0 '$\r$\n'
fileWrite $0 'IF ""%1"" == """" ( $\r$\n'
fileWrite $0 ' %STARTX_APP% /B /D%DELUGEFOLDER% "$INSTDIR\Deluge-Python\deluge.exe"$\r$\n'
fileWrite $0 ') ELSE ( $\r$\n'
fileWrite $0 ' %STARTX_APP% /B /D%DELUGEFOLDER% "$INSTDIR\Deluge-Python\deluge.exe "%1" "%2" "%3" "%4""$\r$\n'
fileWrite $0 ')$\r$\n'
fileClose $0
# Create deluged.cmd file
fileOpen $0 "$INSTDIR\deluged.cmd" w
fileWrite $0 '@ECHO OFF$\r$\n'
fileWrite $0 'SET DELUGEFOLDER="$INSTDIR"$\r$\n'
fileWrite $0 '"$INSTDIR\StartX.exe" /B /D%DELUGEFOLDER% "$INSTDIR\Deluge-Python\deluged.exe "%1" "%2" "%3" "%4""$\r$\n'
fileClose $0
# Create deluge-webui.cmd file
fileOpen $0 "$INSTDIR\deluge-webui.cmd" w
fileWrite $0 '@ECHO OFF$\r$\n'
fileWrite $0 'SET DELUGEFOLDER="$INSTDIR"$\r$\n'
fileWrite $0 '"$INSTDIR\StartX.exe" /B /D%DELUGEFOLDER% "$INSTDIR\Deluge-Python\deluge.exe --ui web"$\r$\n'
fileWrite $0 "ECHO Deluge WebUI started and is running at http://localhost:8112 by default$\r$\n"
fileWrite $0 "ECHO NOTE: The Deluge WebUI process can only be stopped in the Windows Task Manager$\r$\n"
fileWrite $0 "ECHO.$\r$\n"
fileWrite $0 PAUSE
fileClose $0
SectionEnd
Section -StartMenu_Desktop_Links
WriteIniStr "$INSTDIR\homepage.url" "InternetShortcut" "URL" "${PROGRAM_WEB_SITE}"
CreateDirectory "$SMPROGRAMS\Deluge"
CreateShortCut "$SMPROGRAMS\Deluge\Deluge.lnk" "$INSTDIR\deluge.cmd" "" "$INSTDIR\deluge.ico"
CreateShortCut "$SMPROGRAMS\Deluge\Deluge daemon.lnk" "$INSTDIR\deluged.cmd" "" "$INSTDIR\deluge.ico"
CreateShortCut "$SMPROGRAMS\Deluge\Deluge webUI.lnk" "$INSTDIR\deluge-webui.cmd" "" "$INSTDIR\deluge.ico"
CreateShortCut "$SMPROGRAMS\Deluge\Project homepage.lnk" "$INSTDIR\Homepage.url"
CreateShortCut "$SMPROGRAMS\Deluge\Uninstall Deluge.lnk" "$INSTDIR\Deluge-uninst.exe"
CreateShortCut "$DESKTOP\Deluge.lnk" "$INSTDIR\deluge.cmd" "" "$INSTDIR\deluge.ico"
SectionEnd
Section -Uninstaller
WriteUninstaller "$INSTDIR\Deluge-uninst.exe"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "UninstallString" "$INSTDIR\Deluge-uninst.exe"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "DisplayIcon" "$INSTDIR\deluge.ico"
SectionEnd
# Create file association for .torrent
Section "Create .torrent file association for Deluge" Section2
# Set up file association for .torrent files
DeleteRegKey HKCR ".torrent"
WriteRegStr HKCR ".torrent" "" "Deluge"
WriteRegStr HKCR ".torrent" "Content Type" "application/x-bittorrent"
DeleteRegKey HKCR "Deluge"
WriteRegStr HKCR "Deluge" "" "Deluge"
WriteRegStr HKCR "Deluge\Content Type" "" "application/x-bittorrent"
WriteRegStr HKCR "Deluge\DefaultIcon" "" '"$INSTDIR\deluge.ico"'
WriteRegStr HKCR "Deluge\shell" "" "open"
WriteRegStr HKCR "Deluge\shell\open\command" "" '"$INSTDIR\deluge.cmd" "%1"'
SectionEnd
# Create magnet uri association
Section "Create magnet uri link association for Deluge" Section3
DeleteRegKey HKCR "magnet"
WriteRegStr HKCR "magnet" "" "URL:magnet protocol"
WriteRegStr HKCR "magnet" "URL Protocol" ""
WriteRegStr HKCR "magnet\shell\open\command" "" '"$INSTDIR\deluge.cmd" "%1"'
SectionEnd
# Install GTK+ 2.16
Section "GTK+ 2.16 runtime" Section4
GTK_install_start:
MessageBox MB_OK "You will now download and run the installer for the GTK+ 2.16 runtime. \
You must be connected to the internet before you press the OK button. \
The GTK+ runtime can be installed in any location, \
because the GTK+ installer adds the location to the global PATH variable. \
Please note that the GTK+ 2.16 runtime is not removed by the Deluge uninstaller. \
You must use the GTK+ 2.16 uninstaller if you want to remove it together with Deluge."
# Download GTK+ installer to TEMP dir
NSISdl::download http://download.deluge-torrent.org/windows/deps/${DELUGE_GTK_DEPENDENCY} "$TEMP\${DELUGE_GTK_DEPENDENCY}"
# Get return value (success, cancel, or string describing the network error)
Pop $2
StrCmp $2 "success" 0 GTK_download_error
ExecWait '"$TEMP\${DELUGE_GTK_DEPENDENCY}" /compatdlls=yes'
Goto GTK_install_exit
GTK_download_error:
MessageBox MB_ICONEXCLAMATION|MB_OK "Download of GTK+ 2.16 installer failed (return code: $2). \
You must install the GTK+ 2.16 runtime manually, or Deluge will fail to run on your system."
GTK_install_exit:
SectionEnd
LangString DESC_Section1 ${LANG_ENGLISH} "Install Deluge Bittorrent client."
LangString DESC_Section2 ${LANG_ENGLISH} "Select this option unless you have another torrent client which you want to use for opening .torrent files."
LangString DESC_Section3 ${LANG_ENGLISH} "Select this option to have Deluge handle magnet links."
LangString DESC_Section4 ${LANG_ENGLISH} "Download and install the GTK+ 2.16 runtime. \
This is skipped automatically if GTK+ is already installed."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3)
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} $(DESC_Section4)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
# --- Uninstallation section(s) ---
Section Uninstall
Rmdir /r "${DELUGE_PYTHON_SUBDIR}"
Delete "$INSTDIR\Deluge-uninst.exe"
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\deluge.cmd"
Delete "$INSTDIR\deluged.cmd"
Delete "$INSTDIR\deluge-webui.cmd"
Delete "$INSTDIR\StartX.exe"
Delete "$INSTDIR\Homepage.url"
Delete "$INSTDIR\deluge.ico"
Delete "$SMPROGRAMS\Deluge\Deluge.lnk"
Delete "$SMPROGRAMS\Deluge\Deluge daemon.lnk"
Delete "$SMPROGRAMS\Deluge\Deluge webUI.lnk"
Delete "$SMPROGRAMS\Deluge\Uninstall Deluge.lnk"
Delete "$SMPROGRAMS\Deluge\Project homepage.lnk"
Delete "$DESKTOP\Deluge.lnk"
RmDir "$SMPROGRAMS\Deluge"
RmDir "$INSTDIR"
DeleteRegKey ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}"
# Only delete the .torrent association if Deluge owns it
ReadRegStr $1 HKCR ".torrent" ""
StrCmp $1 "Deluge" 0 DELUGE_skip_delete
# Delete the key since it is owned by Deluge; afterwards there is no .torrent association
DeleteRegKey HKCR ".torrent"
DELUGE_skip_delete:
# This key is only used by Deluge, so we should always delete it
DeleteRegKey HKCR "Deluge"
SectionEnd
# Deluge Windows installer script
# Version 0.4 28-Apr-2009
# Copyright (C) 2009 by
# Jesper Lund <mail@jesperlund.com>
# Andrew Resch <andrewresch@gmail.com>
# John Garland <johnnybg@gmail.com>
# Deluge is free software.
#
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# Deluge is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with deluge. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
# Set default compressor
SetCompressor lzma
###
### --- The PROGRAM_VERSION !define need to be updated with new Deluge versions ---
###
# Script version; displayed when running the installer
!define DELUGE_INSTALLER_VERSION "0.4"
# Deluge program information
!define PROGRAM_NAME "Deluge"
!define PROGRAM_VERSION "1.3.0-rc2"
!define PROGRAM_WEB_SITE "http://deluge-torrent.org"
# Python files generated with bbfreeze (without DLLs from GTK+ runtime)
!define DELUGE_PYTHON_BBFREEZE_OUTPUT_DIR "..\build-win32\deluge-bbfreeze-${PROGRAM_VERSION}"
# Installer for GTK+ 2.12 runtime; will be downloaded from deluge-torrent.org
!define DELUGE_GTK_DEPENDENCY "gtk2-runtime-2.16.6-2010-05-12-ash.exe"
# --- Interface settings ---
# Modern User Interface 2
!include MUI2.nsh
# Installer
!define MUI_ICON "deluge.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "installer-top.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "installer-side.bmp"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_ABORTWARNING
# Uninstaller
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_HEADERIMAGE_UNBITMAP "installer-top.bmp"
!define MUI_WELCOMEFINISHPAGE_UNBITMAP "installer-side.bmp"
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
# --- Start of Modern User Interface ---
# Welcome page
!insertmacro MUI_PAGE_WELCOME
# License page
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
# Components page
!insertmacro MUI_PAGE_COMPONENTS
# Let the user select the installation directory
!insertmacro MUI_PAGE_DIRECTORY
# Run installation
!insertmacro MUI_PAGE_INSTFILES
# Display 'finished' page
!insertmacro MUI_PAGE_FINISH
# Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES
# Language files
!insertmacro MUI_LANGUAGE "English"
# --- Functions ---
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
# --- Installation sections ---
# Compare versions
!include "WordFunc.nsh"
!define PROGRAM_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}"
!define PROGRAM_UNINST_ROOT_KEY "HKLM"
# Branding text
BrandingText "Deluge Windows Installer v${DELUGE_INSTALLER_VERSION}"
Name "${PROGRAM_NAME} ${PROGRAM_VERSION}"
OutFile "..\build-win32\deluge-${PROGRAM_VERSION}-win32-setup.exe"
InstallDir "$PROGRAMFILES\Deluge"
ShowInstDetails show
ShowUnInstDetails show
# Install main application
Section "Deluge Bittorrent Client" Section1
SectionIn RO
SetOutPath $INSTDIR
File /r "${DELUGE_PYTHON_BBFREEZE_OUTPUT_DIR}\*.*"
SetOverwrite ifnewer
File "..\LICENSE"
SectionEnd
Section -StartMenu_Desktop_Links
WriteIniStr "$INSTDIR\homepage.url" "InternetShortcut" "URL" "${PROGRAM_WEB_SITE}"
# create shortcuts for all users
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\Deluge"
CreateShortCut "$SMPROGRAMS\Deluge\Deluge.lnk" "$INSTDIR\deluge.exe"
CreateShortCut "$SMPROGRAMS\Deluge\Deluge daemon.lnk" "$INSTDIR\deluged.exe"
CreateShortCut "$SMPROGRAMS\Deluge\Deluge webUI.lnk" "$INSTDIR\deluge-web.exe"
CreateShortCut "$SMPROGRAMS\Deluge\Project homepage.lnk" "$INSTDIR\Homepage.url"
CreateShortCut "$SMPROGRAMS\Deluge\Uninstall Deluge.lnk" "$INSTDIR\Deluge-uninst.exe"
CreateShortCut "$DESKTOP\Deluge.lnk" "$INSTDIR\deluge.exe"
SectionEnd
Section -Uninstaller
WriteUninstaller "$INSTDIR\Deluge-uninst.exe"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}" "UninstallString" "$INSTDIR\Deluge-uninst.exe"
SectionEnd
# Create file association for .torrent
Section "Create .torrent file association for Deluge" Section2
# Set up file association for .torrent files
DeleteRegKey HKCR ".torrent"
WriteRegStr HKCR ".torrent" "" "Deluge"
WriteRegStr HKCR ".torrent" "Content Type" "application/x-bittorrent"
DeleteRegKey HKCR "Deluge"
WriteRegStr HKCR "Deluge" "" "Deluge"
WriteRegStr HKCR "Deluge\Content Type" "" "application/x-bittorrent"
WriteRegStr HKCR "Deluge\DefaultIcon" "" "$INSTDIR\deluge.exe,0"
WriteRegStr HKCR "Deluge\shell" "" "open"
WriteRegStr HKCR "Deluge\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"'
SectionEnd
# Create magnet uri association
Section "Create magnet uri link association for Deluge" Section3
DeleteRegKey HKCR "magnet"
WriteRegStr HKCR "magnet" "" "URL:magnet protocol"
WriteRegStr HKCR "magnet" "URL Protocol" ""
WriteRegStr HKCR "magnet\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"'
SectionEnd
# Install GTK+ 2.16
Section "GTK+ 2.16 runtime" Section4
GTK_install_start:
MessageBox MB_OK "You will now download and run the installer for the GTK+ 2.16 runtime. \
You must be connected to the internet before you press the OK button. \
The GTK+ runtime can be installed in any location, \
because the GTK+ installer adds the location to the global PATH variable. \
Please note that the GTK+ 2.16 runtime is not removed by the Deluge uninstaller. \
You must use the GTK+ 2.16 uninstaller if you want to remove it together with Deluge."
# Download GTK+ installer to TEMP dir
NSISdl::download http://download.deluge-torrent.org/windows/deps/${DELUGE_GTK_DEPENDENCY} "$TEMP\${DELUGE_GTK_DEPENDENCY}"
# Get return value (success, cancel, or string describing the network error)
Pop $2
StrCmp $2 "success" 0 GTK_download_error
ExecWait '"$TEMP\${DELUGE_GTK_DEPENDENCY}" /compatdlls=yes'
Goto GTK_install_exit
GTK_download_error:
MessageBox MB_ICONEXCLAMATION|MB_OK "Download of GTK+ 2.16 installer failed (return code: $2). \
You must install the GTK+ 2.16 runtime manually, or Deluge will fail to run on your system."
GTK_install_exit:
SectionEnd
LangString DESC_Section1 ${LANG_ENGLISH} "Install Deluge Bittorrent client."
LangString DESC_Section2 ${LANG_ENGLISH} "Select this option unless you have another torrent client which you want to use for opening .torrent files."
LangString DESC_Section3 ${LANG_ENGLISH} "Select this option to have Deluge handle magnet links."
LangString DESC_Section4 ${LANG_ENGLISH} "Download and install the GTK+ 2.16 runtime. \
This is skipped automatically if GTK+ is already installed."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3)
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} $(DESC_Section4)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
# --- Uninstallation section(s) ---
Section Uninstall
RmDir /r "$INSTDIR"
SetShellVarContext all
Delete "$SMPROGRAMS\Deluge\Deluge.lnk"
Delete "$SMPROGRAMS\Deluge\Deluge daemon.lnk"
Delete "$SMPROGRAMS\Deluge\Deluge webUI.lnk"
Delete "$SMPROGRAMS\Deluge\Uninstall Deluge.lnk"
Delete "$SMPROGRAMS\Deluge\Project homepage.lnk"
Delete "$DESKTOP\Deluge.lnk"
RmDir "$SMPROGRAMS\Deluge"
DeleteRegKey ${PROGRAM_UNINST_ROOT_KEY} "${PROGRAM_UNINST_KEY}"
# Only delete the .torrent association if Deluge owns it
ReadRegStr $1 HKCR ".torrent" ""
StrCmp $1 "Deluge" 0 DELUGE_skip_delete
# Delete the key since it is owned by Deluge; afterwards there is no .torrent association
DeleteRegKey HKCR ".torrent"
DELUGE_skip_delete:
# This key is only used by Deluge, so we should always delete it
DeleteRegKey HKCR "Deluge"
SectionEnd

191
win32/icon.py Normal file
View File

@ -0,0 +1,191 @@
#! /usr/bin/env python
# Copyright (C) 2005, Giovanni Bajo
# Based on previous work under copyright (c) 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# This code is courtesy of Thomas Heller, who
# has kindly donated it to this project.
RT_ICON = 3
RT_GROUP_ICON = 14
LOAD_LIBRARY_AS_DATAFILE = 2
import struct
import types
try:
StringTypes = types.StringTypes
except AttributeError:
StringTypes = [ type("") ]
class Structure:
def __init__ (self):
size = self._sizeInBytes = struct.calcsize (self._format_)
self._fields_ = list (struct.unpack (self._format_, '\000' * size))
indexes = self._indexes_ = {}
for i in range (len (self._names_)):
indexes[self._names_[i]] = i
def dump (self):
print "I: DUMP of", self
for name in self._names_:
if name[0] != '_':
print "I: %20s = %s" % (name, getattr (self, name))
print
def __getattr__ (self, name):
if name in self._names_:
index = self._indexes_[name]
return self._fields_[index]
try:
return self.__dict__[name]
except KeyError:
raise AttributeError, name
def __setattr__ (self, name, value):
if name in self._names_:
index = self._indexes_[name]
self._fields_[index] = value
else:
self.__dict__[name] = value
def tostring (self):
return apply (struct.pack, [self._format_,] + self._fields_)
def fromfile (self, file):
data = file.read (self._sizeInBytes)
self._fields_ = list (struct.unpack (self._format_, data))
class ICONDIRHEADER (Structure):
_names_ = "idReserved", "idType", "idCount"
_format_ = "hhh"
class ICONDIRENTRY (Structure):
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "dwImageOffset"
_format_ = "bbbbhhii"
class GRPICONDIR (Structure):
_names_ = "idReserved", "idType", "idCount"
_format_ = "hhh"
class GRPICONDIRENTRY (Structure):
_names_ = "bWidth", "bHeight", "bColorCount", "bReserved", "wPlanes", "wBitCount", "dwBytesInRes", "nID"
_format_ = "bbbbhhih"
class IconFile:
def __init__ (self, path):
self.path = path
file = open (path, "rb")
self.entries = []
self.images = []
header = self.header = ICONDIRHEADER()
header.fromfile (file)
for i in range (header.idCount):
entry = ICONDIRENTRY()
entry.fromfile (file)
self.entries.append (entry)
for e in self.entries:
file.seek (e.dwImageOffset, 0)
self.images.append (file.read (e.dwBytesInRes))
def grp_icon_dir (self):
return self.header.tostring()
def grp_icondir_entries (self, id=1):
data = ""
for entry in self.entries:
e = GRPICONDIRENTRY()
for n in e._names_[:-1]:
setattr(e, n, getattr (entry, n))
e.nID = id
id = id + 1
data = data + e.tostring()
return data
def CopyIcons_FromIco (dstpath, srcpath, id=1):
import win32api #, win32con
icons = map(IconFile, srcpath)
print "I: Updating icons from", srcpath, "to", dstpath
hdst = win32api.BeginUpdateResource (dstpath, 0)
iconid = 1
for i in range(len(icons)):
f = icons[i]
data = f.grp_icon_dir()
data = data + f.grp_icondir_entries(iconid)
win32api.UpdateResource (hdst, RT_GROUP_ICON, i, data)
print "I: Writing RT_GROUP_ICON %d resource with %d bytes" % (i, len(data))
for data in f.images:
win32api.UpdateResource (hdst, RT_ICON, iconid, data)
print "I: Writing RT_ICON %d resource with %d bytes" % (iconid, len (data))
iconid = iconid + 1
win32api.EndUpdateResource (hdst, 0)
def CopyIcons (dstpath, srcpath):
import os.path, string
if type(srcpath) in StringTypes:
srcpath = [ srcpath ]
def splitter(s):
try:
srcpath, index = map(string.strip, string.split(s, ','))
return srcpath, int(index)
except ValueError:
return s, None
srcpath = map(splitter, srcpath)
print "I: SRCPATH", srcpath
if len(srcpath) > 1:
# At the moment, we support multiple icons only from .ico files
srcs = []
for s in srcpath:
e = os.path.splitext(s[0])[1]
if string.lower(e) != '.ico':
raise ValueError, "multiple icons supported only from .ico files"
if s[1] is not None:
raise ValueError, "index not allowed for .ico files"
srcs.append(s[0])
return CopyIcons_FromIco(dstpath, srcs)
srcpath,index = srcpath[0]
srcext = os.path.splitext(srcpath)[1]
if string.lower (srcext) == '.ico':
return CopyIcons_FromIco (dstpath, [srcpath])
if index is not None:
print "I: Updating icons from", srcpath, ", %d to" % index, dstpath
else:
print "I: Updating icons from", srcpath, "to", dstpath
import win32api #, win32con
hdst = win32api.BeginUpdateResource (dstpath, 0)
hsrc = win32api.LoadLibraryEx (srcpath, 0, LOAD_LIBRARY_AS_DATAFILE)
if index is None:
grpname = win32api.EnumResourceNames (hsrc, RT_GROUP_ICON)[0]
elif index >= 0:
grpname = win32api.EnumResourceNames (hsrc, RT_GROUP_ICON)[index]
else:
grpname = -index
data = win32api.LoadResource (hsrc, RT_GROUP_ICON, grpname)
win32api.UpdateResource (hdst, RT_GROUP_ICON, grpname, data)
for iconname in win32api.EnumResourceNames (hsrc, RT_ICON):
data = win32api.LoadResource (hsrc, RT_ICON, iconname)
win32api.UpdateResource (hdst, RT_ICON, iconname, data)
win32api.FreeLibrary (hsrc)
win32api.EndUpdateResource (hdst, 0)
if __name__ == "__main__":
import sys
dstpath = sys.argv[1]
srcpath = sys.argv[2:]
CopyIcons(dstpath, srcpath)