summaryrefslogtreecommitdiff
path: root/build.sh
blob: 31b180c8d4db583ce20599ba814d0f4559a455bf (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
#!/bin/bash 
 
# mostly copied from github.com:phhusson/treble_experimentations 
set -e
 
thisdir="$(readlink -f "$(dirname "$0")")"
echo "thisdir=$thisdir"
release_name="$(date +%y%m%d)"
mkdir -p release/"$release_name"
 
jobs=$(nproc)
 
function clone_or_checkout() {
    local dir="$1"
    local repo="$2"
    local branch="$3"
    
    if [[ -d "$dir" ]];then
        (
            cd "$dir"
            git fetch
            git reset --hard
            git checkout origin/"$branch"
        )
    else
        git clone "$repo" "$dir" -b "$branch"
    fi
}
 
function init_repo() {
    rm -rf .repo/local_manifests/
    rm -rf dakkar-patches/
    rm -rf patches/
    repo init -u https://github.com/LineageOS/android.git -b lineage-15.1
}
 
function setup_code() {
    # manifests 
    clone_or_checkout .repo/local_manifests https://github.com/phhusson/treble_manifest android-8.1
 
    cp "$thisdir"/manifest/dakkar.xml .repo/local_manifests/
    rm -f .repo/local_manifests/replace.xml
 
    # Remove exfat entry from local_manifest if it exists in ROM manifest 
    if grep -rqF exfat .repo/manifests || grep -qF exfat .repo/manifest.xml; then
        sed -i -E '/external\/exfat/d' .repo/local_manifests/manifest.xml
    fi
 
    # patches 
    clone_or_checkout patches https://github.com/phhusson/treble_patches android-8.1
 
    mkdir -p dakkar-patches/
    cp -a "$thisdir"/patches dakkar-patches/
 
    repo sync -c -j$jobs -f --force-sync --no-tag --no-clone-bundle --optimized-fetch --prune
 
    rm -f device/*/sepolicy/common/private/genfs_contexts
 
    bash "$thisdir/apply-patches.sh" patches
    #bash "$thisdir/apply-patches.sh" dakkar-patches 
}
 
if [[ "$1" == "init" ]]; then
    init_repo
    setup_code
elif [[ "$1" == "setup" ]]; then
    setup_code
fi
 
. build/envsetup.sh
 
lunch treble_dakkar_m5-userdebug
make WITHOUT_CHECK_API=true BUILD_NUMBER="$release_name" installclean
make WITHOUT_CHECK_API=true BUILD_NUMBER="$release_name" -j$jobs systemimage
make WITHOUT_CHECK_API=true BUILD_NUMBER="$release_name" vndk-test-sepolicy
cp $OUT/system.img release/"$release_name"/system-dakkar-m5.img