summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-04-18 16:11:51 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-04-18 16:11:51 -0700
commit88ae12a652fada249414cb7913cb697d23c14f97 (patch)
tree4c0ad9ba98ba390a77fae953ff2d1e61ff926f57
parent9dcbd210f76714e9ccf9426e4c78726a8a3ba76e (diff)
downloadtools-88ae12a652fada249414cb7913cb697d23c14f97.tar.gz
tools-88ae12a652fada249414cb7913cb697d23c14f97.tar.bz2
tools-88ae12a652fada249414cb7913cb697d23c14f97.tar.xz
tools-88ae12a652fada249414cb7913cb697d23c14f97.zip
Support music updates in "make updates"
-rwxr-xr-xclient/make-updates51
1 files changed, 45 insertions, 6 deletions
diff --git a/client/make-updates b/client/make-updates
index aef0aaf..2020d8b 100755
--- a/client/make-updates
+++ b/client/make-updates
@@ -43,14 +43,15 @@ function add_resource()
popd >/dev/null
}
-# TODO actually use this
function add_music()
{
+ pushd $output >/dev/null
adler32 $1 | {
read name hash
chmod a+r $name
sed '/<\/updates>/i <update type="music" required="no" file="'$name'" hash="'$hash'" />' -i resources.xml
}
+ popd >/dev/null
}
function do_initial_zip()
@@ -60,6 +61,14 @@ function do_initial_zip()
| zip -q $output/$zip -@
add_resource $zip
}
+function do_initial_music()
+{
+ zip=music-$this_update.zip
+ ( cd music/ ; git ls-files --with-tree=HEAD ) \
+ | sed 's:^:music/:' \
+ | zip -q $output/$zip -@
+ add_music $zip
+}
function git_diff_tree()
{
@@ -77,6 +86,18 @@ function do_delta_zip()
| zip -q $output/$zip -@
add_resource $zip
}
+function do_delta_music()
+{
+ zip=music-$last_update..$this_update.zip
+ if (cd music; git_diff_tree --quiet $last_update $this_update )
+ then
+ return
+ fi
+ (cd music; git_diff_tree --name-only $last_update $this_update ) \
+ | sed 's:^:music/:' \
+ | zip -q $output/$zip -@
+ add_music $zip
+}
function do_initial_zips()
{
@@ -96,6 +117,14 @@ function main()
echo "$output"
return 1
fi
+ if ! test -f $output/resources.xml
+ then
+ (
+ echo '<?xml version="1.0"?>'
+ echo '<updates>'
+ echo '</updates>'
+ ) > $output/resources.xml
+ fi
this_update=$(git rev-parse --short HEAD)
if ! last_update=$(git rev-parse --short $branch 2>/dev/null)
@@ -110,16 +139,26 @@ function main()
do_delta_zips
fi
git branch -f $branch
+
+ this_update=$(cd music; git rev-parse --short HEAD)
+ if ! last_update=$(cd music; git rev-parse --short $branch 2>/dev/null)
+ then
+ echo 'Doing initial music updates'
+ do_initial_music
+ elif test "$this_update" = "$last_update"
+ then
+ echo 'No commits since last music update generation ...'
+ else
+ echo 'Doing incremental music updates'
+ do_delta_music
+ fi
+ ( cd music; git branch -f $branch )
}
if test "$0" = "$BASH_SOURCE"
then
echo 'Generating updates automatically'
main
-elif test "$0" = 'bash'
-then
- echo 'sourcing detected - you can do manual updates'
else
- echo 'How did you get here?'
- exit 3
+ echo 'sourcing detected - you can do manual updates'
fi