#!/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 '' > $patchrepopath/resources.xml # overwrite resource file echo '' >> $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 "" >> $patchrepopath/resources.xml done echo '' >> $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