-
Notifications
You must be signed in to change notification settings - Fork 1
/
duilder
executable file
·692 lines (595 loc) · 16.6 KB
/
duilder
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
#!/bin/bash
set -e
function duilder_final()
{
PRJ="${1}"
VER="${2}"
RELEASE_SCRIPT="${3}"
# Run release script
if [ ! -z "${RELEASE_SCRIPT}" -a -x "${RELEASE_SCRIPT}" ]; then
echo "[*] Running ${RELEASE_SCRIPT}..."
${RELEASE_SCRIPT}
fi
}
function duilder_docs()
{
PRJ="${1}"
VER="${2}"
EXPORT_PATH="${3}"
if [ ! -d "${EXPORT_PATH}" ]; then
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..."
mkdir -p "${EXPORT_PATH}"
fi
if [ "${BUILD_SDEB}" = "1" ]; then
if [ -d "debian" ]; then
>debian/docs
fi
fi
echo "[*] Copying docs to [${EXPORT_PATH}]..."
for f in README License LICENSE Changelog Changelog-last TODO FAQ INSTALL AUTHORS samples; do
if [ -r "${f}" ]; then
cp -avp "${f}" "${EXPORT_PATH}/"
if [ "${BUILD_SDEB}" = "1" ]; then
# No need to install the license file
if [ "${f}" = "LICENSE" ]; then
continue
fi
echo "${f}" >> debian/docs
fi
fi
done
echo
if [ -d "screenshot" ]; then
echo "[*] Copying screenshots..."
mkdir -p "${EXPORT_PATH}"
cp -vp screenshot/* "${EXPORT_PATH}/"
echo
fi
}
function duilder_git()
{
PRJ="${1}"
GIT_DEST="${2}"
EXPORT_GIT="${3}"
GIT_CHANGELOG="${4}"
GIT_PUSH="${5}"
if [ ! -x /usr/bin/git ]; then
echo "[*] Warning: Git not found!"
exit 0
fi
if [ ! -d .git ]; then
echo "[*] Warning: I cannot find .git directory!"
exit 0
fi
echo "[*] Testing if a tag is present for HEAD..."
D=`git describe | sed -e 's/^.*-g[0-9a-fA-F]*$//'`
if [ "${D}" = "" ]; then
echo "No annotated tag preset for HEAD! Please add one!"
exit 1
fi
if [ "${EXPORT_GIT}" = "1" ]; then
echo "[*] Generating GIT tree for HTTP transport..."
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then
git clone --bare . "${GIT_DEST}/${PRJ}.git"
# Activate post-update hook
cp "${GIT_DEST}/${PRJ}.git/hooks/post-update.sample" \
"${GIT_DEST}/${PRJ}.git/hooks/post-update"
chmod a+x "${GIT_DEST}/${PRJ}.git/hooks/post-update"
# add project name and description
echo "${PRJ}" > "${GIT_DEST}/${PRJ}.git/description"
# allow export by git daemon?
#touch "${GIT_DEST}/${PRJ}.git/git-daemon-export-ok
else
# --force?
echo "Running git push -v --all \"${GIT_DEST}/${PRJ}.git\"..."
git push -v --all "${GIT_DEST}/${PRJ}.git"
echo "Running git push -v --tags \"${GIT_DEST}/${PRJ}.git\"..."
git push -v --tags "${GIT_DEST}/${PRJ}.git"
fi
(cd "${GIT_DEST}/${PRJ}.git" && git update-server-info)
fi
if [ "${GIT_PUSH}" = "1" ]; then
echo "[*] Git push..."
git push -v --all
fi
if [ "${GIT_CHANGELOG}" = "1" ]; then
echo "[*] Generating Changelog from git..."
echo -n > Changelog
# get the list of tags
number_of_tags=0
git show-ref --tags -d | grep refs/tags/v > duilder.tmp
while read sha1 full_tag; do
tag=`echo ${full_tag} | sed -e 's#refs/tags/##' | cut -d'^' -f1`
tags[${number_of_tags}]=${tag}
tags_commit[${number_of_tags}]=${sha1}
number_of_tags=$[${number_of_tags}+1]
done < duilder.tmp
rm -f duilder.tmp
# get the list of commits, test if is a tag and do the diff
prev=""
add=""
first=1
git log --pretty=oneline | cut -f1 | \
while read commit junk; do
# test if it is a tag
tag=""
i=0
while [ "${i}" -lt "${number_of_tags}" ]; do
if [ "${commit}" = "${tags_commit[${i}]}" ]; then
tag="${tags[${i}]}"
break
fi
i=$[${i}+1]
done
if [ -z "${tag}" ]; then
continue
fi
if [ ! -z "${prev}" ]; then
echo "[*] Generating Changelog from ${tag} -> ${prev}..."
echo -en "${add}" >> Changelog
add="\n"
echo "[${tag} -> ${prev}]" >> Changelog
git shortlog ${tag}..${prev} | \
(IFS=""
while read line; do
echo " ${line}"
done) \
>> Changelog
if [ "${first}" = "1" ]; then
echo "[*] Generating Changelog-last..."
cp Changelog Changelog-last
first=0
fi
fi
prev=${tag}
done
fi
}
function duilder_srpm()
{
PRJ="${1}"
VER="${2}"
EXPORT_PATH="${3}"
BUILD_SRPM="${4}"
SRPM_DEST="${5}"
SRPM_POST_RUN="${6}"
P="${PRJ}-${VER}"
if [ "${BUILD_SRPM}" != "1" ]; then
exit 0
fi
if [ ! -d "${EXPORT_PATH}" ]; then
echo "WARN: ${EXPORT_PATH} does not exists. Creating it..."
mkdir -p "${EXPORT_PATH}"
fi
echo "[*] Building SRPM..."
rpmbuild -ts "${P}.tar.gz"
echo
PKG="${RPMBUILD}/SRPMS/${P}-${REV}.src.rpm"
# Run a rpmlint on it
if [ -x /usr/bin/rpmlint ]; then
echo "[*] RPMlinting..."
rpmlint -iv "${PKG}" > rpmlint.out
else
echo "[*] WARN: rpmlint is missing!"
fi
if [ ! -z "${SRPM_DEST}" ]; then
echo "[*] Copying [${PKG}] to [${SRPM_DEST}]..."
cp -vp "${PKG}" "${SRPM_DEST}/"
fi
echo "[*] Copying to export dir [${EXPORT_PATH}]..."
mkdir -p "${EXPORT_PATH}"
cp -vp "${PKG}" "${EXPORT_PATH}/"
echo
if [ -x "${SRPM_POST_RUN}" ]; then
echo "[*] Running post SRPM build script [${SRPM_POST_RUN}]..."
${SRPM_POST_RUN} "${PKG}"
fi
}
function duilder_sdeb()
{
PRJ="${1}"
VER="${2}"
EXPORT_PATH="${3}"
BUILD_SDEB="${4}"
SDEB_DEST="${5}"
SDEB_POST_RUN="${6}"
P="${PRJ}-${VER}"
if [ "${BUILD_SDEB}" != "1" ]; then
exit 0
fi
if [ ! -d "${EXPORT_PATH}" ]; then
echo "WARN: ${EXPORT_PATH} does not exists. Creating it..."
mkdir -p "${EXPORT_PATH}"
fi
echo "[*] Copying SDEB..."
PKG="${PRJ}_${VER}.orig.tar.gz"
if [ -n "${SDEB_DEST}" ]; then
cp -vp "${P}.tar.gz" "${SDEB_DEST}/${PKG}"
fi
echo "[*] Copying to export dir [${DEB_EXPORT_PATH}]..."
mkdir -p "${EXPORT_PATH}"
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/${PKG}"
echo
if [ -x "${SDEB_POST_RUN}" ]; then
echo "[*] Running post SDEB build script [${SDEB_POST_RUN}]..."
${SDEB_POST_RUN} "${SDEB}/${PKG}"
fi
}
function duilder_tar()
{
PRJ="${1}"
VER="${2}"
EXPORT_PATH="${3}"
EXCLUDE="${4}"
P="${PRJ}-${VER}"
if [ ! -d "${EXPORT_PATH}" ]; then
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..."
mkdir -p "${EXPORT_PATH}"
fi
echo "[*] Generating tarball [${P}.tar.gz]..."
ADD_EXCLUDE=""
if [ -r "${EXCLUDE}" ]; then
ADD_EXCLUDE="--exclude-from ${P}/${EXCLUDE}"
echo "[*] ADD_EXCLUDE=${ADD_EXCLUDE}"
fi
(cd .. \
&& rm -rf "${P}" \
&& cp -a --link "${PRJ}" "${P}" \
&& tar czf "${PRJ}/${P}.tar.gz" \
--exclude-vcs \
--exclude ${P}/Makefile \
${ADD_EXCLUDE} \
"${P}" \
&& rm -rf "${P}"
)
echo "[*] Copying source to ${EXPORT_PATH}..."
mkdir -p "${EXPORT_PATH}"
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/"
echo
}
####################################################################
# Variables
if [ -d "${HOME}/rpmbuild" ]; then
RPMBUILD="${HOME}/rpmbuild"
else
RPMBUILD="/usr/src/redhat"
fi
if [ ! -r duilder.conf ]; then
echo "[*] You must build a duilder.conf file!"
exit 1
fi
source ${PWD}/duilder.conf
# fixes
if [ -z "${GIT_DEST}" ]; then
GIT_DEST="${EXPORT_PATH}"
fi
if [ -z "${PRJ}" ]; then
echo "ERROR: PRJ= parameter is missing."
exit 1
fi
if [ -z "${VER}" ]; then
echo "ERROR: VER= parameter is missing."
exit 1
fi
if [ -z "${REV}" ]; then
echo "ERROR: REV= parameter is missing."
exit 1
fi
# export variables - just in case a script cares
export PRJ VER REV SHORT_DESCRIPTION EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST
export SRPM_DEST SDEB_DEST LICENSE MAINTAINER_NAME MAINTAINER_EMAIL
export HOME_PAGE BUILD_SRPM BUILD_SDEB
# Multiplexer
if [ "${1}" = "docs" ]; then
shift
duilder_docs "$@"
exit $?
fi
if [ "${1}" = "tar" ]; then
shift
duilder_tar "$@"
exit $?
fi
if [ "${1}" = "git" ]; then
shift
duilder_git "$@"
exit $?
fi
if [ "${1}" = "srpm" ]; then
shift
duilder_srpm "$@"
exit $?
fi
if [ "${1}" = "sdeb" ]; then
shift
duilder_sdeb "$@"
exit $?
fi
if [ "${1}" = "final" ]; then
shift
duilder_final "$@"
exit $?
fi
###### Main stuff
echo "[*] Duilder builder script"
echo "[*] Copyright Catalin(ux) M. BOIE - catab at embedromix dot ro"
echo "[*] PRJ=${PRJ}, VER=${VER}, REV=${REV}"
echo "[*] System: `uname -a`"
echo "[*] Parameters: ${@}"
ETC="/etc"
BIN="/bin"
USR="/usr"
USR_BIN="/usr/bin"
USR_SBIN="/usr/sbin"
USR_INCLUDE="/usr/include"
if [ "`uname -m`" = "i686" ]; then
USR_LIB="/usr/lib"
else
USR_LIB="/usr/lib64"
fi
USR_SHARE="/usr/share"
USR_SHARE_DOC="/usr/share/doc/${PRJ}"
SBIN="/usr/sbin"
VAR="/var"
VAR_LIB="/var/lib"
MAN="/usr/share/man"
PREFIX="/usr"
while [ "${1}" != "" ]; do
xVAR="`echo ${1} | cut -d'=' -f1`"
xVAL="`echo ${1} | cut -d'=' -f2 | sed -e "s|\\${prefix}|${PREFIX}|"`"
shift
case ${xVAR} in
--sysconfdir)
ETC="${xVAL}"
;;
--bindir)
USR_BIN="${xVAL}"
;;
--sbindir)
USR_SBIN="${xVAL}"
;;
--includedir)
USR_INCLUDE="${xVAL}"
;;
--libdir)
USR_LIB="${xVAL}"
;;
--localstatedir)
VAR="${xVAL}"
;;
--sharedstatedir)
VAR_LIB="${xVAL}"
;;
--datadir)
USR_SHARE="${xVAL}"
;;
--mandir)
MAN="${xVAL}"
;;
--prefix)
PREFIX="${xVAL}"
USR="${xVAL}"
;;
esac
done
# Last fixes
VAR_LOG="${VAR}/log"
VAR_RUN="${VAR}/run"
DUILDER_SYSTEMD="${USR}/lib/systemd"
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
eval value=\$$i
echo "[*] Var ${i}=${value}"
done
# Truncate future sed file
> tmp.sed
DB_SUPPORT=0
echo -n "[*] Searching for PostgreSQL..."
set +e
PG_VERSION="`pg_config --version 2>/dev/null`"
set -e
if [ -z "${PG_VERSION}" ]; then
echo " not found."
PG_FOUND=0
else
echo " found version ${PG_VERSION}."
PG_FOUND=1
PG_INC="-I`pg_config --includedir`"
PG_LIB="-L`pg_config --libdir` -lpq"
echo "s#@PG_VERSION@#${PG_VERSION}#g" >> tmp.sed
echo "s#@PG_INC@#${PG_INC}#g" >> tmp.sed
echo "s#@PG_LIB@#${PG_LIB}#g" >> tmp.sed
DB_SUPPORT=1
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed
fi
echo "s#@PG_FOUND@#${PG_FOUND}#g" >> tmp.sed
echo -n "[*] Searching for MySQL..."
set +e
MYSQL_VERSION="`mysql_config --version 2>/dev/null`"
set -e
if [ -z "${MYSQL_VERSION}" ]; then
echo " not found."
MYSQL_FOUND=0
else
echo " found version ${MYSQL_VERSION}."
MYSQL_FOUND=1
MYSQL_INC="`mysql_config --include`"
MYSQL_LIB="`mysql_config --libs`"
echo "s#@MYSQL_VERSION@#${MYSQL_VERSION}#g" >> tmp.sed
echo "s#@MYSQL_INC@#${MYSQL_INC}#g" >> tmp.sed
echo "s#@MYSQL_LIB@#${MYSQL_LIB}#g" >> tmp.sed
DB_SUPPORT=1
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed
fi
echo "s#@MYSQL_FOUND@#${MYSQL_FOUND}#g" >> tmp.sed
echo -n "[*] Searching for poll..."
set +e
echo -e "#include <poll.h> \n int main(void) { return poll(0, 0, 0); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null
E="${?}"
set -e
if [ "${E}" != "0" ]; then
echo " not found."
echo "s#@POLL_FOUND@#0#g" >> tmp.sed
else
echo " found."
echo "s#@POLL_FOUND@#1#g" >> tmp.sed
fi
echo -n "[*] Searching for epoll..."
set +e
echo -e "#include <sys/epoll.h> \n int main(void) { return epoll_create(64); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null
E="${?}"
set -e
if [ "${E}" != "0" ]; then
echo " not found."
echo "s#@EPOLL_FOUND@#0#g" >> tmp.sed
else
echo " found."
echo "s#@EPOLL_FOUND@#1#g" >> tmp.sed
fi
echo -n "[*] Searching for ncurses..."
set +e
echo -e "#include <ncurses.h> \n int main(void) { initscr(); return 0; }" | gcc -x c -pipe - -o /dev/null -lncurses 2>/dev/null
E="${?}"
set -e
if [ "${E}" != "0" ]; then
echo " not found."
echo "s#@NCURSES_FOUND@#0#g" >> tmp.sed
else
echo " found."
echo "s#@NCURSES_FOUND@#1#g" >> tmp.sed
fi
if [ -n "${CC_SWITCHES}" ]; then
_CC_SWITCHES=""
echo "[*] Search for valid compiler flags..."
add=""
for s in ${CC_SWITCHES}; do
echo -n " [*] Testing switch [${s}]..."
set +e
echo "int main(void) { return 0; }" | gcc ${s} -x c -pipe - -o /dev/null 2>/dev/null
E=${?}
set -e
if [ "${E}" != "0" ]; then
echo "not supported"
else
echo "supported"
_CC_SWITCHES="${_CC_SWITCHES}${add}${s}"
add=" "
fi
done
fi
# generic stuff
echo "s#@PRJ@#${PRJ}#g" >> tmp.sed
echo "s#@VER@#${VER}#g" >> tmp.sed
echo "s#@REV@#${REV}#g" >> tmp.sed
echo "s#@ETC@#${ETC}#g" >> tmp.sed
echo "s#@BIN@#${BIN}#g" >> tmp.sed
echo "s#@USR@#${USR}#g" >> tmp.sed
echo "s#@USR_BIN@#${USR_BIN}#g" >> tmp.sed
echo "s#@SBIN@#${SBIN}#g" >> tmp.sed
echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed
echo "s#@VAR@#${VAR}#g" >> tmp.sed
echo "s#@VAR_LIB@#${VAR_LIB}#g" >> tmp.sed
echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed
echo "s#@VAR_RUN@#${VAR_RUN}#g" >> tmp.sed
echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed
echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed
echo "s#@USR_SHARE@#${USR_SHARE}#g" >> tmp.sed
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed
echo "s#@MAN@#${MAN}#g" >> tmp.sed
echo "s#@DUILDER_SYSTEMD@#${DUILDER_SYSTEMD}#g" >> tmp.sed
# Export stuff
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed
# cc_switches
echo "s#@CC_SWITCHES@#${_CC_SWITCHES}#g" >> tmp.sed
echo "s#@MAINTAINER_NAME@#${MAINTAINER_NAME}#g" >> tmp.sed
echo "s#@MAINTAINER_EMAIL@#${MAINTAINER_EMAIL}#g" >> tmp.sed
echo "s#@SHORT_DESCRIPTION@#${SHORT_DESCRIPTION}#g" >> tmp.sed
echo "s#@HOME_PAGE@#${HOME_PAGE}#g" >> tmp.sed
if [ -r Makefile.in ]; then
echo "[*] Building Makefile..."
echo -n > Makefile
echo "# duilder header starts #" >> Makefile
echo "export PRJ := ${PRJ}" >> Makefile
echo "export VER := ${VER}" >> Makefile
echo "export REV := ${REV}" >> Makefile
echo "export DESTDIR" >> Makefile
echo >> Makefile
echo "export I_ETC := \$(DESTDIR)${ETC}" >> Makefile
echo "export I_BIN := \$(DESTDIR)${BIN}" >> Makefile
echo "export I_SBIN := \$(DESTDIR)${SBIN}" >> Makefile
echo "export I_USR := \$(DESTDIR)${USR}" >> Makefile
echo "export I_USR_BIN := \$(DESTDIR)${USR_BIN}" >> Makefile
echo "export I_USR_SBIN := \$(DESTDIR)${USR_SBIN}" >> Makefile
echo "export I_USR_INCLUDE := \$(DESTDIR)${USR_INCLUDE}" >> Makefile
echo "export I_USR_INC := \$(DESTDIR)${USR_INCLUDE}" >> Makefile
echo "export I_USR_SHARE := \$(DESTDIR)${USR_SHARE}" >> Makefile
echo "export I_USR_SHARE_DOC := \$(DESTDIR)${USR_SHARE_DOC}" >> Makefile
echo "export I_USR_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile
echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile
echo "export I_VAR := \$(DESTDIR)${VAR}" >> Makefile
echo "export I_VAR_LIB := \$(DESTDIR)${VAR_LIB}" >> Makefile
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile
echo "export I_VAR_RUN := \$(DESTDIR)${VAR_RUN}" >> Makefile
echo "export I_MAN := \$(DESTDIR)${MAN}" >> Makefile
echo "export I_DUILDER_SYSTEMD := \$(DESTDIR)${DUILDER_SYSTEMD}" >> Makefile
echo >> Makefile
echo "# DB stuff" >> Makefile
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile
echo "# PG" >> Makefile
echo "export PG_FOUND := ${PG_FOUND}" >> Makefile
echo "export PG_INC := ${PG_INC}" >> Makefile
echo "export PG_LIB := ${PG_LIB}" >> Makefile
echo "# MySQL" >> Makefile
echo "export MYSQL_FOUND := ${MYSQL_FOUND}" >> Makefile
echo "export MYSQL_INC := ${MYSQL_INC}" >> Makefile
echo "export MYSQL_LIB := ${MYSQL_LIB}" >> Makefile
echo >> Makefile
echo "# duilder header ends #" >> Makefile
echo >> Makefile
sed -f tmp.sed Makefile.in >> Makefile
echo >> Makefile
echo "# duilder tail starts #" >> Makefile
echo >> Makefile
echo "# This is to allow exporting only the git tree" >> Makefile
echo "dist_git:" >> Makefile
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${EXPORT_PATH}\" \"${GIT_CHANGELOG}\"" >> Makefile
echo >> Makefile
echo ".PHONY: dist" >> Makefile
echo "dist: clean" >> Makefile
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${GIT_CHANGELOG}\"" \"${GIT_PUSH}\" >> Makefile
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile
echo " @./duilder sdeb \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SDEB}\" \"${SDEB_DEST}\" \"${SDEB_POST_RUN}\"" >> Makefile
echo " @./duilder docs \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\"" >> Makefile
echo " @./duilder final \"\$(PRJ)\" \"\$(VER)\" \"${RELEASE_SCRIPT}\"" >> Makefile
echo " @rm -f \"\$(PRJ)-\$(VER).tar.gz\"" >> Makefile
echo >> Makefile
fi
if [ -r "${PRJ}.spec.in" ]; then
echo "[*] Generating .spec file..."
sed -f tmp.sed ${PRJ}.spec.in > ${PRJ}.spec
fi
if [ ! -z "${CONFIG_H}" ]; then
echo "[*] Generating ${CONFIG_H} file..."
sed -f tmp.sed ${CONFIG_H}.in > ${CONFIG_H}
fi
if [ "${BUILD_SDEB}" = "1" ]; then
AUTOGENERATE="${AUTOGENERATE} debian/control.in debian/changelog.in"
AUTOGENERATE="${AUTOGENERATE} debian/copyright.in debian/rules.in"
fi
echo "[*] Autogenerate files from .in..."
for f in ${AUTOGENERATE}; do
if [ -r "${f}" ]; then
dst="${f%.in}"
echo " [*] Autogenerate ${dst} from ${f}..."
sed -f tmp.sed "${f}" > "${dst}"
# We need to have the same rights (maybe is executable...)
chmod --reference="${f}" "${dst}"
fi
done
rm -f tmp.sed
if [ "`basename ${0}`" = "duilderx" ]; then
echo "[*] Cloning myself to destination as 'duilder'..."
cp -vpf "${0}" ${PWD}/duilder
fi
echo "[*] Done. Run make."