From 7616d97e4c2ec40a9ba63a1f198598aed45c1b6a Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Mar 2020 14:55:59 +0800 Subject: [PATCH] avoid repacking every time --- aosp.sh | 6 +++++- cros.sh | 3 ++- git.sh | 3 ++- homebrew.sh | 3 ++- llvm.sh | 3 ++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/aosp.sh b/aosp.sh index 91813e5..7ec2efe 100755 --- a/aosp.sh +++ b/aosp.sh @@ -5,6 +5,9 @@ REPO=${REPO:-"/usr/local/bin/repo"} USE_BITMAP_INDEX=${USE_BITMAP_INDEX:-"0"} UPSTREAM=${TUNASYNC_UPSTREAM_URL:-"https://android.googlesource.com/mirror/manifest"} +git config --global user.email "mirrors@tuna" +git config --global user.name "tuna mirrors" + function repo_init() { mkdir -p $TUNASYNC_WORKING_DIR cd $TUNASYNC_WORKING_DIR @@ -22,7 +25,8 @@ function git_repack() { cd $repo size=$(du -sk .|cut -f1) total_size=$(($total_size+1024*$size)) - if [[ "$size" -gt "100000" ]]; then + objs=$(find objects -type f | wc -l) + if [[ "$objs" -gt 8 && "$size" -gt "100000" ]]; then git repack -a -b -d fi done < <(find $TUNASYNC_WORKING_DIR -type d -not -path "*/.repo/*" -name "*.git") diff --git a/cros.sh b/cros.sh index 4531741..3ed451c 100755 --- a/cros.sh +++ b/cros.sh @@ -41,7 +41,8 @@ function git_repack() { cd $repo size=$(du -sk .|cut -f1) total_size=$(($total_size+1024*$size)) - if [[ "$size" -gt "100000" ]]; then + objs=$(find objects -type f | wc -l) + if [[ "$objs" -gt 8 && "$size" -gt "100000" ]]; then git repack -a -b -d fi done < <(find $TUNASYNC_WORKING_DIR -not -path "$MANIFEST_DIR/.git/*" -type f -name HEAD -exec dirname '{}' ';') diff --git a/git.sh b/git.sh index 7ceaf01..7c4fe2e 100755 --- a/git.sh +++ b/git.sh @@ -13,7 +13,8 @@ function update_linux_git() { cd $TUNASYNC_WORKING_DIR echo "==== SYNC $UPSTREAM START ====" /usr/bin/timeout -s INT 3600 git remote -v update - git repack -a -b -d + objs=$(find objects -type f | wc -l) + [[ "$objs" -gt 8 ]] && git repack -a -b -d sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+') sz=$(($sz*1024)) echo "size-pack:" $(numfmt --to=iec $sz) diff --git a/homebrew.sh b/homebrew.sh index c304f3a..39c732d 100755 --- a/homebrew.sh +++ b/homebrew.sh @@ -10,7 +10,8 @@ function update_homebrew_git() { cd $repo_dir echo "==== SYNC $repo_dir START ====" /usr/bin/timeout -s INT 3600 git remote -v update - git repack -a -b -d + objs=$(find objects/ -type f | wc -l) + [[ "$objs" -gt 8 ]] && git repack -a -b -d sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+') total_size=$(($total_size+1024*$sz)) echo "==== SYNC $repo_dir DONE ====" diff --git a/llvm.sh b/llvm.sh index ab2a649..2288dd6 100755 --- a/llvm.sh +++ b/llvm.sh @@ -10,7 +10,8 @@ function repo_update() { cd $repo_dir echo "==== SYNC $repo_dir START ====" /usr/bin/timeout -s INT 3600 git remote -v update - git repack -a -b -d + objs=$(find objects/ -type f | wc -l) + [[ "$objs" -gt 8 ]] && git repack -a -b -d sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+') total_size=$(($total_size+1024*$sz)) echo "==== SYNC $repo_dir DONE ===="