From a04024d455c8ba35ae8a10c65b8cd359beeb477c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 25 Aug 2009 11:10:44 -0600 Subject: [PATCH] IGN:New windows build system --- installer/windows/freeze.py | 38 ++++++++-------------- setup.py | 17 +++++----- src/calibre/library/server.py | 12 +++---- upload.py | 59 ++++++++++++++++++++++------------- 4 files changed, 66 insertions(+), 60 deletions(-) diff --git a/installer/windows/freeze.py b/installer/windows/freeze.py index 4dadc8875c..bf64637dab 100644 --- a/installer/windows/freeze.py +++ b/installer/windows/freeze.py @@ -7,15 +7,12 @@ __docformat__ = 'restructuredtext en' Freeze app into executable using py2exe. ''' QT_DIR = 'C:\\Qt\\4.5.2' -LIBUSB_DIR = 'C:\\libusb' +LIBUSB_DIR = r'C:\cygwin\home\kovid\win32\libusb' LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll' -PDFTOHTML = 'C:\\cygwin\\home\\kovid\\poppler-0.10.6\\rel\\pdftohtml.exe' -POPPLER = 'C:\\cygwin\\home\\kovid\\poppler' -IMAGEMAGICK_DIR = 'C:\\ImageMagick' -PDFTK = 'C:\\pdftk.exe' -PODOFO = 'C:\\podofo' -FONTCONFIG_DIR = 'C:\\fontconfig' -VC90 = r'C:\VC90.CRT' +BINARIES = r'C:\cygwin\home\kovid\win32\bin' +IMAGEMAGICK_DIR = r'C:\cygwin\home\kovid\win32\imagemagick' +FONTCONFIG_DIR = r'C:\cygwin\home\kovid\win32\etc' +VC90 = r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT' # ModuleFinder can't handle runtime changes to __path__, but win32com uses them import sys @@ -98,25 +95,17 @@ class BuildEXE(py2exe.build_exe.py2exe): shutil.copyfile(f, os.path.join(tdir, os.path.basename(f))) print '\tAdding unrar' shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR))) - print '\tAdding poppler' - for x in ('bin\\pdftohtml.exe', 'bin\\poppler-qt4.dll', - 'bin\\freetype.dll', 'bin\\jpeg62.dll'): - shutil.copyfile(os.path.join(POPPLER, x), - os.path.join(PY2EXE_DIR, os.path.basename(x))) - print '\tAdding podofo' - for f in glob.glob(os.path.join(PODOFO, '*.dll')): - shutil.copyfile(f, os.path.join(PY2EXE_DIR, os.path.basename(f))) - + print '\tAdding Binaries' + for x in glob.glob(os.path.join(BINARIES, '*.dll')) + \ + [os.path.join(BINARIES, 'pdftohtml.exe')] + \ + glob.glob(os.path.join(BINARIES, '*.manifest')): + shutil.copyfile(x, os.path.join(PY2EXE_DIR, os.path.basename(x))) print '\tAdding ImageMagick' for f in os.listdir(IMAGEMAGICK_DIR): shutil.copyfile(os.path.join(IMAGEMAGICK_DIR, f), os.path.join(PY2EXE_DIR, f)) print '\tCopying fontconfig' - for f in glob.glob(os.path.join(FONTCONFIG_DIR, '*')): - tgt = os.path.join(PY2EXE_DIR, os.path.basename(f)) - if os.path.isdir(f): - shutil.copytree(f, tgt) - else: - shutil.copyfile(f, tgt) + tgt = os.path.join(PY2EXE_DIR, 'etc') + shutil.copytree(FONTCONFIG_DIR, tgt) print print 'Doing DLL redirection' # See http://msdn.microsoft.com/en-us/library/ms682600(VS.85).aspx @@ -169,8 +158,7 @@ def main(args=sys.argv): 'email.iterators', 'email.generator', 'win32process', 'win32api', 'msvcrt', - 'win32event', 'calibre.ebooks.lrf.any.*', - 'calibre.ebooks.lrf.feeds.*', + 'win32event', 'BeautifulSoup', 'pyreadline', 'pydoc', 'IPython.Extensions.*', 'calibre.web.feeds.recipes.*', diff --git a/setup.py b/setup.py index ed372920de..a7d5b009ab 100644 --- a/setup.py +++ b/setup.py @@ -94,8 +94,8 @@ if __name__ == '__main__': sources=['src/calibre/utils/windows/winutil.c'], libraries=['shell32', 'setupapi'], include_dirs=os.environ.get('INCLUDE', - 'C:/WinDDK/6001.18001/inc/api/;' - 'C:/WinDDK/6001.18001/inc/crt/').split(';'), + 'C:/WinDDK/7600.16385.0/inc/api/;' + 'C:/WinDDK/7600.16385.0/inc/crt/').split(';'), extra_compile_args=['/X'] )) @@ -103,8 +103,8 @@ if __name__ == '__main__': poppler_lib = '/usr/lib' poppler_libs = [] if iswindows: - poppler_inc = r'C:\cygwin\home\kovid\poppler\include\poppler\qt4' - poppler_lib = r'C:\cygwin\home\kovid\poppler\lib' + poppler_inc = r'C:\cygwin\home\kovid\win32\include\poppler\qt4' + poppler_lib = r'C:\cygwin\home\kovid\win32\lib' poppler_libs = ['QtCore4', 'QtGui4'] if isosx: poppler_inc = '/Volumes/sw/build/poppler-0.10.7/qt4/src' @@ -124,9 +124,10 @@ if __name__ == '__main__': print 'POPPLER_LIB_DIR environment variables.' podofo_inc = '/usr/include/podofo' if islinux else \ - 'C:\\podofo\\include\\podofo' if iswindows else \ + r'C:\cygwin\home\kovid\win32\include\podofo' if iswindows else \ '/usr/local/include/podofo' - podofo_lib = '/usr/lib' if islinux else r'C:\podofo' if iswindows else \ + podofo_lib = '/usr/lib' if islinux else \ + r'C:\cygwin\home\kovid\win32\lib' if iswindows else \ '/usr/local/lib' podofo_inc = os.environ.get('PODOFO_INC_DIR', podofo_inc) if os.path.exists(os.path.join(podofo_inc, 'podofo.h')): @@ -141,10 +142,10 @@ if __name__ == '__main__': print 'PODOFO_LIB_DIR environment variables.' fc_inc = '/usr/include/fontconfig' if islinux else \ - r'C:\cygwin\home\kovid\fontconfig\include\fontconfig' if iswindows else \ + r'C:\cygwin\home\kovid\win32\include\fontconfig' if iswindows else \ '/Users/kovid/fontconfig/include/fontconfig' fc_lib = '/usr/lib' if islinux else \ - r'C:\cygwin\home\kovid\fontconfig\lib' if iswindows else \ + r'C:\cygwin\home\kovid\win32\lib' if iswindows else \ '/Users/kovid/fontconfig/lib' diff --git a/src/calibre/library/server.py b/src/calibre/library/server.py index 58cb457971..4ab254555e 100644 --- a/src/calibre/library/server.py +++ b/src/calibre/library/server.py @@ -110,7 +110,7 @@ class LibraryServer(object): ${authors} urn:calibre:${record[FM['id']]} ${timestamp} - + ''')) @@ -120,7 +120,7 @@ class LibraryServer(object): calibre Library $id ${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')} - + calibre http://calibre.kovidgoyal.net @@ -140,7 +140,7 @@ class LibraryServer(object): calibre Library $id ${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')} - + calibre http://calibre.kovidgoyal.net @@ -152,19 +152,19 @@ class LibraryServer(object): By Author urn:uuid:fc000fa0-8c23-11de-a31d-0002a5d5c51b ${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')} - + By Title urn:uuid:1df4fe40-8c24-11de-b4c6-0002a5d5c51b ${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')} - + By Newest urn:uuid:3c6d4940-8c24-11de-a4d7-0002a5d5c51b ${updated.strftime('%Y-%m-%dT%H:%M:%S+00:00')} - + ''')) diff --git a/upload.py b/upload.py index e82946af37..95d8013985 100644 --- a/upload.py +++ b/upload.py @@ -528,6 +528,27 @@ class VMInstaller(OptionlessCommand): def get_build_script(self, subs): return self.BUILD_SCRIPT%subs + def vmware_started(self): + return 'started' in subprocess.Popen('/etc/init.d/vmware status', shell=True, stdout=subprocess.PIPE).stdout.read() + + def start_vmware(self): + if not self.vmware_started(): + if os.path.exists('/dev/kvm'): + check_call('sudo rmmod -w kvm-intel kvm', shell=True) + subprocess.Popen('sudo /etc/init.d/vmware start', shell=True) + + def stop_vmware(self): + while True: + try: + check_call('sudo /etc/init.d/vmware stop', shell=True) + break + except: + pass + while 'vmblock' in open('/proc/modules').read(): + check_call('sudo rmmod -f vmblock') + check_call('sudo modprobe kvm-intel', shell=True) + + def run_vm(self): vmware = ('vmware', '-q', '-x', '-n', self.VM) self.__p = Popen(vmware) @@ -547,9 +568,18 @@ class VMInstaller(OptionlessCommand): check_call(('scp', t.name, ssh_host+':build-calibre')) check_call('ssh -t %s bash build-calibre'%ssh_host, shell=True) -class build_linux32(VMInstaller): +class KVMInstaller(VMInstaller): + + def run_vm(self): + self.stop_vmware() + self.__p = Popen(self.VM) + + + +class build_linux32(KVMInstaller): description = 'Build linux 32bit installer' + VM = '/vmware/bin/linux_build' def run_vm(self): self.__p = Popen('/vmware/bin/linux_build') @@ -569,25 +599,23 @@ class build_linux32(VMInstaller): return _build_linux() -class build_windows(VMInstaller): +class build_windows(KVMInstaller): description = 'Build windows installer' - VM = '/mnt/backup/calibre_windows_xp_home/calibre_windows_xp_home.vmx' - if not os.path.exists(VM): - VM = '/home/kovid/calibre_windows_xp_home/calibre_windows_xp_home.vmx' + VM = '/vmware/bin/win_build' def run(self): installer = installer_name('exe') - self.start_vm('windows', ('python setup.py develop', + self.start_vm('win_build', ('python setup.py develop', 'python', r'installer\\windows\\freeze.py')) if os.path.exists('build/py2exe'): shutil.rmtree('build/py2exe') - check_call(('scp', '-rp', 'windows:build/%s/build/py2exe'%__appname__, + check_call(('scp', '-rp', 'win_build:build/%s/build/py2exe'%__appname__, 'build')) if not os.path.exists('build/py2exe'): raise Exception('Failed to run py2exe') if not self.dont_shutdown: - Popen(('ssh', 'windows', 'shutdown', '-s', '-t', '0')) + Popen(('ssh', 'win_build', 'shutdown', '-s', '-t', '0')) self.run_windows_install_jammer(installer) return os.path.basename(installer) @@ -613,9 +641,7 @@ class build_osx(VMInstaller): def run(self): installer = installer_name('dmg') python = '/Library/Frameworks/Python.framework/Versions/Current/bin/python' - if os.path.exists('/dev/kvm'): - check_call('sudo rmmod -w kvm-intel kvm', shell=True) - check_call('sudo /etc/init.d/vmware restart', shell=True) + self.start_vmware() self.start_vm('osx_build', ('sudo %s setup.py develop'%python, python, 'installer/osx/freeze.py')) check_call(('scp', 'osx_build:build/calibre/dist/*.dmg', 'dist')) @@ -624,18 +650,9 @@ class build_osx(VMInstaller): if not self.dont_shutdown: Popen(('ssh', 'osx_build', 'sudo', '/sbin/shutdown', '-h', 'now')) time.sleep(20) - while True: - try: - check_call('sudo /etc/init.d/vmware stop', shell=True) - break - except: - pass - check_call('sudo modprobe kvm-intel', shell=True) - + self.stop_vmware() return os.path.basename(installer) - - class upload_installers(OptionlessCommand): description = 'Upload any installers present in dist/' def curl_list_dir(self, url=MOBILEREAD, listonly=1):