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() {
repo init -u https://github.com/LineageOS/android.git -b lineage-15.1
}
function setup_code() {
clone_or_checkout .repo/local_manifests "$thisdir" master
clone_or_checkout dakkar-patches "$thisdir" master
clone_or_checkout patches https://github.com/phhusson/treble_patches android-8.1
repo sync -c -j$jobs --force-sync
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