summaryrefslogtreecommitdiff
path: root/client/make-music.sh
blob: 5b914cf1371ffac00767fd907638a47799c04513 (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
#!/usr/bin/env bash

# Copyright (C) 2011-2012  Evol Online
# Author: Andrei Karas (4144)

dir=`pwd`
output=~/www/updates
cdata=../../client-data
http_root="http://updates.themanaworld.org/updates"

LDLIBS=-lz
prefix=/usr/local
CC=${CC:=gcc}

function check_update() {
    test_command=`           \
        curl -sL             \
        -w "%{http_code}\n"  \
        "$1"                 \
        -o /dev/null         \
        --connect-timeout 3  \
        --max-time 5`

    if [ ${test_command} == "200" ] ;
    then
       echo -e "hit $1 (\e[92m$test_command OK\e[0m)";
    else
       echo -e "\e[31m!!FAILED!!\e[0m $1 ($test_command)";
       exit 1;
    fi
}


echo "======= Legacy-music ======="

echo ">> Building adler32..."
rm -f adler32 2>/dev/null || :
$CC -lz adler32.c -o adler32

echo ">> Creating directory tree..."
mkdir -pv files
mkdir -pv $output

echo ">> Removing leftovers..."
rm -v files/Legacy-music.zip 2>/dev/null || :
rm -v $output/Legacy-music.zip 2>/dev/null || :

echo ">> Entering client-data..."
pushd $cdata
echo ">> Changing file dates..."
find -path ./sfx -prune -o -iregex ".+[.]\(ogg\)" -exec touch --date=2015-01-01 {} \;
echo ">> Compressing files..."
find -path ./sfx -prune -o -iregex ".+[.]\(ogg\)" -printf "%P\n" | zip -X -@ $dir/files/Legacy-music.zip
touch $dir/files/Legacy-music.zip
echo ">> Dumping git revision to file..."
git rev-parse HEAD >$dir/musiccommit.txt

pushd $dir/files
echo ">> Calculating adler32 checksum..."
sum=`../adler32 1 Legacy-music.zip`

echo ">> Generating xml file..."
echo "    <update type=\"music\" required=\"no\" file=\"Legacy-music.zip\" hash=\"${sum}\" description=\"TMW music\" />" >> xml_header.txt

cp xml_header.txt resources.xml
cat xml_footer.txt >>resources.xml

echo ">> Moving stuff around..."
cp -v Legacy-music.zip $output/
cp -v resources.xml $output/

echo ">> Giving read permissions..."
pushd $output
chmod a+r Legacy-music.zip
chmod a+r resources.xml

echo ">> Checking updates..."
check_update "$http_root/Legacy-music.zip"
check_update "$http_root/resources.xml"

popd # $dir/files
popd # $cdata
popd # tools/client