forked from psi-plus/psi-plus-snapshots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-single-repo.sh
executable file
·255 lines (209 loc) · 6.84 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
#! /bin/sh
# Author: Boris Pek <tehnick-8@mail.ru>
# License: GPLv2 or later
# Created: 2012-02-13
# Updated: 2016-04-06
# Version: N/A
set -e
export PSIPLUS_DIR="$(dirname $(realpath -s ${0}))"
export MAIN_DIR="${PSIPLUS_DIR}/.."
# Test Internet connection:
host github.com > /dev/null
cd "${PSIPLUS_DIR}"
if [ "${1}" = "push" ]; then
git push
git push --tags
exit 0
fi
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 https://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 https://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 https://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 https://github.com/psi-plus/${MOD}.git
echo;
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')
$(cd ${MAIN_DIR}/plugins && git log -n1 --date=short --pretty=format:'%ad')
$(cd ${MAIN_DIR}/resources && git log -n1 --date=short --pretty=format:'%ad')"
LAST_REVISION_DATE=$(echo "${REVISION_DATE_LIST}" | sort -r | head -n1)
MAIN_REVISION=$(cd ${MAIN_DIR}/main && git describe --tags | sed -e "s/^\(.\+\)-g.*$/\1/" | sed -e "s/-/\./")
if [ "$(cd ${MAIN_DIR}/psi && git describe --tags | sed -e "s/-/\n/g" | wc -l)" = "3" ]; then
if [ "${MAIN_REVISION}" = "$(cd ${MAIN_DIR}/main && git describe --tags)" ]; then
PSI_REVISION=".0.$(cd ${MAIN_DIR}/psi && git describe --tags | sed -e 's/^.*-\([0-9]\+\)-.*$/\1/')"
else
PSI_REVISION=".$(cd ${MAIN_DIR}/psi && git describe --tags | sed -e 's/^.*-\([0-9]\+\)-.*$/\1/')"
fi
else
PSI_REVISION=""
fi
NEW_VER="${MAIN_REVISION}${PSI_REVISION}"
OLD_VER=$(cd "${PSIPLUS_DIR}" && git tag -l | sort -V | tail -n1)
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;
# Some paranoid checks:
for FILE in generate-single-repo.sh configure README; do
if [ ! -e "${PSIPLUS_DIR}/${FILE}" ]; then
wget -c "https://raw.github.com/psi-plus/psi-plus-snapshots/master/${FILE}"
fi
done
chmod uog+x generate-single-repo.sh configure
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 are 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 are 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 are copied."
echo;
rsync -a "${MAIN_DIR}/plugins" "${PSIPLUS_DIR}/src/" \
--exclude=".git*"
echo "Plugins from Psi+ project are copied."
echo;
rsync -a "${MAIN_DIR}/main/iconsets/system/" "${PSIPLUS_DIR}/iconsets/system/"
echo "Iconsets from Psi+ project are copied."
echo;
rsync -a "${MAIN_DIR}/resources/sound/" "${PSIPLUS_DIR}/sound/"
echo "Sound files from Psi+ project are copied."
echo;
mkdir -p "${PSIPLUS_DIR}/skins/"
rsync -a "${MAIN_DIR}/resources/skins/" "${PSIPLUS_DIR}/skins/"
echo "Skins from Psi+ project are copied."
echo;
rsync -a "${MAIN_DIR}/resources/themes/" "${PSIPLUS_DIR}/themes/"
echo "Themes from Psi+ project are copied."
echo;
cp "${MAIN_DIR}/main/changelog.txt" "${PSIPLUS_DIR}/ChangeLog"
echo "ChangeLog from Psi+ project is copied."
echo;
rm configure.exe
rm iris/configure.exe
rm -r win32/
rm -r src/libpsi/tools/idle/win32/
echo "Trash is removed."
echo;
# Update repo and make analysis
git add -A
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
COMMENT="Current version is ${NEW_VER}:\n"
if [ "${TEST_SRC}" -gt "$((${TEST_LIBPSI}+${TEST_PLUGINS}+0))" ]; then
COMMENT="${COMMENT}Psi+ is updated.\n"
fi
if [ "${TEST_IRIS}" -gt 0 ]; then
COMMENT="${COMMENT}iris is updated.\n"
fi
if [ "${TEST_LIBPSI}" -gt 0 ]; then
COMMENT="${COMMENT}libpsi is updated.\n"
fi
if [ "${TEST_PLUGINS}" -eq 1 ]; then
COMMENT="${COMMENT}One plugin is updated.\n"
elif [ "${TEST_PLUGINS}" -gt 1 ]; then
COMMENT="${COMMENT}Plugins are updated.\n"
fi
if [ "${TEST_PATCHES}" -eq 1 ]; then
COMMENT="${COMMENT}One extra patch is updated.\n"
elif [ "${TEST_PATCHES}" -gt 1 ]; then
COMMENT="${COMMENT}Extra patches are updated.\n"
fi
echo "${COMMENT}"
git cm -a -m "$(echo ${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} is created."
fi
echo;