blob: 0ba93161e8b6d2b02cfbd4464002f2d05165cfa4 [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 ;;
47 *)
48 echo "ERROR: Unknown repo to be cloned. sync.sh failed!"
49 exit 1
50 ;;
51 esac
52
53 # Check if the repo clone exists in the job's workspace
54 if [ ! -d $1 ]
55 then
56 # Fresh clone
57 echo Cloning $repo_name from trustedfirmware.org...
58 git clone $repo_url
59 else
60 echo Will use existing repo for "$repo_name"...
61 fi
62}
63
64# Pull changes from tf.org to the local repo
65#
66# $1 = repo to update. It must be the same with the directory name
67pull_changes()
68{
69 cd $1
70 echo Pulling $1 from trustedfirmware.org...
71 git remote update --prune
72 git checkout master
73 git merge --ff-only origin/master
74 cd - > /dev/null
75}
76
77# exit if anything fails
78set -e
79
80# Source this file to get TF-A and TF-A-Tests repo URLs
81source "$CI_ROOT/utils.sh"
82
83clone_repo trusted-firmware-a
84clone_repo tf-a-tests
85
86pull_changes trusted-firmware-a
87pull_changes tf-a-tests
88
89# stop exiting automatically
90set +e
91
92# Update TF-A remotes
93cd trusted-firmware-a
94sync_repo GitHub https://$GH_USER:$GH_PASSWORD@github.com/ARM-software/arm-trusted-firmware.git
95github=$?
96sync_repo "internal TF-A Gerrit" $tf_arm_gerrit_repo
97tfa_gerrit=$?
98
99# Update TF-A-Tests
100cd ../tf-a-tests
101sync_repo "internal TF-A-Tests Gerrit" $tftf_arm_gerrit_repo
102tftf_gerrit=$?
103
104if [ $github != 0 -o $tfa_gerrit != 0 -o $tftf_gerrit != 0 ]
105then
106 exit 1
107fi