]> Dogcows Code - chaz/yoink/blob - win32/makepackage.sh
now can create win32 portable packages
[chaz/yoink] / win32 / makepackage.sh
1 #!/bin/sh
2
3 #
4 # Yoink
5 # Run this script to create a portable win32 package.
6 #
7
8 function showhelp()
9 {
10 echo "Create a portable win32 package or installer."
11 echo "Usage: $0 [-h] [-i makensis] [-s strip] -d assets -V version -p prefix"
12 echo ""
13 echo " -d Specify the game assets to be included."
14 echo " -h Show this help an exit."
15 echo " -i To make an installer, specify the makensis program."
16 echo " -V Specify the version of the program to be packaged"
17 echo " -s To strip the binaries, specify the strip program."
18 echo " -p Specify the path to your toolchain installation."
19 }
20
21 while getopts ":V:hd:i:p:s:" opt
22 do
23 case $opt in
24 V)
25 VERSION="$OPTARG"
26 ;;
27 d)
28 ASSETS="$OPTARG"
29 ;;
30 h)
31 showhelp
32 exit 0
33 ;;
34 i)
35 MAKENSIS="$OPTARG"
36 ;;
37 p)
38 PREFIX="$OPTARG"
39 ;;
40 s)
41 STRIP="$OPTARG"
42 ;;
43 \?)
44 echo "Invalid option: -$OPTARG" >&2
45 showhelp
46 exit 1
47 ;;
48 esac
49 done
50
51 if test "x$ASSETS" = x || test "x$VERSION" = x || test "x$PREFIX" = x
52 then
53 showhelp
54 exit 1
55 fi
56
57 function die()
58 {
59 rm -rf "$BUILD"
60 echo "die:" $@
61 exit 1
62 }
63
64 ROOT="$PWD"
65 BUILD="$PWD/tmp-$$"
66 NAME="yoink-$VERSION"
67 ARCHIVE="$BUILD/$NAME"
68 INSTALLER_SCRIPT="$ROOT/win32/yoink.nsi"
69
70 MAN2HTML="$ROOT/doc/man2html.sh"
71 UNIX2DOS="$ROOT/win32/unix2dos.sh"
72
73 DLLS="libogg-0 libpng14-14 libvorbis-0 libvorbisfile-3 lua51 OpenAL32 SDL zlib1"
74
75
76 if test ! -f "src/version.c"
77 then
78 echo "Run the script from the repository root directory."
79 exit 1
80 fi
81
82 if ! mkdir "$BUILD"
83 then
84 "The temp directory $BUILD could not be created."
85 exit 1
86 fi
87 mkdir -p "$ARCHIVE"
88
89
90 cp -f "$ROOT/src/yoink.exe" "$ARCHIVE" || die "copying yoink.exe"
91 test "x$STRIP" != x && "$STRIP" "$ARCHIVE/yoink.exe"
92
93 for dll in $DLLS
94 do
95 cp -f "$PREFIX/bin/$dll.dll" "$ARCHIVE" || die "copying $dll"
96 test "x$STRIP" != x && "$STRIP" "$ARCHIVE/$dll.dll"
97 done
98
99 for asset in $ASSETS
100 do
101 cp -f --parents "data/$asset" "$ARCHIVE"
102 done
103
104 for doc in AUTHORS ChangeLog COPYING README TODO
105 do
106 "$UNIX2DOS" "$doc" "$ARCHIVE/$doc.txt" || die "unix2dos $doc"
107 done
108
109 "$MAN2HTML" -f -o "$ARCHIVE/Manual.html"
110 "$UNIX2DOS" "$ARCHIVE/Manual.html"
111
112 cp -rf "$ROOT/doc/licenses" "$ARCHIVE" || die "copying doc/licenses"
113 cd "$ARCHIVE/licenses"
114 for license in $(ls)
115 do
116 (mv "$license" "$license.txt" && "$UNIX2DOS" "$license.txt") \
117 || die "moving and unix2dos $license"
118 done
119 cd "$ROOT"
120
121
122 if test "x$MAKENSIS" = x
123 then
124 # build the portable archive
125 cd "$BUILD"
126 zip -r $NAME.zip $NAME || die "zipping portable archive"
127 cd "$ROOT"
128 mv "$BUILD/$NAME.zip" .
129 echo "Done! Package saved to $NAME.zip."
130 else
131 # build an installer
132 cd "$BULID"
133 "$MAKENSIS" "$INSTALLER_SCRIPT" \
134 -DINSTALLFILES="$NAME" -DVERSION="$VERSION" \
135 || die "running '$MAKENSIS'"
136 cd "$ROOT"
137 mv "$BUILD/$NAME.exe" .
138 echo "Done! Installer saved to $NAME.exe."
139 fi
140
141
142 rm -rf "$BUILD"
143
This page took 0.036095 seconds and 4 git commands to generate.