tools: append time to test_data and automagically update build-deps
Add time to prevent clash of multiple files being updated at the same
date.
Also use sed black magic to automatically change install-build-deps with
new filename and SHA
Change-Id: Icd46d0cb5d45235feb1b1ab41ece47688fbe2754
diff --git a/tools/add_test_trace.sh b/tools/add_test_trace.sh
index 410cef8..6472ffd 100755
--- a/tools/add_test_trace.sh
+++ b/tools/add_test_trace.sh
@@ -21,7 +21,7 @@
echo ""
echo "Zipping file back up"
echo ""
-NEW_TEST_DATA="test-data-$(date +%Y%m%d).zip"
+NEW_TEST_DATA="test-data-$(date +%Y%m%d-%H%M%S).zip"
CWD="$(pwd)"
cd /tmp/latest-test-data
zip -r /tmp/$NEW_TEST_DATA *
@@ -40,10 +40,11 @@
echo ""
echo "SHA1 of file $NEW_TEST_DATA is"
if which shasum; then
-echo $(shasum /tmp/$NEW_TEST_DATA) # Mac OS
+NEW_SHA=$(shasum /tmp/$NEW_TEST_DATA) # Mac OS
else
-echo $(sha1sum /tmp/$NEW_TEST_DATA) # Linux
+NEW_SHA=$(sha1sum /tmp/$NEW_TEST_DATA) # Linux
fi
+echo $NEW_SHA
echo ""
echo "Cleaning up leftover files"
@@ -53,6 +54,12 @@
rm /tmp/$NEW_TEST_DATA
echo ""
-echo "All done! Please update tools/install-build-deps"
-echo "with the new file name and sha1sum"
+echo "Updating tools/install-build-deps"
echo ""
+OLD_URL="https://\(.*/perfetto\)/test-data-.*.zip"
+NEW_URL="https://\1/$NEW_TEST_DATA"
+OLD_SHA="\w*"
+SED_MAGIC="s|'$OLD_URL',\n\(\s*\)'$OLD_SHA'|'$NEW_URL',\n\2'$NEW_SHA'|g"
+sed -i '' -z -e "$SED_MAGIC" tools/install-build-deps
+
+echo "All done!"