From e4a0685bab5414d074a23e7249ee0a4dbfd90908 Mon Sep 17 00:00:00 2001 From: MZO9400 Date: Wed, 28 Mar 2018 09:00:51 +0200 Subject: [PATCH 1/2] Init: DirtyUnicorns --- build-rom.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-rom.sh b/build-rom.sh index d0245df0..32a245df 100644 --- a/build-rom.sh +++ b/build-rom.sh @@ -5,7 +5,7 @@ mkdir -p release/$rom_fp/ set -e if [ "$#" -le 1 ];then - echo "Usage: $0 '# of jobs'" + echo "Usage: $0 '# of jobs'" exit 0 fi localManifestBranch=$1 @@ -22,6 +22,8 @@ elif [ "$rom" == "lineage" ];then repo init -u https://github.com/LineageOS/android.git -b lineage-15.1 elif [ "$rom" == "rr" ];then repo init -u https://github.com/ResurrectionRemix/platform_manifest.git -b oreo +elif [ "$rom" == "du" ];then + repo init -u https://github.com/DirtyUnicorns/android_manifest.git -b o8x fi if [ -d .repo/local_manifests ] ;then From cad88ec3bf88fee6078e85c5ebc251baf6151e8b Mon Sep 17 00:00:00 2001 From: MZO9400 Date: Wed, 28 Mar 2018 23:03:48 +0200 Subject: [PATCH 2/2] Overhaul build-rom.sh Depend on user input Be able to just build the ROM without patching or cleaning --- build-rom.sh | 121 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 92 insertions(+), 29 deletions(-) mode change 100644 => 100755 build-rom.sh diff --git a/build-rom.sh b/build-rom.sh old mode 100644 new mode 100755 index 32a245df..72fab666 --- a/build-rom.sh +++ b/build-rom.sh @@ -1,63 +1,126 @@ #!/bin/bash +if [[ ${0##*/} == -* ]]; then +echo "Do not source the file!" +echo "Run it as bash" +echo " ./build-rom.sh" +return 1 +else +echo +fi + rom_fp="$(date +%y%m%d)" mkdir -p release/$rom_fp/ set -e +nl=`echo -e $'\n.'` +nl=${nl%.} -if [ "$#" -le 1 ];then - echo "Usage: $0 '# of jobs'" - exit 0 -fi -localManifestBranch=$1 -rom=$2 -if [[ -n "$3" ]] +read -e -i "android-8.1" -p "manifest branch for device tree: " localManifestBranch +echo -e $'\n' +read -e -i "all" -p "Type of build? $nl a for arm64 A_only partition $nl b for arm64 A/B $nl a_arm for arm A_only $nl 'all' for building all types $nl >> " buildtype +echo -e $'\n' +read -e -p "Number of jobs? (number) (def:all) " jobv +echo -e $'\n' +read -e -n1 -i "Y" -p "Sync the ROM again (Y/N) " syncv +echo -e $'\n' +read -e -n1 -i "Y" -p "Patch the ROM (Y/N) " patchv +echo -e $'\n' +read -e -n1 -i "Y" -p "Clean the build dir and trees? (Y/N) " cleanv +echo -e $'\n' +read -e -p "ROM name: " rom +if [ -n "$jobv" ] then - jobs=$3 + jobs=$jobv else jobs=$(nproc) fi -if [ "$rom" == "carbon" ];then - repo init -u https://github.com/CarbonROM/android -b cr-6.1 -elif [ "$rom" == "lineage" ];then - repo init -u https://github.com/LineageOS/android.git -b lineage-15.1 -elif [ "$rom" == "rr" ];then - repo init -u https://github.com/ResurrectionRemix/platform_manifest.git -b oreo -elif [ "$rom" == "du" ];then - repo init -u https://github.com/DirtyUnicorns/android_manifest.git -b o8x -fi +if [ "$syncv" = "Y" ]; then +echo "Syncing @ j=${jobs}" if [ -d .repo/local_manifests ] ;then ( cd .repo/local_manifests; git fetch; git reset --hard; git checkout origin/$localManifestBranch) else git clone https://github.com/phhusson/treble_manifest .repo/local_manifests -b $localManifestBranch fi +rm -f .repo/local_manifests/replace.xml if [ -d patches ];then ( cd patches; git fetch; git reset --hard; git checkout origin/$localManifestBranch) else git clone https://github.com/phhusson/treble_patches patches -b $localManifestBranch fi +repo sync -c -j${jobs} --force-sync +elif [ "$syncv" = "N" ]; then +echo "Will not sync" +else +exit "Wrong choice of sync" +fi + -#We don't want to replace from AOSP since we'll be applying patches by hand +if [ "$cleanv" = "Y" ]; then +echo Cleaning +# We don't want to replace from AOSP since we'll be applying patches by hand rm -f .repo/local_manifests/replace.xml rm -f .repo/local_manifests/opengapps.xml - -repo sync -c -j$jobs --force-sync (cd device/phh/treble; git clean -fdx; bash generate.sh $rom) +elif [ "$cleanv" = "N" ]; then +echo "Will not clean the repos and DIRs" +else +exit "Wrong choice of clean" +fi + +if [ "$patchv" = "Y" ]; then +echo Patching bash "$(dirname "$0")/apply-patches.sh" patches +elif [ "$patchv" = "N" ]; then +echo "Will not patch" +else +exit "Wrong choice of patch" +fi +function buildVar { . build/envsetup.sh - -buildVariant() { - lunch $1 + lunch $lname make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp installclean - make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp -j$jobs systemimage + make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp -j${jobs} systemimage make WITHOUT_CHECK_API=true BUILD_NUMBER=$rom_fp vndk-test-sepolicy - cp $OUT/system.img release/$rom_fp/system-${2}.img -} + cp $OUT/system.img release/$rom_fp/system-${rom}-${lname}.img repo manifest -r > release/$rom_fp/manifest.xml -buildVariant treble_arm64_avN-userdebug arm64-aonly -buildVariant treble_arm64_bvN-userdebug arm64-ab -buildVariant treble_arm_avN-userdebug arm-aonly +} + +function build { +echo "$nl Building $nl" +echo "Partition layout is:$nl $buildtype" + +case $buildtype in +"a") +lname=treble_arm64_avN-userdebug +buildVar treble_arm64_avN-userdebug arm64-aonly +;; +"b") +lname=treble_arm64_bvN-userdebug +buildVar treble_arm64_bvN-userdebug arm64-ab +;; +"a_arm") +lname=treble_arm64_avN-userdebug +buildVar treble_arm_avN-userdebug arm-aonly +;; +"all") +lname=treble_arm64_avN-userdebug +buildVar treble_arm64_avN-userdebug arm64-aonly +lname=treble_arm64_bvN-userdebug +buildVar treble_arm64_bvN-userdebug arm64-ab +lname=treble_arm64_avN-userdebug +buildVar treble_arm_avN-userdebug arm-aonly +;; +*) +echo " Missing" +echo -e '\n' +echo "Chose a right build target" +exit 1 +esac +} + +build