forked from tuna/tunasync-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aosp.sh
executable file
·40 lines (33 loc) · 835 Bytes
/
aosp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
set -e
REPO=${REPO:-"/usr/local/bin/repo"}
USE_BITMAP_INDEX=${USE_BITMAP_INDEX:-"0"}
UPSTREAM=${TUNASYNC_UPSTREAM_URL:-"https://android.googlesource.com/mirror/manifest"}
function repo_init() {
mkdir -p $TUNASYNC_WORKING_DIR
cd $TUNASYNC_WORKING_DIR
$REPO init -u $UPSTREAM --mirror
}
function repo_sync() {
cd $TUNASYNC_WORKING_DIR
$REPO sync -f
}
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
fi