blob: c96eb437181ea88302340aa85de3feea3d71bfdf [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Zelalem917b43e2020-08-04 11:39:55 -05002#
Leonardo Sandoval579c7372020-10-23 15:23:32 -05003# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
Zelalem917b43e2020-08-04 11:39:55 -05004#
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
12sync_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
33clone_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 Brisson29ca0a02020-09-22 16:15:35 -050047 tf-a-ci-scripts)
48 repo_url=$ci_src_repo_url
49 repo_name="TF-A-CI-Scripts"
50 ;;
Zelalem917b43e2020-08-04 11:39:55 -050051 *)
52 echo "ERROR: Unknown repo to be cloned. sync.sh failed!"
53 exit 1
54 ;;
55 esac
Zelalem393f2a12020-10-15 09:27:46 -050056
57 # Remove old tree if it exists
58 if [ -d $1 ]; then
59 rm -rf "$1"
Zelalem917b43e2020-08-04 11:39:55 -050060 fi
Zelalem393f2a12020-10-15 09:27:46 -050061 # Fresh clone
62 echo Cloning $repo_name from trustedfirmware.org...
63 git clone $repo_url
Zelalem917b43e2020-08-04 11:39:55 -050064}
65
66# Pull changes from tf.org to the local repo
67#
68# $1 = repo to update. It must be the same with the directory name
69pull_changes()
70{
71 cd $1
72 echo Pulling $1 from trustedfirmware.org...
73 git remote update --prune
74 git checkout master
75 git merge --ff-only origin/master
76 cd - > /dev/null
77}
78
79# exit if anything fails
80set -e
81
82# Source this file to get TF-A and TF-A-Tests repo URLs
83source "$CI_ROOT/utils.sh"
84
85clone_repo trusted-firmware-a
86clone_repo tf-a-tests
Jimmy Brisson29ca0a02020-09-22 16:15:35 -050087clone_repo tf-a-ci-scripts
Zelalem917b43e2020-08-04 11:39:55 -050088
89pull_changes trusted-firmware-a
90pull_changes tf-a-tests
Jimmy Brisson29ca0a02020-09-22 16:15:35 -050091pull_changes tf-a-ci-scripts
Zelalem917b43e2020-08-04 11:39:55 -050092
93# stop exiting automatically
94set +e
95
96# Update TF-A remotes
97cd trusted-firmware-a
98sync_repo GitHub https://$GH_USER:$GH_PASSWORD@github.com/ARM-software/arm-trusted-firmware.git
99github=$?
100sync_repo "internal TF-A Gerrit" $tf_arm_gerrit_repo
101tfa_gerrit=$?
102
103# Update TF-A-Tests
104cd ../tf-a-tests
105sync_repo "internal TF-A-Tests Gerrit" $tftf_arm_gerrit_repo
106tftf_gerrit=$?
107
Jimmy Brisson29ca0a02020-09-22 16:15:35 -0500108cd ../tf-a-ci-scripts
109sync_repo "internal TF-A-CI-Scripts Gerrit" $ci_arm_gerrit_repo
110ci_gerrit=$?
111
112if [ $github != 0 -o $tfa_gerrit != 0 -o $tftf_gerrit != 0 -o $ci_gerrit != 0 ]
Zelalem917b43e2020-08-04 11:39:55 -0500113then
114 exit 1
115fi