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() {
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
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 --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