From b4d65a810d0eca3c13de5dffa72bc10d7f6b78ba Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 11:56:25 +0000 Subject: [PATCH 01/16] Add variables to control whether or not tasks are implemented --- Dockerfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Dockerfile b/Dockerfile index 1e2c6013..86c86715 100644 --- a/Dockerfile +++ b/Dockerfile @@ -116,6 +116,18 @@ ENV BUILD_TYPE "userdebug" # we can use --depth=1 here ENV REPO_INIT_ARGS "" +# variables to control whether or not tasks are implemented +ENV INIT_MIRROR true +ENV SYNC_MIRROR true +ENV RESET_VENDOR_UNDO_PATCHES true +ENV CALL_REPO_INIT true +ENV CALL_REPO_SYNC true +ENV APPLY_PATCHES true +ENV PREPARE_BUILD_ENVIRONMENT true +ENV CALL_BREAKFAST true +ENV CALL_MKA true +ENV ZIP_UP_IMAGES false + # You can optionally specify a USERSCRIPTS_DIR volume containing these scripts: # * begin.sh, run at the very beginning # * before.sh, run after the syncing and patching, before starting the builds From 481218c49389acffef1d71c0d969ede972ee5c16 Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 12:10:49 +0000 Subject: [PATCH 02/16] Make init mirror switchable --- src/build.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/build.sh b/src/build.sh index 0d9ee30c..379e2e53 100755 --- a/src/build.sh +++ b/src/build.sh @@ -66,15 +66,18 @@ if [ -n "${PARALLEL_JOBS-}" ]; then fi fi - if [ "$LOCAL_MIRROR" = true ]; then cd "$MIRROR_DIR" - - if [ ! -d .repo ]; then - echo ">> [$(date)] Initializing mirror repository" | tee -a "$repo_log" - ( yes||: ) | repo init -u https://github.com/LineageOS/mirror --mirror --no-clone-bundle -p linux --git-lfs &>> "$repo_log" + if [ "$INIT_MIRROR" = true ]; then + if [ ! -d .repo ]; then + echo ">> [$(date)] Initializing mirror repository" | tee -a "$repo_log" + ( yes||: ) | repo init -u https://github.com/LineageOS/mirror --mirror --no-clone-bundle -p linux --git-lfs &>> "$repo_log" + fi + else + echo ">> [$(date)] Initializing mirror repository disabled" | tee -a "$repo_log" fi +fi # Copy local manifests to the appropriate folder in order take them into consideration echo ">> [$(date)] Copying '$LMANIFEST_DIR/*.xml' to '.repo/local_manifests/'" @@ -439,7 +442,6 @@ for branch in ${BRANCH_NAME//,/ }; do fi done - fi done From d92b5150b9f75e33aa97e2b8b5209485f404b397 Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 12:16:19 +0000 Subject: [PATCH 03/16] Make sync mirror switchable --- src/build.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/build.sh b/src/build.sh index 379e2e53..7a749d3f 100755 --- a/src/build.sh +++ b/src/build.sh @@ -91,9 +91,12 @@ fi "https://gitlab.com/the-muppets/manifest/raw/mirror/default.xml" .repo/local_manifests/proprietary_gitlab.xml fi - echo ">> [$(date)] Syncing mirror repository" | tee -a "$repo_log" - repo sync "${jobs_arg[@]}" --force-sync --no-clone-bundle &>> "$repo_log" -fi + if [ "$SYNC_MIRROR" = true ]; then + echo ">> [$(date)] Syncing mirror repository" | tee -a "$repo_log" + repo sync "${jobs_arg[@]}" --force-sync --no-clone-bundle &>> "$repo_log" + else + echo ">> [$(date)] Sync mirror repository disabled" | tee -a "$repo_log" + fi for branch in ${BRANCH_NAME//,/ }; do branch_dir=${branch//[^[:alnum:]]/_} From d7eb60fa6026cd39d5abce70de3b3632c91022b6 Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 12:26:56 +0000 Subject: [PATCH 04/16] Make reset vendor & undo patches switchable --- src/build.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/build.sh b/src/build.sh index 7a749d3f..e063ec21 100755 --- a/src/build.sh +++ b/src/build.sh @@ -162,16 +162,20 @@ for branch in ${BRANCH_NAME//,/ }; do echo ">> [$(date)] Branch: $branch" echo ">> [$(date)] Devices: $devices" - # Remove previous changes of vendor/cm, vendor/lineage and frameworks/base (if they exist) - # TODO: maybe reset everything using https://source.android.com/setup/develop/repo#forall - for path in "vendor/cm" "vendor/lineage" "frameworks/base" "packages/apps/PermissionController" "packages/modules/Permission"; do - if [ -d "$path" ]; then - cd "$path" - git reset -q --hard - git clean -q -fd - cd "$SRC_DIR/$branch_dir" - fi - done + if [ "$RESET_VENDOR_UNDO_PATCHES" = true ]; then + # Remove previous changes of vendor/cm, vendor/lineage and frameworks/base (if they exist) + # TODO: maybe reset everything using https://source.android.com/setup/develop/repo#forall + for path in "vendor/cm" "vendor/lineage" "frameworks/base" "packages/apps/PermissionController" "packages/modules/Permission"; do + if [ -d "$path" ]; then + cd "$path" + git reset -q --hard + git clean -q -fd + cd "$SRC_DIR/$branch_dir" + fi + done + else + echo ">> [$(date)] Resetting vendor and undoing patches disabled" | tee -a "$repo_log" + fi echo ">> [$(date)] (Re)initializing branch repository" | tee -a "$repo_log" if [ "$LOCAL_MIRROR" = true ]; then From 49f326ac1c281c945e3bd083c8a13d1f2f173819 Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 12:28:40 +0000 Subject: [PATCH 05/16] Make syncing branch repository switchable --- src/build.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/build.sh b/src/build.sh index e063ec21..d34367b6 100755 --- a/src/build.sh +++ b/src/build.sh @@ -196,9 +196,13 @@ for branch in ${BRANCH_NAME//,/ }; do "https://gitlab.com/the-muppets/manifest/raw/$themuppets_branch/muppets.xml" .repo/local_manifests/proprietary_gitlab.xml fi - echo ">> [$(date)] Syncing branch repository" | tee -a "$repo_log" - builddate=$(date +%Y%m%d) - repo sync "${jobs_arg[@]}" -c --force-sync &>> "$repo_log" + if [ "$CALL_REPO_INIT" = true ]; then + echo ">> [$(date)] Syncing branch repository" | tee -a "$repo_log" + builddate=$(date +%Y%m%d) + repo sync "${jobs_arg[@]}" -c --force-sync &>> "$repo_log" + else + echo ">> [$(date)] Syncing branch repository disabled" | tee -a "$repo_log" + fi if [ ! -d "vendor/$vendor" ]; then echo ">> [$(date)] Missing \"vendor/$vendor\", aborting" From 5db041b0bb9743f68d217f8a19aa9f43b64ce64c Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 15:48:48 +0000 Subject: [PATCH 06/16] Make syncing branch repository switchable --- src/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/build.sh b/src/build.sh index d34367b6..2ad292b6 100755 --- a/src/build.sh +++ b/src/build.sh @@ -77,7 +77,6 @@ if [ "$LOCAL_MIRROR" = true ]; then else echo ">> [$(date)] Initializing mirror repository disabled" | tee -a "$repo_log" fi -fi # Copy local manifests to the appropriate folder in order take them into consideration echo ">> [$(date)] Copying '$LMANIFEST_DIR/*.xml' to '.repo/local_manifests/'" @@ -97,6 +96,7 @@ fi else echo ">> [$(date)] Sync mirror repository disabled" | tee -a "$repo_log" fi +fi for branch in ${BRANCH_NAME//,/ }; do branch_dir=${branch//[^[:alnum:]]/_} @@ -196,9 +196,9 @@ for branch in ${BRANCH_NAME//,/ }; do "https://gitlab.com/the-muppets/manifest/raw/$themuppets_branch/muppets.xml" .repo/local_manifests/proprietary_gitlab.xml fi - if [ "$CALL_REPO_INIT" = true ]; then + builddate=$(date +%Y%m%d) + if [ "$CALL_REPO_SYNC" = true ]; then echo ">> [$(date)] Syncing branch repository" | tee -a "$repo_log" - builddate=$(date +%Y%m%d) repo sync "${jobs_arg[@]}" -c --force-sync &>> "$repo_log" else echo ">> [$(date)] Syncing branch repository disabled" | tee -a "$repo_log" From d7484ac8d2774e3f414a9035db299004fb6ecc4d Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 12:34:40 +0000 Subject: [PATCH 07/16] Make applying patches switchable --- src/build.sh | 64 ++++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/src/build.sh b/src/build.sh index 2ad292b6..fd8612a1 100755 --- a/src/build.sh +++ b/src/build.sh @@ -221,40 +221,44 @@ for branch in ${BRANCH_NAME//,/ }; do los_ver_minor=$(sed -n -e 's/^\s*PRODUCT_VERSION_MINOR = //p' "$makefile_containing_version") los_ver="$los_ver_major.$los_ver_minor" + if [ "$APPLY_PATCHES" = true ]; then # If needed, apply the microG's signature spoofing patch - if [ "$SIGNATURE_SPOOFING" = "yes" ] || [ "$SIGNATURE_SPOOFING" = "restricted" ]; then - # Determine which patch should be applied to the current Android source tree - cd frameworks/base - if [ "$SIGNATURE_SPOOFING" = "yes" ]; then - echo ">> [$(date)] Applying the standard signature spoofing patch ($frameworks_base_patch) to frameworks/base" - echo ">> [$(date)] WARNING: the standard signature spoofing patch introduces a security threat" - patch --quiet --force -p1 -i "/root/signature_spoofing_patches/$frameworks_base_patch" - else - echo ">> [$(date)] Applying the restricted signature spoofing patch (based on $frameworks_base_patch) to frameworks/base" - sed 's/android:protectionLevel="dangerous"/android:protectionLevel="signature|privileged"/' "/root/signature_spoofing_patches/$frameworks_base_patch" | patch --quiet --force -p1 - fi - git clean -q -f - cd ../.. - - if [ -n "$apps_permissioncontroller_patch" ] && [ "$SIGNATURE_SPOOFING" = "yes" ]; then - cd packages/apps/PermissionController - echo ">> [$(date)] Applying the apps/PermissionController patch ($apps_permissioncontroller_patch) to packages/apps/PermissionController" - patch --quiet --force -p1 -i "/root/signature_spoofing_patches/$apps_permissioncontroller_patch" + if [ "$SIGNATURE_SPOOFING" = "yes" ] || [ "$SIGNATURE_SPOOFING" = "restricted" ]; then + # Determine which patch should be applied to the current Android source tree + cd frameworks/base + if [ "$SIGNATURE_SPOOFING" = "yes" ]; then + echo ">> [$(date)] Applying the standard signature spoofing patch ($frameworks_base_patch) to frameworks/base" + echo ">> [$(date)] WARNING: the standard signature spoofing patch introduces a security threat" + patch --quiet --force -p1 -i "/root/signature_spoofing_patches/$frameworks_base_patch" + else + echo ">> [$(date)] Applying the restricted signature spoofing patch (based on $frameworks_base_patch) to frameworks/base" + sed 's/android:protectionLevel="dangerous"/android:protectionLevel="signature|privileged"/' "/root/signature_spoofing_patches/$frameworks_base_patch" | patch --quiet --force -p1 + fi git clean -q -f - cd ../../.. - fi + cd ../.. + + if [ -n "$apps_permissioncontroller_patch" ] && [ "$SIGNATURE_SPOOFING" = "yes" ]; then + cd packages/apps/PermissionController + echo ">> [$(date)] Applying the apps/PermissionController patch ($apps_permissioncontroller_patch) to packages/apps/PermissionController" + patch --quiet --force -p1 -i "/root/signature_spoofing_patches/$apps_permissioncontroller_patch" + git clean -q -f + cd ../../.. + fi - if [ -n "$modules_permission_patch" ] && [ "$SIGNATURE_SPOOFING" = "yes" ]; then - cd packages/modules/Permission - echo ">> [$(date)] Applying the modules/Permission patch ($modules_permission_patch) to packages/modules/Permission" - patch --quiet --force -p1 -i "/root/signature_spoofing_patches/$modules_permission_patch" - git clean -q -f - cd ../../.. - fi + if [ -n "$modules_permission_patch" ] && [ "$SIGNATURE_SPOOFING" = "yes" ]; then + cd packages/modules/Permission + echo ">> [$(date)] Applying the modules/Permission patch ($modules_permission_patch) to packages/modules/Permission" + patch --quiet --force -p1 -i "/root/signature_spoofing_patches/$modules_permission_patch" + git clean -q -f + cd ../../.. + fi - # Override device-specific settings for the location providers - mkdir -p "vendor/$vendor/overlay/microg/frameworks/base/core/res/res/values/" - cp /root/signature_spoofing_patches/frameworks_base_config.xml "vendor/$vendor/overlay/microg/frameworks/base/core/res/res/values/config.xml" + # Override device-specific settings for the location providers + mkdir -p "vendor/$vendor/overlay/microg/frameworks/base/core/res/res/values/" + cp /root/signature_spoofing_patches/frameworks_base_config.xml "vendor/$vendor/overlay/microg/frameworks/base/core/res/res/values/config.xml" + fi + else + echo ">> [$(date)] Applying patches disabled" fi echo ">> [$(date)] Setting \"$RELEASE_TYPE\" as release type" From 03bfa1eff5f2bea16375d8f713c7bf9dc0882dc7 Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 12:45:28 +0000 Subject: [PATCH 08/16] Make calling envsetup.sh and breakfast switchable --- src/build.sh | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/build.sh b/src/build.sh index fd8612a1..377c715b 100755 --- a/src/build.sh +++ b/src/build.sh @@ -312,12 +312,16 @@ for branch in ${BRANCH_NAME//,/ }; do fi fi - # Prepare the environment - echo ">> [$(date)] Preparing build environment" - set +eu - # shellcheck source=/dev/null - source build/envsetup.sh > /dev/null - set -eu + if [ "$PREPARE_BUILD_ENVIRONMENT" = true ]; then + # Prepare the environment + echo ">> [$(date)] Preparing build environment" + set +eu + # shellcheck source=/dev/null + source build/envsetup.sh > /dev/null + set -eu + else + echo ">> [$(date)] Preparing build environment disabled" + fi if [ -f /root/userscripts/before.sh ]; then echo ">> [$(date)] Running before.sh" @@ -355,10 +359,16 @@ for branch in ${BRANCH_NAME//,/ }; do DEBUG_LOG="$LOGS_DIR/$logsubdir/lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename.log" - set +eu - breakfast "$codename" "$BUILD_TYPE" &>> "$DEBUG_LOG" - breakfast_returncode=$? - set -eu + breakfast_returncode=0 + if [ "$CALL_BREAKFAST" = true ]; then + set +eu + breakfast "$codename" "$BUILD_TYPE" &>> "$DEBUG_LOG" + breakfast_returncode=$? + set -eu + else + echo ">> [$(date)] Calling breakfast disabled" + fi + if [ $breakfast_returncode -ne 0 ]; then echo ">> [$(date)] breakfast failed for $codename, $branch branch" | tee -a "$DEBUG_LOG" # call post-build.sh so the failure is logged in a way that is more visible From 4535d1876c75c06168d6c2f3525b3282bb72d27b Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 12:48:39 +0000 Subject: [PATCH 09/16] Make calling mka switchable --- src/build.sh | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/build.sh b/src/build.sh index 377c715b..e4bb23ed 100755 --- a/src/build.sh +++ b/src/build.sh @@ -384,20 +384,22 @@ for branch in ${BRANCH_NAME//,/ }; do /root/userscripts/pre-build.sh "$codename" &>> "$DEBUG_LOG" || echo ">> [$(date)] Warning: pre-build.sh failed!" fi - # Start the build - echo ">> [$(date)] Starting build for $codename, $branch branch" | tee -a "$DEBUG_LOG" - build_successful=false - if (set +eu ; mka "${jobs_arg[@]}" bacon) &>> "$DEBUG_LOG"; then - - # Move produced ZIP files to the main OUT directory - echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR/$zipsubdir'" | tee -a "$DEBUG_LOG" - cd out/target/product/"$codename" - files_to_hash=() - for build in lineage-*.zip; do - cp -v system/build.prop "$ZIP_DIR/$zipsubdir/$build.prop" &>> "$DEBUG_LOG" - mv "$build" "$ZIP_DIR/$zipsubdir/" &>> "$DEBUG_LOG" - files_to_hash+=( "$build" ) - done + build_successful=true + if [ "$CALL_MKA" = true ]; then + # Start the build + echo ">> [$(date)] Starting build for $codename, $branch branch" | tee -a "$DEBUG_LOG" + build_successful=false + if (set +eu ; mka "${jobs_arg[@]}" bacon) &>> "$DEBUG_LOG"; then + + # Move produced ZIP files to the main OUT directory + echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR/$zipsubdir'" | tee -a "$DEBUG_LOG" + cd out/target/product/"$codename" + files_to_hash=() + for build in lineage-*.zip; do + cp -v system/build.prop "$ZIP_DIR/$zipsubdir/$build.prop" &>> "$DEBUG_LOG" + mv "$build" "$ZIP_DIR/$zipsubdir/" &>> "$DEBUG_LOG" + files_to_hash+=( "$build" ) + done cd "$source_dir/out/target/product/$codename/obj/PACKAGING/target_files_intermediates/lineage_$codename-target_files-eng.root/IMAGES/" for image in recovery boot vendor_boot dtbo super_empty vbmeta vendor_kernel_boot; do @@ -414,9 +416,13 @@ for branch in ${BRANCH_NAME//,/ }; do done cd "$source_dir" build_successful=true + else + echo ">> [$(date)] Failed build for $codename" | tee -a "$DEBUG_LOG" + fi else - echo ">> [$(date)] Failed build for $codename" | tee -a "$DEBUG_LOG" - fi + echo ">> [$(date)] Calling mka for $codename, $branch branch disabled" + fi + # Remove old zips and logs if [ "$DELETE_OLD_ZIPS" -gt "0" ]; then From 8b613706072751bd8e688d7deda7ab8ca25c75fa Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 4 Dec 2023 16:05:35 +0000 Subject: [PATCH 10/16] Make repo init switchable --- src/build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/build.sh b/src/build.sh index e4bb23ed..a6ffc024 100755 --- a/src/build.sh +++ b/src/build.sh @@ -177,11 +177,15 @@ for branch in ${BRANCH_NAME//,/ }; do echo ">> [$(date)] Resetting vendor and undoing patches disabled" | tee -a "$repo_log" fi - echo ">> [$(date)] (Re)initializing branch repository" | tee -a "$repo_log" - if [ "$LOCAL_MIRROR" = true ]; then - ( yes||: ) | repo init -u https://github.com/LineageOS/android.git --reference "$MIRROR_DIR" -b "$branch" --git-lfs &>> "$repo_log" + if [ "$CALL_REPO_INIT" = true ]; then + echo ">> [$(date)] (Re)initializing branch repository" | tee -a "$repo_log" + if [ "$LOCAL_MIRROR" = true ]; then + ( yes||: ) | repo init -u https://github.com/LineageOS/android.git --reference "$MIRROR_DIR" -b "$branch" --git-lfs &>> "$repo_log" + else + ( yes||: ) | repo init -u https://github.com/LineageOS/android.git -b "$branch" --git-lfs &>> "$repo_log" + fi else - ( yes||: ) | repo init -u https://github.com/LineageOS/android.git -b "$branch" --git-lfs &>> "$repo_log" + echo ">> [$(date)] Calling repo init disabled" fi # Copy local manifests to the appropriate folder in order take them into consideration @@ -423,7 +427,6 @@ for branch in ${BRANCH_NAME//,/ }; do echo ">> [$(date)] Calling mka for $codename, $branch branch disabled" fi - # Remove old zips and logs if [ "$DELETE_OLD_ZIPS" -gt "0" ]; then if [ "$ZIP_SUBDIR" = true ]; then From 54a6f2e7f33c31a8efe5bc11ca3f30675766ef7f Mon Sep 17 00:00:00 2001 From: Pete Date: Tue, 5 Dec 2023 11:42:27 +0000 Subject: [PATCH 11/16] Add variable to control making -img.zip file --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 86c86715..9b5605e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -127,6 +127,7 @@ ENV PREPARE_BUILD_ENVIRONMENT true ENV CALL_BREAKFAST true ENV CALL_MKA true ENV ZIP_UP_IMAGES false +ENV MAKE_IMG_ZIP_FILE false # You can optionally specify a USERSCRIPTS_DIR volume containing these scripts: # * begin.sh, run at the very beginning From 081cf6a70d9f315a303ba78dedf8811b0cf5727e Mon Sep 17 00:00:00 2001 From: Pete Date: Tue, 5 Dec 2023 12:00:24 +0000 Subject: [PATCH 12/16] Make the -img.zip file --- src/build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/build.sh b/src/build.sh index a6ffc024..472f1cdb 100755 --- a/src/build.sh +++ b/src/build.sh @@ -394,6 +394,15 @@ for branch in ${BRANCH_NAME//,/ }; do echo ">> [$(date)] Starting build for $codename, $branch branch" | tee -a "$DEBUG_LOG" build_successful=false if (set +eu ; mka "${jobs_arg[@]}" bacon) &>> "$DEBUG_LOG"; then + if [ "$MAKE_IMG_ZIP_FILE" = true ]; then + # make the `-img.zip` file + echo ">> [$(date)] Making -img.zip file" | tee -a "$DEBUG_LOG" + infile="out/target/product/$codename/obj/PACKAGING/target_files_intermediates/lineage_$codename-target_files-eng.root.zip" + img_zip_file="out/target/product/$codename/lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename-img.zip" + img_from_target_files "$infile" "$img_zip_file" &>> "$DEBUG_LOG" + else + echo ">> [$(date)] Making -img.zip file disabled" + fi # Move produced ZIP files to the main OUT directory echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR/$zipsubdir'" | tee -a "$DEBUG_LOG" From 94fac01a4a52d2ebbe8c551c8ca841f472c07bb6 Mon Sep 17 00:00:00 2001 From: Pete Date: Tue, 5 Dec 2023 12:31:07 +0000 Subject: [PATCH 13/16] Zip up the .img files --- src/build.sh | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/build.sh b/src/build.sh index 472f1cdb..c6cbf07c 100755 --- a/src/build.sh +++ b/src/build.sh @@ -414,15 +414,37 @@ for branch in ${BRANCH_NAME//,/ }; do files_to_hash+=( "$build" ) done cd "$source_dir/out/target/product/$codename/obj/PACKAGING/target_files_intermediates/lineage_$codename-target_files-eng.root/IMAGES/" + if [ "$ZIP_UP_IMAGES" = true ]; then + # zipping the `-img` files + echo ">> [$(date)] Zipping the `-img` files" | tee -a "$DEBUG_LOG" + + files_to_zip=() + images_zip_file="lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename-images.zip" + cd "$source_dir/out/target/product/$codename/obj/PACKAGING/target_files_intermediates/lineage_$codename-target_files-eng.root/IMAGES/" + + for image in recovery boot vendor_boot dtbo super_empty vbmeta vendor_kernel_boot; do + if [ -f "$image.img" ]; then + echo ">> [$(date)] Adding $image.img" to "$images_zip_file" | tee -a "$DEBUG_LOG" + files_to_zip+=( "$image.img" ) + fi + done + + zip "$images_zip_file" "${files_to_zip[@]}" + mv "$images_zip_file" "$ZIP_DIR/$zipsubdir/" + files_to_hash+=( "$images_zip_file" ) + else + # just copy the mages to the zips directory + echo ">> [$(date)] Zipping the `-img` files disabled" + for image in recovery boot vendor_boot dtbo super_empty vbmeta vendor_kernel_boot; do + if [ -f "$image.img" ]; then + recovery_name="lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename-$image.img" + echo ">> [$(date)] Copying $image.img" to "$ZIP_DIR/$zipsubdir/$recovery_name" >> "$DEBUG_LOG" + cp "$image.img" "$ZIP_DIR/$zipsubdir/$recovery_name" &>> "$DEBUG_LOG" + files_to_hash+=( "$recovery_name" ) + fi + done + fi - for image in recovery boot vendor_boot dtbo super_empty vbmeta vendor_kernel_boot; do - if [ -f "$image.img" ]; then - recovery_name="lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename-$image.img" - echo ">> [$(date)] Copying $image.img" to "$ZIP_DIR/$zipsubdir/$recovery_name" >> "$DEBUG_LOG" - cp "$image.img" "$ZIP_DIR/$zipsubdir/$recovery_name" &>> "$DEBUG_LOG" - files_to_hash+=( "$recovery_name" ) - fi - done cd "$ZIP_DIR/$zipsubdir" for f in "${files_to_hash[@]}"; do sha256sum "$f" > "$ZIP_DIR/$zipsubdir/$f.sha256sum" @@ -434,6 +456,7 @@ for branch in ${BRANCH_NAME//,/ }; do fi else echo ">> [$(date)] Calling mka for $codename, $branch branch disabled" + fi fi # Remove old zips and logs From 9469b366db81d15a4a063423cb05f91d524c4fa3 Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 1 Jan 2024 14:36:10 +0000 Subject: [PATCH 14/16] Zipping typo --- src/build.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/build.sh b/src/build.sh index c6cbf07c..069f3c37 100755 --- a/src/build.sh +++ b/src/build.sh @@ -404,19 +404,20 @@ for branch in ${BRANCH_NAME//,/ }; do echo ">> [$(date)] Making -img.zip file disabled" fi - # Move produced ZIP files to the main OUT directory - echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR/$zipsubdir'" | tee -a "$DEBUG_LOG" - cd out/target/product/"$codename" - files_to_hash=() - for build in lineage-*.zip; do - cp -v system/build.prop "$ZIP_DIR/$zipsubdir/$build.prop" &>> "$DEBUG_LOG" - mv "$build" "$ZIP_DIR/$zipsubdir/" &>> "$DEBUG_LOG" - files_to_hash+=( "$build" ) - done + # Move produced ZIP files to the main OUT directory + echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR/$zipsubdir'" | tee -a "$DEBUG_LOG" + cd out/target/product/"$codename" + files_to_hash=() + for build in lineage-*.zip; do + cp -v system/build.prop "$ZIP_DIR/$zipsubdir/$build.prop" &>> "$DEBUG_LOG" + mv "$build" "$ZIP_DIR/$zipsubdir/" &>> "$DEBUG_LOG" + files_to_hash+=( "$build" ) + done + cd "$source_dir/out/target/product/$codename/obj/PACKAGING/target_files_intermediates/lineage_$codename-target_files-eng.root/IMAGES/" if [ "$ZIP_UP_IMAGES" = true ]; then - # zipping the `-img` files - echo ">> [$(date)] Zipping the `-img` files" | tee -a "$DEBUG_LOG" + # zipping the .img files + echo ">> [$(date)] Zipping the .img files" | tee -a "$DEBUG_LOG" files_to_zip=() images_zip_file="lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename-images.zip" @@ -505,8 +506,6 @@ for branch in ${BRANCH_NAME//,/ }; do (set +eu ; mka "${jobs_arg[@]}" clean) &>> "$DEBUG_LOG" fi fi - - fi done fi done From 1f56e1396a5b5408036f978be7c57b3048178e61 Mon Sep 17 00:00:00 2001 From: Pete Date: Thu, 7 Dec 2023 16:54:45 +0000 Subject: [PATCH 15/16] Dont create a .prop file for the -img.zip --- src/build.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/build.sh b/src/build.sh index 069f3c37..6208d28a 100755 --- a/src/build.sh +++ b/src/build.sh @@ -393,21 +393,27 @@ for branch in ${BRANCH_NAME//,/ }; do # Start the build echo ">> [$(date)] Starting build for $codename, $branch branch" | tee -a "$DEBUG_LOG" build_successful=false + files_to_hash=() + if (set +eu ; mka "${jobs_arg[@]}" bacon) &>> "$DEBUG_LOG"; then if [ "$MAKE_IMG_ZIP_FILE" = true ]; then # make the `-img.zip` file echo ">> [$(date)] Making -img.zip file" | tee -a "$DEBUG_LOG" infile="out/target/product/$codename/obj/PACKAGING/target_files_intermediates/lineage_$codename-target_files-eng.root.zip" - img_zip_file="out/target/product/$codename/lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename-img.zip" + img_zip_file="lineage-$los_ver-$builddate-$RELEASE_TYPE-$codename-img.zip" img_from_target_files "$infile" "$img_zip_file" &>> "$DEBUG_LOG" + + # move it to the zips directory + mv "$img_zip_file" "$ZIP_DIR/$zipsubdir/" &>> "$DEBUG_LOG" + files_to_hash+=( "$img_zip_file" ) else echo ">> [$(date)] Making -img.zip file disabled" fi - # Move produced ZIP files to the main OUT directory + # Move the ROM zip files to the main OUT directory echo ">> [$(date)] Moving build artifacts for $codename to '$ZIP_DIR/$zipsubdir'" | tee -a "$DEBUG_LOG" cd out/target/product/"$codename" - files_to_hash=() + for build in lineage-*.zip; do cp -v system/build.prop "$ZIP_DIR/$zipsubdir/$build.prop" &>> "$DEBUG_LOG" mv "$build" "$ZIP_DIR/$zipsubdir/" &>> "$DEBUG_LOG" From 95270877c11ce2083e7bd23c398040d3d0678efe Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 1 Jan 2024 15:00:45 +0000 Subject: [PATCH 16/16] Add switchable git lfs pull call --- Dockerfile | 1 + src/build.sh | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9b5605e9..608ce190 100644 --- a/Dockerfile +++ b/Dockerfile @@ -122,6 +122,7 @@ ENV SYNC_MIRROR true ENV RESET_VENDOR_UNDO_PATCHES true ENV CALL_REPO_INIT true ENV CALL_REPO_SYNC true +ENV CALL_GIT_LFS_PULL false ENV APPLY_PATCHES true ENV PREPARE_BUILD_ENVIRONMENT true ENV CALL_BREAKFAST true diff --git a/src/build.sh b/src/build.sh index 6208d28a..ac53a019 100755 --- a/src/build.sh +++ b/src/build.sh @@ -208,6 +208,13 @@ for branch in ${BRANCH_NAME//,/ }; do echo ">> [$(date)] Syncing branch repository disabled" | tee -a "$repo_log" fi + if [ "$CALL_GIT_LFS_PULL" = true ]; then + echo ">> [$(date)] Calling git lfs pull" | tee -a "$repo_log" + repo forall -v -c git lfs pull &>> "$repo_log" + else + echo ">> [$(date)] Calling git lfs pull disabled" | tee -a "$repo_log" + fi + if [ ! -d "vendor/$vendor" ]; then echo ">> [$(date)] Missing \"vendor/$vendor\", aborting" exit 1