-
Notifications
You must be signed in to change notification settings - Fork 3
/
merge-tag.sh
executable file
·142 lines (122 loc) · 3.89 KB
/
merge-tag.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# CLO tag merge script for ReloadedOS
# Author: Adithya R (ghostrider-reborn)
#
# Usage (from source root):
# ./manifest/merge-tag.sh <TAG>
# Colors
red=$'\e[1;31m'
grn=$'\e[1;32m'
blu=$'\e[1;34m'
end=$'\e[0m'
REMOTE="reloaded"
BRANCH="u"
BLACKLIST="device/qcom/common \
external/zlib"
# verify tag
if [ -z "$1" ]; then
echo -e "Unspecified tag!\nUsage: ./manifest/merge-tag.sh <TAG>"
exit 1
else
TAG="$1"
fi
if [[ $TAG = "LA.QSSI"* ]]; then
IS_QSSI=true
MANIFEST_URL="https://git.codelinaro.org/clo/la/la/system/manifest/-/raw/release/$TAG.xml"
MANIFEST_XML="manifest/system.xml"
else
IS_QSSI=false
MANIFEST_URL="https://git.codelinaro.org/clo/la/la/vendor/manifest/-/raw/release/$TAG.xml"
MANIFEST_XML="manifest/vendor.xml"
fi
if ! wget -q --spider $MANIFEST_URL; then
echo "Invalid tag: $TAG!"
exit 1
fi
# fetch all existing repos
echo "${blu}Fetching list of repos to be merged...$end"
REPOS=$(repo forall -v -c "if [ \"\$REPO_REMOTE\" = \"$REMOTE\" ]; then echo \$REPO_PATH; fi")
echo $REPOS
# save root dir
src_root=$(pwd)
# initialize some files
for file in failed success unchanged; do
rm -f $file
touch $file
done
# main
for repo in $REPOS; do echo;
if [[ $BLACKLIST =~ $repo ]]; then
echo -e "$repo is in blacklist, skipped"
continue
fi
if ! grep -q -e "path=\"$repo\"" -e "name=\"$repo\"" $MANIFEST_XML; then
echo "${red}$repo not found in CLO manifest, skipping..."
continue
fi
# this is where the fun begins
echo "${blu}Merging ${repo}..."
name=$(grep "path=\"$repo\"" $MANIFEST_XML | sed -e 's/.*name="//' -e 's/".*//')
if [[ -z $name ]]; then
name=$(grep "name=\"$repo\"" $MANIFEST_XML | sed -e 's/.*name="//' -e 's/".*//')
fi
cd $repo
git checkout -q $BRANCH &> /dev/null || echo "${red}$repo checkout failed!"
if ! git fetch -q https://git.codelinaro.org/clo/la/$name $TAG &> /dev/null; then
echo "${red}$repo fetch failed!"
else
if ! git merge FETCH_HEAD -q -m "Merge tag '$TAG' into $BRANCH" &> /dev/null; then
echo "$repo" >> $src_root/failed
echo "${red}$repo merge failed!"
else
if [[ $(git rev-parse HEAD) != $(git rev-parse $REMOTE/$BRANCH) ]] && [[ $(git diff HEAD $REMOTE/$BRANCH) ]]; then
echo "$repo" >> $src_root/success
echo "${grn}$repo merged succesfully!"
else
echo "${end}$repo unchanged"
echo "$repo" >> $src_root/unchanged
git reset --hard $REMOTE/$BRANCH &> /dev/null
fi
fi
fi
cd $src_root
done
# update manifest
echo -e "${blu}\nUpdating manifest..."
if curl -Ls $MANIFEST_URL > $MANIFEST_XML; then
$IS_QSSI || sed -i '3,7d' $MANIFEST_XML
if git -C manifest commit -aq -m "manifest: Update to $TAG" &> /dev/null; then
echo -e "${blu}Manifest updated succesfully!"
echo manifest >> success
else
echo -e "${red}Manifest already up to date!"
fi
else
echo -e "${red}Manifest update failed!"
echo manifest >> failed
fi
# update clo rev in vendor
if $IS_QSSI; then
echo -e "\n${blu}Updating CLO revision in vendor/reloaded..."
sed -i "s|CLO_REVISION := .*|CLO_REVISION := $TAG|g" vendor/reloaded/config/branding.mk
if git -C vendor/reloaded commit -aq -m "config: Update CLO revision to $TAG" &> /dev/null; then
echo -e "${blu}CLO revision updated succesfully!"
echo vendor/reloaded >> success
else
echo -e "${red}CLO revision already up to date!"
fi
fi
if [ -s success ]; then
echo -e "${grn}\nPushing succeeded repos:$end"
for repo in $(cat success); do
cd $repo
echo $repo
git push -q &> /dev/null || echo "${red}$repo push failed!"
cd $src_root
done
fi
if [ -s failed ]; then
echo -e "$red \nThese repos failed merging:$end"
cat failed
fi
echo $end