new convenient script methods
[chaz/yoink] / win32 / makepackage.sh
1 #!/bin/sh
2
3 #
4 # Yoink
5 # Run this script to create a 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="$ROOT/tmp-$$"
66 DIRECTORY="yoink-$VERSION"
67 ARCHIVE="$BUILD/$DIRECTORY"
68
69 MAN2HTML="$ROOT/doc/man2html.sh"
70 UNIX2DOS="$ROOT/win32/unix2dos.sh"
71
72 DLLS="libogg-0 libpng14 libvorbis-0 libvorbisfile-3 lua51 OpenAL32 SDL zlib1"
73
74
75 if test ! -f "src/version.c"
76 then
77 echo "Run the script from the repository root directory."
78 exit 1
79 fi
80
81 if ! mkdir "$BUILD"
82 then
83 "The temp directory $BUILD could not be created."
84 exit 1
85 fi
86 mkdir -p "$ARCHIVE"
87
88
89 cp -f "$ROOT/src/yoink.exe" "$ARCHIVE" || die "copying yoink.exe"
90 test "x$STRIP" != x && "$STRIP" "$ARCHIVE/yoink.exe"
91
92 for dll in $DLLS
93 do
94 cp -f "$PREFIX/bin/$dll.dll" "$ARCHIVE" || die "copying $dll"
95 test "x$STRIP" != x && "$STRIP" "$ARCHIVE/$dll.dll"
96 done
97
98 for asset in $ASSETS
99 do
100 cp -f --parents "data/$asset" "$ARCHIVE"
101 done
102
103 for doc in AUTHORS ChangeLog COPYING README TODO
104 do
105 "$UNIX2DOS" "$doc" "$ARCHIVE/$doc.txt" || die "unix2dos $doc"
106 done
107
108 "$MAN2HTML" -f -o "$ARCHIVE/Manual.html"
109 "$UNIX2DOS" "$ARCHIVE/Manual.html"
110
111 cp -rf "$ROOT/doc/licenses" "$ARCHIVE" || die "copying doc/licenses"
112 cd "$ARCHIVE/licenses"
113 for license in $(ls)
114 do
115 (mv "$license" "$license.txt" && "$UNIX2DOS" "$license.txt") \
116 || die "moving and unix2dos $license"
117 done
118 cd "$ROOT"
119
120
121 if test "x$MAKENSIS" = x
122 then
123 # build portable archive
124 echo "No valid makensis executable passed;"
125 echo "making portable package instead..."
126 NAME="$DIRECTORY.zip"
127 cd "$BUILD"
128 zip -r "$NAME" "$DIRECTORY" || die "zipping portable archive"
129 cd "$ROOT"
130 mv "$BUILD/$NAME" .
131 echo "Done! Package saved to $NAME."
132 else
133 # build an installer
134 NAME="yoinksetup-$VERSION.exe"
135 cd "$BUILD"
136 cp "$ROOT/win32/yoink.nsi" .
137 "$MAKENSIS" -DROOTPATH="$ROOT" -DINSTALLFILES="$ARCHIVE" \
138 -DVERSION="$VERSION" -DOUTFILE="$NAME" yoink.nsi \
139 || die "running '$MAKENSIS'"
140 cd "$ROOT"
141 mv "$BUILD/$NAME" .
142 echo "Done! Installer saved to $NAME."
143 fi
144
145
146 rm -rf "$BUILD"
147
This page took 0.034917 seconds and 4 git commands to generate.