diff --git a/pkg/CleanHashCache.py b/pkg/CleanHashCache.py deleted file mode 100644 index 837a46afe..000000000 --- a/pkg/CleanHashCache.py +++ /dev/null @@ -1,108 +0,0 @@ -##################################################################### -# -*- coding: iso-8859-1 -*- # -# # -# Frets on Fire X (FoFiX) # -# Copyright (C) 2009 myfingershurt # -# 2009 John Stumpo # -# # -# 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. # -##################################################################### - -__version__ = '$Id$' - -import os -import sys -if os.name != 'nt': - sys.stderr.write('This script only works on Windows.\n') - sys.exit(1) - -import win32api -import win32con -import sha -try: - import sqlite3 -except ImportError: - import pysqlite2.dbapi2 as sqlite3 - -from Tkinter import * - -class CleanHashCacheWindow(object): - def __init__(self, master, db): - self.master = master - self.db = db - master.title('CleanHashCache') - master.protocol('WM_DELETE_WINDOW', self.close) - frame = Frame(master) - - lbl = Label(master, text='Double-click a version\nto delete its hashes.') - lbl.pack(side=TOP, padx=10, pady=10) - - self.listbox = Listbox(master, exportselection=0) - for version in [row[0] for row in self.db.execute('SELECT `version` FROM `verlist`').fetchall()]: - self.listbox.insert(END, version) - self.listbox.bind('', lambda e: self.delete()) - self.listbox.pack(side=TOP, padx=10, pady=0) - - okbutton = Button(master, text='Done', command=self.close) - okbutton.pack(side=TOP, padx=10, pady=10, fill=BOTH, expand=1) - - master.resizable(0, 0) - - def run(self): - self.master.mainloop() - - def delete(self): - if len(self.listbox.curselection()): - if win32api.MessageBox(self.master.winfo_id(), - 'Really delete this version\'s hashes?\nThis cannot be undone!', - 'CleanHashCache', win32con.MB_YESNO|win32con.MB_ICONQUESTION) == win32con.IDYES: - vername = str(self.listbox.get(self.listbox.curselection()[0])) - self.db.execute('DELETE FROM `verlist` WHERE `version` = ?', [vername]) - self.db.commit() - self.db.execute('DROP TABLE `hashes_%s`' % sha.sha(vername).hexdigest()) - self.db.commit() - self.listbox.delete(self.listbox.curselection()[0]) - - def close(self): - self.db.commit() - self.db.execute('VACUUM') - self.db.commit() - self.db.close() - self.master.withdraw() - self.master.quit() - -def main(): - hashcache = sqlite3.Connection('HashCache') - hashcache.execute('CREATE TABLE IF NOT EXISTS `verlist` (`version` STRING UNIQUE)') - hashcache.commit() - CleanHashCacheWindow(Tk(), hashcache).run() - sys.exit(0) - -try: - main() -except (KeyboardInterrupt, SystemExit): - raise -except: - import traceback - import win32clipboard - if win32api.MessageBox(0, 'A fatal error has occurred. This program will now terminate.\n\n' + - traceback.format_exc() + '\n\nCopy traceback to Clipboard?', - 'CleanHashCache', win32con.MB_YESNO|win32con.MB_ICONSTOP) == win32con.IDYES: - win32clipboard.OpenClipboard() - win32clipboard.EmptyClipboard() - win32clipboard.SetClipboardText(traceback.format_exc()) - win32clipboard.CloseClipboard() - raise diff --git a/pkg/ListToNSIS.py b/pkg/ListToNSIS.py index 0ad46201d..4b9e3a74a 100644 --- a/pkg/ListToNSIS.py +++ b/pkg/ListToNSIS.py @@ -32,23 +32,9 @@ import hashlib class NsisScriptGenerator(object): - def __init__(self, baseFolder='.', hashCache=None, oldTblName=None, newTblName=None): + def __init__(self, baseFolder='.'): self.nodeList = [] self.baseFolder = baseFolder - self.hashCache = hashCache - self.oldTblName = None - self.newTblName = None - if oldTblName is not None: - self.oldTblName = hashlib.sha1(oldTblName).hexdigest() - if newTblName is not None: - self.newTblName = hashlib.sha1(newTblName).hexdigest() - if self.hashCache is not None: - self.hashCache.execute('INSERT OR REPLACE INTO `verlist` (`version`) VALUES (?)', [newTblName]) - self.hashCache.execute('DROP TABLE IF EXISTS `hashes_%s`' % self.newTblName) - self.hashCache.commit() - self.hashCache.execute('VACUUM') - self.hashCache.execute('CREATE TABLE `hashes_%s` (`path` STRING UNIQUE, `hash` STRING)' % self.newTblName) - self.hashCache.commit() def readList(self, listname): l = open(listname, 'r') for line in l: @@ -63,13 +49,6 @@ def readList(self, listname): for f in win32api.FindFiles(line): path = os.path.join(os.path.dirname(line), f[8]) if os.path.isfile(path) and path.find('.svn') == -1: # omit .svn folders - if self.hashCache is not None: - newhash = hashlib.sha1(open(path, 'rb').read()).hexdigest() - self.hashCache.execute('INSERT OR REPLACE INTO `hashes_%s` (`path`, `hash`) VALUES (?, ?)' % self.newTblName, [path, newhash]) - if self.oldTblName is not None: - oldhash = self.hashCache.execute('SELECT `hash` FROM `hashes_%s` WHERE `path` = ?' % self.oldTblName, [path]).fetchone() - if oldhash is not None and oldhash[0] == newhash: - continue self.nodeList.append(path) os.chdir(oldpwd) l.close() diff --git a/pkg/MakeFoFiXInstaller.py b/pkg/MakeFoFiXInstaller.py index 3ce1ae6b9..425417906 100644 --- a/pkg/MakeFoFiXInstaller.py +++ b/pkg/MakeFoFiXInstaller.py @@ -34,10 +34,6 @@ import shutil import win32api import hashlib -try: - import sqlite3 -except ImportError: - import pysqlite2.dbapi2 as sqlite3 us = r'..\FoFiX.exe' if not os.path.isfile(us): @@ -48,14 +44,9 @@ FOFIX_VERSION = '%d.%d.%d.%d' % (vdict['FileVersionMS'] >> 16, vdict['FileVersionMS'] & 0xffff, vdict['FileVersionLS'] >> 16, vdict['FileVersionLS'] & 0xffff) FOFIX_VERSION_FULL = str(win32api.GetFileVersionInfo(us, r'\StringFileInfo\%04x%04x\ProductVersion' % win32api.GetFileVersionInfo(us, r'\VarFileInfo\Translation')[0])) -# Make the hashcache. -hashcache = sqlite3.Connection('HashCache') -hashcache.execute('CREATE TABLE IF NOT EXISTS `verlist` (`version` STRING UNIQUE)') -hashcache.commit() -MLDist = ListToNSIS.NsisScriptGenerator('..', hashcache, newTblName=FOFIX_VERSION_FULL) +MLDist = ListToNSIS.NsisScriptGenerator('..') MLDist.readList('Dist-All.lst') MLDist.readExcludeList('filesToExclude.lst') -hashcache.commit() oldcwd = os.getcwd() os.chdir('..') @@ -225,137 +216,6 @@ try: if os.spawnl(os.P_WAIT, makensis, 'makensis.exe', 'Setup.nsi') != 0: raise RuntimeError, 'Installer generation failed.' - # Yank out the new uninstaller. - os.spawnl(os.P_WAIT, os.path.join(oldcwd, 'FoFiX v%s Setup.exe' % FOFIX_VERSION_FULL), 'FoFiX v%s Setup.exe' % FOFIX_VERSION_FULL, '/WriteUninstallerOnly') - - # Now we can go back through the hashcache and make the patches. - versions = [row[0] for row in hashcache.execute('SELECT `version` FROM `verlist` WHERE `version` != ?', [FOFIX_VERSION_FULL])] - for v in versions: - os.chdir(oldcwd) - MLDist = ListToNSIS.NsisScriptGenerator('..', hashcache, oldTblName=v, newTblName=FOFIX_VERSION_FULL) - MLDist.readList('Dist-All.lst') - MLDist.readExcludeList('filesToExclude.lst') - hashcache.commit() - os.chdir('..') - os.unlink('Setup.nsi') - oldExeSha1 = hashcache.execute("SELECT `hash` FROM `hashes_%s` WHERE `path` = 'FoFiX.exe'" % hashlib.sha1(v).hexdigest()).fetchone()[0] - patcher = ListToNSIS.NsisScriptBuilder(r""" -!define FOFIX_VERSION %s -!define FOFIX_VERSION_FULL "%s" -!define FOFIX_VERSION_OLD "%s" -!define FOFIX_VERSION_OLD_EXE_SHA1 "%s" -!include "MUI2.nsh" - -# Installer title and filename. -Name 'FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch' -Caption 'FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch' -OutFile 'pkg\FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch.exe' - -# Installer parameters. -SetCompressor /SOLID lzma -RequestExecutionLevel user # no UAC on Vista -ShowInstDetails show -InstallButtonText "&Upgrade" - -# Where we're going (by default at least) -InstallDir '$DOCUMENTS\FoFiX' -# Where we stashed the install location. -InstallDirRegKey HKCU 'SOFTWARE\myfingershurt\FoFiX' InstallRoot - -# Function to run FoFiX from the finish page. -Function runFoFiX - SetOutPath $INSTDIR - Exec $INSTDIR\FoFiX.exe -FunctionEnd - -# More installer parameters. -!define MUI_ABORTWARNING -!define MUI_ABORTWARNING_TEXT "Are you sure you want to quit FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch?" -!define MUI_FINISHPAGE_NOAUTOCLOSE -!define MUI_FINISHPAGE_NOREBOOTSUPPORT -!define MUI_FINISHPAGE_RUN -!define MUI_FINISHPAGE_RUN_TEXT "Run FoFiX v${FOFIX_VERSION_FULL}" -!define MUI_FINISHPAGE_RUN_FUNCTION runFoFiX -!define MUI_FINISHPAGE_LINK "FoFiX Development Home" -!define MUI_FINISHPAGE_LINK_LOCATION "http://code.google.com/p/fofix/" -!define MUI_LICENSEPAGE_RADIOBUTTONS -!define MUI_HEADERIMAGE -!define MUI_WELCOMEPAGE_TITLE "Welcome to the FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch Wizard" -!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the upgrade of FoFiX v${FOFIX_VERSION_OLD} to version ${FOFIX_VERSION_FULL}.$\r$\n$\r$\nBefore upgrading, make sure FoFiX v${FOFIX_VERSION_OLD} is not running.$\r$\n$\r$\nClick Next to continue." -!define MUI_DIRECTORYPAGE_TEXT_TOP "Setup will upgrade the installation of FoFiX v${FOFIX_VERSION_OLD} in the following folder to version ${FOFIX_VERSION_FULL}. To perform the upgrade in a different folder, click Browse and select another folder. Click Upgrade to start the upgrade." -!define MUI_INSTFILESPAGE_FINISHHEADER_TEXT "Upgrade Complete" -!define MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT "Upgrade was completed successfully." -!define MUI_INSTFILESPAGE_ABORTHEADER_TEXT "Upgrade Aborted" -!define MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT "Upgrade was aborted." -!define MUI_FINISHPAGE_TITLE "Completing the FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch Wizard" -!define MUI_FINISHPAGE_TEXT "FoFiX v${FOFIX_VERSION_OLD} has been upgraded to version ${FOFIX_VERSION_FULL}.$\r$\n$\r$\nClick Finish to close this wizard.$\r$\n$\r$\nInstaller by John Stumpo.$\r$\nInstaller graphics by akedrou." -!define MUI_FINISHPAGE_TEXT_LARGE -!define MUI_HEADERIMAGE_BITMAP "pkg\installer_gfx\header.bmp" -!define MUI_WELCOMEFINISHPAGE_BITMAP "pkg\installer_gfx\welcome.bmp" - -# Function to verify the install path. -Function verifyFoFiXInstDir - IfFileExists $INSTDIR haveDir - Abort -haveDir: - IfFileExists $INSTDIR\FoFiX.exe haveFoFexe - MessageBox MB_YESNO|MB_ICONEXCLAMATION "This does not look like a valid FoFiX installation folder.$\r$\n$\r$\nIf you would like to merely unpack the altered files into this folder, you may continue anyway.$\r$\n$\r$\nContinue?" IDYES allow - Abort -haveFoFexe: - Crypto::HashFile "SHA1" $INSTDIR\FoFiX.exe - Pop $0 - StrCmp $0 ${FOFIX_VERSION_OLD_EXE_SHA1} allow - MessageBox MB_YESNO|MB_ICONEXCLAMATION "This looks like a valid FoFiX installation folder, but not version ${FOFIX_VERSION_OLD}.$\r$\n$\r$\nApplying this patch will more than likely break your installation!$\r$\n$\r$\nContinue anyway?" IDYES allow - Abort -allow: -FunctionEnd - -# The pages of the installer... -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "COPYING" -!define MUI_PAGE_HEADER_TEXT "Choose Upgrade Location" -!define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to upgrade FoFiX v${FOFIX_VERSION_OLD} to version ${FOFIX_VERSION_FULL}." -!define MUI_PAGE_CUSTOMFUNCTION_LEAVE verifyFoFiXInstDir -!insertmacro MUI_PAGE_DIRECTORY -!define MUI_PAGE_HEADER_TEXT "Upgrading" -!define MUI_PAGE_HEADER_SUBTEXT "Please wait while FoFiX v${FOFIX_VERSION_OLD} is upgraded to version ${FOFIX_VERSION_FULL}." -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_PAGE_FINISH - -# Throw in a cool background image. -#!define MUI_CUSTOMFUNCTION_GUIINIT startBackground -#Function startBackground -# InitPluginsDir -# File /oname=$PLUGINSDIR\background.bmp pkg\installer_gfx\background.bmp -# BgImage::SetBG /NOUNLOAD /FILLSCREEN $PLUGINSDIR\background.bmp -# BgImage::Redraw /NOUNLOAD -#FunctionEnd -#Function .onGUIEnd -# BgImage::Destroy -#FunctionEnd - -!insertmacro MUI_LANGUAGE "English" - -# Add version info to the resulting installers. -VIProductVersion "${FOFIX_VERSION}" -VIAddVersionKey /LANG=1033 "CompanyName" "FoFiX Team" -VIAddVersionKey /LANG=1033 "FileDescription" "FoFiX Patch Utility" -VIAddVersionKey /LANG=1033 "FileVersion" "${FOFIX_VERSION_FULL}" -VIAddVersionKey /LANG=1033 "InternalName" "FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch.exe" -VIAddVersionKey /LANG=1033 "LegalCopyright" "© 2008-2010 FoFiX Team. GNU GPL v2 or later." -VIAddVersionKey /LANG=1033 "OriginalFilename" "FoFiX v${FOFIX_VERSION_OLD} to v${FOFIX_VERSION_FULL} Patch.exe" -VIAddVersionKey /LANG=1033 "ProductName" "FoFiX" -VIAddVersionKey /LANG=1033 "ProductVersion" "${FOFIX_VERSION_FULL}" -""" % (FOFIX_VERSION, FOFIX_VERSION_FULL, str(v), str(oldExeSha1))) - patcher.addSection('Patch', r''' -SectionIn RO -%s -SetOutPath $INSTDIR -File "%s" -''' % (MLDist.getInstallScript(), os.path.join(oldcwd, 'uninst.exe')), '', 'All altered files for this patch.') - open('Setup.nsi', 'w').write(patcher.getScript()) - if os.spawnl(os.P_WAIT, makensis, 'makensis.exe', 'Setup.nsi') != 0: - raise RuntimeError, 'Installer generation failed.' finally: if os.getcwd() == oldcwd: