build_all_pkg.sh: improve build_all_pkg step. [1/1]

PD#SWPL-67525

Problem:
improve build scripts

Solution:
improve build scripts

Verify:
ad401_a113l

Signed-off-by: shijie.xiong <shijie.xiong@amlogic.com>
Signed-off-by: Kelvin Zhang <kelvin.zhang@amlogic.com>
Change-Id: Id84016a036eaf160a1c094b229e7d4a9b49f2947
diff --git a/build_all_pkg.sh b/build_all_pkg.sh
index 917348b..8d7d5e6 100755
--- a/build_all_pkg.sh
+++ b/build_all_pkg.sh
@@ -15,38 +15,45 @@
 }
 
 if [[ "$SUBMIT_TYPE" == "daily" ]] || [[ "$SUBMIT_TYPE" == "release" ]]; then
-	make docs
+echo "======== Building document ========" | tee $BUILD_LOG
+	make docs >> $BUILD_LOG 2>&1
 	if [ -d $LOCAL_DOC_PATH ]; then
 		pushd $LOCAL_DOC_PATH >/dev/null
 		publish_docoment
 		if [ $? -ne 0 ]; then
-			echo "Failed to update document"
+			echo "Failed to update document!"
 		else
-			echo "Document updated!"
+			echo "Document updated."
 		fi
 		popd >/dev/null
 	else
 		echo "$LOCAL_DOC_PATH not exist!"
 	fi
+echo -e "======== Done ========\n" | tee -a $BUILD_LOG
 fi
 
-# Manually cherry pick patches
-./scripts/cherry_pick.sh
+echo "======== Building all packages ========" | tee -a $BUILD_LOG
 
 source scripts/gen_package_combination.sh
 
 index=0
 while IFS= read -r LINE; do
-	source scripts/pkg_env.sh $index gen_all
+	source scripts/pkg_env.sh $index gen_all >> $BUILD_LOG 2>&1
 	[ "$?" -ne 0 ] && echo "Ignore unsupported combination!" && continue
-	make package
+	echo -n "$index. Building ... "
+	make package >> $BUILD_LOG 2>&1
 	get_new_package_dir
-	[ "$?" -ne 0 ] && echo "Failed to make!" && exit 3
+	[ "$?" -ne 0 ] && echo "failed!" && cat $BUILD_LOG && echo -e "\nAborted with errors!\n" && exit 3
+	grep -qr "warning: " $BUILD_LOG
+	[ "$?" -eq 0 ] && cat $BUILD_LOG && echo -e "\nAborted with warnings!\n" && exit 1
+	echo "OK."
 	if [[ "$SUBMIT_TYPE" == "release" ]]; then
-		publish_packages
+		publish_packages >> $BUILD_LOG 2>&1
 		[ "$?" -ne 0 ] && echo "Failed to publish packages!" && exit 4
 	fi
 	index=$((index + 1))
 done <"$PACKAGE_COMBINATION"
 
-echo "Build completed!"
+[[ "$SUBMIT_TYPE" == "release" ]] && post_publish_packages >> $BUILD_LOG 2>&1
+
+echo -e "======== Done ========\n" | tee -a $BUILD_LOG