Kelvin Zhang | 14bca5e | 2021-12-15 19:19:35 +0800 | [diff] [blame] | 1 | #!/bin/bash |
yang.li | 0952092 | 2022-01-12 15:51:51 +0800 | [diff] [blame] | 2 | # |
yang.li | ffa60e5 | 2022-01-11 14:38:56 +0800 | [diff] [blame] | 3 | # Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
yang.li | 0952092 | 2022-01-12 15:51:51 +0800 | [diff] [blame] | 4 | # |
yang.li | ffa60e5 | 2022-01-11 14:38:56 +0800 | [diff] [blame] | 5 | # SPDX-License-Identifier: MIT |
yang.li | 0952092 | 2022-01-12 15:51:51 +0800 | [diff] [blame] | 6 | # |
yang.li | ffa60e5 | 2022-01-11 14:38:56 +0800 | [diff] [blame] | 7 | |
Kelvin Zhang | 2307521 | 2022-02-11 18:26:18 +0800 | [diff] [blame] | 8 | LOCAL_DOC_PATH="$PWD/output/docs/html" |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 9 | REMOTE_DOC_PATH="ftp://platform:platform@10.68.11.163:2222/Documents/Ecosystem/RTOS/rtos-sdk/" |
Kelvin Zhang | 14bca5e | 2021-12-15 19:19:35 +0800 | [diff] [blame] | 10 | |
Kelvin Zhang | 0978612 | 2022-02-11 15:56:08 +0800 | [diff] [blame] | 11 | # Build and upload document |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 12 | update_docoment() { |
| 13 | find -type f | while read filename; do |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 14 | curl -s --ftp-create-dirs -T $filename $REMOTE_DOC_PATH/$filename |
Kelvin Zhang | 1fea914 | 2022-02-11 18:19:56 +0800 | [diff] [blame] | 15 | if [ $? -ne 0 ]; then |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 16 | return 1 |
Kelvin Zhang | 1fea914 | 2022-02-11 18:19:56 +0800 | [diff] [blame] | 17 | fi |
| 18 | done |
| 19 | } |
| 20 | |
Kelvin Zhang | 0978612 | 2022-02-11 15:56:08 +0800 | [diff] [blame] | 21 | if [[ "$SUBMIT_TYPE" == "daily" ]]; then |
| 22 | make docs |
kelvin.zhang | 77dd544 | 2022-02-14 10:26:15 +0800 | [diff] [blame] | 23 | if [ -d $LOCAL_DOC_PATH ]; then |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 24 | pushd $LOCAL_DOC_PATH >/dev/null |
Kelvin Zhang | 2307521 | 2022-02-11 18:26:18 +0800 | [diff] [blame] | 25 | update_docoment |
| 26 | if [ $? -ne 0 ]; then |
| 27 | echo "Failed to update document" |
| 28 | else |
| 29 | echo "Document updated!" |
| 30 | fi |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 31 | popd >/dev/null |
Kelvin Zhang | 1fea914 | 2022-02-11 18:19:56 +0800 | [diff] [blame] | 32 | else |
Kelvin Zhang | 2307521 | 2022-02-11 18:26:18 +0800 | [diff] [blame] | 33 | echo "$LOCAL_DOC_PATH not exist!" |
Kelvin Zhang | 7f0d2e0 | 2022-02-14 10:16:35 +0800 | [diff] [blame] | 34 | fi |
Kelvin Zhang | 0978612 | 2022-02-11 15:56:08 +0800 | [diff] [blame] | 35 | fi |
| 36 | |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 37 | BUILD_DATE=$(date +%F) |
| 38 | LOCAL_OUTPUT_PATH=output |
| 39 | FIRMWARE_ACCOUNT=autobuild |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 40 | FIRMWARE_SERVER=firmware.amlogic.com |
| 41 | |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 42 | publish_image() { |
| 43 | LOCAL_IMAGE_PATH=$LOCAL_OUTPUT_PATH/$ARCH-$BOARD-$PRODUCT |
| 44 | REMOTE_IMAGE_PATH=/data/shanghai/image/RTOS/$BUILD_DATE/$ARCH-$BOARD-$PRODUCT |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 45 | |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 46 | if [ -d $LOCAL_IMAGE_PATH ]; then |
| 47 | ssh -n $FIRMWARE_ACCOUNT@$FIRMWARE_SERVER "mkdir -p $REMOTE_IMAGE_PATH" |
| 48 | if [ $? -ne 0 ]; then |
| 49 | echo "Failed to create remote image path! $REMOTE_IMAGE_PATH" |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 50 | exit 1 |
| 51 | else |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 52 | echo "Remote image path: $REMOTE_IMAGE_PATH" |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 53 | fi |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 54 | scp build.log $FIRMWARE_ACCOUNT@$FIRMWARE_SERVER:$REMOTE_IMAGE_PATH |
| 55 | pushd $LOCAL_IMAGE_PATH >/dev/null |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 56 | tar -cJf $KERNEL.tar.xz $KERNEL/$KERNEL.* |
| 57 | LOCAL_FILES="manifest.xml $KERNEL.tar.xz" |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 58 | scp $LOCAL_FILES $FIRMWARE_ACCOUNT@$FIRMWARE_SERVER:$REMOTE_IMAGE_PATH |
| 59 | scp -r images $FIRMWARE_ACCOUNT@$FIRMWARE_SERVER:$REMOTE_IMAGE_PATH |
| 60 | popd >/dev/null |
| 61 | echo "Publish images success." |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 62 | else |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 63 | echo "No local image path! $LOCAL_IMAGE_PATH" |
| 64 | fi |
| 65 | } |
| 66 | |
| 67 | publish_package() { |
| 68 | LOCAL_PACKAGE_PATH=$LOCAL_OUTPUT_PATH/package/images |
| 69 | REMOTE_PACKAGE_PATH=/data/shanghai/image/RTOS/$BUILD_DATE/package |
| 70 | |
| 71 | if [ -d $LOCAL_PACKAGE_PATH ]; then |
| 72 | ssh -n $FIRMWARE_ACCOUNT@$FIRMWARE_SERVER "mkdir -p $REMOTE_PACKAGE_PATH" |
| 73 | if [ $? -ne 0 ]; then |
| 74 | echo "Failed to create remote package path! $REMOTE_PACKAGE_PATH" |
| 75 | exit 1 |
| 76 | else |
| 77 | echo "Remote package path: $REMOTE_PACKAGE_PATH" |
| 78 | fi |
| 79 | pushd $LOCAL_PACKAGE_PATH >/dev/null |
| 80 | scp -r . $FIRMWARE_ACCOUNT@$FIRMWARE_SERVER:$REMOTE_PACKAGE_PATH |
| 81 | popd >/dev/null |
| 82 | echo "Publish packages success." |
| 83 | else |
| 84 | echo "No local package path! $LOCAL_PACKAGE_PATH" |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 85 | fi |
| 86 | } |
| 87 | |
kelvin.zhang | 2219b41 | 2022-03-04 16:44:41 +0800 | [diff] [blame] | 88 | # Manually cherry pick patches |
| 89 | ./scripts/cherry_pick.sh |
kelvin.zhang | 5fd2598 | 2022-03-04 09:43:01 +0800 | [diff] [blame] | 90 | |
Kelvin Zhang | c18bac6 | 2022-03-14 10:31:57 +0800 | [diff] [blame] | 91 | source scripts/gen_build_combination.sh |
Kelvin Zhang | 69dc9fb | 2022-02-18 16:44:04 +0800 | [diff] [blame] | 92 | |
Kelvin Zhang | 14bca5e | 2021-12-15 19:19:35 +0800 | [diff] [blame] | 93 | i=0 |
| 94 | while IFS= read -r LINE; do |
| 95 | [[ "$i" -ne 0 ]] && echo "" |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 96 | i=$((i + 1)) |
Kelvin Zhang | c18bac6 | 2022-03-14 10:31:57 +0800 | [diff] [blame] | 97 | |
| 98 | check_project "$LINE" |
| 99 | [ "$?" -ne 0 ] && continue |
Kelvin Zhang | 14bca5e | 2021-12-15 19:19:35 +0800 | [diff] [blame] | 100 | source scripts/env.sh $LINE |
kelvin.zhang | b721785 | 2022-03-10 11:18:18 +0800 | [diff] [blame] | 101 | [ "$?" -ne 0 ] && echo "Ignore unsupported combination!" && continue |
kelvin.zhang | 05852a7 | 2022-01-19 10:30:24 +0800 | [diff] [blame] | 102 | make distclean |
Xiaohu.Huang | b6ad976 | 2022-02-11 17:49:09 +0800 | [diff] [blame] | 103 | [ "$?" -ne 0 ] && echo "Failed to make distclean!" && exit 2 |
bin.chen | e987511 | 2022-01-18 15:00:50 +0800 | [diff] [blame] | 104 | make |
Xiaohu.Huang | b6ad976 | 2022-02-11 17:49:09 +0800 | [diff] [blame] | 105 | [ "$?" -ne 0 ] && echo "Failed to make!" && exit 3 |
Xiaohu.Huang | 7dac872 | 2022-01-18 16:21:29 +0800 | [diff] [blame] | 106 | if [[ "$SUBMIT_TYPE" == "daily" ]]; then |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 107 | publish_image |
Xiaohu.Huang | b6ad976 | 2022-02-11 17:49:09 +0800 | [diff] [blame] | 108 | [ "$?" -ne 0 ] && echo "Failed to source scripts/scp.sh!" && exit 4 |
bin.chen | 439b934 | 2022-01-18 13:35:42 +0800 | [diff] [blame] | 109 | fi |
shijie.xiong | bc5d367 | 2022-04-01 17:52:16 +0800 | [diff] [blame^] | 110 | done <"$BUILD_COMBINATION" |
| 111 | |
| 112 | source scripts/gen_package_combination.sh |
| 113 | |
| 114 | index=0 |
| 115 | while IFS= read -r LINE; do |
| 116 | source scripts/pkg_env.sh $index gen_all |
| 117 | [ "$?" -ne 0 ] && echo "Ignore unsupported combination!" && continue |
| 118 | make package |
| 119 | [ "$?" -ne 0 ] && echo "Failed to make!" && exit 3 |
| 120 | if [[ "$SUBMIT_TYPE" == "release" ]]; then |
| 121 | publish_package |
| 122 | [ "$?" -ne 0 ] && echo "Failed to source scripts/scp.sh!" && exit 4 |
| 123 | fi |
| 124 | index=$((index + 1)) |
| 125 | done <"$PACKAGE_COMBINATION" |
kelvin.zhang | f59bf9a | 2022-02-16 10:41:47 +0800 | [diff] [blame] | 126 | |
| 127 | echo "Build completed!" |