blob: 72fd625779ecfe670632b4c80b3b9c54230de069 [file] [log] [blame]
kelvin.zhanga1170fa2022-03-03 20:06:57 +08001#!/bin/bash
2#
3# Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
4#
5# SPDX-License-Identifier: MIT
6#
7
Kelvin Zhange1cb8732022-03-22 11:39:49 +08008source /etc/profile.d/TOOLSENV.sh
9
kelvin.zhanga1170fa2022-03-03 20:06:57 +080010export PATH=/opt/cmake-3.18.4-Linux-x86_64/bin/:$PATH
11export PATH=/proj/coverity/cov-analysis/bin/:$PATH
12export LM_LICENSE_FILE=/mnt/fileroot/jenkins/Xplorer_key.txt:$LM_LICENSE_FILE
13export PATH=/opt/xtensa/XtDevTools/install/tools/RG-2018.9-linux/XtensaTools/bin:$PATH
14export XTENSA_SYSTEM=/opt/xtensa/XtDevTools/install/builds/RG-2018.9-linux/Amlogic_v0/config
15export XTENSA_CORE=Amlogic_v0
16
17if [ -z "$MANIFEST_URL" ] || [ -z "$MANIFEST_BRANCH" ] || [ -z "$PROJECT_NAME" ] || [ -z "$BRANCH_NAME" ]; then
18 echo "NULL params!"
19 exit 1
20fi
21
Kelvin Zhangd64c8832022-04-02 19:56:24 +080022if [ "$SUBMIT_TYPE" = "daily" -o "$SUBMIT_TYPE" = "release" ];then
kelvin.zhanga1170fa2022-03-03 20:06:57 +080023 BUILDCHECK_BASE_PATH=/mnt/fileroot/autobuild/workdir/workspace/RTOS/RTOS_SDK/patchbuild
kelvin.zhang01393902022-03-03 20:42:46 +080024elif [ "$SUBMIT_TYPE" = "every" ];then
kelvin.zhanga1170fa2022-03-03 20:06:57 +080025 BUILDCHECK_BASE_PATH=/mnt/fileroot/jenkins/build-check
kelvin.zhanga1170fa2022-03-03 20:06:57 +080026fi
27
28MATCH_PATTERN="projects/"
Kelvin Zhange1cb8732022-03-22 11:39:49 +080029BRANCH=${MANIFEST_BRANCH#*${MATCH_PATTERN}}
kelvin.zhanga1170fa2022-03-03 20:06:57 +080030WORK_DIR=$BUILDCHECK_BASE_PATH/$PROJECT_NAME/$BRANCH
Kelvin Zhangb2630702022-04-20 11:22:32 +080031OUTPUT_DIR=$WORK_DIR/output
kelvin.zhanga1170fa2022-03-03 20:06:57 +080032
Kelvin Zhang4982b0b2022-08-31 19:15:24 +080033LAST_MANIFEST="$OUTPUT_DIR/last_manifest.xml"
34CURRENT_MANIFEST="$OUTPUT_DIR/curr_manifest.xml"
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080035DIFF_MANIFEST="$OUTPUT_DIR/diff_manifest.xml"
kelvin.zhang5fd25982022-03-04 09:43:01 +080036
Kelvin Zhangb2630702022-04-20 11:22:32 +080037if [ -n "$EXCLUDE_REPOS" ]; then
38 echo "Exclude repos:"
39 echo "$EXCLUDE_REPOS"
40 while IFS= read -r line
41 do
42 [ -n "$REPO_SYNC_IPATTERN" ] && REPO_SYNC_IPATTERN+="|"
43 REPO_SYNC_IPATTERN+="$line"
44 done <<< "$EXCLUDE_REPOS"
45fi
46
47[ "$FRESH_DOWNLOAD" = "yes" ] && rm -rf $WORK_DIR
48
kelvin.zhang01393902022-03-03 20:42:46 +080049if [ ! -d "$WORK_DIR" ]; then
50 echo -e "\n======== Downloading source code ========"
51 mkdir -p $WORK_DIR
Kelvin Zhangb2630702022-04-20 11:22:32 +080052 mkdir -p $OUTPUT_DIR
kelvin.zhang01393902022-03-03 20:42:46 +080053 cd $WORK_DIR
54 repo init -u ${MANIFEST_URL} -b ${MANIFEST_BRANCH} --repo-url=git://scgit.amlogic.com/tools/repo.git --no-repo-verify
kelvin.zhang5fd25982022-03-04 09:43:01 +080055else
56 echo -e "\n======== Syncing source code ========"
57 cd $WORK_DIR
Kelvin Zhang442c9152022-05-30 17:29:53 +080058 if [ -n "$REPO_SYNC_IPATTERN" ]; then
59 repo forall -i "$REPO_SYNC_IPATTERN" -c git reset -q --hard origin/$BRANCH_NAME
60 else
61 repo forall -c git reset -q --hard origin/$BRANCH_NAME
62 fi
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080063 repo manifest -r -o $LAST_MANIFEST
kelvin.zhang01393902022-03-03 20:42:46 +080064fi
kelvin.zhanga1170fa2022-03-03 20:06:57 +080065
Kelvin Zhang81eb1b12022-06-09 14:35:18 +080066repo sync -cq -j8 --prune
Kelvin Zhang442c9152022-05-30 17:29:53 +080067[ "$?" -ne 0 ] && cd - && echo "Sync error! will do fresh download next time" && exit 1
68if [ -n "$REPO_SYNC_IPATTERN" ]; then
69 repo forall -i "$REPO_SYNC_IPATTERN" -c git reset -q --hard origin/$BRANCH_NAME
70else
71 repo forall -c git reset -q --hard origin/$BRANCH_NAME
72fi
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080073repo manifest -r -o $CURRENT_MANIFEST
kelvin.zhang5fd25982022-03-04 09:43:01 +080074echo -e "======== Done ========\n"
kelvin.zhang01393902022-03-03 20:42:46 +080075
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080076if [ -f $LAST_MANIFEST ] && [ -f $CURRENT_MANIFEST ]; then
77 comm -23 <(sort $LAST_MANIFEST) <(sort $CURRENT_MANIFEST) > $DIFF_MANIFEST
kelvin.zhang5fd25982022-03-04 09:43:01 +080078
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080079 if [ -s $DIFF_MANIFEST ]; then
kelvin.zhang5fd25982022-03-04 09:43:01 +080080 echo "======== Recent Changes ========"
81
82 while IFS= read -r line
83 do
84 keyline=`echo "$line" | grep 'name=.* path='`
85
86 for keyword in $keyline; do
87 [[ $keyword == path=* ]] && repo_path=`echo ${keyword#*path=} | sed 's/\"//g'`
88 [[ $keyword == name=* ]] && repo_name=`echo ${keyword#*name=} | sed 's/\"//g'`
89 [[ $keyword == revision=* ]] && repo_version=`echo ${keyword#*revision=} | sed 's/\"//g'`
90 done
91
92 if [ -d "$repo_path" ]; then
93 pushd $repo_path > /dev/null
94 echo -e "\nProject $repo_name"
95 git log $repo_version..HEAD
96 popd > /dev/null
97 fi
Kelvin Zhang7052f1c2022-09-20 11:11:41 +080098 done < $DIFF_MANIFEST
Kelvin Zhange98bd542022-09-07 15:43:58 +080099 echo -e "================\n"
kelvin.zhang5fd25982022-03-04 09:43:01 +0800100 else
Kelvin Zhange98bd542022-09-07 15:43:58 +0800101 echo -e "======== Nothing changed since last build ========\n"
kelvin.zhang5fd25982022-03-04 09:43:01 +0800102 fi
Kelvin Zhang81eb1b12022-06-09 14:35:18 +0800103fi
104
Kelvin Zhangc07a8db2022-09-06 21:06:31 +0800105# Cherry pick patches
Kelvin Zhang0f582792022-08-31 18:52:20 +0800106source scripts/cherry_pick.sh
kelvin.zhang2219b412022-03-04 16:44:41 +0800107
Kelvin Zhang7052f1c2022-09-20 11:11:41 +0800108# Generate Jenkins trigger
109[ "$SUBMIT_TYPE" = "release" ] && source gen_jenkins_trigger.sh
110
shijie.xiongec398682022-09-07 15:57:54 +0800111if [[ "$MANIFEST_BRANCH" == "$BRANCH_NAME" ]]; then
112 source scripts/build_all_pkg.sh
kelvin.zhang5fd25982022-03-04 09:43:01 +0800113else
Kelvin Zhang727c3e32022-08-31 20:57:37 +0800114 source scripts/build_all.sh
kelvin.zhang5fd25982022-03-04 09:43:01 +0800115fi