From 49b584807da40a3a1ce16256c85fd41191722011 Mon Sep 17 00:00:00 2001 From: Sumit Pundir Date: Fri, 14 Aug 2020 13:48:39 +0530 Subject: [PATCH 1/3] src: build: add support for minimal apps Signed-off-by: Sumit Pundir --- Dockerfile | 3 ++ src/build.sh | 94 +++++++++++++++++++++++++++------------------------- 2 files changed, 51 insertions(+), 46 deletions(-) diff --git a/Dockerfile b/Dockerfile index b5fe416..1a7fd48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -103,6 +103,9 @@ ENV OPENDELTA_BUILDS_JSON '' # Save recovery image ENV RECOVERY_IMG false +# Ship with Minimal Apps +ENV MINIMAL_APPS 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 diff --git a/src/build.sh b/src/build.sh index 7e44e42..b1c0b09 100755 --- a/src/build.sh +++ b/src/build.sh @@ -204,59 +204,61 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo "Switch to Python2" ln -fs /usr/bin/python2 /usr/bin/python if brunch ${DEVICE}; then - currentdate=$(date +%Y%m%d) - if [ "$builddate" != "$currentdate" ]; then - find out/target/product/${DEVICE} -maxdepth 1 -name "e-*-$currentdate-*.zip*" -type f -exec sh /root/fix_build_date.sh {} $currentdate $builddate \; - fi + if mka MINIMAL_APPS=${MINIMAL_APPS} bacon; then + currentdate=$(date +%Y%m%d) + if [ "$builddate" != "$currentdate" ]; then + find out/target/product/${DEVICE} -maxdepth 1 -name "e-*-$currentdate-*.zip*" -type f -exec sh /root/fix_build_date.sh {} $currentdate $builddate \; + fi - if [ "$BUILD_DELTA" = true ]; then - if [ -d "delta_last/${DEVICE}/" ]; then - # If not the first build, create delta files - echo ">> [$(date)] Generating delta files for ${DEVICE}" - cd /root/delta - if ./opendelta.sh ${DEVICE}; then - echo ">> [$(date)] Delta generation for ${DEVICE} completed" + if [ "$BUILD_DELTA" = true ]; then + if [ -d "delta_last/${DEVICE}/" ]; then + # If not the first build, create delta files + echo ">> [$(date)] Generating delta files for ${DEVICE}" + cd /root/delta + if ./opendelta.sh ${DEVICE}; then + echo ">> [$(date)] Delta generation for ${DEVICE} completed" + else + echo ">> [$(date)] Delta generation for ${DEVICE} failed" + fi + if [ "$DELETE_OLD_DELTAS" -gt "0" ]; then + /usr/bin/python /root/clean_up.py -n $DELETE_OLD_DELTAS -V $los_ver -N 1 "$DELTA_DIR/${DEVICE}" + fi + cd "$source_dir" else - echo ">> [$(date)] Delta generation for ${DEVICE} failed" - fi - if [ "$DELETE_OLD_DELTAS" -gt "0" ]; then - /usr/bin/python /root/clean_up.py -n $DELETE_OLD_DELTAS -V $los_ver -N 1 "$DELTA_DIR/${DEVICE}" + # If the first build, copy the current full zip in $source_dir/delta_last/${DEVICE}/ + echo ">> [$(date)] No previous build for ${DEVICE}; using current build as base for the next delta" + mkdir -p delta_last/${DEVICE}/ + find out/target/product/${DEVICE} -maxdepth 1 -name 'e-*.zip' -type f -exec cp {} "$source_dir/delta_last/${DEVICE}/" \; fi - cd "$source_dir" - else - # If the first build, copy the current full zip in $source_dir/delta_last/${DEVICE}/ - echo ">> [$(date)] No previous build for ${DEVICE}; using current build as base for the next delta" - mkdir -p delta_last/${DEVICE}/ - find out/target/product/${DEVICE} -maxdepth 1 -name 'e-*.zip' -type f -exec cp {} "$source_dir/delta_last/${DEVICE}/" \; - fi - fi - # Move produced ZIP files to the main OUT directory - echo ">> [$(date)] Moving build artifacts for ${DEVICE} to '$ZIP_DIR/$zipsubdir'" - cd out/target/product/${DEVICE} - for build in e-*.zip; do - sha256sum "$build" > "$ZIP_DIR/$zipsubdir/$build.sha256sum" - find . -maxdepth 1 -name 'e-*.zip*' -type f -exec mv {} "$ZIP_DIR/$zipsubdir/" \; - - if [ "$BACKUP_IMG" = true ]; then - find . -maxdepth 1 -name '*.img' -type f -exec zip "$ZIP_DIR/$zipsubdir/IMG-$build" {} \; - cd $ZIP_DIR/$zipsubdir - sha256sum "IMG-$build" > "IMG-$build.sha256sum" - md5sum "IMG-$build" > "IMG-$build.md5sum" fi + # Move produced ZIP files to the main OUT directory + echo ">> [$(date)] Moving build artifacts for ${DEVICE} to '$ZIP_DIR/$zipsubdir'" + cd out/target/product/${DEVICE} + for build in e-*.zip; do + sha256sum "$build" > "$ZIP_DIR/$zipsubdir/$build.sha256sum" + find . -maxdepth 1 -name 'e-*.zip*' -type f -exec mv {} "$ZIP_DIR/$zipsubdir/" \; + + if [ "$BACKUP_IMG" = true ]; then + find . -maxdepth 1 -name '*.img' -type f -exec zip "$ZIP_DIR/$zipsubdir/IMG-$build" {} \; + cd $ZIP_DIR/$zipsubdir + sha256sum "IMG-$build" > "IMG-$build.sha256sum" + md5sum "IMG-$build" > "IMG-$build.md5sum" + fi - if [ "$RECOVERY_IMG" = true ]; then - if [ -f "recovery.img" ]; then - cp -a recovery.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" - else - cp -a boot.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" + if [ "$RECOVERY_IMG" = true ]; then + if [ -f "recovery.img" ]; then + cp -a recovery.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" + else + cp -a boot.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" + fi fi - fi - done + done - cd "$source_dir" - build_successful=true - else - echo ">> [$(date)] Failed build for ${DEVICE}" + cd "$source_dir" + build_successful=true + else + echo ">> [$(date)] Failed build for ${DEVICE}" + fi fi # Remove old zips and logs -- GitLab From d1cb5eb791e7b62d8b07f35c5e9e62460477d1e5 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 24 Aug 2020 17:22:12 +0200 Subject: [PATCH 2/3] Clean build script --- src/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.sh b/src/build.sh index b1c0b09..42dd8a9 100755 --- a/src/build.sh +++ b/src/build.sh @@ -244,7 +244,7 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then sha256sum "IMG-$build" > "IMG-$build.sha256sum" md5sum "IMG-$build" > "IMG-$build.md5sum" fi - + if [ "$RECOVERY_IMG" = true ]; then if [ -f "recovery.img" ]; then cp -a recovery.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" -- GitLab From f9c80f987439561b2c2fe83ebf2fad29386a0d0e Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 24 Aug 2020 17:22:55 +0200 Subject: [PATCH 3/3] Clean again build script --- src/build.sh | 94 +++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/src/build.sh b/src/build.sh index 42dd8a9..28e3964 100755 --- a/src/build.sh +++ b/src/build.sh @@ -204,61 +204,59 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo "Switch to Python2" ln -fs /usr/bin/python2 /usr/bin/python if brunch ${DEVICE}; then - if mka MINIMAL_APPS=${MINIMAL_APPS} bacon; then - currentdate=$(date +%Y%m%d) - if [ "$builddate" != "$currentdate" ]; then - find out/target/product/${DEVICE} -maxdepth 1 -name "e-*-$currentdate-*.zip*" -type f -exec sh /root/fix_build_date.sh {} $currentdate $builddate \; - fi + currentdate=$(date +%Y%m%d) + if [ "$builddate" != "$currentdate" ]; then + find out/target/product/${DEVICE} -maxdepth 1 -name "e-*-$currentdate-*.zip*" -type f -exec sh /root/fix_build_date.sh {} $currentdate $builddate \; + fi - if [ "$BUILD_DELTA" = true ]; then - if [ -d "delta_last/${DEVICE}/" ]; then - # If not the first build, create delta files - echo ">> [$(date)] Generating delta files for ${DEVICE}" - cd /root/delta - if ./opendelta.sh ${DEVICE}; then - echo ">> [$(date)] Delta generation for ${DEVICE} completed" - else - echo ">> [$(date)] Delta generation for ${DEVICE} failed" - fi - if [ "$DELETE_OLD_DELTAS" -gt "0" ]; then - /usr/bin/python /root/clean_up.py -n $DELETE_OLD_DELTAS -V $los_ver -N 1 "$DELTA_DIR/${DEVICE}" - fi - cd "$source_dir" + if [ "$BUILD_DELTA" = true ]; then + if [ -d "delta_last/${DEVICE}/" ]; then + # If not the first build, create delta files + echo ">> [$(date)] Generating delta files for ${DEVICE}" + cd /root/delta + if ./opendelta.sh ${DEVICE}; then + echo ">> [$(date)] Delta generation for ${DEVICE} completed" else - # If the first build, copy the current full zip in $source_dir/delta_last/${DEVICE}/ - echo ">> [$(date)] No previous build for ${DEVICE}; using current build as base for the next delta" - mkdir -p delta_last/${DEVICE}/ - find out/target/product/${DEVICE} -maxdepth 1 -name 'e-*.zip' -type f -exec cp {} "$source_dir/delta_last/${DEVICE}/" \; + echo ">> [$(date)] Delta generation for ${DEVICE} failed" fi - fi - # Move produced ZIP files to the main OUT directory - echo ">> [$(date)] Moving build artifacts for ${DEVICE} to '$ZIP_DIR/$zipsubdir'" - cd out/target/product/${DEVICE} - for build in e-*.zip; do - sha256sum "$build" > "$ZIP_DIR/$zipsubdir/$build.sha256sum" - find . -maxdepth 1 -name 'e-*.zip*' -type f -exec mv {} "$ZIP_DIR/$zipsubdir/" \; - - if [ "$BACKUP_IMG" = true ]; then - find . -maxdepth 1 -name '*.img' -type f -exec zip "$ZIP_DIR/$zipsubdir/IMG-$build" {} \; - cd $ZIP_DIR/$zipsubdir - sha256sum "IMG-$build" > "IMG-$build.sha256sum" - md5sum "IMG-$build" > "IMG-$build.md5sum" + if [ "$DELETE_OLD_DELTAS" -gt "0" ]; then + /usr/bin/python /root/clean_up.py -n $DELETE_OLD_DELTAS -V $los_ver -N 1 "$DELTA_DIR/${DEVICE}" fi + cd "$source_dir" + else + # If the first build, copy the current full zip in $source_dir/delta_last/${DEVICE}/ + echo ">> [$(date)] No previous build for ${DEVICE}; using current build as base for the next delta" + mkdir -p delta_last/${DEVICE}/ + find out/target/product/${DEVICE} -maxdepth 1 -name 'e-*.zip' -type f -exec cp {} "$source_dir/delta_last/${DEVICE}/" \; + fi + fi + # Move produced ZIP files to the main OUT directory + echo ">> [$(date)] Moving build artifacts for ${DEVICE} to '$ZIP_DIR/$zipsubdir'" + cd out/target/product/${DEVICE} + for build in e-*.zip; do + sha256sum "$build" > "$ZIP_DIR/$zipsubdir/$build.sha256sum" + find . -maxdepth 1 -name 'e-*.zip*' -type f -exec mv {} "$ZIP_DIR/$zipsubdir/" \; + + if [ "$BACKUP_IMG" = true ]; then + find . -maxdepth 1 -name '*.img' -type f -exec zip "$ZIP_DIR/$zipsubdir/IMG-$build" {} \; + cd $ZIP_DIR/$zipsubdir + sha256sum "IMG-$build" > "IMG-$build.sha256sum" + md5sum "IMG-$build" > "IMG-$build.md5sum" + fi - if [ "$RECOVERY_IMG" = true ]; then - if [ -f "recovery.img" ]; then - cp -a recovery.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" - else - cp -a boot.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" - fi + if [ "$RECOVERY_IMG" = true ]; then + if [ -f "recovery.img" ]; then + cp -a recovery.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" + else + cp -a boot.img "$ZIP_DIR/$zipsubdir/recovery-${build%.*}.img" fi - done + fi + done - cd "$source_dir" - build_successful=true - else - echo ">> [$(date)] Failed build for ${DEVICE}" - fi + cd "$source_dir" + build_successful=true + else + echo ">> [$(date)] Failed build for ${DEVICE}" fi # Remove old zips and logs -- GitLab