11
12
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
tmp="`echo $0 | sed 's,.*gnupg-\([^/]*\)/.*,\1,'`"
21
if [ -f "../gnupg-$tmp/README" ]; then
22
srcdir="../gnupg-$tmp"
23
bindir="../gnupg-$tmp"
25
elif [ -f ../README ]; then
27
elif [ -f ../../README ]; then
30
elif [ -f ../../gnupg-stable/README ]; then
31
srcdir=../../gnupg-stable
32
elif [ -f ../../../gnupg-stable/README ]; then
33
srcdir=../../../gnupg-stable
35
echo "cannot figure out the source dir" >&2
17
[ -z "$w32root" ] && w32root="$HOME/w32root"
39
19
# Windows uses an internal build number. We use the last day of the
40
20
# year concatenated with the hour. for it. If it happens that a new
44
24
if [ "$1" = "--build-number" -a -n "$2" ]; then
49
29
build_number=$(date -u '+%j%H' | sed 's/^0*\(.*\)/\1/')
53
if i586-mingw32msvc-strip --version >/dev/null 2>&1 ; then
32
if [ "$1" = "--iconv-dir" -a -n "$2" ]; then
37
iconvdir="${w32root}/share/gnupg-1-extra/iconv"
40
if [ $# -lt 1 -o $# -gt 2 -o "$1" = "--help" ]; then
41
echo "usage: $PGM [options] TARBALL [PATCHFILE]" >&2
43
echo " --build-number N Windows build number" >&2
44
echo " --iconv-dir DIR Directory with inconv files" >&2
49
if [ ! -d "$iconvdir" ]; then
50
echo "$PGM: iconv directory does not exists (use option --iconv-dir)" >&2
55
cat <<EOF | sha1sum -c >/dev/null
56
44f7289042b71631acac29b2f143330d2da2479e COPYING.LIB
57
3f4262714a3b508cf20428f046d511f7bfb9fd89 README.iconv
58
a21c860b81ed158e91b2b921b752f48fda6d6f1e iconv.dll
61
echo "$PGM: iconv files are not available or not correct" >&2
68
builddir=w32-build-root
72
if [ ! -f "$tarball" ]; then
73
echo "$PGM: tarball does not exist" >&2
76
[ "$(echo "$tarball" | head -c 1)" != "/" ] && tarball="$(pwd)/$tarball"
78
if [ -n "$patchfile" -a ! -f "$patchfile" ]; then
79
echo "$PGM: patchfile does not exist" >&2
83
if ! makensis -version >/dev/null 2>&1 ; then
84
echo "$PGM: error: makensis is not installed" >&2
89
if i686-w64-mingw32-strip --version >/dev/null 2>&1 ; then
90
STRIP=i686-w64-mingw32-strip
91
elif i586-mingw32msvc-strip --version >/dev/null 2>&1 ; then
54
92
STRIP=i586-mingw32msvc-strip
59
# If we don't have an installer we don't need to prepare for it.
60
if ! makensis -version >/dev/null 2>&1 ; then
94
echo "$PGM: error: strip tool not found" >&2
98
echo "tarball: $tarball" >&2
99
version="$(echo "$tarball" | sed 's,.*/gnupg-\(.*\)\.tar\.gz$,\1,')"
100
prod_version=$(echo "$version"|awk -F'[^0-9]' '{print $1 "." $2 "." $3 }')
101
prod_version="${prod_version}.${build_number}"
102
echo "version: $version ($prod_version)" >&2
104
[ -n "$patchfile" ] && echo "patchfile: $patchfile" >&2
105
echo "workdir: $builddir" >&2
107
echo "preparing work directory ..." >&2
108
[ -d "$builddir" ] && rm -rf "$builddir"
113
echo "unpacking tarball ..." >&2
117
if [ -n "$patchfile" ]; then
118
echo "applying patchfile ..." >&2
119
patch -p1 -t < "$patchfile"
122
echo "running configure ..." >&2
123
./autogen.sh --build-w32 --silent
125
echo "running make ..." >&2
130
srcdir="../gnupg-$version"
131
bindir="../gnupg-$version"
65
134
# A function to return a plain ASCII (or Latin-1) encoded description
107
# Figure out the version
108
version=$(sed -n 's/^#[ ]*define[ ][ ]*VERSION[ ][ ]*\"\([0-9.a-z-]*\)\"/\1/p' $bindir/config.h)
109
prod_version=$(echo "$version"|awk -F'[^0-9]' '{print $1 "." $2 "." $3 }')
110
prod_version="${prod_version}.${build_number}"
111
echo "building version $version ($prod_version)"
113
rm * >/dev/null 2>/dev/null || true
176
echo "copying files ..." >&2
115
177
cp ${bindir}/g10/gpg.exe gpg.exe
117
179
cp ${bindir}/g10/gpgv.exe gpgv.exe
119
for name in hkp curl ldap finger; do
181
for name in hkp curl ldap finger; do
120
182
cp ${bindir}/keyserver/gpgkeys_$name.exe gpgkeys_$name.exe
121
183
$STRIP gpgkeys_$name.exe
123
185
cp ${bindir}/tools/gpgsplit.exe gpgsplit.exe
124
186
$STRIP gpgsplit.exe
127
cp ${bindir}/doc/$i $i.txt
130
188
man -Tlatin1 -l ${srcdir}/doc/gpg.1 | sed `printf "s/_\b//g;s/\b.//g"` >gpg.man
132
190
man -Tlatin1 -l ${srcdir}/doc/gpgv.1 | sed `printf "s/_\b//g;s/\b.//g"` >gpgv.man
141
199
cp ${srcdir}/doc/README.W32 README-W32.txt
142
200
todos README-W32.txt
145
for i in `find "$topdir/patches" -type f \( -name '*.diff' -o -name '*.tar.gz' \)`; do
202
if [ -n "$patchfile" ]; then
203
echo "copying patch file ..." >&2
204
cp $patchfile patches.diff
147
205
patches_defs="-DWITH_PATCHES"
209
echo "converting MO files ..." >&2
151
210
# We must distribute the MO files in UTF-8, the conversion is done by
152
# gpg at runtime. To include English at the right position in the list we
211
# gpg at runtime. To include English at the right position in the list we
153
212
# need a special case.
158
217
if [ $lang != "en" ]; then
159
218
grep -s $lang ${srcdir}/po/LINGUAS >/dev/null || continue
160
219
[ -f$lang.mo -a $lang.mo -nt $i ] && continue
162
221
fromset=`sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' $i`
164
utf8|utf-8|UTF8|UTF-8)
165
echo "$lang: keeping $fromset" >&2
223
utf8|utf-8|UTF8|UTF-8)
224
echo "$lang: keeping $fromset" >&2
166
225
msgfmt --output-file=$lang.mo $i
169
echo "$lang: converting from $fromset to utf-8" >&2
228
echo "$lang: converting from $fromset to utf-8" >&2
170
229
iconv --silent --from-code=$fromset --to-code=utf-8 < $i | \
171
230
sed "/^\"Content-Type:/ s/charset=[a-zA-Z0-9_-]*/charset=utf-8/"|\
172
231
msgfmt --output-file=$lang.mo -
198
# If we have a topdir, assume the full build environment and
199
# prepare the installer
200
if [ -n "$topdir" ]; then
203
buildinfo="`date -u '+%Y-%m-%d %H:%M UTC'`"
205
# iconv.dll is a hard requirement
206
if [ ! -f "$topdir/iconv/iconv.dll" ]; then
207
echo "iconv.dll not available" >&2
210
ln "$topdir/iconv/iconv.dll" iconv.dll
211
for i in COPYING.LIB README.iconv; do
212
cp ${topdir}/iconv/$i $i.txt
217
if [ -f "$topdir/winpt/WinPT.exe" ]; then
218
ln "$topdir/winpt/WinPT.exe" WinPT.exe
219
ln "$topdir/winpt/PTD.dll" PTD.dll
220
cp "$topdir/winpt/README-0.9.txt" README.winpt.txt
221
cp "$topdir/winpt/NEWS-0.9.txt" NEWS.winpt.txt
222
cp "$topdir/winpt/keyserver.conf" keyserver.conf
223
winpt_defs="-DWITH_WINPT"
226
# See whether we should include the source and figure out the
227
# version numbers of the source files.
228
if [ -d "$topdir/tarballs" ]; then
232
for i in `find "$topdir/tarballs" -type f -name '*.tar.gz'`; do
233
fname=$(basename "$i" .gz)
237
tmp=$(echo "$fname" | \
238
sed -n 's/^[^-]*-\([0-9.a-z-]*\)\.tar$/\1/p')
239
echo "gnupg source version is $tmp" >&2
240
if [ "$version" != "$tmp" ]; then
241
echo "gnupg source version does not match" >&2
247
tmp=$(echo "$fname" | \
248
sed -n 's/^[^-]*-\([0-9.a-z-]*\)\.tar$/\1/p')
249
echo "libiconv source version is $tmp" >&2
250
src_defs="$src_defs -DLIBICONV_VERSION=$tmp"
251
have_libiconv_src=yes
254
tmp=$(echo "$fname" | \
255
sed -n 's/^[^-]*-\([0-9.a-z-]*\)\.tar$/\1/p')
256
echo "winpt source version is $tmp" >&2
257
src_defs="$src_defs -DWINPT_VERSION=$tmp"
262
echo "WARNING: unknown source file $fname ignored" >&2
266
if [ -n "$src_defs" ]; then
267
if [ $have_gnupg_src = "no" ]; then
268
echo "gnupg source missing" >&2
271
if [ $have_libiconv_src = "no" ]; then
272
echo "libiconv source missing" >&2
275
if [ -n "$winpt_defs" ]; then
276
if [ $have_winpt_src = "no" ]; then
277
echo "winpt source missing" >&2
282
src_defs="$src_defs -DWITH_SOURCE"
287
# Now run the installer
288
echo "invoking installer as:"
289
echo makensis -v0 -nocd -DVERSION="${version}" \
290
-DPROD_VERSION="${prod_version}" \
291
-DGNUPG_SRCDIR="${srcdir}" ${winpt_defs} ${src_defs} \
292
${patches_defs} ${srcdir}/scripts/w32installer.nsi
293
BUILDINFO=$buildinfo makensis -v0 -nocd -DVERSION="${version}" \
294
-DPROD_VERSION="${prod_version}" \
295
-DGNUPG_SRCDIR="${srcdir}" ${winpt_defs} ${src_defs} \
296
${patches_defs} ${srcdir}/scripts/w32installer.nsi
297
echo "Installer created" >&2
299
zip -9 "gnupg-w32cli-${version}.zip" *
300
echo "ZIP archive created" >&2
258
buildinfo="`date -u '+%Y-%m-%d %H:%M UTC'`"
260
echo "copying iconv ..." >&2
261
cp "${iconvdir}/iconv.dll" iconv.dll
262
for i in COPYING.LIB README.iconv; do
263
cp ${iconvdir}/$i $i.txt
267
# Now run the installer
268
echo "invoking installer as:"
269
echo makensis -v0 -nocd -DVERSION="${version}" \
270
-DPROD_VERSION="${prod_version}" \
271
-DGNUPG_SRCDIR="${srcdir}" ${winpt_defs} ${src_defs} \
272
${patches_defs} ${srcdir}/scripts/w32installer.nsi
273
BUILDINFO=$buildinfo makensis -v0 -nocd -DVERSION="${version}" \
274
-DPROD_VERSION="${prod_version}" \
275
-DGNUPG_SRCDIR="${srcdir}" ${winpt_defs} ${src_defs} \
276
${patches_defs} ${srcdir}/scripts/w32installer.nsi
277
mv gnupg-w32cli-${version}.exe "${here}"/
279
echo "gnupg-w32cli-${version}.exe ready." >&2