1# UNUSED
2
3#!/bin/bash
4
5# Run with as parameter a setup.py that works in the current directory
6# e.g. no os.chdir()
7# It will run twice, the first time will crash
8
9set -e
10
11SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
12
13if [ ! -d wine-py2exe ]; then
14
15    sudo apt-get install wine1.3 axel bsdiff
16
17    mkdir wine-py2exe
18    cd wine-py2exe
19    export WINEPREFIX=`pwd`
20
21    axel -a "http://www.python.org/ftp/python/2.7/python-2.7.msi"
22    axel -a "http://downloads.sourceforge.net/project/py2exe/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe"
23    #axel -a "http://winetricks.org/winetricks"
24
25    # http://appdb.winehq.org/objectManager.php?sClass=version&iId=21957
26    echo "Follow python setup on screen"
27    wine msiexec /i python-2.7.msi
28
29    echo "Follow py2exe setup on screen"
30    wine py2exe-0.6.9.win32-py2.7.exe
31
32    #echo "Follow Microsoft Visual C++ 2008 Redistributable Package setup on screen"
33    #bash winetricks vcrun2008
34
35    rm py2exe-0.6.9.win32-py2.7.exe
36    rm python-2.7.msi
37    #rm winetricks
38
39    # http://bugs.winehq.org/show_bug.cgi?id=3591
40
41    mv drive_c/Python27/Lib/site-packages/py2exe/run.exe drive_c/Python27/Lib/site-packages/py2exe/run.exe.backup
42    bspatch drive_c/Python27/Lib/site-packages/py2exe/run.exe.backup drive_c/Python27/Lib/site-packages/py2exe/run.exe "$SCRIPT_DIR/SizeOfImage.patch"
43    mv drive_c/Python27/Lib/site-packages/py2exe/run_w.exe drive_c/Python27/Lib/site-packages/py2exe/run_w.exe.backup
44    bspatch drive_c/Python27/Lib/site-packages/py2exe/run_w.exe.backup drive_c/Python27/Lib/site-packages/py2exe/run_w.exe "$SCRIPT_DIR/SizeOfImage_w.patch"
45
46    cd -
47
48else
49
50    export WINEPREFIX="$( cd wine-py2exe && pwd )"
51
52fi
53
54wine "C:\\Python27\\python.exe" "$1" py2exe > "py2exe.log" 2>&1 || true
55echo '# Copying python27.dll' >> "py2exe.log"
56cp "$WINEPREFIX/drive_c/windows/system32/python27.dll" build/bdist.win32/winexe/bundle-2.7/
57wine "C:\\Python27\\python.exe" "$1" py2exe >> "py2exe.log" 2>&1
58
59