Annotation of /trunk/mage/usr/lib/mage/smage2.sh
Parent Directory | Revision Log
Revision 1615 -
(hide annotations)
(download)
(as text)
Mon Jan 9 20:09:41 2012 UTC (12 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 42017 byte(s)
Mon Jan 9 20:09:41 2012 UTC (12 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 42017 byte(s)
-minstalldocs(): fixed compressed docs installation
1 | niro | 24 | #!/bin/bash |
2 | niro | 1571 | # $Id$ |
3 | niro | 24 | |
4 | # compiles/installs .smage2 source install scripts | ||
5 | # needs pkgbuild_dir (mage) | ||
6 | |||
7 | niro | 1571 | # TODO: record dynlib, gz | xz database |
8 | niro | 24 | |
9 | |||
10 | niro | 419 | # set default user mage.rc |
11 | : ${MAGERC="/etc/mage.rc"} | ||
12 | |||
13 | niro | 169 | # export default C locale |
14 | export LC_ALL=C | ||
15 | |||
16 | niro | 439 | source /etc/mage.rc.global |
17 | niro | 419 | source ${MAGERC} |
18 | niro | 1273 | source ${MLIBDIR}/mage4.functions.sh |
19 | niro | 24 | |
20 | niro | 1589 | ## setup ## |
21 | SMAGENAME="$1" | ||
22 | SMAGEVERSION="$(< ${MLIBDIR}/version)" | ||
23 | |||
24 | niro | 347 | # set PKGDIR and BUILDDIR and BINDIR to MROOT |
25 | if [[ -n ${MROOT} ]] | ||
26 | then | ||
27 | export PKGDIR=${MROOT}/${PKGDIR} | ||
28 | export BUILDDIR=${MROOT}/${BUILDDIR} | ||
29 | export BINDIR=${MROOT}/${BINDIR} | ||
30 | fi | ||
31 | |||
32 | niro | 1346 | # sources the smage file and uses state from distribution file if exist |
33 | # may helpful for repository support later on | ||
34 | smagesource() | ||
35 | { | ||
36 | local file="$1" | ||
37 | local mystate | ||
38 | local mycodename | ||
39 | |||
40 | source ${file} | ||
41 | |||
42 | [[ -n ${STATE} ]] && mystate="${STATE}" | ||
43 | niro | 1349 | |
44 | # do not overide if local state was broken or disabled! | ||
45 | case ${STATE} in | ||
46 | broken) return ;; | ||
47 | disabled) return ;; | ||
48 | esac | ||
49 | |||
50 | niro | 1346 | if [ -f ${SMAGESCRIPTSDIR}/distribution ] |
51 | then | ||
52 | source ${SMAGESCRIPTSDIR}/distribution | ||
53 | [[ -n ${STATE} ]] && mystate="${STATE}" | ||
54 | fi | ||
55 | # now switch state and export it | ||
56 | STATE="${mystate}" | ||
57 | } | ||
58 | |||
59 | niro | 306 | showversion() |
60 | { | ||
61 | niro | 24 | echo -en "Magellan Source Install v${SMAGEVERSION} " |
62 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" | ||
63 | } | ||
64 | |||
65 | niro | 306 | die() |
66 | { | ||
67 | niro | 24 | xtitleclean |
68 | niro | 413 | echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
69 | niro | 24 | echo "SMAGE failed: $@" |
70 | exit 1 | ||
71 | } | ||
72 | |||
73 | niro | 941 | die_pipestatus() |
74 | { | ||
75 | niro | 943 | # the status change if we do any parameter declarations!! |
76 | # dont do this anymore, keep this in mind! | ||
77 | # | ||
78 | # local pos="$1" | ||
79 | # local comment="$2" | ||
80 | # | ||
81 | # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" | ||
82 | # | ||
83 | [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" | ||
84 | niro | 941 | } |
85 | |||
86 | niro | 306 | xtitle() |
87 | { | ||
88 | if [[ ${TERM} = xterm ]] | ||
89 | niro | 24 | then |
90 | echo -ne "\033]0;[sMage: $@]\007" | ||
91 | fi | ||
92 | return 0 | ||
93 | } | ||
94 | |||
95 | niro | 306 | xtitleclean() |
96 | { | ||
97 | if [[ ${TERM} = xterm ]] | ||
98 | niro | 24 | then |
99 | echo -ne "\033]0;\007" | ||
100 | fi | ||
101 | return 0 | ||
102 | } | ||
103 | |||
104 | niro | 306 | syncsmage2() |
105 | { | ||
106 | niro | 24 | xtitle "Updating smage2-script tree ..." |
107 | local i | ||
108 | for i in ${SMAGE2RSYNC} | ||
109 | do | ||
110 | niro | 386 | rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR} |
111 | niro | 306 | if [[ $? = 0 ]] |
112 | niro | 24 | then |
113 | break | ||
114 | else | ||
115 | continue | ||
116 | fi | ||
117 | done | ||
118 | niro | 306 | |
119 | # clean up backup files (foo~) | ||
120 | niro | 24 | find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';' |
121 | niro | 306 | |
122 | niro | 24 | xtitleclean |
123 | } | ||
124 | |||
125 | niro | 59 | # $1 filename |
126 | niro | 306 | get_db_md5_sum() |
127 | { | ||
128 | niro | 59 | local DB_FILE |
129 | local MD5_FILE | ||
130 | local i | ||
131 | |||
132 | DB_ENTRY="$(basename $1)" | ||
133 | MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})" | ||
134 | |||
135 | i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)" | ||
136 | |||
137 | echo "${i}" | ||
138 | } | ||
139 | |||
140 | niro | 306 | download_sources() |
141 | { | ||
142 | niro | 61 | [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
143 | niro | 59 | |
144 | niro | 1580 | local count=${#SRC_URI[*]} |
145 | local uri | ||
146 | local subdir | ||
147 | local outputdir | ||
148 | local db_md5_file="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" | ||
149 | local fetching | ||
150 | local i | ||
151 | niro | 59 | |
152 | # check if FETCHING is needed | ||
153 | niro | 1580 | if mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 |
154 | niro | 59 | then |
155 | niro | 439 | # md5's ok, no fetching needed |
156 | niro | 1580 | fetching=false |
157 | niro | 59 | else |
158 | niro | 1580 | fetching=true |
159 | niro | 59 | fi |
160 | niro | 306 | |
161 | niro | 1580 | if [[ ${fetching} = true ]] |
162 | then | ||
163 | for ((i=0; i < count; i++)) | ||
164 | do | ||
165 | # url to file | ||
166 | uri="${SRC_URI[${i}]%%' '*}" | ||
167 | niro | 59 | |
168 | niro | 1580 | # subdir in sources dir; the my_SRCI_URI file goes to there |
169 | subdir="${SRC_URI[${i}]##*' '}" | ||
170 | niro | 66 | |
171 | niro | 1580 | # if $subdir is not equal with $uri then an other dir is used |
172 | if [[ ${uri} != ${subdir} ]] | ||
173 | niro | 59 | then |
174 | niro | 1580 | outputdir="${SOURCEDIR}/${PNAME}/${subdir}" |
175 | else | ||
176 | outputdir="${SOURCEDIR}/${PNAME}" | ||
177 | niro | 59 | fi |
178 | niro | 306 | |
179 | niro | 1580 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}" |
180 | niro | 1600 | # do not die here, mchecksum catches download errors |
181 | mdownload --uri "${uri}" --dir "${outputdir}" | ||
182 | niro | 59 | |
183 | niro | 1580 | # unset them to be sure |
184 | unset uri | ||
185 | unset subdir | ||
186 | unset outputdir | ||
187 | done | ||
188 | niro | 59 | |
189 | niro | 1580 | # recheck md5 sums after download |
190 | echo | ||
191 | echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" | ||
192 | mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed" | ||
193 | echo | ||
194 | else | ||
195 | echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}" | ||
196 | fi | ||
197 | |||
198 | niro | 59 | # not needed anymore |
199 | unset SRC_URI | ||
200 | } | ||
201 | |||
202 | niro | 1573 | # dummy function, used if that does not exist in smage file |
203 | niro | 306 | src_prepare() |
204 | { | ||
205 | niro | 1592 | echo "no src_prepare defined; doing nothing ..." |
206 | niro | 24 | return 0 |
207 | } | ||
208 | |||
209 | niro | 1573 | # dummy function, used if that does not exist in smage file |
210 | niro | 1577 | src_compile() |
211 | niro | 1575 | { |
212 | niro | 1591 | echo "no src_compile defined; doing nothing ..." |
213 | niro | 1575 | return 0 |
214 | } | ||
215 | |||
216 | # dummy function, used if that does not exist in smage file | ||
217 | niro | 1577 | src_check() |
218 | niro | 306 | { |
219 | niro | 1591 | echo "no src_check defined; doing nothing ..." |
220 | niro | 24 | return 0 |
221 | } | ||
222 | |||
223 | niro | 1573 | # dummy function, used if that does not exist in smage file |
224 | niro | 306 | src_install() |
225 | { | ||
226 | niro | 1591 | echo "no src_install defined; doing nothing ..." |
227 | niro | 24 | return 0 |
228 | } | ||
229 | |||
230 | niro | 351 | mlibdir() |
231 | { | ||
232 | local libdir=lib | ||
233 | [[ ${ARCH} = x86_64 ]] && libdir=lib64 | ||
234 | |||
235 | echo "${libdir}" | ||
236 | } | ||
237 | |||
238 | niro | 306 | mconfigure() |
239 | { | ||
240 | niro | 1613 | local myopts |
241 | if [[ ! -z ${CTARGET} ]] | ||
242 | then | ||
243 | myopts="--target=${CTARGET}" | ||
244 | fi | ||
245 | |||
246 | niro | 24 | if [ -x ./configure ] |
247 | then | ||
248 | niro | 306 | ./configure \ |
249 | --prefix=/usr \ | ||
250 | --host=${CHOST} \ | ||
251 | niro | 833 | --build=${CHOST} \ |
252 | niro | 306 | --mandir=/usr/share/man \ |
253 | --infodir=/usr/share/info \ | ||
254 | --datadir=/usr/share \ | ||
255 | --sysconfdir=/etc \ | ||
256 | --localstatedir=/var/lib \ | ||
257 | niro | 351 | --libdir=/usr/$(mlibdir) \ |
258 | niro | 1613 | ${myopts} \ |
259 | niro | 306 | "$@" || die "mconfigure failed" |
260 | niro | 24 | else |
261 | echo "configure is not an executable ..." | ||
262 | exit 1 | ||
263 | fi | ||
264 | } | ||
265 | |||
266 | niro | 306 | minstall() |
267 | { | ||
268 | if [ -f ./[mM]akefile -o -f ./GNUmakefile ] | ||
269 | then | ||
270 | niro | 24 | make prefix=${BINDIR}/usr \ |
271 | datadir=${BINDIR}/usr/share \ | ||
272 | infodir=${BINDIR}/usr/share/info \ | ||
273 | localstatedir=${BINDIR}/var/lib \ | ||
274 | mandir=${BINDIR}/usr/share/man \ | ||
275 | sysconfdir=${BINDIR}/etc \ | ||
276 | niro | 351 | libdir=${BINDIR}/usr/$(mlibdir) \ |
277 | niro | 24 | "$@" install || die "minstall failed" |
278 | else | ||
279 | die "no Makefile found" | ||
280 | fi | ||
281 | } | ||
282 | |||
283 | niro | 306 | mmake() |
284 | { | ||
285 | niro | 24 | make ${MAKEOPTS} ${EXTRA_EMAKE} "$@" |
286 | } | ||
287 | |||
288 | niro | 306 | munpack() |
289 | { | ||
290 | niro | 24 | local SRCFILE |
291 | local IFTAR | ||
292 | local DEST | ||
293 | |||
294 | SRCFILE=$1 | ||
295 | niro | 306 | |
296 | niro | 597 | if [[ -z $2 ]] |
297 | niro | 24 | then |
298 | DEST=${BUILDDIR} | ||
299 | else | ||
300 | DEST=$2 | ||
301 | fi | ||
302 | niro | 306 | |
303 | niro | 411 | [[ ! -d ${DEST} ]] && install -d ${DEST} |
304 | |||
305 | niro | 24 | case "${SRCFILE##*.}" in |
306 | bz2) | ||
307 | IFTAR="$(basename $SRCFILE .bz2)" | ||
308 | IFTAR="${IFTAR##*.}" | ||
309 | niro | 306 | if [[ ${IFTAR} = tar ]] |
310 | niro | 24 | then |
311 | niro | 597 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." |
312 | else | ||
313 | pushd ${DEST} > /dev/null | ||
314 | bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." | ||
315 | popd > /dev/null | ||
316 | niro | 24 | fi |
317 | ;; | ||
318 | gz) | ||
319 | IFTAR="$(basename $SRCFILE .gz)" | ||
320 | IFTAR="${IFTAR##*.}" | ||
321 | niro | 306 | if [[ ${IFTAR} = tar ]] |
322 | niro | 24 | then |
323 | niro | 597 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." |
324 | else | ||
325 | pushd ${DEST} > /dev/null | ||
326 | zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." | ||
327 | popd > /dev/null | ||
328 | niro | 24 | fi |
329 | ;; | ||
330 | niro | 1351 | xz) |
331 | IFTAR="$(basename $SRCFILE .xz)" | ||
332 | IFTAR="${IFTAR##*.}" | ||
333 | if [[ ${IFTAR} = tar ]] | ||
334 | then | ||
335 | tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed." | ||
336 | else | ||
337 | pushd ${DEST} > /dev/null | ||
338 | xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed." | ||
339 | popd > /dev/null | ||
340 | fi | ||
341 | ;; | ||
342 | niro | 600 | tbz2|mpks|mpk) |
343 | niro | 597 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
344 | niro | 24 | ;; |
345 | tgz) | ||
346 | niro | 597 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
347 | niro | 24 | ;; |
348 | niro | 1351 | txz|mpkzs|mpkz) |
349 | tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed." | ||
350 | ;; | ||
351 | niro | 597 | rar) |
352 | unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." | ||
353 | ;; | ||
354 | niro | 1604 | zip|xpi|jar) |
355 | niro | 597 | unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
356 | ;; | ||
357 | rpm) | ||
358 | niro | 635 | pushd ${DEST} > /dev/null |
359 | niro | 597 | rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
360 | niro | 602 | tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
361 | niro | 635 | if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
362 | niro | 602 | then |
363 | niro | 635 | rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
364 | niro | 602 | fi |
365 | niro | 597 | ;; |
366 | niro | 24 | *) |
367 | die "munpack failed" | ||
368 | ;; | ||
369 | esac | ||
370 | } | ||
371 | |||
372 | niro | 306 | mpatch() |
373 | { | ||
374 | niro | 24 | local PATCHOPTS |
375 | local PATCHFILE | ||
376 | niro | 447 | local i |
377 | niro | 24 | |
378 | PATCHOPTS=$1 | ||
379 | PATCHFILE=$2 | ||
380 | |||
381 | niro | 447 | if [[ -z $2 ]] |
382 | then | ||
383 | PATCHFILE=$1 | ||
384 | |||
385 | ## patch level auto-detection, get patch level | ||
386 | for ((i=0; i < 10; i++)) | ||
387 | do | ||
388 | patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null | ||
389 | if [[ $? = 0 ]] | ||
390 | then | ||
391 | PATCHOPTS="-Np${i}" | ||
392 | break | ||
393 | fi | ||
394 | done | ||
395 | fi | ||
396 | |||
397 | niro | 384 | echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
398 | niro | 24 | patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
399 | } | ||
400 | |||
401 | niro | 497 | mlibtoolize() |
402 | { | ||
403 | local opts="$@" | ||
404 | niro | 1435 | [[ -z ${opts} ]] && opts="--verbose --install --force" |
405 | niro | 24 | |
406 | niro | 497 | libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
407 | } | ||
408 | |||
409 | niro | 1291 | mautoreconf() |
410 | { | ||
411 | local opts="$@" | ||
412 | [[ -z ${opts} ]] && opts="--verbose --install --force" | ||
413 | |||
414 | autoreconf ${opts} || die "running: mautoreconf ${opts}" | ||
415 | } | ||
416 | |||
417 | niro | 306 | minstalldocs() |
418 | { | ||
419 | niro | 24 | local docfiles |
420 | niro | 1581 | local doc |
421 | niro | 24 | docfiles="$@" |
422 | niro | 306 | |
423 | niro | 24 | if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
424 | then | ||
425 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." | ||
426 | fi | ||
427 | niro | 306 | |
428 | niro | 1581 | for doc in ${docfiles} |
429 | niro | 24 | do |
430 | niro | 1581 | if [ -f ${doc} ] |
431 | niro | 953 | then |
432 | niro | 1584 | if mqueryfeature "compressdoc" |
433 | niro | 1581 | then |
434 | niro | 1615 | cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "gzipping +installing ${doc}." |
435 | chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "fixing permissions of ${doc}." | ||
436 | niro | 1581 | else |
437 | install -m 0644 ${SRCDIR}/${i} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}." | ||
438 | fi | ||
439 | niro | 953 | fi |
440 | niro | 24 | done |
441 | } | ||
442 | |||
443 | niro | 306 | mstriplibs() |
444 | { | ||
445 | niro | 79 | local stripdir="$@" |
446 | |||
447 | niro | 1578 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
448 | [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug" | ||
449 | find ${stripdir} ! -type d | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null | ||
450 | niro | 79 | } |
451 | |||
452 | niro | 306 | mstripbins() |
453 | { | ||
454 | niro | 79 | local stripdir="$@" |
455 | |||
456 | niro | 1578 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
457 | [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug" | ||
458 | find ${stripdir} ! -type d | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null | ||
459 | niro | 79 | } |
460 | |||
461 | niro | 1543 | mstripstatic() |
462 | { | ||
463 | local stripdir="$@" | ||
464 | |||
465 | niro | 1578 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
466 | [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug" | ||
467 | find ${stripdir} ! -type d | xargs file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null | ||
468 | niro | 1543 | } |
469 | |||
470 | niro | 1580 | mstriplibtoolarchive() |
471 | { | ||
472 | local stripdir="$@" | ||
473 | |||
474 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" | ||
475 | niro | 1601 | find ${stripdir} ! -type d -name \*.la | xargs | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null |
476 | niro | 1580 | } |
477 | |||
478 | mpurgetargets() | ||
479 | { | ||
480 | local stripdir="$@" | ||
481 | local target | ||
482 | |||
483 | [[ -z ${stripdir} ]] && stripdir=${BINDIR} | ||
484 | # nothing to do in this case | ||
485 | [[ -z ${PURGE_TARGETS[*]} ]] && return | ||
486 | |||
487 | for target in ${PURGE_TARGETS[*]} | ||
488 | do | ||
489 | # check if target is a regex pattern without any slashes | ||
490 | if [[ ${target} = ${target//\/} ]] | ||
491 | then | ||
492 | find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null | ||
493 | else | ||
494 | rm -f -- ${target} 2> /dev/null | ||
495 | fi | ||
496 | done | ||
497 | } | ||
498 | |||
499 | niro | 943 | mcompressdocs() |
500 | { | ||
501 | local bindir="$@" | ||
502 | |||
503 | if [ -d ${bindir}/usr/share/man ] | ||
504 | then | ||
505 | echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" | ||
506 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man | ||
507 | fi | ||
508 | |||
509 | if [ -d ${bindir}/usr/share/info ] | ||
510 | then | ||
511 | echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" | ||
512 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info | ||
513 | fi | ||
514 | } | ||
515 | |||
516 | niro | 306 | sminclude() |
517 | { | ||
518 | niro | 172 | local i |
519 | |||
520 | niro | 183 | if [[ -n "$@" ]] |
521 | niro | 172 | then |
522 | for i in $@ | ||
523 | do | ||
524 | niro | 175 | echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
525 | niro | 172 | source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
526 | done | ||
527 | niro | 177 | echo |
528 | niro | 172 | fi |
529 | } | ||
530 | |||
531 | niro | 306 | setup_distcc_environment() |
532 | { | ||
533 | niro | 24 | if [ -x /usr/bin/distcc ] |
534 | then | ||
535 | niro | 441 | echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" |
536 | niro | 351 | export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
537 | niro | 24 | |
538 | export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" | ||
539 | |||
540 | niro | 306 | # creating distcc tempdir |
541 | niro | 24 | install -o distcc -g daemon -d ${DISTCC_DIR} |
542 | chmod 1777 ${DISTCC_DIR} | ||
543 | fi | ||
544 | } | ||
545 | |||
546 | niro | 306 | setup_ccache_environment() |
547 | { | ||
548 | niro | 24 | if [ -x /usr/bin/ccache ] |
549 | then | ||
550 | niro | 441 | echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" |
551 | niro | 351 | export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
552 | niro | 24 | fi |
553 | } | ||
554 | |||
555 | niro | 193 | # fixes given dependencies to match a MAGE_TARGET |
556 | niro | 198 | # fix_mage_deps -target s/depend # <-- note -target ! |
557 | niro | 306 | fix_mage_deps() |
558 | { | ||
559 | niro | 193 | local target="$1" |
560 | local depend="$2" | ||
561 | local NDEPEND | ||
562 | local sym dep cat pver pname | ||
563 | |||
564 | # deps and provides are special | ||
565 | # they must be fixed to match the target | ||
566 | |||
567 | # run this only if target and depend is not empty | ||
568 | if [ -n "${target}" ] && [ -n "${depend}" ] | ||
569 | then | ||
570 | # fix DEPEND | ||
571 | while read sym dep | ||
572 | do | ||
573 | niro | 427 | # ignore empty lines |
574 | [[ -z ${dep} ]] && continue | ||
575 | |||
576 | niro | 193 | cat="$(dirname ${dep})" |
577 | niro | 199 | # change if not virtual |
578 | niro | 200 | if [[ ${cat} = virtual ]] |
579 | niro | 199 | then |
580 | niro | 200 | pname="$(basename ${dep})" |
581 | else | ||
582 | niro | 199 | # fix pver to target-pver |
583 | # to get pname-target-pver | ||
584 | niro | 193 | |
585 | niro | 199 | # doing it backwards ! |
586 | pver="${dep##*-}" | ||
587 | niro | 200 | # full pver |
588 | pname="$(basename ${dep/-${pver}/})${target}-${pver}" | ||
589 | niro | 199 | fi |
590 | niro | 193 | |
591 | # do not add empty lines | ||
592 | if [ -z "${NDEPEND}" ] | ||
593 | then | ||
594 | niro | 200 | NDEPEND="${sym} ${cat}/${pname}" |
595 | niro | 193 | else |
596 | NDEPEND="${NDEPEND} | ||
597 | niro | 201 | ${sym} ${cat}/${pname}" |
598 | niro | 193 | fi |
599 | |||
600 | unset cat pname pver | ||
601 | done << EOF | ||
602 | ${depend} | ||
603 | EOF | ||
604 | # set NDEPEND to DEPEND | ||
605 | depend="${NDEPEND}" | ||
606 | fi | ||
607 | |||
608 | echo "${depend}" | ||
609 | } | ||
610 | |||
611 | niro | 192 | # build_mage_script(): helper functions for regen_mage_tree() |
612 | niro | 191 | # generates an mage file with given information in smage file |
613 | # needs at least: | ||
614 | # PNAME name of pkg | ||
615 | # PVER version | ||
616 | # PBUILD revision | ||
617 | # PCATEGORIE categorie of the pkg | ||
618 | # STATE state of pkg stable|unstable|old | ||
619 | # DESCRIPTION va short description (opt) | ||
620 | # HOMEPAGE homepage (opt) | ||
621 | # DEPEND runtime dependencies (opt) | ||
622 | # SDEPEND add. needed deps to build the pkg (opt) | ||
623 | # PROVIDE provides a virtual (opt) | ||
624 | # | ||
625 | # special tags: | ||
626 | # PKGTYPE type of pkg | ||
627 | # INHERITS which functions get included | ||
628 | niro | 832 | # SPECIAL_FUNCTIONS special functions which should also be added |
629 | niro | 191 | # warning: they get killed before the build starts ! |
630 | niro | 943 | # SPLIT_PACKAGES names of all subpackages which are splitted from parent |
631 | # SPLIT_PACKAGE_BASE base package name for splitpackages | ||
632 | # (only in the resulting magefile} | ||
633 | niro | 191 | # |
634 | # MAGE_TREE_DEST target destination of the generated tree | ||
635 | # REGEN_MAGE_TREE set to 'true' to enable this | ||
636 | niro | 193 | # |
637 | niro | 195 | # gets called with build_mage_script target |
638 | niro | 192 | build_mage_script() |
639 | niro | 191 | { |
640 | local magefile | ||
641 | local dest | ||
642 | niro | 193 | local target |
643 | niro | 943 | local split_pkg_base |
644 | niro | 191 | local sym |
645 | local depname | ||
646 | |||
647 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
648 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
649 | |||
650 | # determinate which suffix this mage file should get, if any | ||
651 | niro | 943 | [[ $1 = --target ]] && shift && target="-$1" |
652 | niro | 191 | |
653 | niro | 943 | # mark package as splitpackage |
654 | [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" | ||
655 | |||
656 | niro | 191 | # name of magefile |
657 | niro | 193 | magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
658 | niro | 191 | |
659 | # destination to magefile | ||
660 | niro | 193 | dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
661 | niro | 191 | |
662 | # show what we are doing | ||
663 | niro | 439 | echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" |
664 | echo "${dest}" | ||
665 | niro | 191 | |
666 | install -d "$(dirname ${dest})" | ||
667 | # now build the mage file | ||
668 | > ${dest} | ||
669 | |||
670 | # pgkname and state | ||
671 | niro | 193 | echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
672 | niro | 191 | echo "STATE=\"${STATE}\"" >> ${dest} |
673 | |||
674 | # description and homepage | ||
675 | echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} | ||
676 | echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} | ||
677 | |||
678 | niro | 196 | # special tags and vars |
679 | niro | 191 | echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
680 | niro | 214 | |
681 | # echo MAGE_TARGETS ## note -target is needed ! | ||
682 | echo "MAGE_TARGETS=\"${target}\"" >> ${dest} | ||
683 | |||
684 | niro | 943 | # split package base |
685 | echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} | ||
686 | |||
687 | niro | 197 | # add special vars |
688 | if [ -n "${SPECIAL_VARS}" ] | ||
689 | niro | 191 | then |
690 | local i | ||
691 | niro | 197 | for i in ${SPECIAL_VARS} |
692 | niro | 191 | do |
693 | niro | 197 | # being tricky here :) |
694 | echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} | ||
695 | niro | 191 | done |
696 | fi | ||
697 | niro | 214 | |
698 | niro | 197 | # add at least all includes |
699 | if [ -n "${INHERITS}" ] | ||
700 | niro | 196 | then |
701 | niro | 197 | echo -n "minclude" >> ${dest} |
702 | niro | 196 | local i |
703 | niro | 197 | for i in ${INHERITS} |
704 | niro | 196 | do |
705 | niro | 197 | echo -n " ${i}" >> ${dest} |
706 | niro | 196 | done |
707 | niro | 1351 | # a CRLF is needed here! |
708 | echo >> ${dest} | ||
709 | niro | 196 | fi |
710 | |||
711 | niro | 191 | # deps and provides |
712 | niro | 193 | echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
713 | echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} | ||
714 | niro | 191 | echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
715 | |||
716 | # add special functions | ||
717 | if [ -n "${SPECIAL_FUNCTIONS}" ] | ||
718 | then | ||
719 | local i | ||
720 | for i in ${SPECIAL_FUNCTIONS} | ||
721 | do | ||
722 | # add to mage (quotes needed !) | ||
723 | typeset -f "${i}" >> ${dest} | ||
724 | # unset to be safe (quotes needed !) | ||
725 | niro | 192 | #unset "${i}" <-- later to get every target built |
726 | niro | 191 | done |
727 | fi | ||
728 | |||
729 | # pre|post-install|removes | ||
730 | typeset -f preinstall >> ${dest} | ||
731 | typeset -f postinstall >> ${dest} | ||
732 | typeset -f preremove >> ${dest} | ||
733 | typeset -f postremove >> ${dest} | ||
734 | } | ||
735 | |||
736 | regen_mage_tree() | ||
737 | { | ||
738 | niro | 1436 | local subpackage |
739 | niro | 191 | |
740 | # build them only if requested | ||
741 | niro | 1584 | if mqueryfeature regentree |
742 | niro | 191 | then |
743 | niro | 195 | # run it without targets |
744 | niro | 943 | if [[ -n ${MAGE_TARGETS} ]] |
745 | niro | 195 | then |
746 | niro | 943 | # build for each target a mage file |
747 | # run it with several targets | ||
748 | niro | 191 | echo |
749 | niro | 1436 | for subpackage in ${MAGE_TARGETS} |
750 | niro | 943 | do |
751 | niro | 1436 | build_mage_script --target "${subpackage}" |
752 | niro | 943 | done |
753 | niro | 191 | echo |
754 | niro | 195 | |
755 | niro | 943 | # run it for splitpackages |
756 | elif [[ -n ${SPLIT_PACKAGES} ]] | ||
757 | then | ||
758 | local split_pkg_base="${PNAME}" | ||
759 | # save smage environment | ||
760 | split_save_variables | ||
761 | # build for each subpackage a mage file | ||
762 | niro | 195 | # run it with several targets |
763 | niro | 943 | echo |
764 | niro | 1436 | for subpackage in ${SPLIT_PACKAGES} |
765 | niro | 195 | do |
766 | niro | 943 | # get the right variables for the split |
767 | niro | 1436 | export PNAME="${subpackage}" |
768 | split_info_${subpackage} | ||
769 | # get the preinstall etc | ||
770 | split_export_inherits ${subpackage} | ||
771 | niro | 943 | build_mage_script --split-pkg-base "${split_pkg_base}" |
772 | niro | 1436 | # delete split preinstall etc |
773 | split_delete_inherits ${subpackage} | ||
774 | niro | 951 | # restore smage environment |
775 | split_restore_variables | ||
776 | niro | 195 | done |
777 | niro | 943 | echo |
778 | niro | 951 | # unset all saved smage variables |
779 | split_unset_variables | ||
780 | niro | 943 | |
781 | else | ||
782 | echo | ||
783 | build_mage_script | ||
784 | echo | ||
785 | niro | 195 | fi |
786 | niro | 191 | fi |
787 | |||
788 | # now unset all uneeded vars to be safe | ||
789 | niro | 192 | # unset PKGNAME <-- don't do that; smage needs this var |
790 | # unset to be safe (quotes needed !) | ||
791 | niro | 477 | # for i in ${SPECIAL_FUNCTIONS} |
792 | # do | ||
793 | # unset "${i}" | ||
794 | # done | ||
795 | niro | 192 | unset SPECIAL_FUNCTIONS |
796 | niro | 477 | # for i in ${SPECIAL_VARS} |
797 | # do | ||
798 | # unset "${i}" | ||
799 | # done | ||
800 | niro | 194 | unset SPECIAL_VARS |
801 | niro | 191 | unset STATE |
802 | unset DESCRIPTION | ||
803 | unset HOMEPAGE | ||
804 | niro | 1594 | # unset PKGTYPE <-- don't do that either; smage needs this var |
805 | niro | 191 | unset INHERITS |
806 | unset DEPEND | ||
807 | unset SDEPEND | ||
808 | unset PROVIDE | ||
809 | unset preinstall | ||
810 | unset postinstall | ||
811 | unset preremove | ||
812 | unset postremove | ||
813 | } | ||
814 | |||
815 | niro | 943 | split_save_variables() |
816 | { | ||
817 | export SAVED_PNAME="${PNAME}" | ||
818 | export SAVED_PVER="${PVER}" | ||
819 | export SAVED_PBUILD="${PBUILD}" | ||
820 | export SAVED_PCATEGORIE="${PCATEGORIE}" | ||
821 | export SAVED_DESCRIPTION="${DESCRIPTION}" | ||
822 | export SAVED_HOMEPAGE="${HOMEPAGE}" | ||
823 | export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" | ||
824 | export SAVED_STATE="${STATE}" | ||
825 | export SAVED_PKGTYPE="${PKGTYPE}" | ||
826 | export SAVED_INHERITS="${INHERITS}" | ||
827 | export SAVED_DEPEND="${DEPEND}" | ||
828 | export SAVED_SDEPEND="${SDEPEND}" | ||
829 | export SAVED_PROVIDE="${PROVIDE}" | ||
830 | niro | 1582 | export SAVED_PKGTYPE="${PKGTYPE}" |
831 | niro | 943 | |
832 | niro | 1584 | # special handling needed for mage features |
833 | # pkgbuild | ||
834 | mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild" | ||
835 | mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild" | ||
836 | # strip | ||
837 | mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip" | ||
838 | mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip" | ||
839 | # libtool | ||
840 | mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool" | ||
841 | mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool" | ||
842 | # compressdoc | ||
843 | mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc" | ||
844 | mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc" | ||
845 | |||
846 | niro | 945 | # bindir too |
847 | export SAVED_BINDIR="${BINDIR}" | ||
848 | |||
849 | # export the SPLIT_PACKAGE_BASE | ||
850 | export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" | ||
851 | |||
852 | niro | 943 | # functions |
853 | if [[ ! -z $(typeset -f preinstall) ]] | ||
854 | then | ||
855 | # rename the old one | ||
856 | local saved_preinstall | ||
857 | saved_preinstall=SAVED_$(typeset -f preinstall) | ||
858 | eval "${saved_preinstall}" | ||
859 | export -f SAVED_preinstall | ||
860 | fi | ||
861 | |||
862 | if [[ ! -z $(typeset -f postinstall) ]] | ||
863 | then | ||
864 | # rename the old one | ||
865 | local saved_postinstall | ||
866 | saved_postinstall=SAVED_$(typeset -f postinstall) | ||
867 | eval "${saved_postinstall}" | ||
868 | export -f SAVED_postinstall | ||
869 | fi | ||
870 | |||
871 | if [[ ! -z $(typeset -f preremove) ]] | ||
872 | then | ||
873 | # rename the old one | ||
874 | local saved_preremove | ||
875 | saved_preremove=SAVED_$(typeset -f preremove) | ||
876 | eval "${saved_preremove}" | ||
877 | export -f SAVED_preremove | ||
878 | fi | ||
879 | |||
880 | if [[ ! -z $(typeset -f postremove) ]] | ||
881 | then | ||
882 | # rename the old one | ||
883 | local saved_postremove | ||
884 | saved_postremove=SAVED_$(typeset -f postremove) | ||
885 | eval "${saved_postremove}" | ||
886 | export -f SAVED_postremove | ||
887 | fi | ||
888 | } | ||
889 | |||
890 | split_restore_variables() | ||
891 | { | ||
892 | export PNAME="${SAVED_PNAME}" | ||
893 | export PVER="${SAVED_PVER}" | ||
894 | export PBUILD="${SAVED_PBUILD}" | ||
895 | export PCATEGORIE="${SAVED_PCATEGORIE}" | ||
896 | export DESCRIPTION="${SAVED_DESCRIPTION}" | ||
897 | export HOMEPAGE="${SAVED_HOMEPAGE}" | ||
898 | export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" | ||
899 | export STATE="${SAVED_STATE}" | ||
900 | export PKGTYPE="${SAVED_PKGTYPE}" | ||
901 | export INHERITS="${SAVED_INHERITS}" | ||
902 | export DEPEND="${SAVED_DEPEND}" | ||
903 | export SDEPEND="${SAVED_SDEPEND}" | ||
904 | export PROVIDE="${SAVED_PROVIDE}" | ||
905 | niro | 1582 | export PKGTYPE="${SAVED_PKGTYPE}" |
906 | niro | 943 | |
907 | niro | 1584 | # special handling needed for mage features |
908 | # pkgbuild | ||
909 | niro | 1614 | FVERBOSE=off msetfeature "${SAVED_FEATURE_PKGBUILD}" |
910 | niro | 1584 | # strip |
911 | niro | 1614 | FVERBOSE=off msetfeature "${SAVED_FEATURE_STRIP}" |
912 | niro | 1584 | # libtool |
913 | niro | 1614 | FVERBOSE=off msetfeature "${SAVED_FEATURE_LIBTOOL}" |
914 | niro | 1584 | # compressdoc |
915 | niro | 1614 | FVERBOSE=off msetfeature "${SAVED_FEATURE_COMPRESSDOC}" |
916 | niro | 1584 | |
917 | niro | 945 | # bindir too |
918 | export BINDIR="${SAVED_BINDIR}" | ||
919 | |||
920 | niro | 943 | # functions |
921 | if [[ ! -z $(typeset -f SAVED_preinstall) ]] | ||
922 | then | ||
923 | # rename the old one | ||
924 | local saved_preinstall | ||
925 | saved_preinstall=$(typeset -f SAVED_preinstall) | ||
926 | eval "${saved_preinstall/SAVED_/}" | ||
927 | export -f preinstall | ||
928 | fi | ||
929 | |||
930 | if [[ ! -z $(typeset -f SAVED_postinstall) ]] | ||
931 | then | ||
932 | # rename the old one | ||
933 | local saved_postinstall | ||
934 | saved_postinstall=$(typeset -f SAVED_postinstall) | ||
935 | eval "${saved_postinstall/SAVED_/}" | ||
936 | export -f postinstall | ||
937 | fi | ||
938 | |||
939 | if [[ ! -z $(typeset -f SAVED_preremove) ]] | ||
940 | then | ||
941 | # rename the old one | ||
942 | local saved_preremove | ||
943 | saved_preremove=$(typeset -f SAVED_preremove) | ||
944 | eval "${saved_preremove/SAVED_/}" | ||
945 | export -f preremove | ||
946 | fi | ||
947 | |||
948 | if [[ ! -z $(typeset -f SAVED_postremove) ]] | ||
949 | then | ||
950 | # rename the old one | ||
951 | local saved_postremove | ||
952 | saved_postremove=$(typeset -f SAVED_postremove) | ||
953 | eval "${saved_postremove/SAVED_/}" | ||
954 | export -f postremove | ||
955 | fi | ||
956 | niro | 951 | } |
957 | niro | 943 | |
958 | niro | 951 | split_unset_variables() |
959 | { | ||
960 | niro | 943 | # unset saved vars; not needed anymore |
961 | unset SAVED_PNAME | ||
962 | unset SAVED_PVER | ||
963 | unset SAVED_PBUILD | ||
964 | unset SAVED_PCATEGORIE | ||
965 | unset SAVED_DESCRIPTION | ||
966 | unset SAVED_HOMEPAGE | ||
967 | unset SAVED_SPECIAL_VARS | ||
968 | unset SAVED_STATE | ||
969 | unset SAVED_PKGTYPE | ||
970 | unset SAVED_INHERITS | ||
971 | unset SAVED_DEPEND | ||
972 | unset SAVED_SDEPEND | ||
973 | unset SAVED_PROVIDE | ||
974 | niro | 945 | unset SAVED_BINDIR |
975 | niro | 1582 | unset SAVED_PKGTYPE |
976 | niro | 1584 | unset SAVED_FEATURE_PKGBUILD |
977 | unset SAVED_FEATURE_STRIP | ||
978 | unset SAVED_FEATURE_LIBTOOL | ||
979 | unset SAVED_FEATURE_COMPRESSDOC | ||
980 | niro | 945 | unset SPLIT_PACKAGE_BASE |
981 | niro | 943 | unset -f SAVED_preinstall |
982 | unset -f SAVED_postinstall | ||
983 | unset -f SAVED_preremove | ||
984 | unset -f SAVED_postremove | ||
985 | } | ||
986 | |||
987 | niro | 1436 | split_export_inherits() |
988 | { | ||
989 | local subpackage="$1" | ||
990 | local func | ||
991 | local newfunc | ||
992 | |||
993 | for func in preinstall postinstall preremove postremove | ||
994 | do | ||
995 | if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] | ||
996 | then | ||
997 | newfunc=$(typeset -f ${func}_${subpackage}) | ||
998 | newfunc="${newfunc/_${subpackage} (/ (}" | ||
999 | eval "${newfunc}" | ||
1000 | fi | ||
1001 | done | ||
1002 | } | ||
1003 | |||
1004 | split_delete_inherits() | ||
1005 | { | ||
1006 | local subpackage="$1" | ||
1007 | local func | ||
1008 | |||
1009 | for func in preinstall postinstall preremove postremove | ||
1010 | do | ||
1011 | if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] | ||
1012 | then | ||
1013 | unset -f ${func} | ||
1014 | fi | ||
1015 | done | ||
1016 | } | ||
1017 | |||
1018 | niro | 253 | export_inherits() |
1019 | { | ||
1020 | local include="$1" | ||
1021 | shift | ||
1022 | |||
1023 | while [ "$1" ] | ||
1024 | do | ||
1025 | local functions="$1" | ||
1026 | |||
1027 | # sanity checks | ||
1028 | [ -z "${include}" ] && die "export_inherits(): \$include not given." | ||
1029 | [ -z "${functions}" ] && die "export_inherits(): \$functions not given." | ||
1030 | |||
1031 | eval "${functions}() { ${include}_${functions} ; }" | ||
1032 | |||
1033 | # debug | ||
1034 | [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" | ||
1035 | |||
1036 | shift | ||
1037 | done | ||
1038 | } | ||
1039 | |||
1040 | niro | 255 | generate_package_md5sum() |
1041 | { | ||
1042 | local dest | ||
1043 | local pcat | ||
1044 | local pname | ||
1045 | local pver | ||
1046 | local pbuild | ||
1047 | local parch | ||
1048 | local target | ||
1049 | local pkgname | ||
1050 | |||
1051 | # very basic getops | ||
1052 | for i in $* | ||
1053 | do | ||
1054 | case $1 in | ||
1055 | --pcat|-c) shift; pcat="$1" ;; | ||
1056 | --pname|-n) shift; pname="$1" ;; | ||
1057 | --pver|-v) shift; pver="$1" ;; | ||
1058 | --pbuild|-b) shift; pbuild="$1" ;; | ||
1059 | --parch|a) shift; parch="$1" ;; | ||
1060 | --target|t) shift; target="$1" ;; | ||
1061 | esac | ||
1062 | shift | ||
1063 | done | ||
1064 | |||
1065 | # sanity checks; abort if not given | ||
1066 | [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given." | ||
1067 | [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given." | ||
1068 | [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given." | ||
1069 | [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given." | ||
1070 | [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given." | ||
1071 | |||
1072 | # check needed global vars | ||
1073 | [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set." | ||
1074 | [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set." | ||
1075 | |||
1076 | # fix target as it may be empty ! | ||
1077 | [ -n "${target}" ] && target="-${target}" | ||
1078 | |||
1079 | # build pkgname | ||
1080 | pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" | ||
1081 | |||
1082 | # build pkg-md5-sum only if requested | ||
1083 | niro | 1584 | if mqueryfeature regentree |
1084 | niro | 255 | then |
1085 | niro | 439 | echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
1086 | niro | 255 | |
1087 | # abort if not exist | ||
1088 | if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] | ||
1089 | then | ||
1090 | niro | 439 | echo -e "${COLRED}! exists${COLDEFAULT}" |
1091 | niro | 255 | return 0 |
1092 | fi | ||
1093 | |||
1094 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
1095 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
1096 | |||
1097 | # setup md5 dir | ||
1098 | niro | 891 | dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1099 | niro | 255 | install -d ${dest} |
1100 | |||
1101 | # gen md5sum | ||
1102 | ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ | ||
1103 | niro | 256 | > ${dest}/${pkgname}.md5 |
1104 | niro | 439 | echo -e "${COLGREEN}done${COLDEFAULT}" |
1105 | niro | 255 | fi |
1106 | } | ||
1107 | |||
1108 | niro | 403 | source_pkg_build() |
1109 | { | ||
1110 | if [[ ${PKGTYPE} = virtual ]] | ||
1111 | then | ||
1112 | echo "Virtual package detected; src-pkg-tarball not necessary ..." | ||
1113 | return 0 | ||
1114 | fi | ||
1115 | |||
1116 | if [[ ! -d ${SOURCEDIR}/${PNAME} ]] | ||
1117 | then | ||
1118 | echo "No SRC_URI defined; src-pkg-tarball not necessary ..." | ||
1119 | return 0 | ||
1120 | fi | ||
1121 | |||
1122 | niro | 419 | [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." |
1123 | niro | 406 | |
1124 | niro | 403 | echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
1125 | niro | 412 | |
1126 | # include the smage2 file | ||
1127 | cp ${SMAGENAME} ${SOURCEDIR}/${PNAME} | ||
1128 | |||
1129 | niro | 403 | ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; ) |
1130 | niro | 406 | [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR} |
1131 | mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} | ||
1132 | niro | 403 | |
1133 | echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" | ||
1134 | } | ||
1135 | |||
1136 | niro | 859 | step_by_step() |
1137 | { | ||
1138 | niro | 1584 | if mqueryfeature stepbystep |
1139 | niro | 859 | then |
1140 | niro | 945 | echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1141 | niro | 859 | echo "Press [enter] to continue" |
1142 | read | ||
1143 | fi | ||
1144 | } | ||
1145 | niro | 403 | |
1146 | niro | 859 | |
1147 | niro | 59 | # print out our version |
1148 | showversion | ||
1149 | echo | ||
1150 | |||
1151 | niro | 24 | if [ -z "$1" ] |
1152 | then | ||
1153 | echo "No .smage2 file given. Exiting." | ||
1154 | echo | ||
1155 | exit 1 | ||
1156 | fi | ||
1157 | |||
1158 | niro | 1584 | # load supported mage features |
1159 | load_mage_features | ||
1160 | |||
1161 | niro | 192 | # updating smage2-scripts |
1162 | niro | 306 | if [[ $1 = update ]] |
1163 | niro | 24 | then |
1164 | niro | 59 | if [ ! -d ${SOURCEDIR} ] |
1165 | then | ||
1166 | install -d ${SOURCEDIR} | ||
1167 | fi | ||
1168 | syncsmage2 | ||
1169 | exit 0 | ||
1170 | fi | ||
1171 | |||
1172 | niro | 192 | # creates md5sums for smages to given dir |
1173 | niro | 306 | if [[ $1 = calcmd5 ]] |
1174 | niro | 59 | then |
1175 | niro | 1207 | if [ $# -ge 2 ] |
1176 | niro | 59 | then |
1177 | SMAGENAME="$2" | ||
1178 | MD5DIR="$3" | ||
1179 | niro | 1207 | [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1180 | |||
1181 | niro | 1346 | smagesource ${SMAGENAME} || die "download source failed" |
1182 | niro | 59 | |
1183 | niro | 66 | # overridable sourcedir; must be declared after source of the smage2 |
1184 | CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" | ||
1185 | |||
1186 | niro | 59 | [ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
1187 | |||
1188 | # end of array | ||
1189 | EOA=${#SRC_URI[*]} | ||
1190 | |||
1191 | [ ! -d ${MD5DIR} ] && install -d ${MD5DIR} | ||
1192 | |||
1193 | # clear md5sum file | ||
1194 | MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" | ||
1195 | echo -n > ${MY_MD5_FILE} | ||
1196 | |||
1197 | for ((i=0; i < EOA; i++)) | ||
1198 | do | ||
1199 | niro | 66 | # url to file |
1200 | my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" | ||
1201 | |||
1202 | # subdir in sources dir; the my_SRCI_URI file goes to there | ||
1203 | my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" | ||
1204 | |||
1205 | # if my_src_uri_dest is not equal my_src_uri; than an other dir is used | ||
1206 | if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] | ||
1207 | then | ||
1208 | MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" | ||
1209 | else | ||
1210 | MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" | ||
1211 | fi | ||
1212 | |||
1213 | niro | 59 | if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
1214 | then | ||
1215 | echo "calculating $(basename ${MY_SRC_FILE}) ..." | ||
1216 | ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} | ||
1217 | else | ||
1218 | echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." | ||
1219 | fi | ||
1220 | niro | 66 | |
1221 | # unset them to be shure | ||
1222 | unset my_SRC_URI | ||
1223 | unset my_SRC_URI_DEST | ||
1224 | unset my_SRC_URI_MIRROR | ||
1225 | unset my_SOURCEDIR | ||
1226 | niro | 59 | done |
1227 | niro | 306 | |
1228 | niro | 59 | echo |
1229 | echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." | ||
1230 | echo | ||
1231 | else | ||
1232 | echo "Usage: Calculating MD5 Sums:" | ||
1233 | niro | 1207 | echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1234 | niro | 59 | echo |
1235 | echo | ||
1236 | echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." | ||
1237 | echo | ||
1238 | exit 1 | ||
1239 | fi | ||
1240 | niro | 306 | |
1241 | niro | 59 | exit 0 |
1242 | fi | ||
1243 | |||
1244 | niro | 192 | # download sources |
1245 | niro | 59 | if [ "$1" == "download" -a -n "$2" ] |
1246 | then | ||
1247 | niro | 24 | if [ ! -d ${SMAGESCRIPTSDIR} ] |
1248 | then | ||
1249 | install -d ${SMAGESCRIPTSDIR} | ||
1250 | fi | ||
1251 | niro | 59 | |
1252 | # get smage | ||
1253 | SMAGENAME="$2" | ||
1254 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
1255 | niro | 1346 | smagesource ${SMAGENAME} || die "download source failed" |
1256 | niro | 59 | |
1257 | download_sources | ||
1258 | niro | 24 | exit 0 |
1259 | fi | ||
1260 | |||
1261 | niro | 202 | # regen-mage-tree |
1262 | if [ "$1" == "only-regen-tree" -a -n "$2" ] | ||
1263 | then | ||
1264 | # set correct SMAGENAME | ||
1265 | SMAGENAME="$2" | ||
1266 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
1267 | niro | 1346 | smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1268 | niro | 202 | |
1269 | regen_mage_tree | ||
1270 | niro | 255 | |
1271 | niro | 890 | # build several targets |
1272 | niro | 943 | if [[ -n ${MAGE_TARGETS} ]] |
1273 | niro | 890 | then |
1274 | for target in ${MAGE_TARGETS} | ||
1275 | do | ||
1276 | # build md5sum for existing packages | ||
1277 | generate_package_md5sum \ | ||
1278 | --pcat "${PCATEGORIE}" \ | ||
1279 | --pname "${PNAME}" \ | ||
1280 | --pver "${PVER}" \ | ||
1281 | --pbuild "${PBUILD}" \ | ||
1282 | --parch "${ARCH}" \ | ||
1283 | --target "${target}" | ||
1284 | done | ||
1285 | niro | 943 | |
1286 | # build several subpackages | ||
1287 | elif [[ -n ${SPLIT_PACKAGES} ]] | ||
1288 | then | ||
1289 | split_save_variables | ||
1290 | niro | 964 | for subpackage in ${SPLIT_PACKAGES} |
1291 | niro | 943 | do |
1292 | # get the right variables for the split | ||
1293 | export PNAME="${subpackage}" | ||
1294 | split_info_${subpackage} | ||
1295 | # build md5sum for existing packages | ||
1296 | generate_package_md5sum \ | ||
1297 | --pcat "${PCATEGORIE}" \ | ||
1298 | --pname "${PNAME}" \ | ||
1299 | --pver "${PVER}" \ | ||
1300 | --pbuild "${PBUILD}" \ | ||
1301 | --parch "${ARCH}" | ||
1302 | niro | 951 | # restore smage environment |
1303 | split_restore_variables | ||
1304 | niro | 943 | done |
1305 | niro | 951 | # unset all saved smage variables |
1306 | split_unset_variables | ||
1307 | niro | 943 | |
1308 | niro | 890 | else |
1309 | # build md5sum for existing packages | ||
1310 | generate_package_md5sum \ | ||
1311 | --pcat "${PCATEGORIE}" \ | ||
1312 | --pname "${PNAME}" \ | ||
1313 | --pver "${PVER}" \ | ||
1314 | --pbuild "${PBUILD}" \ | ||
1315 | niro | 943 | --parch "${ARCH}" |
1316 | niro | 890 | fi |
1317 | niro | 255 | |
1318 | niro | 202 | exit 0 |
1319 | fi | ||
1320 | |||
1321 | niro | 412 | if [ "$1" == "--create-src-tarball" -a -n "$2" ] |
1322 | niro | 403 | then |
1323 | # set correct SMAGENAME | ||
1324 | SMAGENAME="$2" | ||
1325 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
1326 | |||
1327 | niro | 412 | echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1328 | niro | 403 | |
1329 | niro | 1346 | smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1330 | niro | 403 | |
1331 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
1332 | then | ||
1333 | echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" | ||
1334 | rm -rf ${SOURCEDIR}/${PKGNAME} | ||
1335 | fi | ||
1336 | |||
1337 | download_sources | ||
1338 | source_pkg_build ${SMAGENAME} | ||
1339 | exit 0 | ||
1340 | fi | ||
1341 | |||
1342 | niro | 406 | if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ] |
1343 | niro | 403 | then |
1344 | niro | 412 | SRCPKGTARBALL="${2}" |
1345 | niro | 1584 | msetfeature "srcpkgtarball" |
1346 | niro | 403 | |
1347 | niro | 412 | # abort if given file is not a source pkg |
1348 | [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file." | ||
1349 | |||
1350 | # set correct SMAGENAME; use the one that the src_pkg provide | ||
1351 | # /path/to/SOURCEDIR/PNAME/SMAGENAME | ||
1352 | SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}" | ||
1353 | |||
1354 | niro | 403 | echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}" |
1355 | |||
1356 | [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR} | ||
1357 | |||
1358 | # unpack srctarball | ||
1359 | [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting." | ||
1360 | |||
1361 | tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}" | ||
1362 | niro | 412 | |
1363 | [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}" | ||
1364 | niro | 403 | fi |
1365 | |||
1366 | |||
1367 | niro | 306 | [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
1368 | [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && | ||
1369 | die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." | ||
1370 | niro | 419 | [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly." |
1371 | [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly." | ||
1372 | [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly." | ||
1373 | [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}" | ||
1374 | [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}" | ||
1375 | [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" | ||
1376 | [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" | ||
1377 | niro | 24 | |
1378 | niro | 1346 | smagesource ${SMAGENAME} || die "source failed" |
1379 | niro | 255 | PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1380 | niro | 59 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
1381 | niro | 941 | SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1382 | niro | 24 | |
1383 | xtitle "Compiling ${PKGNAME}" | ||
1384 | niro | 439 | echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1385 | niro | 59 | |
1386 | niro | 191 | # auto regen mage tree if requested |
1387 | regen_mage_tree | ||
1388 | |||
1389 | niro | 1584 | if mqueryfeature "srcpkg" |
1390 | niro | 403 | then |
1391 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
1392 | then | ||
1393 | niro | 441 | echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
1394 | niro | 408 | rm -rf ${SOURCEDIR}/${PNAME} |
1395 | niro | 403 | fi |
1396 | fi | ||
1397 | |||
1398 | niro | 192 | # download sources |
1399 | niro | 1584 | mqueryfeature "srcpkgtarball" || download_sources |
1400 | niro | 59 | |
1401 | niro | 192 | # fixes some issues with these functions |
1402 | niro | 24 | export -f src_prepare || die "src_prepare export failed" |
1403 | export -f src_compile || die "src_compile export failed" | ||
1404 | niro | 1575 | export -f src_check || die "src_check export failed" |
1405 | niro | 24 | export -f src_install || die "src_install export failed" |
1406 | |||
1407 | niro | 192 | # fixes some compile issues |
1408 | niro | 24 | export CHOST="${CHOST}" || die "CHOST export failed" |
1409 | export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" | ||
1410 | export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" | ||
1411 | export BINDIR="${BINDIR}" || die "BINDIR export failed" | ||
1412 | export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" | ||
1413 | |||
1414 | niro | 192 | # setup distcc |
1415 | niro | 351 | # setup for distcc goes *before* ccache, so ccache comes before distcc in path |
1416 | niro | 1584 | mqueryfeature "distcc" && setup_distcc_environment |
1417 | niro | 24 | |
1418 | niro | 192 | # setup ccache |
1419 | niro | 1584 | mqueryfeature "ccache" && setup_ccache_environment |
1420 | niro | 24 | |
1421 | niro | 1573 | # clean up builddir if a previously one exist |
1422 | niro | 24 | if [ -d ${BUILDDIR} ] |
1423 | then | ||
1424 | rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." | ||
1425 | fi | ||
1426 | install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." | ||
1427 | |||
1428 | niro | 1573 | # clean up srcdir if a previously unpacked one exist |
1429 | niro | 24 | if [ -d ${SRCDIR} ] |
1430 | then | ||
1431 | rm -rf ${SRCDIR} | ||
1432 | fi | ||
1433 | |||
1434 | niro | 1573 | # clean up bindir if a previous build exist or create a new one |
1435 | niro | 24 | if [ -d ${BINDIR} ] |
1436 | then | ||
1437 | rm -rf ${BINDIR} | ||
1438 | fi | ||
1439 | install -d ${BINDIR} || die "couldn't create \$BINDIR." | ||
1440 | |||
1441 | niro | 1579 | # clean up package temp dir if a previous build exist |
1442 | niro | 24 | if [ -d ${BUILDDIR}/${PKGNAME} ] |
1443 | then | ||
1444 | rm -rf ${BUILDDIR}/${PKGNAME} | ||
1445 | fi | ||
1446 | |||
1447 | niro | 1573 | # setup build logging |
1448 | niro | 875 | [[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1449 | echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log | ||
1450 | |||
1451 | niro | 1593 | if [[ ${PKGTYPE} = virtual ]] |
1452 | niro | 1575 | then |
1453 | niro | 1593 | echo "virtual package detected; nothing will be build ..." |
1454 | # automatically set !pkgbuild here too | ||
1455 | msetfeature "!pkgbuild" | ||
1456 | niro | 1575 | else |
1457 | niro | 1593 | src_prepare | ${SMAGE_LOG_CMD} |
1458 | die_pipestatus 0 "src_prepare failed" | ||
1459 | niro | 1575 | step_by_step $_ |
1460 | |||
1461 | niro | 1593 | src_compile | ${SMAGE_LOG_CMD} |
1462 | die_pipestatus 0 "src_compile failed" | ||
1463 | step_by_step $_ | ||
1464 | niro | 945 | |
1465 | niro | 1593 | # only run checks if requested |
1466 | if mqueryfeature "!check" | ||
1467 | then | ||
1468 | echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD} | ||
1469 | step_by_step src_check | ||
1470 | else | ||
1471 | src_check | ${SMAGE_LOG_CMD} | ||
1472 | die_pipestatus 0 "src_check failed" | ||
1473 | step_by_step $_ | ||
1474 | fi | ||
1475 | niro | 945 | |
1476 | niro | 1593 | # build several subpackages |
1477 | if [[ -n ${SPLIT_PACKAGES} ]] | ||
1478 | then | ||
1479 | # save bindir & pname | ||
1480 | split_save_variables | ||
1481 | export SAVED_BINDIR="${BINDIR}" | ||
1482 | for subpackage in ${SPLIT_PACKAGES} | ||
1483 | do | ||
1484 | if typeset -f src_install_${subpackage} > /dev/null | ||
1485 | then | ||
1486 | # export subpackage bindir | ||
1487 | export BINDIR="${SAVED_BINDIR}_${subpackage}" | ||
1488 | # export PNAME, several internal function and include | ||
1489 | # rely on this variable | ||
1490 | export PNAME="${subpackage}" | ||
1491 | |||
1492 | echo | ||
1493 | echo -en "${COLBLUE}*** ${COLDEFAULT}" | ||
1494 | echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" | ||
1495 | echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" | ||
1496 | echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." | ||
1497 | |||
1498 | src_install_${subpackage} | ${SMAGE_LOG_CMD} | ||
1499 | die_pipestatus 0 "src_install_${subpackage} failed" | ||
1500 | step_by_step $_ | ||
1501 | fi | ||
1502 | done | ||
1503 | # restore bindir & pname | ||
1504 | split_restore_variables | ||
1505 | # unset all saved smage variables | ||
1506 | split_unset_variables | ||
1507 | else | ||
1508 | src_install | ${SMAGE_LOG_CMD} | ||
1509 | die_pipestatus 0 "src_install failed" | ||
1510 | step_by_step $_ | ||
1511 | fi | ||
1512 | niro | 943 | fi |
1513 | niro | 24 | |
1514 | niro | 1593 | # echo for sake of good-looking |
1515 | echo | ||
1516 | |||
1517 | niro | 1584 | if mqueryfeature "!compressdoc" |
1518 | niro | 24 | then |
1519 | niro | 1584 | echo -e "!compressdoc detected; documentation will not be compressed ..." |
1520 | niro | 1595 | elif mqueryfeature "!pkgbuild" |
1521 | then | ||
1522 | echo "!pkgbuild detected; skipping documentation compression..." | ||
1523 | niro | 943 | else |
1524 | niro | 1584 | # compressing doc, info & man files |
1525 | if [[ -n ${SPLIT_PACKAGES} ]] | ||
1526 | then | ||
1527 | for subpackage in ${SPLIT_PACKAGES} | ||
1528 | do | ||
1529 | mcompressdocs ${BINDIR}_${subpackage} | ||
1530 | done | ||
1531 | else | ||
1532 | mcompressdocs ${BINDIR} | ||
1533 | fi | ||
1534 | niro | 24 | fi |
1535 | |||
1536 | niro | 1584 | if mqueryfeature "!libtool" |
1537 | niro | 1580 | then |
1538 | niro | 1595 | if mqueryfeature "!pkgbuild" |
1539 | then | ||
1540 | echo "!pkgbuild detected; skipping libtool archive stripping ..." | ||
1541 | else | ||
1542 | niro | 1580 | if [[ -n ${SPLIT_PACKAGES} ]] |
1543 | then | ||
1544 | for subpackage in ${SPLIT_PACKAGES} | ||
1545 | do | ||
1546 | echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}" | ||
1547 | mstriplibtoolarchive ${BINDIR}_${subpackage} | ||
1548 | done | ||
1549 | else | ||
1550 | echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}" | ||
1551 | mstriplibtoolarchive ${BINDIR} | ||
1552 | fi | ||
1553 | niro | 1595 | fi |
1554 | niro | 1580 | fi |
1555 | niro | 24 | |
1556 | niro | 1584 | if mqueryfeature "purge" |
1557 | niro | 1580 | then |
1558 | niro | 1595 | if mqueryfeature "!pkgbuild" |
1559 | then | ||
1560 | echo "!pkgbuild detected; skipping file purgation..." | ||
1561 | else | ||
1562 | niro | 1580 | if [[ -n ${SPLIT_PACKAGES} ]] |
1563 | then | ||
1564 | for subpackage in ${SPLIT_PACKAGES} | ||
1565 | do | ||
1566 | echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}" | ||
1567 | mpurgetargets ${BINDIR}_${subpackage} | ||
1568 | done | ||
1569 | else | ||
1570 | echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}" | ||
1571 | mpurgetargets ${BINDIR} | ||
1572 | fi | ||
1573 | niro | 1595 | fi |
1574 | niro | 1580 | fi |
1575 | |||
1576 | niro | 79 | # stripping all bins and libs |
1577 | niro | 1584 | if mqueryfeature "!strip" |
1578 | then | ||
1579 | echo -e "!strip detected; Package will not be stripped ..." | ||
1580 | niro | 1595 | elif mqueryfeature "!pkgbuild" |
1581 | then | ||
1582 | echo "!pkgbuild detected; skipping stripping of the package ..." | ||
1583 | niro | 1584 | else |
1584 | niro | 1595 | if [[ -n ${SPLIT_PACKAGES} ]] |
1585 | then | ||
1586 | for subpackage in ${SPLIT_PACKAGES} | ||
1587 | do | ||
1588 | echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" | ||
1589 | mstripbins ${BINDIR}_${subpackage} | ||
1590 | echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" | ||
1591 | mstriplibs ${BINDIR}_${subpackage} | ||
1592 | echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" | ||
1593 | mstripstatic ${BINDIR}_${subpackage} | ||
1594 | done | ||
1595 | else | ||
1596 | echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" | ||
1597 | mstripbins ${BINDIR} | ||
1598 | echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" | ||
1599 | mstriplibs ${BINDIR} | ||
1600 | echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" | ||
1601 | mstripstatic ${BINDIR} | ||
1602 | fi | ||
1603 | niro | 1584 | fi |
1604 | niro | 79 | |
1605 | niro | 1595 | if mqueryfeature "!pkgbuild" |
1606 | niro | 1584 | then |
1607 | niro | 1595 | echo -e "!pkgbuild detected; Package will not be build ..." |
1608 | niro | 1584 | else |
1609 | niro | 306 | # build several targets |
1610 | niro | 943 | if [[ -n ${MAGE_TARGETS} ]] |
1611 | niro | 192 | then |
1612 | for target in ${MAGE_TARGETS} | ||
1613 | do | ||
1614 | niro | 1573 | # check if a special target_pkgbuild exists |
1615 | niro | 192 | if typeset -f ${target}_pkgbuild > /dev/null |
1616 | then | ||
1617 | # run it | ||
1618 | ${target}_pkgbuild | ||
1619 | fi | ||
1620 | # now create the target package | ||
1621 | ${MLIBDIR}/pkgbuild_dir.sh \ | ||
1622 | niro | 255 | "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \ |
1623 | niro | 192 | ${BINDIR} || die "target: ${target} package-build failed" |
1624 | niro | 255 | |
1625 | # build pkg-md5-sum if requested | ||
1626 | generate_package_md5sum \ | ||
1627 | --pcat "${PCATEGORIE}" \ | ||
1628 | --pname "${PNAME}" \ | ||
1629 | --pver "${PVER}" \ | ||
1630 | --pbuild "${PBUILD}" \ | ||
1631 | --parch "${ARCH}" \ | ||
1632 | --target "${target}" | ||
1633 | |||
1634 | niro | 439 | echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1635 | niro | 192 | done |
1636 | niro | 943 | |
1637 | # build several subpackages | ||
1638 | elif [[ -n ${SPLIT_PACKAGES} ]] | ||
1639 | then | ||
1640 | split_save_variables | ||
1641 | for subpackage in ${SPLIT_PACKAGES} | ||
1642 | do | ||
1643 | # get the right variables for the split | ||
1644 | export PNAME="${subpackage}" | ||
1645 | split_info_${PNAME} | ||
1646 | |||
1647 | niro | 1595 | # jump to next one if !pkgbuild is set in split_info |
1648 | mqueryfeature "!pkgbuild" && continue | ||
1649 | niro | 947 | |
1650 | niro | 943 | # check if an special subpackage_pkgbuild exists |
1651 | if typeset -f ${PNAME}_pkgbuild > /dev/null | ||
1652 | then | ||
1653 | # run it | ||
1654 | ${PNAME}_pkgbuild | ||
1655 | fi | ||
1656 | # now create the target package | ||
1657 | ${MLIBDIR}/pkgbuild_dir.sh \ | ||
1658 | "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ | ||
1659 | "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" | ||
1660 | |||
1661 | # build pkg-md5-sum if requested | ||
1662 | generate_package_md5sum \ | ||
1663 | --pcat "${PCATEGORIE}" \ | ||
1664 | --pname "${PNAME}" \ | ||
1665 | --pver "${PVER}" \ | ||
1666 | --pbuild "${PBUILD}" \ | ||
1667 | --parch "${ARCH}" | ||
1668 | |||
1669 | echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" | ||
1670 | niro | 951 | |
1671 | # restore smage environment | ||
1672 | split_restore_variables | ||
1673 | niro | 943 | done |
1674 | niro | 951 | # unset all saved smage variables |
1675 | split_unset_variables | ||
1676 | niro | 943 | |
1677 | niro | 192 | else |
1678 | ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" | ||
1679 | niro | 255 | |
1680 | # build pkg-md5-sum if requested | ||
1681 | generate_package_md5sum \ | ||
1682 | --pcat "${PCATEGORIE}" \ | ||
1683 | --pname "${PNAME}" \ | ||
1684 | --pver "${PVER}" \ | ||
1685 | --pbuild "${PBUILD}" \ | ||
1686 | --parch "${ARCH}" | ||
1687 | |||
1688 | niro | 439 | echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}" |
1689 | niro | 192 | fi |
1690 | niro | 403 | |
1691 | # build src-pkg-tarball if requested | ||
1692 | niro | 1584 | mqueryfeature "srcpkg" && source_pkg_build ${SMAGENAME} |
1693 | fi | ||
1694 | niro | 24 | |
1695 | niro | 1584 | if mqueryfeature "buildlog" |
1696 | niro | 875 | then |
1697 | bzip2 -9f /var/log/smage/${PKGNAME}.log | ||
1698 | else | ||
1699 | [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log | ||
1700 | fi | ||
1701 | |||
1702 | niro | 24 | xtitleclean |
Properties
Name | Value |
---|---|
svn:executable | * |