summaryrefslogtreecommitdiff
path: root/scripts-common/sync-common.sh
blob: d24c10f2a19324bc471312e8633d199bf24ff753 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env sh
export BASE=`pwd`
export MIRROR="https://android.googlesource.com/platform/manifest"
repo_url="git://android.git.linaro.org/tools/repo"
export base_manifest="default.xml"
sync_linaro=true
branch="master"

LOCAL_MANIFEST="git://android.git.linaro.org/platform/manifest.git"
LOCAL_MANIFEST_BRANCH="linaro-master"
#export branch="studio-1.1-dev"

print_usage(){
    echo "$(basename $0) [-nl|--nolinaro] [-b|--branch branch] [-m|--mirror mirror_url]"
    echo "\t -nl|--nolinaro: do not sync linaro source"
    echo "\t -b|--branch branch: sync the specified branch, default master"
    echo "\t -u|--mirror mirror_url: specify the url where you want to sync from"
    echo "\t\t default: $repo_url"
    echo "$(basename $0) [-h|--help]"
    echo "\t -h|--help: print this usage"
}

function parseArgs(){
    while [ -n "$1" ]; do
        case "X$1" in
            X-nl|X--nolinaro)
                sync_linaro=false
                shift
                ;;
            X-b|X--branch)
                if [ -z "$2" ]; then
                    echo "Please specify the branch name for the -b|--branch option"
                    exit 1
                fi
                branch="$2"
                shift
                ;;
            X-h|X--help)
                print_usage
                exit 1
                ;;
            X-*)
                echo "Unknown option: $1"
                print_usage
                exit 1
                ;;
            X*)
                echo "Unknown option: $1"
                print_usage
                exit 1
                ;;
        esac
    done
}

sync_init(){
    #while ! repo init -u $MIRROR -m ${base_manifest} -b ${branch} --no-repo-verify --repo-url=${repo_url} -g "default,-device,-non-default,hikey,flounder,-darwin,-mips,-x86" --depth=1 -p linux; do
    while ! repo init -u $MIRROR -m ${base_manifest} -b ${branch} --no-repo-verify --repo-url=${repo_url} --depth=1 -g "default,device,-notdefault,-darwin,-mips,-x86" -p linux; do
        sleep 30
    done
}

sync(){
    #Syncronize and check out
    CPUS=$(grep processor /proc/cpuinfo |wc -l)
    while ! repo sync -j ${CPUS} -c --force-sync; do
        sleep 30
    done
}

sync_linaro(){
    mkdir -p .repo
    cd .repo
    if [ -d ./local_manifests ]; then
        cd ./local_manifests;
        git pull
    else
        git clone ${LOCAL_MANIFEST} -b ${LOCAL_MANIFEST_BRANCH} local_manifests
    fi

    cd ${BASE}

    cp -uvf liuyq-patches/liuyq.xml .repo/local_manifests/liuyq.xml
    if [ ! -d android-patchsets ]; then
        mkdir -p android-patchsets
    fi
    cp -uvf liuyq-patches/LIUYQ-PATCHSET android-patchsets
    #juno_mali_binary
    #hikey_mali_binary
}

juno_mali_binary(){
    local b_name="juno-20151111-vendor.tar.bz2"
    if [ -f ./${b_name} ]; then
        return
    fi
    curl --fail --show-error -b license_accepted_51722ba4ccc270bcd54cb360cb242798=yes http://snapshots.linaro.org/android/binaries/arm/20151111-members-only/vendor.tar.bz2 >${b_name}
    tar xavf ${b_name}
}

hikey_mali_binary(){
    local b_name="hikey-20160113-vendor.tar.bz2"
    if [ -f ./${b_name} ]; then
        return
    fi
    curl --fail --show-error -b license_accepted_eee6ac0e05136eb58db516d8c9c80d6b=yes http://snapshots.linaro.org/android/binaries/hikey/20160113/vendor.tar.bz2 >${b_name}
    tar xavf ${b_name}
}

main(){
    # update myself first
    git pull
    parseArgs "$@"
    if $sync_linaro; then
        sync_linaro
    fi
    sync_init
    sync
}