forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease_lib.sh
168 lines (143 loc) · 4.77 KB
/
release_lib.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# фильтрует теги, не являющиеся релизными тегами
function tag_filter
{
grep -E "^[0-9]{5,8}$"
}
function add_daemon_impl {
local daemon=$1
local control=$CONTROL
local dependencies=$2
local description_short="${daemon%-metrika-yandex/ daemon}"
local description_full=$3
echo -e "\n\n" >> $control;
echo "Package: $daemon" >> $control;
echo "Section: libdevel" >> $control;
echo "Architecture: any" >> $control;
echo -n "Depends: \${shlibs:Depends}, \${misc:Depends}" >> $control;
for dependency in $dependencies
do
echo -n ", $dependency" >> $control
done
echo >> $control
echo "Description: $description_short" >> $control;
echo " $description_full" >> $control;
}
function add_daemon {
add_daemon_impl "$DAEMON_PKG-metrika-yandex" "$1" "$2"
}
# Создаём файл control из control.in.
# добавляет в файл CONTROL секции для демонов из DAEMONS
function make_control {
local CONTROL="$1"
local DAEMONS="$2"
rm -f $CONTROL
cp -f $CONTROL.in $CONTROL
for DAEMON_PKG in $DAEMONS
do
case "$DAEMON_PKG" in
'clickhouse-server' )
add_daemon_impl clickhouse-server-base '' 'clickhouse-server binary'
[ -n "$BUILD_PACKAGE_FOR_METRIKA" ] && add_daemon_impl clickhouse-server-metrika "clickhouse-server-base(=1.1.$REVISION)" 'Configuration files specific for Metrika project for clickhouse-server-base package'
add_daemon_impl clickhouse-server-common "clickhouse-server-base(=1.1.$REVISION)" 'Common configuration files for clickhouse-server-base package'
;;
'clickhouse-client' )
add_daemon_impl clickhouse-client
;;
esac
done
}
# Генерируем номер ревизии.
# выставляются переменные окружения REVISION, AUTHOR
function gen_revision_author {
# GIT
git fetch --tags
IS_IT_GITHUB=$( git config --get remote.origin.url | grep 'github')
REVISION=$( git tag | tag_filter | tail -1 )
REVISION_FULL_NAME=$REVISION
if [[ $STANDALONE != 'yes' ]]
then
MAX_REVISION=$(($REVISION + 10)) # Максимальное количество попыток отправить тег в Git.
# Создадим номер ревизии и попытаемся залить на сервер.
succeeded=0
attempts=0
max_attempts=5
while [ $succeeded -eq 0 ] && [ $attempts -le $max_attempts ]
do
REVISION=$(($REVISION + 1))
attempts=$(($attempts + 1))
[ "$REVISION" -ge "$MAX_REVISION" ] && exit 1
REVISION_FULL_NAME=$REVISION
if [[ "$IS_IT_GITHUB" = "" ]]
then
REVISION_FULL_NAME=$REVISION_FULL_NAME-mobmet
fi
echo -e "\nTrying to create revision:" $REVISION_FULL_NAME
if git tag $REVISION_FULL_NAME
then
echo -e "\nTrying to push revision to origin:" $REVISION_FULL_NAME
git push origin $REVISION_FULL_NAME
if [ $? -ne 0 ];
then
git tag -d $REVISION_FULL_NAME
else
succeeded=1
fi
fi
done
if [ $succeeded -eq 0 ]; then
echo "Fail to create tag"
exit 1
fi
fi
AUTHOR=$(git config --get user.name)
REVISION=$REVISION_FULL_NAME
export REVISION
export AUTHOR
}
# Генерируем changelog из changelog.in.
# изменяет
# programs/CMakeLists.txt
# dbms/src/CMakeLists.txt
function gen_changelog {
REVISION="$1"
CHDATE="$2"
AUTHOR="$3"
CHLOG="$4"
DAEMONS="$5"
sed \
-e "s/[@]REVISION[@]/$REVISION/g" \
-e "s/[@]DATE[@]/$CHDATE/g" \
-e "s/[@]AUTHOR[@]/$AUTHOR/g" \
-e "s/[@]EMAIL[@]/$(whoami)@yandex-team.ru/g" \
< $CHLOG.in > $CHLOG
}
# Загрузка в репозитории Метрики и БК
# рабочая директория - где лежит сам скрипт
function upload_debs {
REVISION="$1"
DAEMONS="$2"
# Определим репозиторий, в который надо загружать пакеты. Он соответствует версии Ubuntu.
source /etc/lsb-release
if [ "$DISTRIB_CODENAME" == "precise" ]; then
REPO="metrika"
REPO_YABS="bs"
elif [ "$DISTRIB_CODENAME" == "trusty" ]; then
REPO="metrika-trusty"
REPO_YABS="bs-trusty"
else
echo -e "\n\e[0;31mUnknown Ubuntu version $DISTRIB_CODENAME \e[0;0m\n"
fi
# Загрузка в репозиторий Метрики.
cd ../
DUPLOAD_CONF=dupload.conf
cat src/debian/dupload.conf.in | sed -e "s/[@]AUTHOR[@]/$(whoami)/g" > $DUPLOAD_CONF
dupload metrika-yandex_1.1."$REVISION"_amd64.changes -t $REPO -c --nomail
# Загрузка в репозиторий баннерной крутилки (только ClickHouse).
if [[ -z "$(echo $DAEMONS | tr ' ' '\n' | grep -v clickhouse)" ]];
then
echo -e "\n\e[0;32mUploading daemons "$DAEMONS" to Banner System \e[0;0m\n "
dupload metrika-yandex_1.1."$REVISION"_amd64.changes -t $REPO_YABS -c --nomail
else
echo -e "\n\e[0;31mWill not upload daemons to Banner System \e[0;0m\n "
fi
}