blob: 43d971e618b2ed1f6a8b663ab6b08eadb6ab765b [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 ;;
Madhukar Pappireddy4123cfe2023-09-11 11:10:33 -050051 hafnium)
52 repo_url=$spm_src_repo_url
53 repo_name="hafnium"
54 ;;
Zelalem917b43e2020-08-04 11:39:55 -050055 *)
56 echo "ERROR: Unknown repo to be cloned. sync.sh failed!"
57 exit 1
58 ;;
59 esac
Madhukar Pappireddy4123cfe2023-09-11 11:10:33 -050060
Zelalem393f2a12020-10-15 09:27:46 -050061 # Remove old tree if it exists
62 if [ -d $1 ]; then
63 rm -rf "$1"
Zelalem917b43e2020-08-04 11:39:55 -050064 fi
Zelalem393f2a12020-10-15 09:27:46 -050065 # Fresh clone
66 echo Cloning $repo_name from trustedfirmware.org...
67 git clone $repo_url
Zelalem917b43e2020-08-04 11:39:55 -050068}
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
73pull_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
84set -e
85
86# Source this file to get TF-A and TF-A-Tests repo URLs
87source "$CI_ROOT/utils.sh"
88
89clone_repo trusted-firmware-a
90clone_repo tf-a-tests
Jimmy Brisson29ca0a02020-09-22 16:15:35 -050091clone_repo tf-a-ci-scripts
Madhukar Pappireddy4123cfe2023-09-11 11:10:33 -050092clone_repo hafnium
Zelalem917b43e2020-08-04 11:39:55 -050093
94pull_changes trusted-firmware-a
95pull_changes tf-a-tests
Jimmy Brisson29ca0a02020-09-22 16:15:35 -050096pull_changes tf-a-ci-scripts
Madhukar Pappireddy4123cfe2023-09-11 11:10:33 -050097pull_changes hafnium
Zelalem917b43e2020-08-04 11:39:55 -050098
99# stop exiting automatically
100set +e
101
102# Update TF-A remotes
103cd trusted-firmware-a
104sync_repo GitHub https://$GH_USER:$GH_PASSWORD@github.com/ARM-software/arm-trusted-firmware.git
105github=$?
106sync_repo "internal TF-A Gerrit" $tf_arm_gerrit_repo
107tfa_gerrit=$?
108
109# Update TF-A-Tests
110cd ../tf-a-tests
111sync_repo "internal TF-A-Tests Gerrit" $tftf_arm_gerrit_repo
112tftf_gerrit=$?
113
Madhukar Pappireddy4123cfe2023-09-11 11:10:33 -0500114# Update TF-A-CI-Scripts
Jimmy Brisson29ca0a02020-09-22 16:15:35 -0500115cd ../tf-a-ci-scripts
116sync_repo "internal TF-A-CI-Scripts Gerrit" $ci_arm_gerrit_repo
117ci_gerrit=$?
118
Madhukar Pappireddy4123cfe2023-09-11 11:10:33 -0500119# Update Hafnium
120cd ../hafnium
121sync_repo "internal Hafnium Gerrit" $spm_arm_gerrit_repo
122spm_gerrit=$?
123
124if [ $github != 0 -o $tfa_gerrit != 0 -o $tftf_gerrit != 0 -o $ci_gerrit != 0 -o $spm_gerrit != 0 ]
Zelalem917b43e2020-08-04 11:39:55 -0500125then
126 exit 1
127fi