From 41e933da6a49755ce93158ed3d8510fa52bcdfe6 Mon Sep 17 00:00:00 2001 From: bigeagle Date: Wed, 27 Jul 2016 23:29:25 +0800 Subject: [PATCH] aosp bitmap index --- aosp.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/aosp.sh b/aosp.sh index 71ac834..46e7efb 100755 --- a/aosp.sh +++ b/aosp.sh @@ -1,6 +1,8 @@ #!/bin/bash +set -e REPO=${REPO:-"/usr/local/bin/repo"} +USE_BITMAP_INDEX=${USE_BITMAPT_INDEX:-"0"} function repo_init() { mkdir -p $TUNASYNC_WORKING_DIR @@ -13,9 +15,25 @@ function repo_sync() { $REPO sync -f } -if [ ! -d "$TUNASYNC_WORKING_DIR/git-repo.git" ]; then +function git_repack() { + echo "Start writing bitmap index" + while read repo; do + cd $repo + size=$(du -sm .|cut -f1) + if [[ "$size" -gt "100" ]]; then + echo $repo, ${size}M + git repack -a -b -d + fi + done < <$(find $TUNASYNC_WORKING_DIR -type d -not -path "*/.repo/*" -name "*.git") +} + +if [[ ! -d "$TUNASYNC_WORKING_DIR/git-repo.git" ]]; then echo "Initializing AOSP mirror" repo_init fi repo_sync + +if [[ "$USE_BITMAP_INDEX" == "1" ]]; then + git_repack +do