File duilder changed (mode: 100755) (index d6c2add..c93b35d) |
1 |
1 |
#!/bin/bash |
#!/bin/bash |
2 |
2 |
|
|
3 |
|
function git_last_changelog() |
|
4 |
|
{ |
|
5 |
|
changelog="" |
|
6 |
|
|
|
7 |
|
# get the list of tags |
|
8 |
|
i=0 |
|
9 |
|
number_of_tags=0 |
|
10 |
|
for tag in `git tag -l`; do |
|
11 |
|
if [ "${tag:0:1}" != "v" ]; then |
|
12 |
|
# skip other kind of tags beside versions |
|
13 |
|
continue |
|
14 |
|
fi |
|
15 |
|
|
|
16 |
|
tags[${i}]=${tag} |
|
17 |
|
tags_commit[${i}]=`git show-ref ${tag} | cut -d' ' -f1` |
|
18 |
|
number_of_tags=$[${number_of_tags}+1] |
|
19 |
|
|
|
20 |
|
i=$[${i}+1] |
|
21 |
|
done |
|
22 |
|
|
|
23 |
|
# get the list of commits, test if is a tag and do the diff |
|
24 |
|
prev="" |
|
25 |
|
git log --pretty=oneline | cut -f1 | \ |
|
26 |
|
while read commit junk; do |
|
27 |
|
# test if it is a tag |
|
28 |
|
tag="" |
|
29 |
|
i=0 |
|
30 |
|
while [ "${i}" -lt "${number_of_tags}" ]; do |
|
31 |
|
if [ "${commit}" = "${tags_commit[${i}]}" ]; then |
|
32 |
|
tag="${tags[${i}]}" |
|
33 |
|
break |
|
34 |
|
fi |
|
35 |
|
|
|
36 |
|
i=$[${i}+1] |
|
37 |
|
done |
|
38 |
|
|
|
39 |
|
if [ -z "${tag}" ]; then |
|
40 |
|
continue |
|
41 |
|
fi |
|
42 |
|
|
|
43 |
|
if [ ! -z "${prev}" ]; then |
|
44 |
|
current=${tag} |
|
45 |
|
git shortlog ${current}..${prev} | \ |
|
46 |
|
(IFS="" |
|
47 |
|
while read line; do |
|
48 |
|
echo " ${line}" |
|
49 |
|
done) |
|
50 |
|
echo |
|
51 |
|
break |
|
52 |
|
fi |
|
53 |
|
prev=${tag} |
|
54 |
|
done |
|
55 |
|
} |
|
|
3 |
|
set -e |
56 |
4 |
|
|
57 |
5 |
function duilder_final() |
function duilder_final() |
58 |
6 |
{ |
{ |
|
... |
... |
function duilder_final() |
62 |
10 |
|
|
63 |
11 |
# Run release script |
# Run release script |
64 |
12 |
if [ ! -z "${RELEASE_SCRIPT}" -a -x "${RELEASE_SCRIPT}" ]; then |
if [ ! -z "${RELEASE_SCRIPT}" -a -x "${RELEASE_SCRIPT}" ]; then |
65 |
|
echo "Running ${RELEASE_SCRIPT}..." |
|
66 |
|
export CHANGELOG=`git_last_changelog` |
|
|
13 |
|
echo "[*] Running ${RELEASE_SCRIPT}..." |
67 |
14 |
${RELEASE_SCRIPT} |
${RELEASE_SCRIPT} |
68 |
15 |
fi |
fi |
69 |
16 |
} |
} |
|
... |
... |
function duilder_docs() |
75 |
22 |
EXPORT_PATH="${3}" |
EXPORT_PATH="${3}" |
76 |
23 |
|
|
77 |
24 |
if [ ! -d "${EXPORT_PATH}" ]; then |
if [ ! -d "${EXPORT_PATH}" ]; then |
78 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Skipping..." |
|
79 |
|
return |
|
|
25 |
|
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
26 |
|
mkdir -p "${EXPORT_PATH}" |
80 |
27 |
fi |
fi |
81 |
28 |
|
|
82 |
|
echo "Copying docs to [${EXPORT_PATH}]..." |
|
83 |
|
for f in README License LICENSE Changelog TODO FAQ INSTALL; do |
|
|
29 |
|
echo "[*] Copying docs to [${EXPORT_PATH}]..." |
|
30 |
|
for f in README License LICENSE Changelog Changelog-last TODO FAQ INSTALL AUTHORS; do |
84 |
31 |
if [ -r "${f}" ]; then |
if [ -r "${f}" ]; then |
85 |
32 |
cp -vp "${f}" "${EXPORT_PATH}/" |
cp -vp "${f}" "${EXPORT_PATH}/" |
86 |
33 |
fi |
fi |
87 |
34 |
done |
done |
|
35 |
|
echo |
88 |
36 |
|
|
89 |
37 |
if [ -d "screenshot" ]; then |
if [ -d "screenshot" ]; then |
90 |
|
echo "Copying screenshots..." |
|
|
38 |
|
echo "[*] Copying screenshots..." |
91 |
39 |
mkdir -p "${EXPORT_PATH}" |
mkdir -p "${EXPORT_PATH}" |
92 |
40 |
cp -vp screenshot/* "${EXPORT_PATH}/" |
cp -vp screenshot/* "${EXPORT_PATH}/" |
|
41 |
|
echo |
93 |
42 |
fi |
fi |
94 |
43 |
} |
} |
95 |
44 |
|
|
|
... |
... |
function duilder_git() |
102 |
51 |
GIT_PUSH="${5}" |
GIT_PUSH="${5}" |
103 |
52 |
|
|
104 |
53 |
if [ ! -x /usr/bin/git ]; then |
if [ ! -x /usr/bin/git ]; then |
105 |
|
echo "Warning: Git not found!" |
|
|
54 |
|
echo "[*] Warning: Git not found!" |
106 |
55 |
exit 0 |
exit 0 |
107 |
56 |
fi |
fi |
108 |
57 |
|
|
109 |
58 |
if [ ! -d .git ]; then |
if [ ! -d .git ]; then |
110 |
|
echo "Warning: I cannot find .git directory!" |
|
|
59 |
|
echo "[*] Warning: I cannot find .git directory!" |
111 |
60 |
exit 0 |
exit 0 |
112 |
61 |
fi |
fi |
113 |
62 |
|
|
|
63 |
|
echo "[*] Testing if a tag is present for HEAD..." |
|
64 |
|
D=`git describe | sed -e 's/^.*-g[0-9a-fA-F]*$//'` |
|
65 |
|
if [ "${D}" = "" ]; then |
|
66 |
|
echo "No annotated tag preset for HEAD! Please add one!" |
|
67 |
|
exit 1 |
|
68 |
|
fi |
|
69 |
|
|
114 |
70 |
if [ "${EXPORT_GIT}" = "1" ]; then |
if [ "${EXPORT_GIT}" = "1" ]; then |
115 |
|
echo "Generate GIT tree for HTTP transport..." |
|
|
71 |
|
echo "[*] Generating GIT tree for HTTP transport..." |
116 |
72 |
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then |
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then |
117 |
73 |
git clone --bare . "${GIT_DEST}/${PRJ}.git" |
git clone --bare . "${GIT_DEST}/${PRJ}.git" |
118 |
74 |
|
|
|
... |
... |
function duilder_git() |
146 |
102 |
echo -n > Changelog |
echo -n > Changelog |
147 |
103 |
|
|
148 |
104 |
# get the list of tags |
# get the list of tags |
149 |
|
i=0 |
|
150 |
105 |
number_of_tags=0 |
number_of_tags=0 |
151 |
|
for tag in `git tag -l`; do |
|
152 |
|
if [ "${tag:0:1}" != "v" ]; then |
|
153 |
|
# skip other kind of tags beside versions |
|
154 |
|
continue |
|
155 |
|
fi |
|
156 |
|
|
|
157 |
|
tags[${i}]=${tag} |
|
158 |
|
tags_commit[${i}]=`git show-ref ${tag} | cut -d' ' -f1` |
|
|
106 |
|
while read sha1 full_tag; do |
|
107 |
|
tag=`echo ${full_tag} | sed -e 's#refs/tags/##' | cut -d'^' -f1` |
|
108 |
|
tags[${number_of_tags}]=${tag} |
|
109 |
|
tags_commit[${number_of_tags}]=${sha1} |
159 |
110 |
number_of_tags=$[${number_of_tags}+1] |
number_of_tags=$[${number_of_tags}+1] |
160 |
|
|
|
161 |
|
i=$[${i}+1] |
|
162 |
|
done |
|
|
111 |
|
done < <(git show-ref --tags -d | grep refs/tags/v) |
163 |
112 |
|
|
164 |
113 |
# get the list of commits, test if is a tag and do the diff |
# get the list of commits, test if is a tag and do the diff |
165 |
114 |
prev="" |
prev="" |
|
115 |
|
add="" |
|
116 |
|
first=1 |
166 |
117 |
git log --pretty=oneline | cut -f1 | \ |
git log --pretty=oneline | cut -f1 | \ |
167 |
118 |
while read commit junk; do |
while read commit junk; do |
168 |
119 |
# test if it is a tag |
# test if it is a tag |
|
... |
... |
function duilder_git() |
183 |
134 |
|
|
184 |
135 |
if [ ! -z "${prev}" ]; then |
if [ ! -z "${prev}" ]; then |
185 |
136 |
echo "[*] Generating Changelog from ${tag} -> ${prev}..." |
echo "[*] Generating Changelog from ${tag} -> ${prev}..." |
|
137 |
|
echo -en "${add}" >> Changelog |
|
138 |
|
add="\n" |
186 |
139 |
echo "[${tag} -> ${prev}]" >> Changelog |
echo "[${tag} -> ${prev}]" >> Changelog |
187 |
|
echo >> Changelog |
|
188 |
140 |
git shortlog ${tag}..${prev} | \ |
git shortlog ${tag}..${prev} | \ |
189 |
141 |
(IFS="" |
(IFS="" |
190 |
142 |
while read line; do |
while read line; do |
191 |
143 |
echo " ${line}" |
echo " ${line}" |
192 |
144 |
done) \ |
done) \ |
193 |
145 |
>> Changelog |
>> Changelog |
194 |
|
echo >> Changelog |
|
|
146 |
|
|
|
147 |
|
if [ "${first}" = "1" ]; then |
|
148 |
|
echo "[*] Generating Changelog-last..." |
|
149 |
|
cp Changelog Changelog-last |
|
150 |
|
first=0 |
|
151 |
|
fi |
195 |
152 |
fi |
fi |
196 |
153 |
prev=${tag} |
prev=${tag} |
197 |
154 |
done |
done |
|
... |
... |
function duilder_srpm() |
209 |
166 |
|
|
210 |
167 |
P="${PRJ}-${VER}" |
P="${PRJ}-${VER}" |
211 |
168 |
|
|
212 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
213 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Skipping..." |
|
214 |
|
return |
|
215 |
|
fi |
|
216 |
|
|
|
217 |
169 |
if [ "${BUILD_SRPM}" != "1" ]; then |
if [ "${BUILD_SRPM}" != "1" ]; then |
218 |
170 |
exit 0 |
exit 0 |
219 |
171 |
fi |
fi |
220 |
172 |
|
|
221 |
|
echo "Building SRPM..." |
|
|
173 |
|
if [ ! -d "${EXPORT_PATH}" ]; then |
|
174 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
175 |
|
mkdir -p "${EXPORT_PATH}" |
|
176 |
|
fi |
|
177 |
|
|
|
178 |
|
echo "[*] Building SRPM..." |
222 |
179 |
rpmbuild -ts "${P}.tar.gz" |
rpmbuild -ts "${P}.tar.gz" |
|
180 |
|
echo |
223 |
181 |
|
|
224 |
|
PKG="${RPMBUILD}/SRPMS/${P}-1.src.rpm" |
|
|
182 |
|
PKG="${RPMBUILD}/SRPMS/${P}-${REV}.src.rpm" |
225 |
183 |
|
|
226 |
184 |
# Run a rpmlint on it |
# Run a rpmlint on it |
227 |
185 |
if [ -x /usr/bin/rpmlint ]; then |
if [ -x /usr/bin/rpmlint ]; then |
228 |
186 |
echo "[*] RPMlinting..." |
echo "[*] RPMlinting..." |
229 |
187 |
rpmlint -iv "${PKG}" > rpmlint.out |
rpmlint -iv "${PKG}" > rpmlint.out |
|
188 |
|
else |
|
189 |
|
echo "[*] WARN: rpmlint is missing!" |
230 |
190 |
fi |
fi |
231 |
191 |
|
|
232 |
192 |
if [ ! -z "${SRPM_DEST}" ]; then |
if [ ! -z "${SRPM_DEST}" ]; then |
233 |
|
echo "Copying [${PKG}] to [${SRPM_DEST}]..." |
|
|
193 |
|
echo "[*] Copying [${PKG}] to [${SRPM_DEST}]..." |
234 |
194 |
cp -vp "${PKG}" "${SRPM_DEST}/" |
cp -vp "${PKG}" "${SRPM_DEST}/" |
|
195 |
|
echo |
235 |
196 |
fi |
fi |
236 |
197 |
|
|
237 |
|
echo "Copying to export dir [${EXPORT_PATH}]..." |
|
|
198 |
|
echo "[*] Copying to export dir [${EXPORT_PATH}]..." |
238 |
199 |
mkdir -p "${EXPORT_PATH}" |
mkdir -p "${EXPORT_PATH}" |
239 |
200 |
cp -vp "${PKG}" "${EXPORT_PATH}/" |
cp -vp "${PKG}" "${EXPORT_PATH}/" |
|
201 |
|
echo |
240 |
202 |
|
|
241 |
203 |
if [ -x "${SRPM_POST_RUN}" ]; then |
if [ -x "${SRPM_POST_RUN}" ]; then |
242 |
|
echo "Running post SRPM build script [${SRPM_POST_RUN}]..." |
|
|
204 |
|
echo "[*] Running post SRPM build script [${SRPM_POST_RUN}]..." |
243 |
205 |
${SRPM_POST_RUN} "${PKG}" |
${SRPM_POST_RUN} "${PKG}" |
244 |
206 |
fi |
fi |
245 |
207 |
} |
} |
246 |
208 |
|
|
|
209 |
|
function duilder_sdeb() |
|
210 |
|
{ |
|
211 |
|
PRJ="${1}" |
|
212 |
|
VER="${2}" |
|
213 |
|
SDEB_EXPORT_PATH="${3}" |
|
214 |
|
BUILD_SDEB="${4}" |
|
215 |
|
SDEB_DEST="${5}" |
|
216 |
|
SDEB_POST_RUN="${6}" |
|
217 |
|
|
|
218 |
|
P="${PRJ}-${VER}" |
|
219 |
|
|
|
220 |
|
if [ "${BUILD_SDEB}" != "1" ]; then |
|
221 |
|
exit 0 |
|
222 |
|
fi |
|
223 |
|
|
|
224 |
|
if [ ! -d "${SDEB_EXPORT_PATH}" ]; then |
|
225 |
|
echo "WARN: ${SDEB_EXPORT_PATH} does not exists. Creating it..." |
|
226 |
|
mkdir -p "${SDEB_EXPORT_PATH}" |
|
227 |
|
fi |
|
228 |
|
|
|
229 |
|
echo "[*] Building SDEB..." |
|
230 |
|
tmp=`mktemp -d duilder-XXXXXXXXXXXXXXX` |
|
231 |
|
ln ${P}.tar.gz "${tmp}/${PRJ}_${VER}.orig.tar.gz" |
|
232 |
|
mkdir "${tmp}/debian" |
|
233 |
|
touch "${tmp}/debian/changelog" |
|
234 |
|
# control |
|
235 |
|
echo "Source: ${PRJ}" > "${tmp}/debian/control" |
|
236 |
|
echo "Maintainer: ???" >> "${tmp}/debian/control" |
|
237 |
|
echo "Section: misc" >> "${tmp}/debian/control" |
|
238 |
|
echo "Priority: optional" >> "${tmp}/debian/control" |
|
239 |
|
|
|
240 |
|
PKG="${RPMBUILD}/SRPMS/${P}-${REV}.src.rpm" |
|
241 |
|
|
|
242 |
|
if [ ! -z "${SDEB_DEST}" ]; then |
|
243 |
|
echo "[*] Copying [${PKG}] to [${SDEB_DEST}]..." |
|
244 |
|
cp -vp "${PKG}" "${SDEB_DEST}/" |
|
245 |
|
echo |
|
246 |
|
fi |
|
247 |
|
|
|
248 |
|
echo "[*] Copying to export dir [${DEB_EXPORT_PATH}]..." |
|
249 |
|
mkdir -p "${SDEB_EXPORT_PATH}" |
|
250 |
|
cp -vp "${PKG}" "${SDEB_EXPORT_PATH}/" |
|
251 |
|
echo |
|
252 |
|
|
|
253 |
|
if [ -x "${SDEB_POST_RUN}" ]; then |
|
254 |
|
echo "[*] Running post SDEB build script [${SDEB_POST_RUN}]..." |
|
255 |
|
${SDEB_POST_RUN} "${PKG}" |
|
256 |
|
fi |
|
257 |
|
} |
|
258 |
|
|
247 |
259 |
function duilder_tar() |
function duilder_tar() |
248 |
260 |
{ |
{ |
249 |
261 |
PRJ="${1}" |
PRJ="${1}" |
|
... |
... |
function duilder_tar() |
254 |
266 |
P="${PRJ}-${VER}" |
P="${PRJ}-${VER}" |
255 |
267 |
|
|
256 |
268 |
if [ ! -d "${EXPORT_PATH}" ]; then |
if [ ! -d "${EXPORT_PATH}" ]; then |
257 |
|
echo "WARN: ${EXPORT_PATH} does not exists. Skipping..." |
|
258 |
|
return |
|
|
269 |
|
echo "[*] WARN: ${EXPORT_PATH} does not exists. Creating it..." |
|
270 |
|
mkdir -p "${EXPORT_PATH}" |
259 |
271 |
fi |
fi |
260 |
272 |
|
|
261 |
|
echo "Generating tarball [${P}.tar.gz]..." |
|
|
273 |
|
echo "[*] Generating tarball [${P}.tar.gz]..." |
262 |
274 |
ADD_EXCLUDE="" |
ADD_EXCLUDE="" |
263 |
275 |
if [ ! -z "${EXCLUDE}" ]; then |
if [ ! -z "${EXCLUDE}" ]; then |
264 |
276 |
ADD_EXCLUDE="--exclude-from ${P}/${EXCLUDE}" |
ADD_EXCLUDE="--exclude-from ${P}/${EXCLUDE}" |
|
277 |
|
echo "[*] ADD_EXCLUDE=${ADD_EXCLUDE}" |
265 |
278 |
fi |
fi |
266 |
279 |
|
|
267 |
280 |
(cd .. \ |
(cd .. \ |
|
... |
... |
function duilder_tar() |
275 |
288 |
&& rm -rf "${P}" |
&& rm -rf "${P}" |
276 |
289 |
) |
) |
277 |
290 |
|
|
278 |
|
echo "Copying source to ${EXPORT_PATH}/..." |
|
|
291 |
|
echo "[*] Copying source to ${EXPORT_PATH}..." |
279 |
292 |
mkdir -p "${EXPORT_PATH}" |
mkdir -p "${EXPORT_PATH}" |
280 |
293 |
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/" |
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/" |
|
294 |
|
echo |
281 |
295 |
} |
} |
282 |
296 |
|
|
283 |
297 |
#################################################################### |
#################################################################### |
|
... |
... |
else |
290 |
304 |
fi |
fi |
291 |
305 |
|
|
292 |
306 |
|
|
|
307 |
|
if [ ! -r duilder.conf ]; then |
|
308 |
|
echo "[*] You must build a duilder.conf file!" |
|
309 |
|
exit 1 |
|
310 |
|
fi |
|
311 |
|
|
|
312 |
|
source ${PWD}/duilder.conf |
|
313 |
|
|
|
314 |
|
# fixes |
|
315 |
|
if [ -z "${GIT_DEST}" ]; then |
|
316 |
|
GIT_DEST="${EXPORT_PATH}" |
|
317 |
|
fi |
|
318 |
|
|
|
319 |
|
if [ -z "${PRJ}" ]; then |
|
320 |
|
echo "ERROR: PRJ= parameter is missing." |
|
321 |
|
exit 1 |
|
322 |
|
fi |
|
323 |
|
|
|
324 |
|
if [ -z "${VER}" ]; then |
|
325 |
|
echo "ERROR: VER= parameter is missing." |
|
326 |
|
exit 1 |
|
327 |
|
fi |
|
328 |
|
|
|
329 |
|
if [ -z "${REV}" ]; then |
|
330 |
|
echo "ERROR: REV= parameter is missing." |
|
331 |
|
exit 1 |
|
332 |
|
fi |
|
333 |
|
|
|
334 |
|
# export variables - just in case a script cares |
|
335 |
|
export PRJ VER REV SHORT_DESCRIPTION EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST SRPM_DEST LICENSE |
|
336 |
|
|
|
337 |
|
|
293 |
338 |
# Multiplexer |
# Multiplexer |
294 |
339 |
if [ "${1}" = "docs" ]; then |
if [ "${1}" = "docs" ]; then |
295 |
340 |
shift |
shift |
|
... |
... |
if [ "${1}" = "final" ]; then |
321 |
366 |
exit $? |
exit $? |
322 |
367 |
fi |
fi |
323 |
368 |
|
|
324 |
|
if [ ! -r duilder.conf ]; then |
|
325 |
|
echo "You must build a duilder.conf file!" |
|
326 |
|
exit 1 |
|
327 |
|
fi |
|
328 |
|
|
|
329 |
369 |
|
|
330 |
370 |
###### Main stuff |
###### Main stuff |
331 |
|
|
|
332 |
|
source ${PWD}/duilder.conf |
|
333 |
|
|
|
334 |
|
# fixes |
|
335 |
|
if [ -z "${GIT_DEST}" ]; then |
|
336 |
|
GIT_DEST="${EXPORT_PATH}" |
|
337 |
|
fi |
|
338 |
|
|
|
339 |
|
# export variables - just in case a script cares |
|
340 |
|
export PRJ VER REV EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST SRPMS_DEST LICENSE |
|
341 |
|
|
|
342 |
|
if [ -z "${PRJ}" ]; then |
|
343 |
|
echo "ERROR: PRJ= parameter is missing." |
|
344 |
|
exit 1 |
|
345 |
|
fi |
|
346 |
|
|
|
347 |
|
if [ -z "${VER}" ]; then |
|
348 |
|
echo "ERROR: PRJ= parameter is missing." |
|
349 |
|
exit 1 |
|
350 |
|
fi |
|
351 |
|
|
|
352 |
|
if [ -z "${REV}" ]; then |
|
353 |
|
echo "ERROR: REV= parameter is missing." |
|
354 |
|
exit 1 |
|
355 |
|
fi |
|
356 |
|
|
|
357 |
|
echo |
|
358 |
|
echo "Duilder builder script" |
|
359 |
|
echo "Copyright Catalin(ux) M BOIE" |
|
360 |
|
echo |
|
361 |
|
echo "PRJ=${PRJ}, VER=${VER}, REV=${REV}" |
|
362 |
|
echo "System: `uname -a`" |
|
|
371 |
|
echo "[*] Duilder builder script" |
|
372 |
|
echo "[*] Copyright Catalin(ux) M. BOIE - catab at embedromix dot ro" |
|
373 |
|
echo "[*] PRJ=${PRJ}, VER=${VER}, REV=${REV}" |
|
374 |
|
echo "[*] System: `uname -a`" |
363 |
375 |
|
|
364 |
376 |
ETC="/etc" |
ETC="/etc" |
365 |
377 |
BIN="/bin" |
BIN="/bin" |
366 |
378 |
USR_BIN="/usr/bin" |
USR_BIN="/usr/bin" |
367 |
379 |
USR_SBIN="/usr/sbin" |
USR_SBIN="/usr/sbin" |
368 |
380 |
USR_INCLUDE="/usr/include" |
USR_INCLUDE="/usr/include" |
369 |
|
USR_LIB="/usr/lib" |
|
|
381 |
|
if [ "`uname -m`" = "i686" ]; then |
|
382 |
|
USR_LIB="/usr/lib" |
|
383 |
|
else |
|
384 |
|
USR_LIB="/usr/lib64" |
|
385 |
|
fi |
|
386 |
|
USR_SHARE="/usr/share" |
370 |
387 |
USR_SHARE_DOC="/usr/share/doc/${PRJ}-${VER}" |
USR_SHARE_DOC="/usr/share/doc/${PRJ}-${VER}" |
371 |
388 |
SBIN="/usr/sbin" |
SBIN="/usr/sbin" |
372 |
389 |
VAR="/var" |
VAR="/var" |
373 |
|
VAR_LOG="/var/log/${PRJ}" |
|
|
390 |
|
VAR_LIB="/var/lib" |
|
391 |
|
MAN="/usr/share/man" |
374 |
392 |
|
|
375 |
393 |
while [ "${1}" != "" ]; do |
while [ "${1}" != "" ]; do |
376 |
|
VAR="`echo ${1} | cut -d'=' -f1`" |
|
377 |
|
VAL="`echo ${1} | cut -d'=' -f2`" |
|
378 |
|
case ${VAR} in |
|
|
394 |
|
xVAR="`echo ${1} | cut -d'=' -f1`" |
|
395 |
|
xVAL="`echo ${1} | cut -d'=' -f2`" |
|
396 |
|
case ${xVAR} in |
379 |
397 |
--sysconfdir) |
--sysconfdir) |
380 |
|
ETC="${VAL}" |
|
|
398 |
|
ETC="${xVAL}" |
381 |
399 |
;; |
;; |
382 |
400 |
--bindir) |
--bindir) |
383 |
|
USR_BIN="${VAL}" |
|
|
401 |
|
USR_BIN="${xVAL}" |
384 |
402 |
;; |
;; |
385 |
403 |
--sbindir) |
--sbindir) |
386 |
|
USR_SBIN="${VAL}" |
|
|
404 |
|
USR_SBIN="${xVAL}" |
387 |
405 |
;; |
;; |
388 |
406 |
--includedir) |
--includedir) |
389 |
|
USR_INCLUDE="${VAL}" |
|
|
407 |
|
USR_INCLUDE="${xVAL}" |
390 |
408 |
;; |
;; |
391 |
409 |
--libdir) |
--libdir) |
392 |
|
USR_LIB="${VAL}" |
|
|
410 |
|
USR_LIB="${xVAL}" |
393 |
411 |
;; |
;; |
394 |
412 |
--localstatedir) |
--localstatedir) |
395 |
|
VAR="${VAL}" |
|
|
413 |
|
VAR="${xVAL}" |
|
414 |
|
;; |
|
415 |
|
--sharedstatedir) |
|
416 |
|
VAR_LIB="${xVAL}" |
|
417 |
|
;; |
|
418 |
|
--datadir) |
|
419 |
|
USR_SHARE="${xVAL}" |
|
420 |
|
;; |
|
421 |
|
--mandir) |
|
422 |
|
MAN="${xVAL}" |
396 |
423 |
;; |
;; |
397 |
424 |
esac |
esac |
398 |
425 |
shift |
shift |
399 |
426 |
done |
done |
400 |
427 |
|
|
|
428 |
|
# Last fixes |
|
429 |
|
VAR_LOG="${VAR}/log" |
|
430 |
|
VAR_RUN="${VAR}/run" |
|
431 |
|
|
|
432 |
|
for i in ETC BIN USR_BIN USR_SBIN USR_INCLUDE USR_LIB USR_SHARE USR_SHARE_DOC SBIN VAR VAR_LIB MAN VAR_LOG VAR_RUN; do |
|
433 |
|
eval value=\$$i |
|
434 |
|
echo "[*] Var ${i}=${value}" |
|
435 |
|
done |
|
436 |
|
|
401 |
437 |
# Truncate future sed file |
# Truncate future sed file |
402 |
438 |
> tmp.sed |
> tmp.sed |
403 |
439 |
|
|
404 |
440 |
DB_SUPPORT=0 |
DB_SUPPORT=0 |
405 |
441 |
|
|
406 |
|
echo -n "Searching for PostgreSQL..." |
|
|
442 |
|
echo -n "[*] Searching for PostgreSQL..." |
407 |
443 |
set +e |
set +e |
408 |
444 |
PG_VERSION="`pg_config --version 2>/dev/null`" |
PG_VERSION="`pg_config --version 2>/dev/null`" |
409 |
445 |
set -e |
set -e |
|
... |
... |
fi |
426 |
462 |
echo "s#@PG_FOUND@#${PG_FOUND}#g" >> tmp.sed |
echo "s#@PG_FOUND@#${PG_FOUND}#g" >> tmp.sed |
427 |
463 |
|
|
428 |
464 |
|
|
429 |
|
echo -n "Searching for MySQL..." |
|
|
465 |
|
echo -n "[*] Searching for MySQL..." |
430 |
466 |
set +e |
set +e |
431 |
467 |
MYSQL_VERSION="`mysql_config --version 2>/dev/null`" |
MYSQL_VERSION="`mysql_config --version 2>/dev/null`" |
432 |
468 |
set -e |
set -e |
|
... |
... |
else |
448 |
484 |
fi |
fi |
449 |
485 |
echo "s#@MYSQL_FOUND@#${MYSQL_FOUND}#g" >> tmp.sed |
echo "s#@MYSQL_FOUND@#${MYSQL_FOUND}#g" >> tmp.sed |
450 |
486 |
|
|
451 |
|
echo -n "Searching for poll..." |
|
|
487 |
|
echo -n "[*] Searching for poll..." |
452 |
488 |
set +e |
set +e |
453 |
489 |
echo -e "#include <poll.h> \n int main(void) { return poll(0, 0, 0); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
echo -e "#include <poll.h> \n int main(void) { return poll(0, 0, 0); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
454 |
490 |
E="${?}" |
E="${?}" |
|
... |
... |
else |
461 |
497 |
echo "s#@POLL_FOUND@#1#g" >> tmp.sed |
echo "s#@POLL_FOUND@#1#g" >> tmp.sed |
462 |
498 |
fi |
fi |
463 |
499 |
|
|
464 |
|
echo -n "Searching for epoll..." |
|
|
500 |
|
echo -n "[*] Searching for epoll..." |
465 |
501 |
set +e |
set +e |
466 |
502 |
echo -e "#include <sys/epoll.h> \n int main(void) { return epoll_create(64); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
echo -e "#include <sys/epoll.h> \n int main(void) { return epoll_create(64); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null |
467 |
503 |
E="${?}" |
E="${?}" |
|
... |
... |
else |
474 |
510 |
echo "s#@EPOLL_FOUND@#1#g" >> tmp.sed |
echo "s#@EPOLL_FOUND@#1#g" >> tmp.sed |
475 |
511 |
fi |
fi |
476 |
512 |
|
|
|
513 |
|
echo -n "[*] Searching for ncurses..." |
|
514 |
|
set +e |
|
515 |
|
echo -e "#include <ncurses.h> \n int main(void) { initscr(); return 0; }" | gcc -x c -pipe - -o /dev/null -lncurses 2>/dev/null |
|
516 |
|
E="${?}" |
|
517 |
|
set -e |
|
518 |
|
if [ "${E}" != "0" ]; then |
|
519 |
|
echo " not found." |
|
520 |
|
echo "s#@NCURSES_FOUND@#0#g" >> tmp.sed |
|
521 |
|
else |
|
522 |
|
echo " found." |
|
523 |
|
echo "s#@NCURSES_FOUND@#1#g" >> tmp.sed |
|
524 |
|
fi |
|
525 |
|
|
|
526 |
|
if [ -n "${CC_SWITCHES}" ]; then |
|
527 |
|
_CC_SWITCHES="" |
|
528 |
|
echo "[*] Search for valid compiler flags..." |
|
529 |
|
add="" |
|
530 |
|
for s in ${CC_SWITCHES}; do |
|
531 |
|
echo -n " [*] Testing switch [${s}]..." |
|
532 |
|
set +e |
|
533 |
|
echo "int main(void) { return 0; }" | gcc ${s} -x c -pipe - -o /dev/null 2>/dev/null |
|
534 |
|
E=${?} |
|
535 |
|
set -e |
|
536 |
|
if [ "${E}" != "0" ]; then |
|
537 |
|
echo "not supported" |
|
538 |
|
else |
|
539 |
|
echo "supported" |
|
540 |
|
_CC_SWITCHES="${_CC_SWITCHES}${add}${s}" |
|
541 |
|
add=" " |
|
542 |
|
fi |
|
543 |
|
done |
|
544 |
|
fi |
|
545 |
|
|
477 |
546 |
# generic stuff |
# generic stuff |
478 |
547 |
echo "s#@PRJ@#${PRJ}#g" >> tmp.sed |
echo "s#@PRJ@#${PRJ}#g" >> tmp.sed |
479 |
548 |
echo "s#@VER@#${VER}#g" >> tmp.sed |
echo "s#@VER@#${VER}#g" >> tmp.sed |
480 |
549 |
echo "s#@REV@#${REV}#g" >> tmp.sed |
echo "s#@REV@#${REV}#g" >> tmp.sed |
481 |
|
echo "s#@DESCRIPTION@#${DESCRIPTION}#g" >> tmp.sed |
|
482 |
|
|
|
483 |
550 |
echo "s#@ETC@#${ETC}#g" >> tmp.sed |
echo "s#@ETC@#${ETC}#g" >> tmp.sed |
484 |
551 |
echo "s#@BIN@#${BIN}#g" >> tmp.sed |
echo "s#@BIN@#${BIN}#g" >> tmp.sed |
485 |
552 |
echo "s#@USR_BIN@#${USR_BIN}#g" >> tmp.sed |
echo "s#@USR_BIN@#${USR_BIN}#g" >> tmp.sed |
486 |
553 |
echo "s#@SBIN@#${SBIN}#g" >> tmp.sed |
echo "s#@SBIN@#${SBIN}#g" >> tmp.sed |
487 |
554 |
echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed |
echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed |
488 |
555 |
echo "s#@VAR@#${VAR}#g" >> tmp.sed |
echo "s#@VAR@#${VAR}#g" >> tmp.sed |
|
556 |
|
echo "s#@VAR_LIB@#${VAR_LIB}#g" >> tmp.sed |
489 |
557 |
echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed |
echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed |
|
558 |
|
echo "s#@VAR_RUN@#${VAR_RUN}#g" >> tmp.sed |
490 |
559 |
echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed |
echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed |
491 |
560 |
echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed |
echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed |
492 |
561 |
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed |
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed |
|
562 |
|
echo "s#@USR_SHARE@#${USR_SHARE}#g" >> tmp.sed |
493 |
563 |
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed |
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed |
|
564 |
|
echo "s#@MAN@#${MAN}#g" >> tmp.sed |
494 |
565 |
# Export stuff |
# Export stuff |
495 |
566 |
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed |
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed |
|
567 |
|
# cc_switches |
|
568 |
|
echo "s#@CC_SWITCHES@#${_CC_SWITCHES}#g" >> tmp.sed |
496 |
569 |
|
|
497 |
570 |
|
|
498 |
571 |
|
|
499 |
572 |
if [ -r Makefile.in ]; then |
if [ -r Makefile.in ]; then |
500 |
|
echo "Building Makefile..." |
|
|
573 |
|
echo "[*] Building Makefile..." |
501 |
574 |
echo -n > Makefile |
echo -n > Makefile |
502 |
575 |
echo "# duilder header starts #" >> Makefile |
echo "# duilder header starts #" >> Makefile |
503 |
576 |
echo "export PRJ := ${PRJ}" >> Makefile |
echo "export PRJ := ${PRJ}" >> Makefile |
|
... |
... |
if [ -r Makefile.in ]; then |
512 |
585 |
echo "export I_USR_SBIN := \$(DESTDIR)${USR_SBIN}" >> Makefile |
echo "export I_USR_SBIN := \$(DESTDIR)${USR_SBIN}" >> Makefile |
513 |
586 |
echo "export I_USR_INCLUDE := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
echo "export I_USR_INCLUDE := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
514 |
587 |
echo "export I_USR_INC := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
echo "export I_USR_INC := \$(DESTDIR)${USR_INCLUDE}" >> Makefile |
|
588 |
|
echo "export I_USR_SHARE := \$(DESTDIR)${USR_SHARE}" >> Makefile |
515 |
589 |
echo "export I_USR_SHARE_DOC := \$(DESTDIR)${USR_SHARE_DOC}" >> Makefile |
echo "export I_USR_SHARE_DOC := \$(DESTDIR)${USR_SHARE_DOC}" >> Makefile |
516 |
590 |
echo "export I_USR_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
echo "export I_USR_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
517 |
591 |
echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile |
518 |
592 |
echo "export I_VAR := \$(DESTDIR)${VAR}" >> Makefile |
echo "export I_VAR := \$(DESTDIR)${VAR}" >> Makefile |
|
593 |
|
echo "export I_VAR_LIB := \$(DESTDIR)${VAR_LIB}" >> Makefile |
519 |
594 |
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile |
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile |
|
595 |
|
echo "export I_VAR_RUN := \$(DESTDIR)${VAR_RUN}" >> Makefile |
|
596 |
|
echo "export I_MAN := \$(DESTDIR)${MAN}" >> Makefile |
520 |
597 |
echo >> Makefile |
echo >> Makefile |
521 |
598 |
echo "# DB stuff" >> Makefile |
echo "# DB stuff" >> Makefile |
522 |
599 |
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile |
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile |
|
... |
... |
if [ -r Makefile.in ]; then |
553 |
630 |
fi |
fi |
554 |
631 |
|
|
555 |
632 |
if [ -r "${PRJ}.spec.in" ]; then |
if [ -r "${PRJ}.spec.in" ]; then |
556 |
|
echo "Generate .spec file..." |
|
|
633 |
|
echo "[*] Generating .spec file..." |
557 |
634 |
sed -f tmp.sed ${PRJ}.spec.in > ${PRJ}.spec |
sed -f tmp.sed ${PRJ}.spec.in > ${PRJ}.spec |
558 |
635 |
fi |
fi |
559 |
636 |
|
|
560 |
637 |
if [ ! -z "${CONFIG_H}" ]; then |
if [ ! -z "${CONFIG_H}" ]; then |
561 |
|
echo "Generating ${CONFIG_H} file..." |
|
|
638 |
|
echo "[*] Generating ${CONFIG_H} file..." |
562 |
639 |
sed -f tmp.sed ${CONFIG_H}.in > ${CONFIG_H} |
sed -f tmp.sed ${CONFIG_H}.in > ${CONFIG_H} |
563 |
640 |
fi |
fi |
564 |
641 |
|
|
565 |
642 |
rm -f tmp.sed |
rm -f tmp.sed |
566 |
643 |
|
|
567 |
644 |
if [ "`basename ${0}`" = "duilderx" ]; then |
if [ "`basename ${0}`" = "duilderx" ]; then |
568 |
|
echo "Clone myself to destination as 'duilder'..." |
|
|
645 |
|
echo "[*] Cloning myself to destination as 'duilder'..." |
569 |
646 |
cp -vpf "${0}" ${PWD}/duilder |
cp -vpf "${0}" ${PWD}/duilder |
570 |
647 |
fi |
fi |
571 |
648 |
|
|
572 |
|
echo "Done. Run make." |
|
|
649 |
|
echo "[*] Done. Run make." |