~ubuntu-branches/ubuntu/trusty/gnupg/trusty-updates

« back to all changes in this revision

Viewing changes to scripts/mk-w32-dist

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-12-04 22:26:16 UTC
  • mfrom: (1.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20121204222616-cr0fow26geq90l3y
Tags: 1.4.12-6ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Disable mlock() test since it fails with ulimit 0 (on buildds).
  - Set gpg (or gpg2) and gpgsm to use a passphrase agent by default.
  - Only suggest gnupg-curl and libldap; recommendations are pulled into
    minimal, and we don't need the keyserver utilities in a minimal Ubuntu
    system.
  - Remove the Win32 build.
  - Update config.guess/config.sub for aarch64.
* Dropped patches:
  - Fix udeb build failure on powerpc, building with -O2 instead of -Os.
    (No longer seems to be necessary.)
* Simplify removal of Win32 build, to make this easier to merge in future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
#
3
 
# Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
3
# Copyright (C) 2000, 2001, 2002, 2004, 2005,
 
4
#               2012 Free Software Foundation, Inc.
4
5
#
5
6
# This file is free software; as a special exception the author gives
6
7
# unlimited permission to copy and/or distribute it, with or without
11
12
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13
 
13
14
set -e
14
 
cd dist-w32
15
 
 
16
 
tmp="`echo $0 | sed 's,.*gnupg-\([^/]*\)/.*,\1,'`"
17
 
 
18
 
topdir=
19
 
bindir=..
20
 
 
21
 
if [ -f "../gnupg-$tmp/README" ]; then
22
 
    srcdir="../gnupg-$tmp"
23
 
    bindir="../gnupg-$tmp"
24
 
    topdir=".."
25
 
elif [ -f ../README ]; then
26
 
    srcdir=..
27
 
elif [ -f ../../README ]; then
28
 
    srcdir=../..
29
 
    bindir=..
30
 
elif [ -f ../../gnupg-stable/README ]; then
31
 
    srcdir=../../gnupg-stable
32
 
elif [ -f ../../../gnupg-stable/README ]; then
33
 
    srcdir=../../../gnupg-stable
34
 
else
35
 
    echo "cannot figure out the source dir" >&2
36
 
    exit 1
37
 
fi
 
15
 
 
16
PGM="mk-w32-dist"
 
17
[ -z "$w32root" ] && w32root="$HOME/w32root"
38
18
 
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
43
23
# of days.
44
24
if [ "$1" = "--build-number" -a -n "$2" ]; then
45
25
   build_number="$2"
46
 
   shift 
 
26
   shift
47
27
   shift
48
28
else
49
29
   build_number=$(date -u '+%j%H' | sed 's/^0*\(.*\)/\1/')
50
30
fi
51
31
 
52
 
 
53
 
if i586-mingw32msvc-strip --version >/dev/null 2>&1 ; then
 
32
if [ "$1" = "--iconv-dir" -a -n "$2" ]; then
 
33
   iconvdir="$2"
 
34
   shift
 
35
   shift
 
36
else
 
37
   iconvdir="${w32root}/share/gnupg-1-extra/iconv"
 
38
fi
 
39
 
 
40
if [ $# -lt 1 -o $# -gt 2 -o "$1" = "--help" ]; then
 
41
   echo "usage: $PGM [options] TARBALL [PATCHFILE]" >&2
 
42
   echo "       Options:" >&2
 
43
   echo "         --build-number N    Windows build number" >&2
 
44
   echo "         --iconv-dir DIR     Directory with inconv files" >&2
 
45
   exit 1
 
46
fi
 
47
 
 
48
 
 
49
if [ ! -d "$iconvdir" ]; then
 
50
   echo "$PGM: iconv directory does not exists (use option --iconv-dir)" >&2
 
51
   exit 1
 
52
fi
 
53
( set +e
 
54
  cd "${iconvdir}"
 
55
  cat <<EOF | sha1sum -c >/dev/null
 
56
44f7289042b71631acac29b2f143330d2da2479e  COPYING.LIB
 
57
3f4262714a3b508cf20428f046d511f7bfb9fd89  README.iconv
 
58
a21c860b81ed158e91b2b921b752f48fda6d6f1e  iconv.dll
 
59
EOF
 
60
  if [ $? != 0 ]; then
 
61
    echo "$PGM: iconv files are not available or not correct" >&2
 
62
    exit 1
 
63
  fi
 
64
  set -e
 
65
)
 
66
 
 
67
here="$(pwd)"
 
68
builddir=w32-build-root
 
69
tarball="$1"
 
70
patchfile="$2"
 
71
 
 
72
if [ ! -f "$tarball" ]; then
 
73
    echo "$PGM: tarball does not exist" >&2
 
74
    exit 1
 
75
fi
 
76
[ "$(echo "$tarball" | head -c 1)" != "/" ] && tarball="$(pwd)/$tarball"
 
77
 
 
78
if [ -n "$patchfile" -a ! -f "$patchfile" ]; then
 
79
    echo "$PGM: patchfile does not exist" >&2
 
80
    exit 1
 
81
fi
 
82
 
 
83
if ! makensis -version >/dev/null 2>&1 ; then
 
84
    echo "$PGM: error: makensis is not installed" >&2
 
85
    exit 1
 
86
fi
 
87
 
 
88
 
 
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
55
93
else
56
 
   STRIP="mingw32 strip"
57
 
fi
58
 
 
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
61
 
    topdir=
62
 
fi
 
94
   echo "$PGM: error: strip tool not found" >&2
 
95
   exit 1
 
96
fi
 
97
 
 
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
 
103
 
 
104
[ -n "$patchfile" ] && echo "patchfile: $patchfile" >&2
 
105
echo "workdir: $builddir" >&2
 
106
 
 
107
echo "preparing work directory ..." >&2
 
108
[ -d "$builddir" ] && rm -rf "$builddir"
 
109
mkdir "$builddir"
 
110
cd "$builddir"
 
111
mkdir dist-w32
 
112
 
 
113
echo "unpacking tarball ..." >&2
 
114
tar xzf "$tarball"
 
115
cd gnupg-"$version"
 
116
 
 
117
if [ -n "$patchfile" ]; then
 
118
  echo "applying patchfile ..." >&2
 
119
  patch -p1 -t < "$patchfile"
 
120
fi
 
121
 
 
122
echo "running configure ..." >&2
 
123
./autogen.sh --build-w32 --silent
 
124
 
 
125
echo "running make ..." >&2
 
126
make -s
 
127
 
 
128
 
 
129
cd ../dist-w32
 
130
srcdir="../gnupg-$version"
 
131
bindir="../gnupg-$version"
63
132
 
64
133
 
65
134
# A function to return a plain ASCII (or Latin-1) encoded description
95
164
        sk)    r="Slovensky"; ;;
96
165
        sv)    r="Svenska"; ;;
97
166
        tr)    r="Türkçe"; ;;
 
167
        uk)    r="Ukrainian"; ;;
98
168
        zh_CN) r="Chinese (simplified)"; ;;
99
169
        zh_TW) r="Chinese (traditional)"; ;;
100
170
 
103
173
    echo "$r"
104
174
}
105
175
 
106
 
 
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)"
112
 
 
113
 
rm * >/dev/null 2>/dev/null || true
114
 
 
 
176
echo "copying files ..." >&2
115
177
cp ${bindir}/g10/gpg.exe gpg.exe
116
178
$STRIP gpg.exe
117
179
cp ${bindir}/g10/gpgv.exe gpgv.exe
118
180
$STRIP 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
122
184
done
123
185
cp ${bindir}/tools/gpgsplit.exe gpgsplit.exe
124
186
$STRIP gpgsplit.exe
125
187
 
126
 
for i in FAQ; do
127
 
  cp ${bindir}/doc/$i $i.txt
128
 
  todos $i.txt
129
 
done
130
188
man -Tlatin1 -l ${srcdir}/doc/gpg.1 | sed `printf "s/_\b//g;s/\b.//g"`  >gpg.man
131
189
todos 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
143
201
 
144
 
patches_defs=
145
 
for i in `find "$topdir/patches" -type f \( -name '*.diff' -o -name '*.tar.gz' \)`; do
146
 
  cp $i .
 
202
if [ -n "$patchfile" ]; then
 
203
  echo "copying patch file ..." >&2
 
204
  cp $patchfile patches.diff
147
205
  patches_defs="-DWITH_PATCHES"
148
 
done
149
 
 
150
 
 
 
206
fi
 
207
 
 
208
 
 
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.
154
213
langlist=""
155
214
langdesclist=""
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
161
 
    
 
220
 
162
221
       fromset=`sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' $i`
163
 
       case "$fromset" in 
164
 
         utf8|utf-8|UTF8|UTF-8) 
165
 
           echo "$lang: keeping $fromset" >&2 
 
222
       case "$fromset" in
 
223
         utf8|utf-8|UTF8|UTF-8)
 
224
           echo "$lang: keeping $fromset" >&2
166
225
           msgfmt --output-file=$lang.mo $i
167
226
           ;;
168
227
         *)
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 -
195
254
EOF
196
255
 
197
256
 
198
 
# If we have a topdir, assume the full build environment and 
199
 
# prepare the installer
200
 
if [ -n "$topdir" ]; then
201
 
  winpt_defs=
202
 
  src_defs=
203
 
  buildinfo="`date -u '+%Y-%m-%d %H:%M UTC'`"
204
 
 
205
 
  # iconv.dll is a hard requirement
206
 
  if [ ! -f "$topdir/iconv/iconv.dll" ]; then
207
 
    echo "iconv.dll not available" >&2
208
 
    exit 1
209
 
  fi
210
 
  ln "$topdir/iconv/iconv.dll" iconv.dll
211
 
  for i in COPYING.LIB README.iconv; do
212
 
     cp ${topdir}/iconv/$i $i.txt
213
 
     todos $i.txt
214
 
  done
215
 
  
216
 
  # WinPT is optional
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"
224
 
  fi
225
 
 
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
229
 
    have_gnupg_src=no
230
 
    have_libiconv_src=no
231
 
    have_winpt_src=no
232
 
    for i in `find "$topdir/tarballs" -type f -name '*.tar.gz'`; do
233
 
       fname=$(basename "$i" .gz)
234
 
       zcat "$i" > "$fname"
235
 
       case "$fname" in
236
 
           gnupg-*)
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
242
 
                   exit 1
243
 
               fi
244
 
               have_gnupg_src=yes
245
 
               ;;
246
 
           libiconv-*)
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
252
 
               ;;
253
 
           winpt-*)
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"
258
 
               have_winpt_src=yes
259
 
               ;;
260
 
               
261
 
           *) 
262
 
               echo "WARNING: unknown source file $fname ignored" >&2
263
 
               ;;
264
 
       esac
265
 
    done
266
 
    if [ -n "$src_defs" ]; then
267
 
        if [ $have_gnupg_src = "no" ]; then
268
 
            echo "gnupg source missing" >&2
269
 
            exit 1
270
 
        fi
271
 
        if [ $have_libiconv_src = "no" ]; then
272
 
            echo "libiconv source missing" >&2
273
 
            exit 1
274
 
        fi
275
 
        if [ -n "$winpt_defs" ]; then
276
 
            if [ $have_winpt_src = "no" ]; then
277
 
                echo "winpt source missing" >&2
278
 
                exit 1
279
 
            fi
280
 
        fi
281
 
 
282
 
        src_defs="$src_defs -DWITH_SOURCE"
283
 
    fi
284
 
 
285
 
  fi
286
 
 
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
298
 
else
299
 
  zip -9 "gnupg-w32cli-${version}.zip" *
300
 
  echo "ZIP archive created" >&2
301
 
fi
 
257
src_defs=
 
258
buildinfo="`date -u '+%Y-%m-%d %H:%M UTC'`"
 
259
 
 
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
 
264
   todos $i.txt
 
265
done
 
266
 
 
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}"/
 
278
cd "${here}"
 
279
echo "gnupg-w32cli-${version}.exe ready." >&2