-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows-create-installer.sh
executable file
·125 lines (94 loc) · 2.98 KB
/
windows-create-installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
# Source common library
. ./lib.sh
# Check if 32-bit executable exists
if [ ! -f dist/sbagen+-win32.exe ]; then
error "32-bit executable not found. Run ./windows-build-sbagen+.sh first."
exit 1
fi
SETUP_NAME="sbagen+-windows-setup.exe"
# Remove the existing installer if it exists
rm -f dist/${SETUP_NAME}
section_header "Creating Windows Installer..."
# Set up wine environment
export WINEARCH=win32
export WINEPREFIX=/tmp/wineprefix
export WINEDEBUG=-all
export WINEDLLOVERRIDES="winemenubuilder.exe=d"
export DISPLAY=:99
# Increase Wine memory limits
export WINE_LARGE_ADDRESS_AWARE=1
export WINE_HEAP_MAXRESERVE=4096
# Get Xvfb PID
XVFB_PID=$(pgrep -f "Xvfb $DISPLAY -screen 0 1024x768x16")
# Start Xvfb to provide a virtual display if it's not already running
if [ -z "$XVFB_PID" ]; then
info "Starting Xvfb for headless Wine operation..."
Xvfb $DISPLAY -screen 0 1024x768x16 & XVFB_PID=$!
sleep 2 # Wait for Xvfb to start
fi
# Initialize Wine prefix if it doesn't exist
if [ ! -d "$WINEPREFIX" ]; then
info "Initializing Wine prefix..."
wineboot -i > /dev/null 2>&1
# Wait for wineboot to complete
sleep 5
fi
# Check if Inno Setup is installed in Wine
ISCC="$WINEPREFIX/drive_c/Program Files/Inno Setup 6/ISCC.exe"
if [ ! -f "$ISCC" ]; then
info "Inno Setup not found. Downloading and installing..."
# Create temp directory
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
# Download Inno Setup
curl -L -o innosetup.exe -s "https://files.jrsoftware.org/is/6/innosetup-6.4.2.exe"
if [ $? -ne 0 ]; then
error "Failed to download Inno Setup"
kill $XVFB_PID
exit 1
fi
# Install Inno Setup silently
info "Installing Inno Setup..."
wine innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /NOICONS
# Wait for installation to complete
sleep 10
wineserver -w
# Clean up
cd - > /dev/null
rm -rf "$TEMP_DIR"
if [ ! -f "$ISCC" ]; then
error "Failed to install Inno Setup"
kill $XVFB_PID
exit 1
fi
fi
# Create the installer
info "Creating installer..."
# Kill any hanging wine processes
wineserver -k
# For convert *.md to *.txt
create_dir_if_not_exists "build"
# Convert README.md to README.txt
pandoc -f markdown -t plain README.md -o build/README.txt
# Convert USAGE.md to USAGE.txt
pandoc -f markdown -t plain USAGE.md -o build/USAGE.txt
# Convert RESEARCH.md to RESEARCH.txt
pandoc -f markdown -t plain RESEARCH.md -o build/RESEARCH.txt
# Run ISCC with increased memory limits and in silent mode
wine "$ISCC" /O+ /Q setup.iss
# Check if the installer was created successfully
if [ ! -f "dist/${SETUP_NAME}" ]; then
error "Failed to create installer"
# Kill any hanging processes
wineserver -k
kill $XVFB_PID
exit 1
fi
success "Installer created successfully at dist/${SETUP_NAME}"
# Final cleanup
wineserver -w
rm -rf "$WINEPREFIX" build
# Kill Xvfb
kill $XVFB_PID
section_header "Build process completed!"