File duilder added (mode: 100755) (index 0000000..e243861) |
|
1 |
|
#!/bin/bash |
|
2 |
|
|
|
3 |
|
set -e |
|
4 |
|
|
|
5 |
|
function duilder_final() |
|
6 |
|
{ |
|
7 |
|
PRJ="${1}" |
|
8 |
|
VER="${2}" |
|
9 |
|
RELEASE_SCRIPT="${3}" |
|
10 |
|
|
|
11 |
|
# Run release script |
|
12 |
|
if [ ! -z "${RELEASE_SCRIPT}" -a -x "${RELEASE_SCRIPT}" ]; then |
|
13 |
|
echo "[*] Running ${RELEASE_SCRIPT}..." |
|
14 |
|
${RELEASE_SCRIPT} |
|
15 |
|
fi |
|
16 |
|
} |
|
17 |
|
|
|
18 |
|
function duilder_docs() |
|
19 |
|
{ |
|
20 |
|
PRJ="${1}" |
|
21 |
|
VER="${2}" |
|
22 |
|
EXPORT_PATH="${3}" |
|
23 |
|
|
|
24 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
25 |
|
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
26 |
|
mkdir -p "${EXPORT_PATH}" |
|
27 |
|
fi |
|
28 |
|
|
|
29 |
|
if [ "${BUILD_SDEB}" = "1" ]; then |
|
30 |
|
if [ -d "debian" ]; then |
|
31 |
|
>debian/docs |
|
32 |
|
fi |
|
33 |
|
fi |
|
34 |
|
|
|
35 |
|
echo "[*] Copying docs to [${EXPORT_PATH}]..." |
|
36 |
|
for f in README License LICENSE Changelog Changelog-last TODO FAQ INSTALL AUTHORS samples; do |
|
37 |
|
[ ! -r "${f}" ] && continue |
|
38 |
|
|
|
39 |
|
cp -avp "${f}" "${EXPORT_PATH}/" |
|
40 |
|
if [ "${BUILD_SDEB}" = "1" ]; then |
|
41 |
|
# No need to install the license file |
|
42 |
|
if [ "${f}" = "LICENSE" ]; then |
|
43 |
|
continue |
|
44 |
|
fi |
|
45 |
|
echo "${f}" >> debian/docs |
|
46 |
|
fi |
|
47 |
|
done |
|
48 |
|
echo |
|
49 |
|
|
|
50 |
|
if [ -d "screenshot" ]; then |
|
51 |
|
echo "[*] Copying screenshots..." |
|
52 |
|
mkdir -p "${EXPORT_PATH}" |
|
53 |
|
cp -vp screenshot/* "${EXPORT_PATH}/" |
|
54 |
|
echo |
|
55 |
|
fi |
|
56 |
|
} |
|
57 |
|
|
|
58 |
|
function duilder_git() |
|
59 |
|
{ |
|
60 |
|
PRJ="${1}"; shift |
|
61 |
|
GIT_DEST="${1}"; shift |
|
62 |
|
EXPORT_GIT="${1}"; shift |
|
63 |
|
EXPORT_PATH="${1}"; shift |
|
64 |
|
GIT_CHANGELOG="${1}"; shift |
|
65 |
|
GIT_PUSH="${1}"; shift |
|
66 |
|
|
|
67 |
|
if [ ! -x /usr/bin/git ]; then |
|
68 |
|
echo "[*] Warning: Git not found!" |
|
69 |
|
exit 0 |
|
70 |
|
fi |
|
71 |
|
|
|
72 |
|
if [ ! -d .git ]; then |
|
73 |
|
echo "[*] Warning: I cannot find .git directory!" |
|
74 |
|
exit 0 |
|
75 |
|
fi |
|
76 |
|
|
|
77 |
|
echo "[*] Testing if a tag is present for HEAD..." |
|
78 |
|
D=`git describe | sed -e 's/^.*-g[0-9a-fA-F]*$//'` |
|
79 |
|
if [ "${D}" = "" ]; then |
|
80 |
|
echo "No annotated tag preset for HEAD! Please add one!" |
|
81 |
|
exit 1 |
|
82 |
|
fi |
|
83 |
|
|
|
84 |
|
if [ "${EXPORT_GIT}" = "1" ]; then |
|
85 |
|
echo "[*] Generating GIT tree for HTTP transport..." |
|
86 |
|
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then |
|
87 |
|
git clone --bare . "${GIT_DEST}/${PRJ}.git" |
|
88 |
|
|
|
89 |
|
# Activate post-update hook |
|
90 |
|
cp "${GIT_DEST}/${PRJ}.git/hooks/post-update.sample" \ |
|
91 |
|
"${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
92 |
|
chmod a+x "${GIT_DEST}/${PRJ}.git/hooks/post-update" |
|
93 |
|
|
|
94 |
|
# add project name and description |
|
95 |
|
echo "${PRJ}" > "${GIT_DEST}/${PRJ}.git/description" |
|
96 |
|
|
|
97 |
|
# allow export by git daemon? |
|
98 |
|
#touch "${GIT_DEST}/${PRJ}.git/git-daemon-export-ok |
|
99 |
|
else |
|
100 |
|
# --force? |
|
101 |
|
echo "Running git push -v --all \"${GIT_DEST}/${PRJ}.git\"..." |
|
102 |
|
git push -v --all "${GIT_DEST}/${PRJ}.git" |
|
103 |
|
echo "Running git push -v --tags \"${GIT_DEST}/${PRJ}.git\"..." |
|
104 |
|
git push -v --tags "${GIT_DEST}/${PRJ}.git" |
|
105 |
|
fi |
|
106 |
|
(cd "${GIT_DEST}/${PRJ}.git" && git update-server-info) |
|
107 |
|
fi |
|
108 |
|
|
|
109 |
|
if [ "${GIT_PUSH}" = "1" ]; then |
|
110 |
|
echo "[*] Git push..." |
|
111 |
|
git push -v --all |
|
112 |
|
fi |
|
113 |
|
|
|
114 |
|
if [ "${GIT_CHANGELOG}" = "1" ]; then |
|
115 |
|
echo "[*] Generating Changelog from git..." |
|
116 |
|
echo -n > Changelog |
|
117 |
|
|
|
118 |
|
# get the list of tags |
|
119 |
|
number_of_tags=0 |
|
120 |
|
git show-ref --tags -d | grep refs/tags/v > duilder.tmp |
|
121 |
|
while read sha1 full_tag; do |
|
122 |
|
tag=`echo ${full_tag} | sed -e 's#refs/tags/##' | cut -d'^' -f1` |
|
123 |
|
tags[${number_of_tags}]=${tag} |
|
124 |
|
tags_commit[${number_of_tags}]=${sha1} |
|
125 |
|
number_of_tags=$[${number_of_tags}+1] |
|
126 |
|
done < duilder.tmp |
|
127 |
|
rm -f duilder.tmp |
|
128 |
|
|
|
129 |
|
# get the list of commits, test if is a tag and do the diff |
|
130 |
|
prev="" |
|
131 |
|
add="" |
|
132 |
|
first=1 |
|
133 |
|
git log --pretty=oneline | cut -f1 | \ |
|
134 |
|
while read commit junk; do |
|
135 |
|
# test if it is a tag |
|
136 |
|
tag="" |
|
137 |
|
i=0 |
|
138 |
|
while [ "${i}" -lt "${number_of_tags}" ]; do |
|
139 |
|
if [ "${commit}" = "${tags_commit[${i}]}" ]; then |
|
140 |
|
tag="${tags[${i}]}" |
|
141 |
|
break |
|
142 |
|
fi |
|
143 |
|
|
|
144 |
|
i=$[${i}+1] |
|
145 |
|
done |
|
146 |
|
|
|
147 |
|
if [ -z "${tag}" ]; then |
|
148 |
|
continue |
|
149 |
|
fi |
|
150 |
|
|
|
151 |
|
if [ ! -z "${prev}" ]; then |
|
152 |
|
echo "[*] Generating Changelog from ${tag} -> ${prev}..." |
|
153 |
|
echo -en "${add}" >> Changelog |
|
154 |
|
add="\n" |
|
155 |
|
echo "[${tag} -> ${prev}]" >> Changelog |
|
156 |
|
git shortlog ${tag}..${prev} | \ |
|
157 |
|
(IFS="" |
|
158 |
|
while read line; do |
|
159 |
|
echo " ${line}" |
|
160 |
|
done) \ |
|
161 |
|
>> Changelog |
|
162 |
|
|
|
163 |
|
if [ "${first}" = "1" ]; then |
|
164 |
|
echo "[*] Generating Changelog-last..." |
|
165 |
|
cp Changelog Changelog-last |
|
166 |
|
first=0 |
|
167 |
|
fi |
|
168 |
|
fi |
|
169 |
|
prev=${tag} |
|
170 |
|
done |
|
171 |
|
fi |
|
172 |
|
} |
|
173 |
|
|
|
174 |
|
function duilder_srpm() |
|
175 |
|
{ |
|
176 |
|
PRJ="${1}" |
|
177 |
|
VER="${2}" |
|
178 |
|
EXPORT_PATH="${3}" |
|
179 |
|
BUILD_SRPM="${4}" |
|
180 |
|
SRPM_DEST="${5}" |
|
181 |
|
SRPM_POST_RUN="${6}" |
|
182 |
|
|
|
183 |
|
P="${PRJ}-${VER}" |
|
184 |
|
|
|
185 |
|
if [ "${BUILD_SRPM}" != "1" ]; then |
|
186 |
|
exit 0 |
|
187 |
|
fi |
|
188 |
|
|
|
189 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
190 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
191 |
|
mkdir -p "${EXPORT_PATH}" |
|
192 |
|
fi |
|
193 |
|
|
|
194 |
|
echo "[*] Building SRPM..." |
|
195 |
|
rpmbuild -ts "${P}.tar.gz" |
|
196 |
|
echo |
|
197 |
|
|
|
198 |
|
PKG="${RPMBUILD}/SRPMS/${P}-${REV}.src.rpm" |
|
199 |
|
|
|
200 |
|
# Run a rpmlint on it |
|
201 |
|
if [ -x /usr/bin/rpmlint ]; then |
|
202 |
|
echo "[*] RPMlinting..." |
|
203 |
|
rpmlint -iv "${PKG}" > rpmlint.out |
|
204 |
|
else |
|
205 |
|
echo "[*] WARN: rpmlint is missing!" |
|
206 |
|
fi |
|
207 |
|
|
|
208 |
|
if [ ! -z "${SRPM_DEST}" ]; then |
|
209 |
|
if [ -r "${SRPM_DEST}/${PKG}" ]; then |
|
210 |
|
mv "${SRPM_DEST}/${PKG}" "${SRPM_DEST}/${PKG}.old" |
|
211 |
|
fi |
|
212 |
|
echo "[*] Copying [${PKG}] to [${SRPM_DEST}]..." |
|
213 |
|
cp -vp "${PKG}" "${SRPM_DEST}/" |
|
214 |
|
fi |
|
215 |
|
|
|
216 |
|
echo "[*] Copying to export dir [${EXPORT_PATH}]..." |
|
217 |
|
mkdir -p "${EXPORT_PATH}" |
|
218 |
|
cp -vp "${PKG}" "${EXPORT_PATH}/" |
|
219 |
|
echo |
|
220 |
|
|
|
221 |
|
if [ -x "${SRPM_POST_RUN}" ]; then |
|
222 |
|
echo "[*] Running post SRPM build script [${SRPM_POST_RUN}]..." |
|
223 |
|
${SRPM_POST_RUN} "${PKG}" |
|
224 |
|
fi |
|
225 |
|
} |
|
226 |
|
|
|
227 |
|
function duilder_sdeb() |
|
228 |
|
{ |
|
229 |
|
PRJ="${1}" |
|
230 |
|
VER="${2}" |
|
231 |
|
EXPORT_PATH="${3}" |
|
232 |
|
BUILD_SDEB="${4}" |
|
233 |
|
SDEB_DEST="${5}" |
|
234 |
|
SDEB_POST_RUN="${6}" |
|
235 |
|
|
|
236 |
|
P="${PRJ}-${VER}" |
|
237 |
|
|
|
238 |
|
if [ "${BUILD_SDEB}" != "1" ]; then |
|
239 |
|
exit 0 |
|
240 |
|
fi |
|
241 |
|
|
|
242 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
243 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
244 |
|
mkdir -p "${EXPORT_PATH}" |
|
245 |
|
fi |
|
246 |
|
|
|
247 |
|
echo "[*] Copying SDEB..." |
|
248 |
|
PKG="${PRJ}_${VER}.orig.tar.gz" |
|
249 |
|
|
|
250 |
|
if [ -n "${SDEB_DEST}" ]; then |
|
251 |
|
cp -vp "${P}.tar.gz" "${SDEB_DEST}/${PKG}" |
|
252 |
|
fi |
|
253 |
|
|
|
254 |
|
echo "[*] Copying to export dir [${DEB_EXPORT_PATH}]..." |
|
255 |
|
mkdir -p "${EXPORT_PATH}" |
|
256 |
|
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/${PKG}" |
|
257 |
|
echo |
|
258 |
|
|
|
259 |
|
if [ -x "${SDEB_POST_RUN}" ]; then |
|
260 |
|
echo "[*] Running post SDEB build script [${SDEB_POST_RUN}]..." |
|
261 |
|
${SDEB_POST_RUN} "${SDEB}/${PKG}" |
|
262 |
|
fi |
|
263 |
|
} |
|
264 |
|
|
|
265 |
|
function duilder_tar() |
|
266 |
|
{ |
|
267 |
|
PRJ="${1}" |
|
268 |
|
VER="${2}" |
|
269 |
|
EXPORT_PATH="${3}" |
|
270 |
|
EXCLUDE="${4}" |
|
271 |
|
|
|
272 |
|
P="${PRJ}-${VER}" |
|
273 |
|
|
|
274 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
275 |
|
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
276 |
|
mkdir -p "${EXPORT_PATH}" |
|
277 |
|
fi |
|
278 |
|
|
|
279 |
|
echo "[*] Generating tarball [${P}.tar.gz]..." |
|
280 |
|
ADD_EXCLUDE="" |
|
281 |
|
if [ -r "${EXCLUDE}" ]; then |
|
282 |
|
ADD_EXCLUDE="--exclude-from ${P}/${EXCLUDE}" |
|
283 |
|
echo "[*] ADD_EXCLUDE=${ADD_EXCLUDE}" |
|
284 |
|
fi |
|
285 |
|
|
|
286 |
|
(cd .. \ |
|
287 |
|
&& rm -rf "${P}" \ |
|
288 |
|
&& cp -a --link "${PRJ}" "${P}" \ |
|
289 |
|
&& tar czf "${PRJ}/${P}.tar.gz" \ |
|
290 |
|
--exclude-vcs \ |
|
291 |
|
--exclude ${P}/Makefile \ |
|
292 |
|
${ADD_EXCLUDE} \ |
|
293 |
|
"${P}" \ |
|
294 |
|
&& rm -rf "${P}" |
|
295 |
|
) |
|
296 |
|
|
|
297 |
|
echo "[*] Copying source to ${EXPORT_PATH}..." |
|
298 |
|
mkdir -p "${EXPORT_PATH}" |
|
299 |
|
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/" |
|
300 |
|
echo |
|
301 |
|
} |
|
302 |
|
|
|
303 |
|
#################################################################### |
|
304 |
|
|
|
305 |
|
# Variables |
|
306 |
|
if [ -d "${HOME}/rpmbuild" ]; then |
|
307 |
|
RPMBUILD="${HOME}/rpmbuild" |
|
308 |
|
else |
|
309 |
|
RPMBUILD="/usr/src/redhat" |
|
310 |
|
fi |
|
311 |
|
|
|
312 |
|
|
|
313 |
|
if [ ! -r duilder.conf ]; then |
|
314 |
|
echo "[*] You do not have a duilder.conf file. Trying to continue." |
|
315 |
|
else |
|
316 |
|
source ${PWD}/duilder.conf 2>/dev/null |
|
317 |
|
fi |
|
318 |
|
|
|
319 |
|
|
|
320 |
|
# fixes |
|
321 |
|
if [ -z "${GIT_DEST}" ]; then |
|
322 |
|
GIT_DEST="${EXPORT_PATH}" |
|
323 |
|
fi |
|
324 |
|
|
|
325 |
|
if [ -z "${PRJ}" ]; then |
|
326 |
|
echo "WARN: PRJ= parameter is missing." |
|
327 |
|
fi |
|
328 |
|
|
|
329 |
|
if [ -z "${VER}" ]; then |
|
330 |
|
echo "WARN: VER= parameter is missing." |
|
331 |
|
fi |
|
332 |
|
|
|
333 |
|
if [ -z "${REV}" ]; then |
|
334 |
|
echo "WARN: REV= parameter is missing." |
|
335 |
|
fi |
|
336 |
|
|
|
337 |
|
# export variables - just in case a script cares |
|
338 |
|
export PRJ VER REV SHORT_DESCRIPTION EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST |
|
339 |
|
export SRPM_DEST SDEB_DEST LICENSE MAINTAINER_NAME MAINTAINER_EMAIL |
|
340 |
|
export HOME_PAGE BUILD_SRPM BUILD_SDEB |
|
341 |
|
|
|
342 |
|
|
|
343 |
|
# Multiplexer |
|
344 |
|
if [ "${1}" = "docs" ]; then |
|
345 |
|
shift |
|
346 |
|
duilder_docs "$@" |
|
347 |
|
exit $? |
|
348 |
|
fi |
|
349 |
|
|
|
350 |
|
if [ "${1}" = "tar" ]; then |
|
351 |
|
shift |
|
352 |
|
duilder_tar "$@" |
|
353 |
|
exit $? |
|
354 |
|
fi |
|
355 |
|
|
|
356 |
|
if [ "${1}" = "git" ]; then |
|
357 |
|
shift |
|
358 |
|
duilder_git "$@" |
|
359 |
|
exit $? |
|
360 |
|
fi |
|
361 |
|
|
|
362 |
|
if [ "${1}" = "srpm" ]; then |
|
363 |
|
shift |
|
364 |
|
duilder_srpm "$@" |
|
365 |
|
exit $? |
|
366 |
|
fi |
|
367 |
|
|
|
368 |
|
if [ "${1}" = "sdeb" ]; then |
|
369 |
|
shift |
|
370 |
|
duilder_sdeb "$@" |
|
371 |
|
exit $? |
|
372 |
|
fi |
|
373 |
|
|
|
374 |
|
if [ "${1}" = "final" ]; then |
|
375 |
|
shift |
|
376 |
|
duilder_final "$@" |
|
377 |
|
exit $? |
|
378 |
|
fi |
|
379 |
|
|
|
380 |
|
|
|
381 |
|
###### Main stuff |
|
382 |
|
echo "[*] Duilder builder script" |
|
383 |
|
echo "[*] Copyright Catalin(ux) M. BOIE - catab at embedromix dot ro" |
|
384 |
|
echo "[*] PRJ=${PRJ}, VER=${VER}, REV=${REV}" |
|
385 |
|
echo "[*] System: `uname -a`" |
|
386 |
|
echo "[*] Parameters: ${@}" |
|
387 |
|
|
|
388 |
|
ETC="/etc" |
|
389 |
|
BIN="/bin" |
|
390 |
|
USR="/usr" |
|
391 |
|
USR_BIN="/usr/bin" |
|
392 |
|
USR_SBIN="/usr/sbin" |
|
393 |
|
USR_INCLUDE="/usr/include" |
|
394 |
|
if [ "`uname -m`" = "i686" ]; then |
|
395 |
|
USR_LIB="/usr/lib" |
|
396 |
|
else |
|
397 |
|
USR_LIB="/usr/lib64" |
|
398 |
|
fi |
|
399 |
|
USR_SHARE="/usr/share" |
|
400 |
|
USR_SHARE_DOC="/usr/share/doc/${PRJ}" |
|
401 |
|
SBIN="/usr/sbin" |
|
402 |
|
VAR="/var" |
|
403 |
|
VAR_LIB="/var/lib" |
|
404 |
|
MAN="/usr/share/man" |
|
405 |
|
PREFIX="/usr" |
|
406 |
|
|
|
407 |
|
while [ "${1}" != "" ]; do |
|
408 |
|
xVAR="`echo ${1} | cut -d'=' -f1`" |
|
409 |
|
xVAL="`echo ${1} | cut -d'=' -f2 | sed -e "s|\\${prefix}|${PREFIX}|"`" |
|
410 |
|
shift |
|
411 |
|
case ${xVAR} in |
|
412 |
|
--sysconfdir) |
|
413 |
|
ETC="${xVAL}" |
|
414 |
|
;; |
|
415 |
|
--bindir) |
|
416 |
|
USR_BIN="${xVAL}" |
|
417 |
|
;; |
|
418 |
|
--sbindir) |
|
419 |
|
USR_SBIN="${xVAL}" |
|
420 |
|
;; |
|
421 |
|
--includedir) |
|
422 |
|
USR_INCLUDE="${xVAL}" |
|
423 |
|
;; |
|
424 |
|
--libdir) |
|
425 |
|
USR_LIB="${xVAL}" |
|
426 |
|
;; |
|
427 |
|
--localstatedir) |
|
428 |
|
VAR="${xVAL}" |
|
429 |
|
;; |
|
430 |
|
--sharedstatedir) |
|
431 |
|
VAR_LIB="${xVAL}" |
|
432 |
|
;; |
|
433 |
|
--datadir) |
|
434 |
|
USR_SHARE="${xVAL}" |
|
435 |
|
;; |
|
436 |
|
--mandir) |
|
437 |
|
MAN="${xVAL}" |
|
438 |
|
;; |
|
439 |
|
--prefix) |
|
440 |
|
PREFIX="${xVAL}" |
|
441 |
|
USR="${xVAL}" |
|
442 |
|
;; |
|
443 |
|
esac |
|
444 |
|
done |
|
445 |
|
|
|
446 |
|
# Last fixes |
|
447 |
|
VAR_LOG="${VAR}/log" |
|
448 |
|
VAR_RUN="${VAR}/run" |
|
449 |
|
DUILDER_SYSTEMD="${USR}/lib/systemd" |
|
450 |
|
|
|
451 |
|
for i in ETC BIN USR USR_BIN USR_SBIN USR_INCLUDE USR_LIB USR_SHARE USR_SHARE_DOC SBIN VAR VAR_LIB MAN VAR_LOG VAR_RUN DUILDER_SYSTEMD; do |
|
452 |
|
eval value=\$$i |
|
453 |
|
echo "[*] Var ${i}=${value}" |
|
454 |
|
done |
|
455 |
|
|
|
456 |
|
# Truncate future sed file |
|
457 |
|
> tmp.sed |
|
458 |
|
|
|
459 |
|
DB_SUPPORT=0 |
|
460 |
|
|
|
461 |
|
echo -n "[*] Searching for PostgreSQL..." |
|
462 |
|
set +e |
|
463 |
|
PG_VERSION="`pg_config --version 2>/dev/null`" |
|
464 |
|
set -e |
|
465 |
|
if [ -z "${PG_VERSION}" ]; then |
|
466 |
|
echo " not found." |
|
467 |
|
PG_FOUND=0 |
|
468 |
|
else |
|
469 |
|
echo " found version ${PG_VERSION}." |
|
470 |
|
PG_FOUND=1 |
|
471 |
|
PG_INC="-I`pg_config --includedir`" |
|
472 |
|
PG_LIB="-L`pg_config --libdir` -lpq" |
|
473 |
|
|
|
474 |
|
echo "s#@PG_VERSION@#${PG_VERSION}#g" >> tmp.sed |
|
475 |
|
echo "s#@PG_INC@#${PG_INC}#g" >> tmp.sed |
|
476 |
|
echo "s#@PG_LIB@#${PG_LIB}#g" >> tmp.sed |
|
477 |
|
|
|
478 |
|
DB_SUPPORT=1 |
|
479 |
|
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed |
|
480 |
|
fi |
|
481 |
|
echo "s#@PG_FOUND@#${PG_FOUND}#g" >> tmp.sed |
|
482 |
|
|
|
483 |
|
|
|
484 |
|
echo -n "[*] Searching for MySQL..." |
|
485 |
|
set +e |
|
486 |
|
MYSQL_VERSION="`mysql_config --version 2>/dev/null`" |
|
487 |
|
set -e |
|
488 |
|
if [ -z "${MYSQL_VERSION}" ]; then |
|
489 |
|
echo " not found." |
|
490 |
|
MYSQL_FOUND=0 |
|
491 |
|
else |
|
492 |
|
echo " found version ${MYSQL_VERSION}." |
|
493 |
|
MYSQL_FOUND=1 |
|
494 |
|
MYSQL_INC="`mysql_config --include`" |
|
495 |
|
MYSQL_LIB="`mysql_config --libs`" |
|
496 |
|
|
|
497 |
|
echo "s#@MYSQL_VERSION@#${MYSQL_VERSION}#g" >> tmp.sed |
|
498 |
|
echo "s#@MYSQL_INC@#${MYSQL_INC}#g" >> tmp.sed |
|
499 |
|
echo "s#@MYSQL_LIB@#${MYSQL_LIB}#g" >> tmp.sed |
|
500 |
|
|
|
501 |
|
DB_SUPPORT=1 |
|
502 |
|
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed |
|
503 |
|
fi |
|
504 |
|
echo "s#@MYSQL_FOUND@#${MYSQL_FOUND}#g" >> tmp.sed |
|
505 |
|
|
|
506 |
|
echo -n "[*] Searching for poll..." |
|
507 |
|
set +e |
|
508 |
|
echo -e "#include <poll.h> \n int main(void) { return poll(0, 0, 0); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
|
509 |
|
E="${?}" |
|
510 |
|
set -e |
|
511 |
|
if [ "${E}" != "0" ]; then |
|
512 |
|
echo " not found." |
|
513 |
|
echo "s#@POLL_FOUND@#0#g" >> tmp.sed |
|
514 |
|
else |
|
515 |
|
echo " found." |
|
516 |
|
echo "s#@POLL_FOUND@#1#g" >> tmp.sed |
|
517 |
|
fi |
|
518 |
|
|
|
519 |
|
echo -n "[*] Searching for epoll..." |
|
520 |
|
set +e |
|
521 |
|
echo -e "#include <sys/epoll.h> \n int main(void) { return epoll_create(64); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
|
522 |
|
E="${?}" |
|
523 |
|
set -e |
|
524 |
|
if [ "${E}" != "0" ]; then |
|
525 |
|
echo " not found." |
|
526 |
|
echo "s#@EPOLL_FOUND@#0#g" >> tmp.sed |
|
527 |
|
else |
|
528 |
|
echo " found." |
|
529 |
|
echo "s#@EPOLL_FOUND@#1#g" >> tmp.sed |
|
530 |
|
fi |
|
531 |
|
|
|
532 |
|
echo -n "[*] Searching for ncurses..." |
|
533 |
|
set +e |
|
534 |
|
echo -e "#include <ncurses.h> \n int main(void) { initscr(); return 0; }" | gcc -x c -pipe - -o /dev/null -lncurses 2>/dev/null |
|
535 |
|
E="${?}" |
|
536 |
|
set -e |
|
537 |
|
if [ "${E}" != "0" ]; then |
|
538 |
|
echo " not found." |
|
539 |
|
echo "s#@NCURSES_FOUND@#0#g" >> tmp.sed |
|
540 |
|
else |
|
541 |
|
echo " found." |
|
542 |
|
echo "s#@NCURSES_FOUND@#1#g" >> tmp.sed |
|
543 |
|
fi |
|
544 |
|
|
|
545 |
|
if [ "${CC_SWITCHES}" = "" ]; then |
|
546 |
|
CC_SWITCHES="-O3 -fstack-reuse=all -flto -Wtrampolines -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-O1 -Wl,-z,noexecstack -fPIE -pie -fstack-protector-all -Wcast-align -Wformat=2 -Wformat-security -fno-common -Wmissing-prototypes -Wmissing-declarations -Wstrict-overflow -Wstrict-prototypes -fno-guess-branch-probability -fbounds-check -Wl,-O3 -Wpadded -ftree-loop-distribution -ftree-vectorize -ftree-loop-if-convert -ftree-loop-im -ftree-parallelize-loops=4 -fcf-protection -fstack-clash-protection -Wimplicit-fallthrough -fanalyzer" |
|
547 |
|
fi |
|
548 |
|
|
|
549 |
|
if [ "1" = "1" ]; then |
|
550 |
|
_CC_SWITCHES="" |
|
551 |
|
echo "[*] Search for valid compiler flags..." |
|
552 |
|
add="" |
|
553 |
|
for s in ${CC_SWITCHES}; do |
|
554 |
|
echo -n " [*] Testing switch [${s}]..." |
|
555 |
|
case ${s} in |
|
556 |
|
-Wformat-security) extra=" -Wformat" ;; |
|
557 |
|
*) extra="" ;; |
|
558 |
|
esac |
|
559 |
|
set +e |
|
560 |
|
echo "int main(void) { return 0; }" \ |
|
561 |
|
| gcc ${extra} ${s} -x c -pipe - -o /dev/null 2>>duilder.log |
|
562 |
|
E=${?} |
|
563 |
|
set -e |
|
564 |
|
if [ "${E}" != "0" ]; then |
|
565 |
|
echo "not supported" |
|
566 |
|
else |
|
567 |
|
echo "supported" |
|
568 |
|
_CC_SWITCHES="${_CC_SWITCHES}${add}${s}" |
|
569 |
|
add=" " |
|
570 |
|
fi |
|
571 |
|
done |
|
572 |
|
fi |
|
573 |
|
|
|
574 |
|
# generic stuff |
|
575 |
|
echo "s#@PRJ@#${PRJ}#g" >> tmp.sed |
|
576 |
|
echo "s#@VER@#${VER}#g" >> tmp.sed |
|
577 |
|
echo "s#@REV@#${REV}#g" >> tmp.sed |
|
578 |
|
echo "s#@ETC@#${ETC}#g" >> tmp.sed |
|
579 |
|
echo "s#@BIN@#${BIN}#g" >> tmp.sed |
|
580 |
|
echo "s#@USR@#${USR}#g" >> tmp.sed |
|
581 |
|
echo "s#@USR_BIN@#${USR_BIN}#g" >> tmp.sed |
|
582 |
|
echo "s#@SBIN@#${SBIN}#g" >> tmp.sed |
|
583 |
|
echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed |
|
584 |
|
echo "s#@VAR@#${VAR}#g" >> tmp.sed |
|
585 |
|
echo "s#@VAR_LIB@#${VAR_LIB}#g" >> tmp.sed |
|
586 |
|
echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed |
|
587 |
|
echo "s#@VAR_RUN@#${VAR_RUN}#g" >> tmp.sed |
|
588 |
|
echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed |
|
589 |
|
echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed |
|
590 |
|
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed |
|
591 |
|
echo "s#@USR_SHARE@#${USR_SHARE}#g" >> tmp.sed |
|
592 |
|
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed |
|
593 |
|
echo "s#@MAN@#${MAN}#g" >> tmp.sed |
|
594 |
|
echo "s#@DUILDER_SYSTEMD@#${DUILDER_SYSTEMD}#g" >> tmp.sed |
|
595 |
|
# Export stuff |
|
596 |
|
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed |
|
597 |
|
# cc_switches |
|
598 |
|
echo "s#@CC_SWITCHES@#${_CC_SWITCHES}#g" >> tmp.sed |
|
599 |
|
echo "s#@MAINTAINER_NAME@#${MAINTAINER_NAME}#g" >> tmp.sed |
|
600 |
|
echo "s#@MAINTAINER_EMAIL@#${MAINTAINER_EMAIL}#g" >> tmp.sed |
|
601 |
|
echo "s#@SHORT_DESCRIPTION@#${SHORT_DESCRIPTION}#g" >> tmp.sed |
|
602 |
|
echo "s#@HOME_PAGE@#${HOME_PAGE}#g" >> tmp.sed |
|
603 |
|
|
|
604 |
|
|
|
605 |
|
|
|
606 |
|
if [ -r Makefile.in ]; then |
|
607 |
|
echo "[*] Building Makefile..." |
|
608 |
|
echo -n > Makefile |
|
609 |
|
echo "# duilder header starts #" >> Makefile |
|
610 |
|
echo "export PRJ := ${PRJ}" >> Makefile |
|
611 |
|
echo "export VER := ${VER}" >> Makefile |
|
612 |
|
echo "export REV := ${REV}" >> Makefile |
|
613 |
|
echo "export DESTDIR" >> Makefile |
|
614 |
|
echo >> Makefile |
|
615 |
|
echo "export I_ETC := \$(DESTDIR)${ETC}" >> Makefile |
|
616 |
|
echo "export I_BIN := \$(DESTDIR)${BIN}" >> Makefile |
|
617 |
|
echo "export I_SBIN := \$(DESTDIR)${SBIN}" >> Makefile |
|
618 |
|
echo "export I_USR := \$(DESTDIR)${USR}" >> Makefile |
|
619 |
|
echo "export I_USR_BIN := \$(DESTDIR)${USR_BIN}" >> Makefile |
|
620 |
|
echo "export I_USR_SBIN := \$(DESTDIR)${USR_SBIN}" >> Makefile |
|
621 |
|
echo "export I_USR_INCLUDE := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
|
622 |
|
echo "export I_USR_INC := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
|
623 |
|
echo "export I_USR_SHARE := \$(DESTDIR)${USR_SHARE}" >> Makefile |
|
624 |
|
echo "export I_USR_SHARE_DOC := \$(DESTDIR)${USR_SHARE_DOC}" >> Makefile |
|
625 |
|
echo "export I_USR_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
|
626 |
|
echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
|
627 |
|
echo "export I_VAR := \$(DESTDIR)${VAR}" >> Makefile |
|
628 |
|
echo "export I_VAR_LIB := \$(DESTDIR)${VAR_LIB}" >> Makefile |
|
629 |
|
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile |
|
630 |
|
echo "export I_VAR_RUN := \$(DESTDIR)${VAR_RUN}" >> Makefile |
|
631 |
|
echo "export I_MAN := \$(DESTDIR)${MAN}" >> Makefile |
|
632 |
|
echo "export I_DUILDER_SYSTEMD := \$(DESTDIR)${DUILDER_SYSTEMD}" >> Makefile |
|
633 |
|
echo >> Makefile |
|
634 |
|
echo "# DB stuff" >> Makefile |
|
635 |
|
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile |
|
636 |
|
echo "# PG" >> Makefile |
|
637 |
|
echo "export PG_FOUND := ${PG_FOUND}" >> Makefile |
|
638 |
|
echo "export PG_INC := ${PG_INC}" >> Makefile |
|
639 |
|
echo "export PG_LIB := ${PG_LIB}" >> Makefile |
|
640 |
|
echo "# MySQL" >> Makefile |
|
641 |
|
echo "export MYSQL_FOUND := ${MYSQL_FOUND}" >> Makefile |
|
642 |
|
echo "export MYSQL_INC := ${MYSQL_INC}" >> Makefile |
|
643 |
|
echo "export MYSQL_LIB := ${MYSQL_LIB}" >> Makefile |
|
644 |
|
echo >> Makefile |
|
645 |
|
echo "# duilder header ends #" >> Makefile |
|
646 |
|
echo >> Makefile |
|
647 |
|
|
|
648 |
|
sed -f tmp.sed Makefile.in >> Makefile |
|
649 |
|
|
|
650 |
|
echo >> Makefile |
|
651 |
|
echo "# duilder tail starts #" >> Makefile |
|
652 |
|
echo >> Makefile |
|
653 |
|
echo "# This is to allow exporting only the git tree" >> Makefile |
|
654 |
|
echo "dist_git:" >> Makefile |
|
655 |
|
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${EXPORT_PATH}\" \"${GIT_CHANGELOG}\" \"${GIT_PUSH}\"" >> Makefile |
|
656 |
|
echo >> Makefile |
|
657 |
|
echo "# This is to allow making the tar" >> Makefile |
|
658 |
|
echo "dist_tar:" >> Makefile |
|
659 |
|
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile |
|
660 |
|
echo >> Makefile |
|
661 |
|
echo "# This is to allow making rpm" >> Makefile |
|
662 |
|
echo "dist_srpm: dist_tar" >> Makefile |
|
663 |
|
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile |
|
664 |
|
echo >> Makefile |
|
665 |
|
echo ".PHONY: dist" >> Makefile |
|
666 |
|
echo "dist: clean" >> Makefile |
|
667 |
|
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${GIT_CHANGELOG}\"" \"${GIT_PUSH}\" >> Makefile |
|
668 |
|
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile |
|
669 |
|
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile |
|
670 |
|
echo " @./duilder sdeb \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SDEB}\" \"${SDEB_DEST}\" \"${SDEB_POST_RUN}\"" >> Makefile |
|
671 |
|
echo " @./duilder docs \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\"" >> Makefile |
|
672 |
|
echo " @./duilder final \"\$(PRJ)\" \"\$(VER)\" \"${RELEASE_SCRIPT}\"" >> Makefile |
|
673 |
|
echo " @rm -f \"\$(PRJ)-\$(VER).tar.gz\"" >> Makefile |
|
674 |
|
echo >> Makefile |
|
675 |
|
fi |
|
676 |
|
|
|
677 |
|
if [ -r "${PRJ}.spec.in" ]; then |
|
678 |
|
echo "[*] Generating .spec file..." |
|
679 |
|
sed -f tmp.sed ${PRJ}.spec.in > ${PRJ}.spec |
|
680 |
|
fi |
|
681 |
|
|
|
682 |
|
if [ ! -z "${CONFIG_H}" ]; then |
|
683 |
|
echo "[*] Generating ${CONFIG_H} file..." |
|
684 |
|
sed -f tmp.sed ${CONFIG_H}.in > ${CONFIG_H} |
|
685 |
|
fi |
|
686 |
|
|
|
687 |
|
if [ "${BUILD_SDEB}" = "1" ]; then |
|
688 |
|
AUTOGENERATE="${AUTOGENERATE} debian/control.in debian/changelog.in" |
|
689 |
|
AUTOGENERATE="${AUTOGENERATE} debian/copyright.in debian/rules.in" |
|
690 |
|
fi |
|
691 |
|
|
|
692 |
|
echo "[*] Autogenerate files from .in..." |
|
693 |
|
for f in ${AUTOGENERATE}; do |
|
694 |
|
if [ -r "${f}" ]; then |
|
695 |
|
dst="${f%.in}" |
|
696 |
|
echo " [*] Autogenerate ${dst} from ${f}..." |
|
697 |
|
sed -f tmp.sed "${f}" > "${dst}" |
|
698 |
|
# We need to have the same rights (maybe is executable...) |
|
699 |
|
chmod --reference="${f}" "${dst}" |
|
700 |
|
fi |
|
701 |
|
done |
|
702 |
|
|
|
703 |
|
rm -f tmp.sed |
|
704 |
|
|
|
705 |
|
if [ "`basename ${0}`" = "duilderx" ]; then |
|
706 |
|
echo "[*] Cloning myself to destination as 'duilder'..." |
|
707 |
|
cp -vpf "${0}" ${PWD}/duilder |
|
708 |
|
fi |
|
709 |
|
|
|
710 |
|
echo "[*] Done. Run make." |