diff options
author | Akshay <[email protected]> | 2022-04-10 12:13:40 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2022-04-10 12:13:40 +0100 |
commit | dc90387ce7d8ba7b607d9c48540bf6d8b560f14d (patch) | |
tree | 4ccb8fa5886b66fa9d480edef74236c27f035e16 /util/update_chibios_mirror.sh |
Diffstat (limited to 'util/update_chibios_mirror.sh')
-rwxr-xr-x | util/update_chibios_mirror.sh | 92 |
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 | ||
7 | chibios_branches="trunk stable_20.3.x stable_21.6.x" | ||
8 | |||
9 | # The ChibiOS tags to mirror | ||
10 | chibios_tags="ver20.3.1 ver20.3.2 ver20.3.3 ver20.3.4 ver21.6.0" | ||
11 | |||
12 | # The ChibiOS-Contrib branches to mirror | ||
13 | contrib_branches="chibios-20.3.x chibios-21.6.x" | ||
14 | |||
15 | ################################ | ||
16 | # Actions | ||
17 | |||
18 | set -eEuo pipefail | ||
19 | umask 022 | ||
20 | |||
21 | this_script="$(realpath "${BASH_SOURCE[0]}")" | ||
22 | script_dir="$(realpath "$(dirname "$this_script")")" | ||
23 | qmk_firmware_dir="$(realpath "$script_dir/../")" | ||
24 | chibios_dir="$qmk_firmware_dir/lib/chibios" | ||
25 | contrib_dir="$qmk_firmware_dir/lib/chibios-contrib" | ||
26 | |||
27 | chibios_git_location=$(realpath "$chibios_dir/$(cat "$chibios_dir/.git" | awk '/gitdir:/ {print $2}')") | ||
28 | chibios_git_config=$(realpath "$chibios_git_location/config") | ||
29 | contrib_git_location=$(realpath "$contrib_dir/$(cat "$contrib_dir/.git" | awk '/gitdir:/ {print $2}')") | ||
30 | contrib_git_config=$(realpath "$contrib_git_location/config") | ||
31 | |||
32 | cd "$chibios_dir" | ||
33 | |||
34 | if [[ -z "$(cat "$chibios_git_config" | grep '\[svn-remote "svn"\]')" ]] ; then | ||
35 | git svn init --stdlayout --prefix='svn/' http://svn.osdn.net/svnroot/chibios/ | ||
36 | fi | ||
37 | |||
38 | if [[ -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 | ||
41 | else | ||
42 | git remote set-url qmk [email protected]:qmk/ChibiOS.git | ||
43 | git remote set-url qmk [email protected]:qmk/ChibiOS.git --push | ||
44 | fi | ||
45 | |||
46 | echo "Updating remotes..." | ||
47 | git fetch --all --tags --prune | ||
48 | |||
49 | echo "Fetching latest from subversion..." | ||
50 | git svn fetch | ||
51 | |||
52 | echo "Updating ChibiOS branches..." | ||
53 | for 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 | ||
57 | done | ||
58 | |||
59 | echo "Updating ChibiOS tags..." | ||
60 | for 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 | ||
64 | done | ||
65 | |||
66 | cd "$contrib_dir" | ||
67 | |||
68 | if [[ -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 | ||
71 | else | ||
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 | ||
74 | fi | ||
75 | |||
76 | if [[ -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 | ||
79 | else | ||
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 | ||
82 | fi | ||
83 | |||
84 | echo "Updating remotes..." | ||
85 | git fetch --all --tags --prune | ||
86 | |||
87 | echo "Updating ChibiOS-Contrib branches..." | ||
88 | for 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 | ||
92 | done | ||