blob: 4fe50a3b4c2079dfec71c8eb0ac29f7e9d53808e [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Zelalem917b43e2020-08-04 11:39:55 -05002#
3# Copyright (c) 2019, Arm Limited. All rights reserved.
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
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
56
57 # Check if the repo clone exists in the job's workspace
58 if [ ! -d $1 ]
59 then
60 # Fresh clone
61 echo Cloning $repo_name from trustedfirmware.org...
62 git clone $repo_url
63 else
64 echo Will use existing repo for "$repo_name"...
65 fi
66}
67
68# Pull changes from tf.org to the local repo
69#
70# $1 = repo to update. It must be the same with the directory name
71pull_changes()
72{
73 cd $1
74 echo Pulling $1 from trustedfirmware.org...
75 git remote update --prune
76 git checkout master
77 git merge --ff-only origin/master
78 cd - > /dev/null
79}
80
81# exit if anything fails
82set -e
83
84# Source this file to get TF-A and TF-A-Tests repo URLs
85source "$CI_ROOT/utils.sh"
86
87clone_repo trusted-firmware-a
88clone_repo tf-a-tests
Jimmy Brisson29ca0a02020-09-22 16:15:35 -050089clone_repo tf-a-ci-scripts
Zelalem917b43e2020-08-04 11:39:55 -050090
91pull_changes trusted-firmware-a
92pull_changes tf-a-tests
Jimmy Brisson29ca0a02020-09-22 16:15:35 -050093pull_changes tf-a-ci-scripts
Zelalem917b43e2020-08-04 11:39:55 -050094
95# stop exiting automatically
96set +e
97
98# Update TF-A remotes
99cd trusted-firmware-a
100sync_repo GitHub https://$GH_USER:$GH_PASSWORD@github.com/ARM-software/arm-trusted-firmware.git
101github=$?
102sync_repo "internal TF-A Gerrit" $tf_arm_gerrit_repo
103tfa_gerrit=$?
104
105# Update TF-A-Tests
106cd ../tf-a-tests
107sync_repo "internal TF-A-Tests Gerrit" $tftf_arm_gerrit_repo
108tftf_gerrit=$?
109
Jimmy Brisson29ca0a02020-09-22 16:15:35 -0500110cd ../tf-a-ci-scripts
111sync_repo "internal TF-A-CI-Scripts Gerrit" $ci_arm_gerrit_repo
112ci_gerrit=$?
113
114if [ $github != 0 -o $tfa_gerrit != 0 -o $tftf_gerrit != 0 -o $ci_gerrit != 0 ]
Zelalem917b43e2020-08-04 11:39:55 -0500115then
116 exit 1
117fi