summaryrefslogtreecommitdiff
path: root/GenDeb.sh
blob: e4fc44d8e70d5116d8457f988d7b878339b75d33 (plain) (blame)
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
#!/bin/bash

TMW_DEPENDENCIES="libsdl1.2debian (>= 1.2.7), libsdl-image1.2 (>= 1.2.3), libsdl-mixer1.2 (>= 1.2.5), libguichan (>= 0.2.0), libxml2 (>= 2.4.19), libphysfs-1.0-0 (>= 1.0.0-1)";

echo "Debian Package Creation...";

if [ $USER != "root" ]; # only root can create deb packages...
then
	echo "Sorry ! this must be run as root because only root can make Debian Packages !";
	echo "Aborting...";
	exit;
fi

if [ `automake --version | grep "1.9"` == "" ]
then
	echo "Your automake version is inferior to 1.9.";
	echo "Installing  won't work. Please do :";
	echo "'apt-get install automake1.9' and 'apt-get remove automake1.x";
	echo "(x is your version number).";
	echo "Aborting..";
	exit;
fi

rm -f config.h;
./autogen.sh;
./configure;
make clean;
make;

if [ ! -x ./src/tmw ]; # if tmw doesn't exist
then
	echo "Compilation failed somewhere. Please try to correct errors given by gcc output...";
	echo "Aborting...";
	exit;
else
	echo "Compilation successful !";
	cp src/tmw ./tmw;
fi

if [ ! -d ./data ]; # if the data folder doesn't exist...
then
	echo "Can't find the Mana World datas..."
	echo "Aborting...";
	exit;
fi

if [ ! -d ./docs ]; # if the docs folder doesn't exist...
then
	echo "Can't find the Mana World docs..."
	echo "Aborting...";
	exit;
fi

echo "The Mana World seems to have compiled successfully.";
echo "Now creating Debian Repository...";

rm -rf Debian;
mkdir Debian 0>/dev/null 1>/dev/null 2>/dev/null;

if [ ! -d ./Debian ]; # if the Debian folder doesn't exist...
then
	echo "Can't create a Debian folder here...";
	echo "Have you got enough rights to do that ?"
	echo "Aborting...";
	exit;
fi

TMW_VERSION=`cat config.h | grep "PACKAGE_VERSION" | cut -d'"' -f2`;
echo "Version :" $TMW_VERSION;
mkdir `echo 'Debian/manaworld_'$TMW_VERSION'_i386'`;
cd `echo 'Debian/manaworld_'$TMW_VERSION'_i386'`;
mkdir DEBIAN;
mkdir usr;
mkdir usr/share;
mkdir usr/share/manaworld;
cp ../../tmw ./usr/share/manaworld;
cp -a ../../data ./usr/share/manaworld;
cp -a ../../docs ./usr/share/manaworld;

# Creating a good link to launch the game
touch ./usr/share/manaworld/manaworld;
echo "#!/bin/sh" >>./usr/share/manaworld/manaworld;
echo "cd /usr/share/manaworld;" >>./usr/share/manaworld/manaworld;
echo "./tmw;" >>./usr/share/manaworld/manaworld;
echo "cd -" >>./usr/share/manaworld/manaworld;

chmod +x ./usr/share/manaworld/manaworld;
# End of the link

echo "Creating Rules for the Debian package..."
#echo "Set the variables value at the begining of this script if you want to change something...";

touch DEBIAN/postinst;
echo "#!/bin/sh" >>DEBIAN/postinst;
echo 'if [ "$1" = "configure" ]; then' >>DEBIAN/postinst;
echo '   if [ -d /usr/games ]; then' >>DEBIAN/postinst;
echo '      cp /usr/share/manaworld/manaworld /usr/games/manaworld;' >>DEBIAN/postinst;
echo '      chmod +x /usr/share/manaworld/manaworld;' >>DEBIAN/postinst;
echo '   fi' >>DEBIAN/postinst;
echo 'fi' >>DEBIAN/postinst;

chmod 755 DEBIAN/postinst;
# End of postinst script...

touch DEBIAN/prerm;
echo '#!/bin/sh' >>DEBIAN/prerm;
echo 'if [ \( "$1" = "upgrade" -o "$1" = "remove" \) ]; then' >>DEBIAN/prerm;
echo '   if [ -d /usr/games ]; then' >>DEBIAN/prerm;
echo '      rm -rf /usr/games/manaworld;' >>DEBIAN/prerm;
echo '   fi' >>DEBIAN/prerm;
echo 'fi' >>DEBIAN/prerm;

chmod 755 DEBIAN/prerm;
# End of prerm script...

touch DEBIAN/control
echo 'Package: manaworld' >>DEBIAN/control;
echo 'Version: '$TMW_VERSION >>DEBIAN/control;
echo 'Section: bin' >>DEBIAN/control;
echo 'Priority: optional' >>DEBIAN/control;
echo 'Architecture: i386' >>DEBIAN/control;
echo 'Depends: '$TMW_DEPENDENCIES >>DEBIAN/control;
echo 'Suggests: Nothing' >>DEBIAN/control;
echo 'Installed-Size: 1200' >>DEBIAN/control;
echo 'Maintainer: Ferreira Yohann <bertram@cegetel.net>' >>DEBIAN/control;
echo 'Description: The Mana World is a Great Online Game based upon the Seiken Densetsu Serie.' >>DEBIAN/control;
echo ' It has its own universe, and and its own character management system, which will' >>DEBIAN/control;
echo ' give you the opportunity to play in a 2D heroic-fantasy world forever.' >>DEBIAN/control;
echo ' .' >>DEBIAN/control;
echo ' This package depends on the non-official package : libguichan which can be found on : http://guichan.darkbits.org/downloads.shtml' >>DEBIAN/control
echo ' Look at the website for further informations...' >>DEBIAN/control;
echo ' .' >>DEBIAN/control;
echo ' Authors:' >>DEBIAN/control;
echo ' Elven Programmer <elvenprogrammer@sourceforge.net>' >>DEBIAN/control;
echo ' Kth5 <kth5@gawab.com>' >>DEBIAN/control;
echo ' Ultramichy <celdron15@hotmail.com>' >>DEBIAN/control;
echo ' SimEdw <simon@crossnet.se>' >>DEBIAN/control;
echo ' Rotonen <j_orponen@hotmail.com>' >>DEBIAN/control;
echo ' Chetic <Chetic@gmail.com>' >>DEBIAN/control;
echo ' HammerBear <bjorn@lindeijer.nl>' >>DEBIAN/control
echo ' Bertram' >>DEBIAN/control
echo ' .' >>DEBIAN/control;
echo ' Web Site: http://themanaworld.sourceforge.net/' >>DEBIAN/control;
# End of control file...

echo "Rules created..."
echo "Creating Debian Package..."
cd ..
chown -R root:root `echo 'manaworld_'$TMW_VERSION'_i386'`;
dpkg --build `echo 'manaworld_'$TMW_VERSION'_i386'`;
cp `echo 'manaworld_'$TMW_VERSION'_i386.deb'` ..;
cd ..
echo "Cleaning ...";
rm -rf Debian;
echo "Your Debian Package is normally ready :"
echo "Its name is : manaworld_"$TMW_VERSION"_i386.deb";
echo "Don't forget you need "$TMW_DEPENDENCIES".";
echo "You can find libguichan in http://guichan.darkbits.org/downloads.shtml";
echo "End of Debian Creation...";