Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 2 | # |
Leonardo Sandoval | 579c737 | 2020-10-23 15:23:32 -0500 | [diff] [blame] | 3 | # Copyright (c) 2019-2020 Arm Limited. All rights reserved. |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | # Push the updated master from local to the selected remote |
| 9 | # |
| 10 | # $1 = git remote human readable name |
| 11 | # $2 = git remote URL |
| 12 | sync_repo() |
| 13 | { |
| 14 | local result |
| 15 | |
| 16 | echo Pushing to "$1"... |
| 17 | git push --tags $2 master |
| 18 | result=$? |
| 19 | if [ $result != 0 ] |
| 20 | then |
| 21 | echo Pushing to $1 FAILED! |
| 22 | else |
| 23 | echo Pushing to $1 SUCCEEDED! |
| 24 | fi |
| 25 | return $result |
| 26 | } |
| 27 | |
| 28 | # Clone the selected repo from tf.org |
| 29 | # |
| 30 | # Some variables utilised inside this function come from utils.sh |
| 31 | # |
| 32 | # $1 = repo to clone |
| 33 | clone_repo() |
| 34 | { |
| 35 | local repo_url |
| 36 | local repo_name |
| 37 | |
| 38 | case $1 in |
| 39 | trusted-firmware-a) |
| 40 | repo_url=$tf_src_repo_url |
| 41 | repo_name="TF-A" |
| 42 | ;; |
| 43 | tf-a-tests) |
| 44 | repo_url=$tftf_src_repo_url |
| 45 | repo_name="TF-A-Tests" |
| 46 | ;; |
Jimmy Brisson | 29ca0a0 | 2020-09-22 16:15:35 -0500 | [diff] [blame] | 47 | tf-a-ci-scripts) |
| 48 | repo_url=$ci_src_repo_url |
| 49 | repo_name="TF-A-CI-Scripts" |
| 50 | ;; |
Madhukar Pappireddy | 4123cfe | 2023-09-11 11:10:33 -0500 | [diff] [blame] | 51 | hafnium) |
| 52 | repo_url=$spm_src_repo_url |
| 53 | repo_name="hafnium" |
| 54 | ;; |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 55 | *) |
| 56 | echo "ERROR: Unknown repo to be cloned. sync.sh failed!" |
| 57 | exit 1 |
| 58 | ;; |
| 59 | esac |
Madhukar Pappireddy | 4123cfe | 2023-09-11 11:10:33 -0500 | [diff] [blame] | 60 | |
Zelalem | 393f2a1 | 2020-10-15 09:27:46 -0500 | [diff] [blame] | 61 | # Remove old tree if it exists |
| 62 | if [ -d $1 ]; then |
| 63 | rm -rf "$1" |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 64 | fi |
Zelalem | 393f2a1 | 2020-10-15 09:27:46 -0500 | [diff] [blame] | 65 | # Fresh clone |
| 66 | echo Cloning $repo_name from trustedfirmware.org... |
| 67 | git clone $repo_url |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | # Pull changes from tf.org to the local repo |
| 71 | # |
| 72 | # $1 = repo to update. It must be the same with the directory name |
| 73 | pull_changes() |
| 74 | { |
| 75 | cd $1 |
| 76 | echo Pulling $1 from trustedfirmware.org... |
| 77 | git remote update --prune |
| 78 | git checkout master |
| 79 | git merge --ff-only origin/master |
| 80 | cd - > /dev/null |
| 81 | } |
| 82 | |
| 83 | # exit if anything fails |
| 84 | set -e |
| 85 | |
| 86 | # Source this file to get TF-A and TF-A-Tests repo URLs |
| 87 | source "$CI_ROOT/utils.sh" |
| 88 | |
| 89 | clone_repo trusted-firmware-a |
| 90 | clone_repo tf-a-tests |
Jimmy Brisson | 29ca0a0 | 2020-09-22 16:15:35 -0500 | [diff] [blame] | 91 | clone_repo tf-a-ci-scripts |
Madhukar Pappireddy | 4123cfe | 2023-09-11 11:10:33 -0500 | [diff] [blame] | 92 | clone_repo hafnium |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 93 | |
| 94 | pull_changes trusted-firmware-a |
| 95 | pull_changes tf-a-tests |
Jimmy Brisson | 29ca0a0 | 2020-09-22 16:15:35 -0500 | [diff] [blame] | 96 | pull_changes tf-a-ci-scripts |
Madhukar Pappireddy | 4123cfe | 2023-09-11 11:10:33 -0500 | [diff] [blame] | 97 | pull_changes hafnium |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 98 | |
| 99 | # stop exiting automatically |
| 100 | set +e |
| 101 | |
| 102 | # Update TF-A remotes |
| 103 | cd trusted-firmware-a |
| 104 | sync_repo GitHub https://$GH_USER:$GH_PASSWORD@github.com/ARM-software/arm-trusted-firmware.git |
| 105 | github=$? |
| 106 | sync_repo "internal TF-A Gerrit" $tf_arm_gerrit_repo |
| 107 | tfa_gerrit=$? |
| 108 | |
| 109 | # Update TF-A-Tests |
| 110 | cd ../tf-a-tests |
| 111 | sync_repo "internal TF-A-Tests Gerrit" $tftf_arm_gerrit_repo |
| 112 | tftf_gerrit=$? |
| 113 | |
Madhukar Pappireddy | 4123cfe | 2023-09-11 11:10:33 -0500 | [diff] [blame] | 114 | # Update TF-A-CI-Scripts |
Jimmy Brisson | 29ca0a0 | 2020-09-22 16:15:35 -0500 | [diff] [blame] | 115 | cd ../tf-a-ci-scripts |
| 116 | sync_repo "internal TF-A-CI-Scripts Gerrit" $ci_arm_gerrit_repo |
| 117 | ci_gerrit=$? |
| 118 | |
Madhukar Pappireddy | 4123cfe | 2023-09-11 11:10:33 -0500 | [diff] [blame] | 119 | # Update Hafnium |
| 120 | cd ../hafnium |
| 121 | sync_repo "internal Hafnium Gerrit" $spm_arm_gerrit_repo |
| 122 | spm_gerrit=$? |
| 123 | |
| 124 | if [ $github != 0 -o $tfa_gerrit != 0 -o $tftf_gerrit != 0 -o $ci_gerrit != 0 -o $spm_gerrit != 0 ] |
Zelalem | 917b43e | 2020-08-04 11:39:55 -0500 | [diff] [blame] | 125 | then |
| 126 | exit 1 |
| 127 | fi |