aboutsummaryrefslogtreecommitdiff
path: root/util/update_chibios_mirror.sh
diff options
context:
space:
mode:
Diffstat (limited to 'util/update_chibios_mirror.sh')
-rwxr-xr-xutil/update_chibios_mirror.sh92
1 files changed, 92 insertions, 0 deletions
diff --git a/util/update_chibios_mirror.sh b/util/update_chibios_mirror.sh
new file mode 100755
index 000000000..0bf648ebf
--- /dev/null
+++ b/util/update_chibios_mirror.sh
@@ -0,0 +1,92 @@
1#!/bin/bash
2
3################################
4# Configuration
5
6# The ChibiOS branches to mirror
7chibios_branches="trunk stable_20.3.x stable_21.6.x"
8
9# The ChibiOS tags to mirror
10chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver20.3.4 ver21.6.0"
11
12# The ChibiOS-Contrib branches to mirror
13contrib_branches="chibios-20.3.x chibios-21.6.x"
14
15################################
16# Actions
17
18set -eEuo pipefail
19umask 022
20
21this_script="$(realpath "${BASH_SOURCE[0]}")"
22script_dir="$(realpath "$(dirname "$this_script")")"
23qmk_firmware_dir="$(realpath "$script_dir/../")"
24chibios_dir="$qmk_firmware_dir/lib/chibios"
25contrib_dir="$qmk_firmware_dir/lib/chibios-contrib"
26
27chibios_git_location=$(realpath "$chibios_dir/$(cat "$chibios_dir/.git" | awk '/gitdir:/ {print $2}')")
28chibios_git_config=$(realpath "$chibios_git_location/config")
29contrib_git_location=$(realpath "$contrib_dir/$(cat "$contrib_dir/.git" | awk '/gitdir:/ {print $2}')")
30contrib_git_config=$(realpath "$contrib_git_location/config")
31
32cd "$chibios_dir"
33
34if [[ -z "$(cat "$chibios_git_config" | grep '\[svn-remote "svn"\]')" ]] ; then
35 git svn init --stdlayout --prefix='svn/' http://svn.osdn.net/svnroot/chibios/
36fi
37
38if [[ -z "$(cat "$chibios_git_config" | grep '\[remote "qmk"\]')" ]] ; then
39 git remote add qmk [email protected]:qmk/ChibiOS.git
40 git remote set-url qmk [email protected]:qmk/ChibiOS.git --push
41else
42 git remote set-url qmk [email protected]:qmk/ChibiOS.git
43 git remote set-url qmk [email protected]:qmk/ChibiOS.git --push
44fi
45
46echo "Updating remotes..."
47git fetch --all --tags --prune
48
49echo "Fetching latest from subversion..."
50git svn fetch
51
52echo "Updating ChibiOS branches..."
53for branch in $chibios_branches ; do
54 echo "Creating branch 'svn-mirror/$branch' from 'svn/$branch'..."
55 git branch -f svn-mirror/$branch svn/$branch \
56 && git push qmk svn-mirror/$branch
57done
58
59echo "Updating ChibiOS tags..."
60for tagname in $chibios_tags ; do
61 echo "Creating tag 'svn-mirror/$tagname' from 'svn/tags/$tagname'..."
62 GIT_COMMITTER_DATE="$(git log -n1 --pretty=format:'%ad' svn/tags/$tagname)" git tag -f -a -m "Tagging $tagname" svn-mirror/$tagname svn/tags/$tagname
63 git push qmk svn-mirror/$tagname
64done
65
66cd "$contrib_dir"
67
68if [[ -z "$(cat "$contrib_git_config" | grep '\[remote "qmk"\]')" ]] ; then
69 git remote add qmk [email protected]:qmk/ChibiOS-Contrib.git
70 git remote set-url qmk [email protected]:qmk/ChibiOS-Contrib.git --push
71else
72 git remote set-url qmk [email protected]:qmk/ChibiOS-Contrib.git
73 git remote set-url qmk [email protected]:qmk/ChibiOS-Contrib.git --push
74fi
75
76if [[ -z "$(cat "$contrib_git_config" | grep '\[remote "upstream"\]')" ]] ; then
77 git remote add upstream [email protected]:ChibiOS/ChibiOS-Contrib.git
78 git remote set-url upstream [email protected]:ChibiOS/ChibiOS-Contrib.git --push
79else
80 git remote set-url upstream [email protected]:ChibiOS/ChibiOS-Contrib.git
81 git remote set-url upstream [email protected]:ChibiOS/ChibiOS-Contrib.git --push
82fi
83
84echo "Updating remotes..."
85git fetch --all --tags --prune
86
87echo "Updating ChibiOS-Contrib branches..."
88for branch in $contrib_branches ; do
89 echo "Creating branch 'mirror/$branch' from 'upstream/$branch'..."
90 git branch -f mirror/$branch upstream/$branch \
91 && git push qmk mirror/$branch
92done