From 88ae12a652fada249414cb7913cb697d23c14f97 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 18 Apr 2014 16:11:51 -0700 Subject: Support music updates in "make updates" --- client/make-updates | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file 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 ' -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 '' + echo '' + echo '' + ) > $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 -- cgit v1.2.3-70-g09d2