forked from psi-plus/psi-plus-snapshots
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-single-repo.sh
executable file
·270 lines (222 loc) · 6.91 KB
/
generate-single-repo.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#! /bin/bash
# Author: Boris Pek <[email protected]>
# License: GPLv2 or later
# Created: 2012-02-13
# Updated: 2014-03-13
# Version: N/A
set -e
if [[ ${0} =~ ^/.+$ ]]; then
export PSIPLUS_DIR="$(dirname ${0})"
else
export PSIPLUS_DIR="${PWD}/$(dirname ${0})"
fi
export MAIN_DIR="${PSIPLUS_DIR}/.."
# Test Internet connection:
host github.com > /dev/null
cd "${PSIPLUS_DIR}"
OLD_VER=$(git tag -l | sort -V | tail -n1)
OLD_REVISION=$(echo ${OLD_VER} | sed -e "s/^[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/\1/")
MOD=psi
if [ -d "${MAIN_DIR}/${MOD}" ]; then
echo "Updating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}/${MOD}"
git pull --all
git submodule update
echo;
else
echo "Creating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}"
git clone --depth 1 git://github.com/psi-im/${MOD}.git
cd "${MAIN_DIR}/${MOD}"
git submodule init
git submodule update
echo;
fi
MOD=main
if [ -d "${MAIN_DIR}/${MOD}" ]; then
echo "Updating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}/${MOD}"
git pull --all
echo;
else
echo "Creating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}"
git clone git://github.com/psi-plus/${MOD}.git
echo;
fi
MOD=plugins
if [ -d "${MAIN_DIR}/${MOD}" ]; then
echo "Updating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}/${MOD}"
git pull --all
echo;
else
echo "Creating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}"
git clone --depth 1 git://github.com/psi-plus/${MOD}.git
echo;
fi
MOD=resources
if [ -d "${MAIN_DIR}/${MOD}" ]; then
echo "Updating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}/${MOD}"
git pull --all
echo;
else
echo "Creating ${MAIN_DIR}/${MOD}"
cd "${MAIN_DIR}"
git clone --depth 1 git://github.com/psi-plus/${MOD}.git
echo;
fi
MOD=main
cd "${MAIN_DIR}/${MOD}"
rev=$(git describe --tags | sed -e "s/^.*-\([0-9]\+\)-.*$/\1/")
if [ "${rev}" = "$(git describe --tags)" ]; then rev="0"; fi
REVISION_DATE_LIST="$(cd ${MAIN_DIR}/psi && git log -n1 --date=short --pretty=format:'%ad')
$(cd ${MAIN_DIR}/main && git log -n1 --date=short --pretty=format:'%ad')"
LAST_REVISION_DATE=$(echo "${REVISION_DATE_LIST}" | sort -r | head -n1)
CUR_VER="0.16"
LAST_REVISION=${rev}
NEW_VER="${CUR_VER}.${LAST_REVISION}"
# Fix NEW_VER if manually created tag exists
if [ "$(echo -e "${NEW_VER}\\n${OLD_VER}" | sort -V | tail -n1)" != "${NEW_VER}" ]; then
NEW_VER="${OLD_VER}"
EXTRA_TAG="true"
fi
echo "OLD_VER = ${OLD_VER}"
echo "NEW_VER = ${NEW_VER}"
echo;
cd "${PSIPLUS_DIR}"
echo "Updating is started."
echo;
find . -type f | \
grep -v "^\./\.git" | \
grep -v "^\./generate-single-repo.sh" | \
grep -v "^\./configure" | \
grep -v "^\./README" | \
while read var; do rm "$var"; done
find . -depth -type d -empty -exec rmdir {} \;
echo "Directory is cleaned."
echo;
if [ ! -e "${PSIPLUS_DIR}/configure" ]; then
wget -c "https://raw.github.com/tehnick/psi-plus/master/configure" || touch configure
fi
if [ ! -e "${PSIPLUS_DIR}/README" ]; then
wget -c "https://raw.github.com/tehnick/psi-plus/master/README" || touch README
fi
mv "${PSIPLUS_DIR}/configure" "${MAIN_DIR}/configure"
mv "${PSIPLUS_DIR}/README" "${MAIN_DIR}/README"
rsync -a "${MAIN_DIR}/psi/" "${PSIPLUS_DIR}/" \
--exclude=".git*" \
--exclude="^configure" \
--exclude="^README"
mv "${MAIN_DIR}/configure" "${PSIPLUS_DIR}/configure"
mv "${MAIN_DIR}/README" "${PSIPLUS_DIR}/README"
echo "Files from psi project were copied."
echo;
cat "${MAIN_DIR}/main/patches"/*.diff | \
patch -d "${PSIPLUS_DIR}" -p1 2>&1 > \
"${MAIN_DIR}/applying-patches_${NEW_VER}.log"
echo "${NEW_VER} ($(echo ${LAST_REVISION_DATE}))" > version
echo "Patches from Psi+ project were applied."
echo;
mkdir -p "${PSIPLUS_DIR}/patches"
rsync -a "${MAIN_DIR}/main/patches/dev" "${PSIPLUS_DIR}/patches/"
rsync -a "${MAIN_DIR}/main/patches/mac" "${PSIPLUS_DIR}/patches/"
rsync -a "${MAIN_DIR}/main/patches/haiku" "${PSIPLUS_DIR}/patches/"
echo "Extra patches from Psi+ project were copied."
echo;
rsync -a "${MAIN_DIR}/plugins" "${PSIPLUS_DIR}/src/" \
--exclude=".git*"
echo "Plugins from Psi+ project were copied."
echo;
rsync -a "${MAIN_DIR}/main/iconsets/system/" "${PSIPLUS_DIR}/iconsets/system/"
rsync -a "${MAIN_DIR}/main/iconsets/affiliations/" "${PSIPLUS_DIR}/iconsets/affiliations/"
echo "Iconsets from Psi+ project were copied."
echo;
rsync -a "${MAIN_DIR}/resources/sound/" "${PSIPLUS_DIR}/sound/"
echo "Sound files from Psi+ project were copied."
echo;
mkdir -p "${PSIPLUS_DIR}/skins/"
rsync -a "${MAIN_DIR}/resources/skins/" "${PSIPLUS_DIR}/skins/"
echo "Skins from Psi+ project were copied."
echo;
rsync -a "${MAIN_DIR}/resources/themes/" "${PSIPLUS_DIR}/themes/"
echo "Themes from Psi+ project were copied."
echo;
cp "${MAIN_DIR}/main/changelog.txt" "${PSIPLUS_DIR}/ChangeLog"
echo "ChangeLog from Psi+ project was copied."
echo;
rm configure.exe
rm iris/configure.exe
rm -r win32/
rm -r src/libpsi/tools/idle/win32/
echo "Trash was removed."
echo;
# Update repo and make analysis
git add -A
COMMENT=""
STATUS="$(git status)"
TEST_ALL=$(echo "${STATUS}" | grep " " |
grep -v " src/applicationinfo.cpp" | \
grep -v " generate-single-repo.sh" | \
grep -v " configure" | \
grep -v " README" | \
wc -l)
TEST_SRC=$(echo "${STATUS}" | grep " src/" | wc -l)
TEST_IRIS=$(echo "${STATUS}" | grep " iris/" | wc -l)
TEST_LIBPSI=$(echo "${STATUS}" | grep " src/libpsi/" | wc -l)
TEST_PLUGINS=$(echo "${STATUS}" | grep " src/plugins/" | wc -l)
TEST_PATCHES=$(echo "${STATUS}" | grep " patches/" | wc -l)
echo "TEST_ALL = ${TEST_ALL}"
echo "TEST_IRIS = ${TEST_IRIS}"
echo "TEST_LIBPSI = ${TEST_LIBPSI}"
echo "TEST_PLUGINS = ${TEST_PLUGINS}"
echo "TEST_PATCHES = ${TEST_PATCHES}"
echo "TEST_SRC = ${TEST_SRC}"
echo;
if [ "${TEST_ALL}" -eq 0 ]; then
echo "Updating is not required.";
exit 0;
fi
if [ "${NEW_VER}" = "${OLD_VER}" ]; then
if [ -z "${EXTRA_TAG}" ]; then
COMMENT+="Sources were sync with upstream:\n"
else
COMMENT+="Psi+ was updated:\n"
fi
if [ "${TEST_SRC}" -gt "$((${TEST_LIBPSI}+${TEST_PLUGINS}+0))" ]; then
COMMENT+="Psi was updated.\n"
fi
else
COMMENT+="Current version is ${NEW_VER}:\n"
if [ "${TEST_SRC}" -gt "$((${TEST_LIBPSI}+${TEST_PLUGINS}+0))" ]; then
COMMENT+="Psi+ was updated.\n"
fi
fi
if [ "${TEST_IRIS}" -gt 0 ]; then
COMMENT+="Iris was updated.\n"
fi
if [ "${TEST_LIBPSI}" -gt 0 ]; then
COMMENT+="Libpsi was updated.\n"
fi
if [ "${TEST_PLUGINS}" -eq 1 ]; then
COMMENT+="One plugin was updated.\n"
elif [ "${TEST_PLUGINS}" -gt 1 ]; then
COMMENT+="Plugins were updated.\n"
fi
if [ "${TEST_PATCHES}" -gt 0 ]; then
COMMENT+="Extra patches were updated.\n"
fi
echo -e "${COMMENT}"
git cm -a -m "$(echo -e ${COMMENT})" 2>&1 > \
"${MAIN_DIR}/git-commit_${NEW_VER}.log"
if [ "${NEW_VER}" != "${OLD_VER}" ]; then
git tag "${NEW_VER}"
echo "Git tag ${NEW_VER} was created."
echo;
fi
if [ "${1}" = "push" ]; then
git push
git push --tags
fi