File duilder changed (mode: 100755) (index 8fcd888..bf888f6) |
2 |
2 |
|
|
3 |
3 |
set -e |
set -e |
4 |
4 |
|
|
|
5 |
|
function git_last_changelog() |
|
6 |
|
{ |
|
7 |
|
changelog="" |
|
8 |
|
|
|
9 |
|
# get the list of tags |
|
10 |
|
i=0 |
|
11 |
|
number_of_tags=0 |
|
12 |
|
for tag in `git tag -l`; do |
|
13 |
|
if [ "${tag:0:1}" != "v" ]; then |
|
14 |
|
# skip other kind of tags beside versions |
|
15 |
|
continue |
|
16 |
|
fi |
|
17 |
|
|
|
18 |
|
tags[${i}]=${tag} |
|
19 |
|
tags_commit[${i}]=`git show-ref ${tag} | cut -d' ' -f1` |
|
20 |
|
number_of_tags=$[${number_of_tags}+1] |
|
21 |
|
|
|
22 |
|
i=$[${i}+1] |
|
23 |
|
done |
|
24 |
|
|
|
25 |
|
# get the list of commits, test if is a tag and do the diff |
|
26 |
|
prev="" |
|
27 |
|
git log --pretty=oneline | cut -f1 | \ |
|
28 |
|
while read commit junk; do |
|
29 |
|
# test if it is a tag |
|
30 |
|
tag="" |
|
31 |
|
i=0 |
|
32 |
|
while [ "${i}" -lt "${number_of_tags}" ]; do |
|
33 |
|
if [ "${commit}" = "${tags_commit[${i}]}" ]; then |
|
34 |
|
tag="${tags[${i}]}" |
|
35 |
|
break |
|
36 |
|
fi |
|
37 |
|
|
|
38 |
|
i=$[${i}+1] |
|
39 |
|
done |
|
40 |
|
|
|
41 |
|
if [ -z "${tag}" ]; then |
|
42 |
|
continue |
|
43 |
|
fi |
|
44 |
|
|
|
45 |
|
if [ ! -z "${prev}" ]; then |
|
46 |
|
current=${tag} |
|
47 |
|
git shortlog ${current}..${prev} | \ |
|
48 |
|
(IFS="" |
|
49 |
|
while read line; do |
|
50 |
|
echo " ${line}" |
|
51 |
|
done) |
|
52 |
|
echo |
|
53 |
|
break |
|
54 |
|
fi |
|
55 |
|
prev=${tag} |
|
56 |
|
done |
|
57 |
|
} |
|
58 |
|
|
|
59 |
|
function duilder_final() |
|
60 |
|
{ |
|
61 |
|
PRJ="${1}" |
|
62 |
|
VER="${2}" |
|
63 |
|
RELEASE_SCRIPT="${3}" |
|
64 |
|
|
|
65 |
|
# Run release script |
|
66 |
|
if [ ! -z "${RELEASE_SCRIPT}" -a -x "${RELEASE_SCRIPT}" ]; then |
|
67 |
|
echo "Running ${RELEASE_SCRIPT}..." |
|
68 |
|
export CHANGELOG=`git_last_changelog` |
|
69 |
|
${RELEASE_SCRIPT} |
|
70 |
|
fi |
|
71 |
|
} |
|
72 |
|
|
5 |
73 |
function duilder_docs() |
function duilder_docs() |
6 |
74 |
{ |
{ |
7 |
75 |
PRJ="${1}" |
PRJ="${1}" |
|
... |
... |
function duilder_git() |
27 |
95 |
PRJ="${1}" |
PRJ="${1}" |
28 |
96 |
GIT_DEST="${2}" |
GIT_DEST="${2}" |
29 |
97 |
EXPORT_GIT="${3}" |
EXPORT_GIT="${3}" |
30 |
|
EXPORT_PATH="${4}" |
|
31 |
|
GIT_CHANGELOG="${5}" |
|
32 |
|
|
|
33 |
|
if [ "${EXPORT_GIT}" != "1" ]; then |
|
34 |
|
exit 0 |
|
35 |
|
fi |
|
|
98 |
|
GIT_CHANGELOG="${4}" |
|
99 |
|
GIT_PUSH="${5}" |
36 |
100 |
|
|
37 |
101 |
if [ ! -x /usr/bin/git ]; then |
if [ ! -x /usr/bin/git ]; then |
38 |
102 |
echo "Warning: Git not found!" |
echo "Warning: Git not found!" |
|
... |
... |
function duilder_git() |
44 |
108 |
exit 0 |
exit 0 |
45 |
109 |
fi |
fi |
46 |
110 |
|
|
47 |
|
if [ -z "${GIT_DEST}" ]; then |
|
48 |
|
GIT_DEST="${EXPORT_PATH}" |
|
|
111 |
|
if [ "${EXPORT_GIT}" = "1" ]; then |
|
112 |
|
echo "Generate GIT tree for HTTP transport..." |
|
113 |
|
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then |
|
114 |
|
git clone --bare . "${GIT_DEST}/${PRJ}.git" |
|
115 |
|
|
|
116 |
|
# Activate post-update hook |
|
117 |
|
cp "${GIT_DEST}/${PRJ}.git/hooks/post-update.sample" \ |
|
118 |
|
"${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
119 |
|
chmod a+x "${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
120 |
|
|
|
121 |
|
# add project name and description |
|
122 |
|
echo "${PRJ}" > "${GIT_DEST}/${PRJ}.git/description" |
|
123 |
|
|
|
124 |
|
# allow export by git daemon? |
|
125 |
|
#touch "${GIT_DEST}/${PRJ}.git/git-daemon-export-ok |
|
126 |
|
else |
|
127 |
|
# --force? |
|
128 |
|
echo "Running git push -v --all \"${GIT_DEST}/${PRJ}.git\"..." |
|
129 |
|
git push -v --all "${GIT_DEST}/${PRJ}.git" |
|
130 |
|
echo "Running git push -v --tags \"${GIT_DEST}/${PRJ}.git\"..." |
|
131 |
|
git push -v --tags "${GIT_DEST}/${PRJ}.git" |
|
132 |
|
fi |
|
133 |
|
(cd "${GIT_DEST}/${PRJ}.git" && git update-server-info) |
49 |
134 |
fi |
fi |
50 |
135 |
|
|
51 |
|
echo "Generate GIT tree for HTTP transport..." |
|
52 |
|
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then |
|
53 |
|
git clone --bare . "${GIT_DEST}/${PRJ}.git" |
|
54 |
|
|
|
55 |
|
# Activate post-update hook |
|
56 |
|
cp "${GIT_DEST}/${PRJ}.git/hooks/post-update.sample" \ |
|
57 |
|
"${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
58 |
|
chmod a+x "${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
59 |
|
|
|
60 |
|
# add project name and description |
|
61 |
|
echo "${PRJ}" > "${GIT_DEST}/${PRJ}.git/description" |
|
62 |
|
|
|
63 |
|
# allow export by git daemon? |
|
64 |
|
#touch "${GIT_DEST}/${PRJ}.git/git-daemon-export-ok |
|
65 |
|
else |
|
66 |
|
# --force? |
|
67 |
|
echo "Running git push -v --all \"${GIT_DEST}/${PRJ}.git\"..." |
|
68 |
|
git push -v --all "${GIT_DEST}/${PRJ}.git" |
|
69 |
|
echo "Running git push -v --tags \"${GIT_DEST}/${PRJ}.git\"..." |
|
70 |
|
git push -v --tags "${GIT_DEST}/${PRJ}.git" |
|
|
136 |
|
if [ "${GIT_PUSH}" = "1" ]; then |
|
137 |
|
echo "[*] Git push..." |
|
138 |
|
git push -v --all |
71 |
139 |
fi |
fi |
72 |
|
(cd "${GIT_DEST}/${PRJ}.git" && git update-server-info) |
|
73 |
|
|
|
74 |
140 |
|
|
75 |
141 |
if [ "${GIT_CHANGELOG}" = "1" ]; then |
if [ "${GIT_CHANGELOG}" = "1" ]; then |
76 |
142 |
echo "[*] Generating Changelog from git..." |
echo "[*] Generating Changelog from git..." |
|
... |
... |
if [ "${1}" = "srpm" ]; then |
230 |
296 |
exit $? |
exit $? |
231 |
297 |
fi |
fi |
232 |
298 |
|
|
|
299 |
|
if [ "${1}" = "final" ]; then |
|
300 |
|
shift |
|
301 |
|
duilder_final "$@" |
|
302 |
|
exit $? |
|
303 |
|
fi |
|
304 |
|
|
233 |
305 |
if [ ! -r duilder.conf ]; then |
if [ ! -r duilder.conf ]; then |
234 |
306 |
echo "You must build a duilder.conf file!" |
echo "You must build a duilder.conf file!" |
235 |
307 |
exit 1 |
exit 1 |
|
... |
... |
fi |
240 |
312 |
|
|
241 |
313 |
source ${PWD}/duilder.conf |
source ${PWD}/duilder.conf |
242 |
314 |
|
|
|
315 |
|
# fixes |
|
316 |
|
if [ -z "${GIT_DEST}" ]; then |
|
317 |
|
GIT_DEST="${EXPORT_PATH}" |
|
318 |
|
fi |
|
319 |
|
|
|
320 |
|
# export variables - just in case a script cares |
|
321 |
|
export PRJ VER REV EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST SRPMS_DEST LICENSE |
|
322 |
|
|
243 |
323 |
if [ -z "${PRJ}" ]; then |
if [ -z "${PRJ}" ]; then |
244 |
324 |
echo "ERROR: PRJ= parameter is missing." |
echo "ERROR: PRJ= parameter is missing." |
245 |
325 |
exit 1 |
exit 1 |
|
... |
... |
if [ -r Makefile.in ]; then |
438 |
518 |
echo >> Makefile |
echo >> Makefile |
439 |
519 |
echo ".PHONY: dist" >> Makefile |
echo ".PHONY: dist" >> Makefile |
440 |
520 |
echo "dist: clean" >> Makefile |
echo "dist: clean" >> Makefile |
441 |
|
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${EXPORT_PATH}\" \"${GIT_CHANGELOG}\"" >> Makefile |
|
|
521 |
|
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${GIT_CHANGELOG}\"" \"${GIT_PUSH}\" >> Makefile |
442 |
522 |
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile |
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile |
443 |
523 |
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile |
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile |
444 |
524 |
echo " @./duilder docs \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\"" >> Makefile |
echo " @./duilder docs \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\"" >> Makefile |
|
525 |
|
echo " @./duilder final \"\$(PRJ)\" \"\$(VER)\" \"${RELEASE_SCRIPT}\"" >> Makefile |
445 |
526 |
echo " @rm -f \"\$(PRJ)-\$(VER).tar.gz\"" >> Makefile |
echo " @rm -f \"\$(PRJ)-\$(VER).tar.gz\"" >> Makefile |
446 |
527 |
echo >> Makefile |
echo >> Makefile |
447 |
528 |
fi |
fi |