blob: e8e8f6e31d85447546a2100cc5359814b2fe727c (
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
|
#!/bin/bash
# Original data info
repofile="https://github.com/themanaworld/tmwa-client-data/archive/master.zip"
# repofile First directory name
repofirstdir="tmwa-client-data-master"
# Music repo
musicrepo="https://github.com/themanaworld/tmw-music/archive/master.zip"
# repofile First directory name
musicrepofirstdir="tmw-music-master"
# Modified data info
patchrepoaddr="liviorecchia.gitlab.io"
patchreponame="tmw-warworld"
# It must be an absolute path to your existing client data repo. It doesn't matter if it's empty
patchrepopath=$HOME/tmw_devel/$patchreponame
# That's the directory with content modified from original zip NOT the modified repo
patchdir="_patch"
# Working file names
repotemp="original.zip"
repotempmusic="music.zip"
update(){
echo "Downloading original files"
rm $repotemp
wget $repofile -O $repotemp
wget $musicrepo -O $repotempmusic
}
restore(){
echo "Uncompressing original data"
rm $repofirstdir -Rf
unzip $repotemp
rm $musicrepofirstdir -Rf
unzip $repotempmusic
rm ../_uncompressed -Rf
}
patch(){
# compile adler32 utility
gcc -Wall adler32.c -o adler32
mkdir _uncompressed
# copy TMW files and then those in patching directory
cp $repofirstdir/* _uncompressed/ -urf --preserve=all
cp $musicrepofirstdir/* _uncompressed/music -urf --preserve=all
echo "Patching original data"
cp $patchdir/* _uncompressed/ -rf
#--preserve=all
# remove all _includes.xml files from patching directory!
echo "Packing files for updates"
cd _uncompressed # change to uncompressed patched files directory
# Zip compress any subdirectory (-r), show the remaining data to be compressed (-db), maxing out compression -0, and following file system updates (-FS)
zip $patchrepopath/graphics -r -0 -FS graphics
zip $patchrepopath/items -r -0 -FS items
zip $patchrepopath/maps -r -0 -FS maps
zip $patchrepopath/monsters -r -0 -FS monsters
zip $patchrepopath/music -r -0 -FS music
zip $patchrepopath/npcs -r -0 -FS npcs
zip $patchrepopath/quests -r -0 -FS quests
zip $patchrepopath/rules -r -0 -FS rules
zip $patchrepopath/sfx -r -0 -FS sfx
zip $patchrepopath/tilesets -r -0 -FS tilesets
zip $patchrepopath/rootdir -r -0 -FS *.*
cd ..
echo "Computing resources' adler32 checksums"
#cd $patchreponame # entering repo directory
#jacksum -a adler32 -x *.zip > .za32 # writing a temp file with checksums
thisdir=$(pwd)
cd $patchrepopath
$($thisdir/adler32 0 *.zip > .za32)
echo "Creating resource.xml"
declare -a array
readarray -t array < .za32
echo '<?xml version="1.0"?>' > $patchrepopath/resources.xml # overwrite resource file
echo '<updates>' >> $patchrepopath/resources.xml
for element in "${array[@]}" # scan temp file lines for data
do
IFS=$(echo -e ' \t ') read -r -a array2 <<< "${element}" # split by tabs
echo "<update type='data' file='${array2[0]}' hash='${array2[1]}'/>" >> $patchrepopath/resources.xml
done
echo '</updates>' >> $patchrepopath/resources.xml
rm .za32 # remove temp file
#echo "Deleting uncompressed directory"
#rm ../_uncompressed -Rf
echo "Local sync"
rm $HOME/.local/share/mana/updates/$patchrepoaddr/$patchreponame/*.zip -Rf
mkdir $HOME/.local/share/mana/updates/$patchrepoaddr/
mkdir $HOME/.local/share/mana/updates/$patchrepoaddr/$patchreponame/
cp *.zip $HOME/.local/share/mana/updates/$patchrepoaddr/$patchreponame/
cp resources.xml $HOME/.local/share/mana/updates/$patchrepoaddr/$patchreponame/resources.xml
chmod 0777 $HOME/.local/share/mana/updates/$patchrepoaddr/$patchreponame -R
}
push(){
echo "Git pushing"
cd $patchrepopath
git add .
git commit -m "Test of resource packing"
git push -u origin master
cd ..
}
if [ "$1" == "repatch" ]
then
restore
patch
fi
if [ "$1" == "patch" ]
then
patch
fi
if [ "$1" == "update" ]
then
update
fi
if [ "$1" == "restore" ]
then
restore
fi
if [ "$1" == "push" ]
then
push
fi
|