-
Notifications
You must be signed in to change notification settings - Fork 27
/
makesetup.in
617 lines (520 loc) · 15 KB
/
makesetup.in
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
#! /bin/bash
# NSIS installer generator for GNU Smalltalk
# Written by Paolo Bonzini.
# Copyright (C) 2010 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Caveats:
# 0) Only Fedora is supported as a cross-compilation environment
# 1) Install all mingw packages and wine; start a random wine app
# to ensure you have ~/.wine/drive_c
# 2) cp -R /usr/i686-pc-mingw32/sys-root/mingw/ ~/.wine/drive_c/mingw
# 3) Configure gst as follows:
# ../configure \
# --host=i686-pc-mingw32 \
# --prefix=/nonexistent \
# --exec-prefix=/nonexistent \
# --bindir=/nonexistent \
# --datarootdir=/nonexistent \
# --with-imagedir=/nonexistent/image \
# --with-moduledir=/nonexistent/modules \
# --disable-glibtest \
# --disable-gtktest \
# LDFLAGS=-L/usr/i686-pc-mingw32/sys-root/mingw/lib/
# 4) Run ./makesetup
unset BASH_ENV CDPATH ENV MAIL MAILPATH
export LC_ALL=C LANGUAGE=C
(echo <(echo)) >/dev/null 2>&1 || exec bash "$0" "$@"
BS="\\"
set -e
# --------------------------------------------------------------------------
# Autoconf data
# --------------------------------------------------------------------------
PACKAGE='@PACKAGE@'
PACKAGE_NAME='@PACKAGE_NAME@'
PACKAGE_URL='@PACKAGE_URL@'
VERSION='@VERSION@'
prefix='@prefix@'
exec_prefix='@exec_prefix@'
datarootdir=@datarootdir@
datadir=@datadir@
pkgdatadir=@pkgdatadir@
bindir=@bindir@
localstatedir=@localstatedir@
imagedir=@imagedir@
libexecdir=@libexecdir@
moduledir=@moduledir@
# --------------------------------------------------------------------------
# Extra definitions
# --------------------------------------------------------------------------
builddir=$PWD
MINGWROOT=/usr/i686-pc-mingw32/sys-root/mingw
# --------------------------------------------------------------------------
# Shell functions
# --------------------------------------------------------------------------
array_set()
{
local name
name=$1
shift
eval "$name=(\"\$@\")"
}
array_append()
{
local name
name=$1
shift
eval "$name+=(\"\$@\")"
}
array_copy()
{
eval "$1=(\"\${$2[@]}\")"
}
array_concat()
{
eval "$1+=(\"\${$2[@]}\")"
}
array_lines()
{
local template
template="%s\n"
eval printf \$template "\"\${$1[@]}\""
}
array_readfile()
{
local IFS
IFS=$'\n'
read -a $1 -d$'\001' -r < $2 || :
}
array_sort()
{
local -a _copy
local name
name=$1
shift
array_copy _copy $name
array_readfile $name <(array_lines _copy | sort "$@")
}
array_sub()
{
local -a _copy
array_copy _copy $1
array_readfile $1 <(array_lines _copy | grep -Fvxf <(array_lines $2))
}
xargs_dirname()
{
sed 's/^\(.*[^/]\)\/\/*[^/][^/]*\/*$/\1/; t
s/^\(\/\/\)[^/].*/\1/; t
s/^\(\/\/\)$/\1/; t
s/^\(\/\).*/\1/; t
s/.*/./; t'
}
xargs_basename()
{
sed 's/^.*\/\([^/][^/]*\)\/*$/\1/; t
s/^\/\(\/\/\)$/\1/; t
s/^\/\(\/\).*/\1/; t
s/.*/./; t'
}
# --------------------------------------------------------------------------
# Build
# --------------------------------------------------------------------------
DESTDIR=$builddir/stage
rm -rf $DESTDIR
make install DESTDIR=$DESTDIR
cd $DESTDIR/nonexistent
# not distributed
rm -f smalltalk/VFSAddOns.star
# no need to manually load dependencies
find . -name "*.la" | xargs sed -i "s/^dependency_libs=.*/dependency_libs=''/"
# --------------------------------------------------------------------------
# Shell functions to build installation sections
# --------------------------------------------------------------------------
n=1
add_section()
{
eval $1=\$n
array_append sections "$2"
array_append section_descriptions "$3"
shift
shift
shift
array_set outfiles$n "$@"
((n++))
}
add_to_section()
{
local id
id=$1
shift
array_append outfiles$id "$@"
}
distribute_mingw_file()
{
case $1 in
/usr/*) return 1 ;;
bin/*.dll) return 0 ;;
bin/*) return 1 ;;
include/*) return 1 ;;
*/*.def) return 1 ;;
*/*.o) return 1 ;;
*/*.a) return 1 ;;
*/*.la) return 1 ;;
*/*.pc) return 1 ;;
*/*.h) return 1 ;;
*/*.py*) return 1 ;;
*/*.mo) return 1 ;; # debatable, but saves 6 MB
lib/gettext/*) return 1 ;;
share/aclocal/*) return 1 ;;
share/doc/*) return 1 ;;
share/gtk-2.0/demo/*) return 1 ;;
share/gtk-doc) return 1 ;;
share/info/*) return 1 ;;
share/gettext/*) return 1 ;;
share/*/gettext/*) return 1 ;;
share/*/gettext-tools.mo) return 1 ;;
share/man/*) return 1 ;;
*) return 0 ;;
esac
}
add_mingw_rpms ()
{
local -a files instfiles
local name package dest
name=$1
shift
for package; do
rpm -qi $package >/dev/null || exit 1
array_readfile files <(rpm -ql $package)
array_readfile instfiles <(
for i in "${files[@]}"; do
test -d "$i" && continue
dest=${i#$MINGWROOT/}
if distribute_mingw_file $dest; then
dest=${dest#bin/}
mkdir -p `dirname $dest`
ln -sf $i $dest
echo $dest
fi
done)
array_concat outfiles$name instfiles
done
}
# --------------------------------------------------------------------------
# Installation sections
# --------------------------------------------------------------------------
add_section basic \
"Basic installation" \
"Basic installation of GNU Smalltalk, including network access" \
gst.exe \
./libgst-[0-9].dll \
image/gst.im
add_mingw_rpms $basic \
mingw32-runtime \
mingw32-libffi \
mingw32-libltdl \
mingw32-libsigsegv
add_section ide \
"IDE" \
"IDE for GNU Smalltalk" \
./gst-browser.exe \
./gst-blox.exe \
./libgst-gobject-[0-9].dll \
smalltalk/BLOXBrowser.star \
smalltalk/Blox.star \
smalltalk/BloxGTK.star \
smalltalk/Cairo.star \
smalltalk/GLib.star \
smalltalk/GTK.star \
smalltalk/VisualGST.star \
smalltalk/examples/Man.st \
smalltalk/examples/Tetris.st \
modules/gst-glib*.dll \
modules/gst-glib.la
modules/gst-gtk*.dll \
modules/gst-gtk.la
add_mingw_rpms $ide \
mingw32-glib2 mingw32-gtk2 mingw32-pango mingw32-atk \
mingw32-cairo mingw32-pixman \
mingw32-fontconfig mingw32-freetype \
mingw32-jasper mingw32-libjpeg mingw32-libpng \
mingw32-gettext \
mingw32-iconv \
mingw32-zlib
add_section devel \
"Module development" \
"Files needed to write extension modules for GNU Smalltalk" \
gst-config \
`find include -type f` \
`find lib -type f`
add_section expat \
"Expat" \
"Expat bindings for GNU Smalltalk" \
smalltalk/XML-Expat.star \
modules/expat*.dll \
modules/expat.la
add_mingw_rpms $expat mingw32-expat
add_section cairo \
"Cairo" \
"Cairo bindings for GNU Smalltalk" \
smalltalk/Cairo.star
add_mingw_rpms $cairo mingw32-cairo mingw32-pixman
add_section sdl \
"SDL" \
"LibSDL bindings for GNU Smalltalk" \
smalltalk/Cairo.star \
smalltalk/CairoSDL.star \
smalltalk/LibSDL.star \
smalltalk/LibSDL_GL.star \
smalltalk/OpenGL.star \
smalltalk/examples/Cairo*.st \
modules/gstopengl*.dll \
modules/gstopengl.la \
modules/sdl*.dll \
modules/sdl.la
add_mingw_rpms $sdl mingw32-cairo mingw32-pixman mingw32-SDL
add_section iconv \
"Unicode" \
"Unicode support for GNU Smalltalk (required by Iliad and Seaside)" \
smalltalk/Iconv.star \
modules/iconv*.dll \
modules/iconv.la
add_mingw_rpms $iconv mingw32-iconv
add_section zlib \
"zlib" \
"zlib bindings for GNU Smalltalk" \
smalltalk/Zlib.star \
modules/zlib*.dll \
modules/zlib.la
add_mingw_rpms $zlib mingw32-zlib
add_section sqlite \
"sqlite" \
"SQLite bindings for GNU Smalltalk" \
smalltalk/DBD-SQLite.star \
modules/dbd-sqlite3*.dll \
modules/dbd-sqlite3.la
add_mingw_rpms $sqlite mingw32-sqlite
add_section gdbm \
"GDBM" \
"GDBM bindings for GNU Smalltalk" \
smalltalk/GDBM.star \
modules/gdbm*.dll \
modules/gdbm.la
add_mingw_rpms $gdbm mingw32-gdbm
add_section gtk \
"GTK+" \
"GTK+ bindings for GNU Smalltalk" \
smalltalk/BLOXBrowser.star \
smalltalk/Blox.star \
smalltalk/BloxGTK.star \
smalltalk/Cairo.star \
smalltalk/GTK.star \
smalltalk/VisualGST.star \
smalltalk/examples/Man.st \
smalltalk/examples/Tetris.st \
modules/gst-gtk*.dll \
modules/gst-gtk.la
add_mingw_rpms $gtk \
mingw32-glib2 mingw32-gtk2 mingw32-pango mingw32-atk \
mingw32-cairo mingw32-pixman \
mingw32-fontconfig mingw32-freetype \
mingw32-jasper mingw32-libjpeg mingw32-libpng \
mingw32-gettext \
mingw32-iconv \
mingw32-zlib
# Add all other .star files to the Basic section
outfiles=()
n=1
for i in "${sections[@]}"; do
array_concat outfiles outfiles$n
((n++))
done
array_readfile packages <(
find . -name "gst*.exe"
find smalltalk -type f
find modules -type f \! -name "*.a")
array_sub packages outfiles
add_to_section $basic "${packages[@]}"
# --------------------------------------------------------------------------
# Prologue
# --------------------------------------------------------------------------
declare -a outfiles
exec 3>&1
exec > setup.nsi
cat << EOF
; ${PACKAGE_NAME} Windows(R) installation script
; Copyright (C) Free Software Foundation, Inc.
; Written by Paolo Bonzini <[email protected]>
; Product defines
!define PRODUCT_NAME "${PACKAGE_NAME}"
!define PRODUCT_WEB_SITE "${PACKAGE_URL}"
!define PRODUCT_VERSION "${VERSION}"
!define PRODUCT_STARTMENU "${PACKAGE_NAME}"
EOF
case ${VERSION} in
?*.*.*.*) echo "!define PRODUCT_VERSIONINFO_VERSION \"${VERSION}\"" ;;
?*.*.*) echo "!define PRODUCT_VERSIONINFO_VERSION \"${VERSION}.0\"" ;;
?*.*) echo "!define PRODUCT_VERSIONINFO_VERSION \"${VERSION}.0.0\"" ;;
?*) echo "!define PRODUCT_VERSIONINFO_VERSION \"${VERSION}.0.0.0\"" ;;
'') echo "!define PRODUCT_VERSIONINFO_VERSION \"0.0.0.0\"" ;;
esac
# --------------------------------------------------------------------------
cat << \EOF
!define PRODUCT_PUBLISHER "Free Software Foundation, Inc."
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_INSTDIR "$PROGRAMFILES\${PRODUCT_NAME}"
!define OUTFILE_NAME "setup.exe"
; Include required libraries
!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "WinVer.nsh"
!include "x64.nsh"
!include "Sections.nsh"
; MUI Settings
; !define MUI_HEADERIMAGE
; !define MUI_HEADERIMAGE_BITMAP "graphics\RHrgbjpg.bmp"
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_LICENSEPAGE_CHECKBOX
; MUI pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Language files
!insertmacro MUI_LANGUAGE "English"
; NSIS declarations
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${OUTFILE_NAME}"
Icon "${MUI_ICON}"
UninstallIcon "${MUI_UNICON}"
InstallDir "${PRODUCT_INSTDIR}"
RequestExecutionLevel admin
VIProductVersion "${PRODUCT_VERSIONINFO_VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${PRODUCT_NAME}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "${PRODUCT_PUBLISHER}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright (C) ${PRODUCT_PUBLISHER}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${PRODUCT_NAME} Installer"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${PRODUCT_VERSION:-0.0}"
EOF
# --------------------------------------------------------------------------
# File list
# --------------------------------------------------------------------------
n=1
outfiles=()
for i in "${sections[@]}"; do
echo "Section \"$i\" SEC$n"
test $n = 1 && echo ' SectionIn RO'
test $n = 1 && echo ' SetOverwrite try'
array_concat outfiles outfiles$n
array_lines outfiles$n | sort -u | {
prevdir=---
while read i; do
winpath=`echo "$i" | tr / "$BS$BS" `
dir=`dirname $i`
test "$dir" = "$prevdir" || {
windirpath='$INSTDIR\'`echo "$dir" | tr / "$BS$BS" `
echo " SetOutPath \"$windirpath\""
}
prevdir=$dir
echo " File \"$winpath\""
done
}
echo SectionEnd
echo
((n++))
done
array_sort outfiles
# --------------------------------------------------------------------------
# Post-install
# --------------------------------------------------------------------------
cat << \EOF
Section -AdditionalIcons
CreateDirectory "$SMPROGRAMS\${PRODUCT_STARTMENU}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_STARTMENU}\Uninstall.lnk" "$INSTDIR\uninst.exe"
EOF
n=1
for i in "${sections[@]}"; do
cat << EOF
!insertmacro SectionFlagIsSet SEC$n \${SF_SELECTED} sec${n}_yes sec${n}_no
sec${n}_yes:
EOF
exe=`array_lines outfiles$n | grep '\.exe$' | head -1`
if test -n "$exe"; then
name='\$SMPROGRAMS\\\${PRODUCT_STARTMENU}\\${PRODUCT_NAME}'
if test $n != 1; then
name="$name $i"
fi
exe='$INSTDIR\'`echo $exe | tr '/' "$BS$BS" `
echo " CreateShortCut \"$name.lnk\" \"$exe\""
fi
echo " sec${n}_no:"
((n++))
done
cat << \EOF
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
EOF
n=1
for i in "${section_descriptions[@]}"; do
echo "!insertmacro MUI_DESCRIPTION_TEXT \${SEC$n} \"$i\""
((n++))
done
cat << \EOF
!insertmacro MUI_FUNCTION_DESCRIPTION_END
; Uninstaller
Section Uninstall
SetOutPath "\"
EOF
array_lines outfiles | sort -ru | tr '/' "$BS$BS" | \
sed 's/.*/ Delete "$INSTDIR\\&"/'
array_lines outfiles | xargs_dirname | sort -ru | tr '/' "$BS$BS" | \
sed '$d; s/.*/ RMDir "$INSTDIR\\&"/'
cat << \EOF
RMDir "$INSTDIR"
Delete "$SMPROGRAMS\${PRODUCT_STARTMENU}\Uninstall.lnk"
EOF
for i in "${sections[@]}"; do
if array_lines outfiles$n | grep '\.exe$' > /dev/null 2>&1; then
name='\$SMPROGRAMS\\\${PRODUCT_STARTMENU}\\${PRODUCT_NAME}'
if test $n != 1; then
name="$name $i"
fi
echo " Delete \"$name.lnk\""
fi
((n++))
done
cat << \EOF
RMDir "$SMPROGRAMS\${PRODUCT_STARTMENU}"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SectionEnd
EOF
exec >&3-
makensis setup.nsi
chmod +x setup.exe
mv setup.nsi setup.exe ../..