forked from hyphanet/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-wininstaller
executable file
·221 lines (200 loc) · 7.61 KB
/
release-wininstaller
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
# This script uses Wine to build the Windows installer executables under a
# restricted user account. A temporary directory contains both a clone of
# the installer repos and the Wine prefix used to build. It is removed after
# the build to make it difficult for state to persist between builds.
#
# Commands are executed as the Wine user via SSH, so passwordless SSH login with
# authorized_keys may be helpful. Wine GUI elements are surpressed with xvfb.
#
# The following files should be in the releaseDirectory:
#
# * dependencies/bcprov-jdk15on-154.jar - https://bouncycastle.org/download/bcprov-jdk15on-154.jar
# * dependencies/isetup-5.5.9-unicode.exe - http://www.jrsoftware.org/download.php/is-unicode.exe
# * dependencies/jsign-1.3-SNAPSHOT.jar - build from https://github.com/ebourg/jsign
# * freenet.jar - Whatever's pointed at by https://downloads.freenetproject.org/alpha/freenet-stable-latest.jar.url
# * JSTUN.jar - https://downloads.freenetproject.org/alpha/plugins/JSTUN/
# * KeyUtils.jar - https://downloads.freenetproject.org/alpha/plugins/KeyUtils/
# * Library.jar - https://downloads.freenetproject.org/alpha/plugins/Library/
# * seednodes.fref - https://downloads.freenetproject.org/alpha/opennet/seednodes.fref
# * ThawIndexBrowser.jar - https://downloads.freenetproject.org/alpha/plugins/ThawIndexBrowser/
# * UPnP.jar - https://downloads.freenetproject.org/alpha/plugins/UPnP/
#
# Though URLs are provided for convenience, building them or acquiring them over
# Freenet is preferable.
#
# Requirements:
# Build:
# sha1sum
# localhost SSH server on port 22
# xvfb
# wine 1.4
# Sign:
# gpg
# Release:
# rsync
TARGET=$1
if [[ x"$TARGET" == x"" ]]; then
echo usage: "$0" TARGET
echo TARGET: build or snapshot, used in release-fred
exit 1
fi
# Load configuration and utility functions.
source freenet-scripts-common "$TARGET" || exit
# Whether to exit before releasing.
dryRun="false"
# Value of WINEDEBUG to run Wine with.
wineDebug=""
# Wininstaller branch to checkout.
branch="master"
# Whether to use Xnest rather than Xvfb. Useful for debugging.
xnest="false"
if [[ $(id -u) -eq 0 && -z "$RUN_AS_USER" ]]
then
echo "Do not run this script as root."
exit 1
fi
while :
do
case $1 in
--help | - | -\?)
cat <<EOF
Builds the Windows installer.
Configuration file is at $configPath by default.
--branch BRANCH Branch to build. Defaults to master.
--config CONFIG Path to freenetrc
--dry-run Do not release. Build and sign the installer, then exit.
--wine-debug Run Wine with the given WINEDEBUG environment variable value.
See http://wiki.winehq.org/DebugChannels
--xnest Run Wine in an Xnest window to display the graphical output.
EOF
exit 0
;;
--config)
configPath="$2"
shift 2
;;
--dry-run)
dryRun="true"
shift
;;
--xnest)
xnest="true"
shift
;;
--wine-debug)
wineDebug="$2"
shift 2
;;
--branch)
branch="$2"
shift 2
;;
--) # End of all options
shift
break
;;
-*)
echo "Unknown option: $1"
exit 1
;;
*) # No more options; stop parsing.
break
;;
esac
done
# Make temporary build directory to hold installer source, dependencies,
# and Wine prefix. This will be wiped on exit.
makeBuildDir
# The Wine user will need access too, and non-root users cannot chown.
# This assumes the Wine user is in a group of the same name along with
# the current user.
#
# If this is not the case, either the Wine user cannot access the build
# directory or the current user cannot chown to a group it is not in.
if [[ -z "$(groups $USER | grep -F "$wineUser")" ]]; then
cat <<EOF
The current user $USER is not a member of the group $wineUser and will not be
able to chgrp the build directory to give $wineUser access. You may have to
execute a new login shell (su $USER) to have the group change take full effect.
EOF
exit 1
fi
git clone "$wininstallerDir" "$buildDir"
pushd "$buildDir" || exit
git checkout "$branch"
getBuildInfo $TARGET
if [[ -z "$gitVersion" ]]; then echo Could not get git version; exit 1; fi
# Copy files
mkdir -p "install_node/plugins/"
cp "$releaseDir/freenet.jar" "install_node/" || exit
cp "$freenetExtPath" "install_node/freenet-ext.jar" || exit
cp "$dependenciesDir/"* "install_node/" || exit
cp "$releaseDir/seednodes.fref" "install_node/" || exit
# TODO: Create plugin directory in the build dir instead of assuming it's part of the repo.
# TODO: Is this an appropriate place to have a bundled plugin list?
for x in JSTUN KeyUtils ThawIndexBrowser UPnP Library Sharesite; do
cp "$releaseDir/${x}.jar" "install_node/plugins/" || exit
done
cp "$dependenciesDir/isetup-5.5.9-unicode.exe" . || exit
echo Copied dependencies.
# Update the installer's listing of Fred version with the current version.
sed -ri "s/^#define AppVersion .*$/#define AppVersion \"0.7.5 build $buildNumber\"/" "FreenetInstall_InnoSetup.iss" || exit
echo "Setting permissions."
chmod -R 770 . || exit
chgrp -R "$wineUser" . || exit
echo Running the build
# The Wine user must create the prefix directory. If the directory is missing
# Wine will refuse to create it if the directory that would contain it is not
# owned by the user.
xvfbrun="xvfb-run --auto-servernum"
ssh="ssh"
if [ "$xnest" == "true" ]; then
xvfbrun=""
Xnest :10 -ac &
OLDDISPLAY="$DISPLAY"
DISPLAY=:10.0
export DISPLAY
ssh="$ssh -X"
fi
# wineDebug as set in the script arguments.
# WINEPREFIX to set up Wine in the temporary directory.
# WINEDLLOVERRIDES to prevent prompts about Gecko and Mono as they are not needed.
# See https://wiki.archlinux.org/index.php/Wine_PKGBUILD_Guidelines#Gecko
$ssh $wineUser@localhost <<EOF
set -x
cd $buildDir;
mkdir .wine;
export WINEDEBUG=$wineDebug WINEPREFIX=$buildDir/.wine WINEDLLOVERRIDES="mscoree,mshtml=";
$xvfbrun wine64 isetup-5.5.9-unicode.exe /SILENT;
# "Program Files (x86)" is for Windows 7 - later versions of Wine.
# XP is still the default for 1.6.2, which is packaged in Jessie.
# wine 'C:\Program Files\Inno Setup 5\ISCC.exe' "FreenetInstall_InnoSetup.iss";
wine64 'C:\Program Files (x86)\Inno Setup 5\ISCC.exe' "FreenetInstall_InnoSetup.iss";
chmod -R 770 .wine Output;
EOF
if [ "$xnest" == "true" ]; then
killall Xnest
DISPLAY="$OLDDISPLAY"
fi
cp "Output/FreenetInstaller.exe" "FreenetInstaller-$buildNumber.exe" || exit
pushd $freenetRoot/scripts
./sign-exe "$buildDir/FreenetInstaller-$buildNumber.exe" "Freenet 0.7 Installer" || exit
popd
pushd "install_node/updater/" || exit
cp update.cmd update-new.cmd || exit
sha1sum update-new.cmd > update-new.cmd.sha1 || exit
sha1sum update.cmd > update.cmd.sha1 || exit
popd
signingCommand="cd $buildDir; gpg --sign --detach-sign FreenetInstaller-$buildNumber.exe"
if [[ -z "$signingUser" ]]
then
echo Signing
eval "$signingCommand" || exit
else
echo Signing as $signingUser
su - $signingUser -c "$signingCommand" || exit
fi
echo "Fred git version is $gitVersion"
echo "Fred commit ID is $commitID"
cp FreenetInstaller-$buildNumber.exe* $releaseDir || exit