Contents of /trunk/mage/usr/lib/mage/smage2.functions.sh
Parent Directory | Revision Log
Revision 1689 -
(show annotations)
(download)
(as text)
Thu Feb 16 11:58:12 2012 UTC (12 years, 7 months ago) by niro
File MIME type: application/x-sh
File size: 29978 byte(s)
Thu Feb 16 11:58:12 2012 UTC (12 years, 7 months ago) by niro
File MIME type: application/x-sh
File size: 29978 byte(s)
-added march(), marchsrfile(), marchsrcdir(), marchdepend(), marchsdepend() functions
1 | #!/bin/bash |
2 | # smage2 releated functions |
3 | # $Id$ |
4 | |
5 | # sources the smage file and uses state from distribution file if exist |
6 | # may helpful for repository support later on |
7 | smagesource() |
8 | { |
9 | local file="$1" |
10 | local localstate |
11 | local distfilestate |
12 | local mytag |
13 | |
14 | source ${file} |
15 | |
16 | # if PCAT was not set and PCATEGORIE was found |
17 | # inform the user and use PCATEGORIE as PCAT |
18 | if [[ -z ${PCAT} ]] |
19 | then |
20 | if [[ -n ${PCATEGORIE} ]] |
21 | then |
22 | PCAT="${PCATEGORIE}" |
23 | unset PCATEGORIE |
24 | # print a warning |
25 | echo -e "${COLYELLOW}Warning: 'PCATEGORIE' is deprecated and gets removed in the future.${COLDEFAULT}" |
26 | echo -e "${COLYELLOW} Please modify this smage2 script to use the 'PCAT' variable.${COLDEFAULT}" |
27 | echo |
28 | else |
29 | die "Neither PCAT nor PCATEGORIE are defined!" |
30 | fi |
31 | fi |
32 | |
33 | [[ -n ${STATE} ]] && localstate="${STATE}" |
34 | [[ -n ${DISTROTAG} ]] && mytag="${DISTROTAG}" |
35 | |
36 | if [ -f ${SMAGESCRIPTSDIR}/distribution ] |
37 | then |
38 | source ${SMAGESCRIPTSDIR}/distribution |
39 | [[ -n ${STATE} ]] && distfilestate="${STATE}" |
40 | [[ -n ${DISTROTAG} ]] && mytag="${DISTROTAG}" |
41 | fi |
42 | # now switch state and export it but do not overide any local states |
43 | if [[ ! -z ${localstate} ]] |
44 | then |
45 | STATE="${localstate}" |
46 | else |
47 | STATE="${distfilestate}" |
48 | fi |
49 | |
50 | if mqueryfeature "pkgdistrotag" |
51 | then |
52 | # if DISTROTAG was not defined globally |
53 | # or in distribution file then deactivate this feature! |
54 | # at this point $mytag must have the distrotag |
55 | if [[ -z ${mytag} ]] |
56 | then |
57 | FVERBOSE=off msetfeature "!pkgdistrotag" |
58 | unset DISTROTAG |
59 | echo -e "${COLRED}Requested 'pkgdistrotag' but no \$DISTROTAG found!${COLDEFAULT}" |
60 | echo -e "${COLRED}Disabled the feature for pkgbuild sanity!${COLDEFAULT}" |
61 | else |
62 | # now switch state and export it but do not overide any local states |
63 | export DISTROTAG="${mytag}" |
64 | fi |
65 | else |
66 | unset DISTROTAG |
67 | fi |
68 | } |
69 | |
70 | print_distrotag() |
71 | { |
72 | if FVERBOSE=off mqueryfeature "pkgdistrotag" |
73 | then |
74 | if [[ ! -z ${DISTROTAG} ]] |
75 | then |
76 | # add a point as prefix |
77 | echo ".${DISTROTAG}" |
78 | fi |
79 | fi |
80 | } |
81 | |
82 | showversion() |
83 | { |
84 | echo -en "Magellan Source Install v${SMAGEVERSION} " |
85 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" |
86 | } |
87 | |
88 | die() |
89 | { |
90 | xtitleclean |
91 | echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
92 | echo "SMAGE failed: $@" |
93 | exit 1 |
94 | } |
95 | |
96 | die_pipestatus() |
97 | { |
98 | # the status change if we do any parameter declarations!! |
99 | # dont do this anymore, keep this in mind! |
100 | # |
101 | # local pos="$1" |
102 | # local comment="$2" |
103 | # |
104 | # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" |
105 | # |
106 | [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" |
107 | } |
108 | |
109 | xtitle() |
110 | { |
111 | if [[ ${TERM} = xterm ]] |
112 | then |
113 | echo -ne "\033]0;[sMage: $@]\007" |
114 | fi |
115 | return 0 |
116 | } |
117 | |
118 | xtitleclean() |
119 | { |
120 | if [[ ${TERM} = xterm ]] |
121 | then |
122 | echo -ne "\033]0;\007" |
123 | fi |
124 | return 0 |
125 | } |
126 | |
127 | syncsmage2() |
128 | { |
129 | xtitle "Updating smage2-script tree ..." |
130 | local i |
131 | for i in ${SMAGE2RSYNC} |
132 | do |
133 | rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR} |
134 | if [[ $? = 0 ]] |
135 | then |
136 | break |
137 | else |
138 | continue |
139 | fi |
140 | done |
141 | |
142 | # clean up backup files (foo~) |
143 | find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';' |
144 | |
145 | xtitleclean |
146 | } |
147 | |
148 | # $1 filename |
149 | get_db_md5_sum() |
150 | { |
151 | local DB_FILE |
152 | local MD5_FILE |
153 | local i |
154 | |
155 | DB_ENTRY="$(basename $1)" |
156 | MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})" |
157 | |
158 | i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)" |
159 | |
160 | echo "${i}" |
161 | } |
162 | |
163 | download_sources() |
164 | { |
165 | [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
166 | |
167 | local count=${#SRC_URI[*]} |
168 | local uri |
169 | local subdir |
170 | local outputdir |
171 | local db_md5_file="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
172 | local fetching |
173 | local i |
174 | |
175 | # check if FETCHING is needed |
176 | if mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 |
177 | then |
178 | # md5's ok, no fetching needed |
179 | fetching=false |
180 | else |
181 | fetching=true |
182 | fi |
183 | |
184 | if [[ ${fetching} = true ]] |
185 | then |
186 | for ((i=0; i < count; i++)) |
187 | do |
188 | # url to file |
189 | uri="${SRC_URI[${i}]%%' '*}" |
190 | |
191 | # subdir in sources dir; the my_SRCI_URI file goes to there |
192 | subdir="${SRC_URI[${i}]##*' '}" |
193 | |
194 | # if $subdir is not equal with $uri then an other dir is used |
195 | if [[ ${uri} != ${subdir} ]] |
196 | then |
197 | outputdir="${SOURCEDIR}/${PNAME}/${subdir}" |
198 | else |
199 | outputdir="${SOURCEDIR}/${PNAME}" |
200 | fi |
201 | |
202 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}" |
203 | # always use verbose mode for source downloads |
204 | FVERBOSE=off msetfeature "verbose" |
205 | # do not die here, mchecksum catches download errors |
206 | mdownload --uri "${uri}" --dir "${outputdir}" |
207 | |
208 | # unset them to be sure |
209 | unset uri |
210 | unset subdir |
211 | unset outputdir |
212 | done |
213 | |
214 | # recheck md5 sums after download |
215 | echo |
216 | echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
217 | mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed" |
218 | echo |
219 | else |
220 | echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}" |
221 | fi |
222 | |
223 | # not needed anymore |
224 | unset SRC_URI |
225 | } |
226 | |
227 | # dummy function, used if that does not exist in smage file |
228 | src_prepare() |
229 | { |
230 | echo "no src_prepare defined; doing nothing ..." |
231 | return 0 |
232 | } |
233 | |
234 | # dummy function, used if that does not exist in smage file |
235 | src_compile() |
236 | { |
237 | echo "no src_compile defined; doing nothing ..." |
238 | return 0 |
239 | } |
240 | |
241 | # dummy function, used if that does not exist in smage file |
242 | src_check() |
243 | { |
244 | echo "no src_check defined; doing nothing ..." |
245 | return 0 |
246 | } |
247 | |
248 | # dummy function, used if that does not exist in smage file |
249 | src_install() |
250 | { |
251 | echo "no src_install defined; doing nothing ..." |
252 | return 0 |
253 | } |
254 | |
255 | mlibdir() |
256 | { |
257 | local libdir=lib |
258 | [[ ${ARCH} = x86_64 ]] && libdir=lib64 |
259 | |
260 | echo "${libdir}" |
261 | } |
262 | |
263 | mconfigure() |
264 | { |
265 | local myopts |
266 | if [[ ! -z ${CTARGET} ]] |
267 | then |
268 | myopts+=" --target=${CTARGET}" |
269 | fi |
270 | |
271 | if [ -x ./configure ] |
272 | then |
273 | # if requested disable-static |
274 | if [[ ! -z $(./configure --help | grep -- '--.*able-static') ]] |
275 | then |
276 | if mqueryfeature '!static' |
277 | then |
278 | myopts+=" --disable-static" |
279 | else |
280 | myopts+=" --enable-static" |
281 | fi |
282 | fi |
283 | |
284 | # always enable shared by default but not for waf configure |
285 | if [[ ! -z $(./configure --help | grep -- '--.*able-shared') ]] && |
286 | [[ -z $(./configure --version | grep waf) ]] |
287 | then |
288 | myopts+=" --enable-shared" |
289 | fi |
290 | |
291 | ./configure \ |
292 | --prefix=/usr \ |
293 | --host=${CHOST} \ |
294 | --build=${CHOST} \ |
295 | --mandir=/usr/share/man \ |
296 | --infodir=/usr/share/info \ |
297 | --datadir=/usr/share \ |
298 | --sysconfdir=/etc \ |
299 | --localstatedir=/var/lib \ |
300 | --libdir=/usr/$(mlibdir) \ |
301 | ${myopts} \ |
302 | "$@" || die "mconfigure failed" |
303 | else |
304 | echo "configure is not an executable ..." |
305 | exit 1 |
306 | fi |
307 | } |
308 | |
309 | minstall() |
310 | { |
311 | if [ -f ./[mM]akefile -o -f ./GNUmakefile ] |
312 | then |
313 | make prefix=${BINDIR}/usr \ |
314 | datadir=${BINDIR}/usr/share \ |
315 | infodir=${BINDIR}/usr/share/info \ |
316 | localstatedir=${BINDIR}/var/lib \ |
317 | mandir=${BINDIR}/usr/share/man \ |
318 | sysconfdir=${BINDIR}/etc \ |
319 | libdir=${BINDIR}/usr/$(mlibdir) \ |
320 | "$@" install || die "minstall failed" |
321 | else |
322 | die "no Makefile found" |
323 | fi |
324 | } |
325 | |
326 | mmake() |
327 | { |
328 | make ${MAKEOPTS} ${EXTRA_EMAKE} "$@" |
329 | } |
330 | |
331 | munpack() |
332 | { |
333 | local SRCFILE |
334 | local IFTAR |
335 | local DEST |
336 | |
337 | SRCFILE=$1 |
338 | |
339 | if [[ -z $2 ]] |
340 | then |
341 | DEST=${BUILDDIR} |
342 | else |
343 | DEST=$2 |
344 | fi |
345 | |
346 | [[ ! -d ${DEST} ]] && install -d ${DEST} |
347 | |
348 | case "${SRCFILE##*.}" in |
349 | bz2) |
350 | IFTAR="$(basename $SRCFILE .bz2)" |
351 | IFTAR="${IFTAR##*.}" |
352 | if [[ ${IFTAR} = tar ]] |
353 | then |
354 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." |
355 | else |
356 | pushd ${DEST} > /dev/null |
357 | bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." |
358 | popd > /dev/null |
359 | fi |
360 | ;; |
361 | gz) |
362 | IFTAR="$(basename $SRCFILE .gz)" |
363 | IFTAR="${IFTAR##*.}" |
364 | if [[ ${IFTAR} = tar ]] |
365 | then |
366 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." |
367 | else |
368 | pushd ${DEST} > /dev/null |
369 | zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." |
370 | popd > /dev/null |
371 | fi |
372 | ;; |
373 | xz) |
374 | IFTAR="$(basename $SRCFILE .xz)" |
375 | IFTAR="${IFTAR##*.}" |
376 | if [[ ${IFTAR} = tar ]] |
377 | then |
378 | tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed." |
379 | else |
380 | pushd ${DEST} > /dev/null |
381 | xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed." |
382 | popd > /dev/null |
383 | fi |
384 | ;; |
385 | tbz2|mpks|mpk) |
386 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
387 | ;; |
388 | tgz) |
389 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
390 | ;; |
391 | txz|mpkzs|mpkz) |
392 | tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed." |
393 | ;; |
394 | rar) |
395 | unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
396 | ;; |
397 | zip|xpi|jar) |
398 | unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
399 | ;; |
400 | rpm) |
401 | pushd ${DEST} > /dev/null |
402 | rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
403 | tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
404 | if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
405 | then |
406 | rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
407 | fi |
408 | ;; |
409 | *) |
410 | die "munpack failed" |
411 | ;; |
412 | esac |
413 | } |
414 | |
415 | mpatch() |
416 | { |
417 | local PATCHOPTS |
418 | local PATCHFILE |
419 | local i |
420 | |
421 | PATCHOPTS=$1 |
422 | PATCHFILE=$2 |
423 | |
424 | if [[ -z $2 ]] |
425 | then |
426 | PATCHFILE=$1 |
427 | |
428 | ## patch level auto-detection, get patch level |
429 | for ((i=0; i < 10; i++)) |
430 | do |
431 | patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null |
432 | if [[ $? = 0 ]] |
433 | then |
434 | PATCHOPTS="-Np${i}" |
435 | break |
436 | fi |
437 | done |
438 | fi |
439 | |
440 | echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
441 | patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
442 | } |
443 | |
444 | mlibtoolize() |
445 | { |
446 | local opts="$@" |
447 | [[ -z ${opts} ]] && opts="--verbose --install --force" |
448 | |
449 | libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
450 | } |
451 | |
452 | mautoreconf() |
453 | { |
454 | local opts="$@" |
455 | [[ -z ${opts} ]] && opts="--verbose --install --force" |
456 | |
457 | autoreconf ${opts} || die "running: mautoreconf ${opts}" |
458 | } |
459 | |
460 | minstalldocs() |
461 | { |
462 | local docfiles |
463 | local doc |
464 | docfiles="$@" |
465 | |
466 | if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
467 | then |
468 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
469 | fi |
470 | |
471 | for doc in ${docfiles} |
472 | do |
473 | if [ -f ${doc} ] |
474 | then |
475 | if mqueryfeature "compressdoc" |
476 | then |
477 | cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "gzipping +installing ${doc}." |
478 | chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "fixing permissions of ${doc}." |
479 | else |
480 | install -m 0644 ${doc} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}." |
481 | fi |
482 | fi |
483 | done |
484 | } |
485 | |
486 | mstriplibs() |
487 | { |
488 | local stripdir="$@" |
489 | |
490 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
491 | [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug" |
492 | find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null |
493 | } |
494 | |
495 | mstripbins() |
496 | { |
497 | local stripdir="$@" |
498 | |
499 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
500 | [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug" |
501 | find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null |
502 | } |
503 | |
504 | mstripstatic() |
505 | { |
506 | local stripdir="$@" |
507 | |
508 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
509 | [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug" |
510 | find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null |
511 | } |
512 | |
513 | mstriplibtoolarchive() |
514 | { |
515 | local stripdir="$@" |
516 | |
517 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
518 | find ${stripdir} ! -type d -name \*.la | xargs --no-run-if-empty file | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null |
519 | } |
520 | |
521 | mpurgetargets() |
522 | { |
523 | local stripdir="$@" |
524 | local target |
525 | |
526 | [[ -z ${stripdir} ]] && stripdir=${BINDIR} |
527 | # nothing to do in this case |
528 | [[ -z ${PURGE_TARGETS[*]} ]] && return |
529 | |
530 | for target in ${PURGE_TARGETS[*]} |
531 | do |
532 | # check if target is a regex pattern without any slashes |
533 | if [[ ${target} = ${target//\/} ]] |
534 | then |
535 | find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null |
536 | else |
537 | rm -f -- ${target} 2> /dev/null |
538 | fi |
539 | done |
540 | } |
541 | |
542 | mcompressdocs() |
543 | { |
544 | local bindir="$@" |
545 | |
546 | if [ -d ${bindir}/usr/share/man ] |
547 | then |
548 | echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
549 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
550 | fi |
551 | |
552 | if [ -d ${bindir}/usr/share/info ] |
553 | then |
554 | echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
555 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
556 | fi |
557 | } |
558 | |
559 | sminclude() |
560 | { |
561 | local i |
562 | |
563 | if [[ -n "$@" ]] |
564 | then |
565 | for i in $@ |
566 | do |
567 | echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
568 | source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
569 | done |
570 | echo |
571 | fi |
572 | } |
573 | |
574 | march() |
575 | { |
576 | local retval |
577 | |
578 | if [[ ! -z ${ARCH} ]] |
579 | then |
580 | echo "${ARCH}" |
581 | retval=0 |
582 | else |
583 | retval=1 |
584 | fi |
585 | |
586 | return "${retval}" |
587 | } |
588 | |
589 | marchsrcfile() |
590 | { |
591 | local retval |
592 | if [[ ! -z $(eval echo \$SRCFILE_${ARCH/i*86/x86}) ]] |
593 | then |
594 | eval echo \$SRCFILE_${ARCH/i*86/x86} | tr ';' '\n' |
595 | retval=0 |
596 | else |
597 | retval=1 |
598 | fi |
599 | |
600 | return "${retval}" |
601 | } |
602 | |
603 | marchsrcdir() |
604 | { |
605 | local retval |
606 | if [[ ! -z $(eval echo \$SRCDIR_${ARCH/i*86/x86}) ]] |
607 | then |
608 | eval echo \$SRCDIR_${ARCH/i*86/x86} | tr ';' '\n' |
609 | retval=0 |
610 | else |
611 | retval=1 |
612 | fi |
613 | |
614 | return "${retval}" |
615 | } |
616 | |
617 | marchdepend() |
618 | { |
619 | local retval |
620 | |
621 | if [[ ! -z $(eval echo \$DEPEND_${ARCH/i*86/x86}) ]] |
622 | then |
623 | echo "\$(eval echo \\\$DEPEND_\${ARCH/i*86/x86} | tr ';' '\n')" |
624 | retval=0 |
625 | else |
626 | retval=1 |
627 | fi |
628 | |
629 | return "${retval}" |
630 | } |
631 | |
632 | marchsdepend() |
633 | { |
634 | local retval |
635 | if [[ ! -z $(eval echo \$SDEPEND_${ARCH/i*86/x86}) ]] |
636 | then |
637 | echo "\$(eval echo \\\$SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')" |
638 | retval=0 |
639 | else |
640 | retval=1 |
641 | fi |
642 | |
643 | return "${retval}" |
644 | } |
645 | |
646 | setup_distcc_environment() |
647 | { |
648 | if [ -x /usr/bin/distcc ] |
649 | then |
650 | echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" |
651 | export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
652 | |
653 | export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
654 | |
655 | # creating distcc tempdir |
656 | install -o distcc -g daemon -d ${DISTCC_DIR} |
657 | chmod 1777 ${DISTCC_DIR} |
658 | fi |
659 | } |
660 | |
661 | setup_ccache_environment() |
662 | { |
663 | if [ -x /usr/bin/ccache ] |
664 | then |
665 | echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" |
666 | export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
667 | fi |
668 | } |
669 | |
670 | # fixes given dependencies to match a MAGE_TARGET |
671 | # fix_mage_deps -target s/depend # <-- note -target ! |
672 | fix_mage_deps() |
673 | { |
674 | local target="$1" |
675 | local depend="$2" |
676 | local NDEPEND |
677 | local sym dep cat pver pname |
678 | |
679 | # deps and provides are special |
680 | # they must be fixed to match the target |
681 | |
682 | # run this only if target and depend is not empty |
683 | if [ -n "${target}" ] && [ -n "${depend}" ] |
684 | then |
685 | # fix DEPEND |
686 | while read sym dep |
687 | do |
688 | # ignore empty lines |
689 | [[ -z ${dep} ]] && continue |
690 | |
691 | cat="$(dirname ${dep})" |
692 | # change if not virtual |
693 | if [[ ${cat} = virtual ]] |
694 | then |
695 | pname="$(basename ${dep})" |
696 | else |
697 | # fix pver to target-pver |
698 | # to get pname-target-pver |
699 | |
700 | # doing it backwards ! |
701 | pver="${dep##*-}" |
702 | # full pver |
703 | pname="$(basename ${dep/-${pver}/})${target}-${pver}" |
704 | fi |
705 | |
706 | # do not add empty lines |
707 | if [ -z "${NDEPEND}" ] |
708 | then |
709 | NDEPEND="${sym} ${cat}/${pname}" |
710 | else |
711 | NDEPEND="${NDEPEND} |
712 | ${sym} ${cat}/${pname}" |
713 | fi |
714 | |
715 | unset cat pname pver |
716 | done << EOF |
717 | ${depend} |
718 | EOF |
719 | # set NDEPEND to DEPEND |
720 | depend="${NDEPEND}" |
721 | fi |
722 | |
723 | echo "${depend}" |
724 | } |
725 | |
726 | # build_mage_script(): helper functions for regen_mage_tree() |
727 | # generates an mage file with given information in smage file |
728 | # needs at least: |
729 | # PNAME name of pkg |
730 | # PVER version |
731 | # PBUILD revision |
732 | # PCAT category of the pkg |
733 | # PCATEGORIE category of the pkg (deprecated, use PCAT!) |
734 | # STATE state of pkg stable|unstable|old |
735 | # DESCRIPTION a short description (opt) |
736 | # HOMEPAGE homepage (opt) |
737 | # LICENSE license information of the pkg (opt) |
738 | # DEPEND runtime dependencies (opt) |
739 | # SDEPEND adds needed deps to build the pkg (opt) |
740 | # PROVIDE provides a virtual (opt) |
741 | # |
742 | # special tags: |
743 | # PKGTYPE type of pkg |
744 | # INHERITS which functions get included |
745 | # SPECIAL_FUNCTIONS special functions which should also be added |
746 | # warning: they get killed before the build starts ! |
747 | # SPLIT_PACKAGES names of all subpackages which are splitted from parent |
748 | # SPLIT_PACKAGE_BASE base package name for splitpackages |
749 | # (only in the resulting magefile} |
750 | # |
751 | # MAGE_TREE_DEST target destination of the generated tree |
752 | # REGEN_MAGE_TREE set to 'true' to enable this |
753 | # |
754 | # gets called with build_mage_script target |
755 | build_mage_script() |
756 | { |
757 | local magefile |
758 | local dest |
759 | local target |
760 | local split_pkg_base |
761 | local sym |
762 | local depname |
763 | |
764 | # if MAGE_TREE_DEST not set use BUILDDIR |
765 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
766 | |
767 | # determinate which suffix this mage file should get, if any |
768 | [[ $1 = --target ]] && shift && target="-$1" |
769 | |
770 | # mark package as splitpackage |
771 | [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
772 | |
773 | # name of magefile |
774 | magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
775 | |
776 | # destination to magefile |
777 | dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}${target}/${magefile}" |
778 | |
779 | # show what we are doing |
780 | echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" |
781 | echo "${dest}" |
782 | |
783 | install -d "$(dirname ${dest})" |
784 | # now build the mage file |
785 | > ${dest} |
786 | |
787 | # pgkname and state |
788 | echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest} |
789 | echo "STATE=\"${STATE}\"" >> ${dest} |
790 | |
791 | # description and homepage |
792 | echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
793 | echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
794 | |
795 | # license information |
796 | echo "LICENSE=\"${LICENSE}\"" >> ${dest} |
797 | |
798 | # special tags and vars |
799 | echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
800 | |
801 | # echo MAGE_TARGETS ## note -target is needed ! |
802 | echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
803 | |
804 | # split package base |
805 | echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
806 | |
807 | # add special vars |
808 | if [ -n "${SPECIAL_VARS}" ] |
809 | then |
810 | local i |
811 | for i in ${SPECIAL_VARS} |
812 | do |
813 | # being tricky here :) |
814 | echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
815 | done |
816 | fi |
817 | |
818 | # add at least all includes |
819 | if [ -n "${INHERITS}" ] |
820 | then |
821 | echo -n "minclude" >> ${dest} |
822 | local i |
823 | for i in ${INHERITS} |
824 | do |
825 | echo -n " ${i}" >> ${dest} |
826 | done |
827 | # a CRLF is needed here! |
828 | echo >> ${dest} |
829 | fi |
830 | |
831 | # deps and provides |
832 | echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
833 | echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
834 | echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
835 | |
836 | # add special functions |
837 | if [ -n "${SPECIAL_FUNCTIONS}" ] |
838 | then |
839 | local i |
840 | for i in ${SPECIAL_FUNCTIONS} |
841 | do |
842 | # add to mage (quotes needed !) |
843 | typeset -f "${i}" >> ${dest} |
844 | # unset to be safe (quotes needed !) |
845 | #unset "${i}" <-- later to get every target built |
846 | done |
847 | fi |
848 | |
849 | # pre|post-install|removes |
850 | typeset -f preinstall >> ${dest} |
851 | typeset -f postinstall >> ${dest} |
852 | typeset -f preremove >> ${dest} |
853 | typeset -f postremove >> ${dest} |
854 | } |
855 | |
856 | regen_mage_tree() |
857 | { |
858 | local subpackage |
859 | |
860 | # build them only if requested |
861 | if mqueryfeature regentree |
862 | then |
863 | # run it without targets |
864 | if [[ -n ${MAGE_TARGETS} ]] |
865 | then |
866 | # build for each target a mage file |
867 | # run it with several targets |
868 | echo |
869 | for subpackage in ${MAGE_TARGETS} |
870 | do |
871 | build_mage_script --target "${subpackage}" |
872 | done |
873 | echo |
874 | |
875 | # run it for splitpackages |
876 | elif [[ -n ${SPLIT_PACKAGES} ]] |
877 | then |
878 | local split_pkg_base="${PNAME}" |
879 | # save smage environment |
880 | split_save_variables |
881 | # build for each subpackage a mage file |
882 | # run it with several targets |
883 | echo |
884 | for subpackage in ${SPLIT_PACKAGES} |
885 | do |
886 | # get the right variables for the split |
887 | export PNAME="${subpackage}" |
888 | split_info_${subpackage} |
889 | # fix PCATEGORIE -> PCAT |
890 | if [[ ! -z ${PCATEGORIE} ]] |
891 | then |
892 | PCAT="${PCATEGORIE}" |
893 | unset PCATEGORIE |
894 | fi |
895 | # get the preinstall etc |
896 | split_export_inherits ${subpackage} |
897 | build_mage_script --split-pkg-base "${split_pkg_base}" |
898 | # delete split preinstall etc |
899 | split_delete_inherits ${subpackage} |
900 | # restore smage environment |
901 | split_restore_variables |
902 | done |
903 | echo |
904 | # unset all saved smage variables |
905 | split_unset_variables |
906 | |
907 | else |
908 | echo |
909 | build_mage_script |
910 | echo |
911 | fi |
912 | fi |
913 | |
914 | # now unset all uneeded vars to be safe |
915 | # unset PKGNAME <-- don't do that; smage needs this var |
916 | # unset to be safe (quotes needed !) |
917 | # for i in ${SPECIAL_FUNCTIONS} |
918 | # do |
919 | # unset "${i}" |
920 | # done |
921 | unset SPECIAL_FUNCTIONS |
922 | # for i in ${SPECIAL_VARS} |
923 | # do |
924 | # unset "${i}" |
925 | # done |
926 | unset SPECIAL_VARS |
927 | unset STATE |
928 | unset DESCRIPTION |
929 | unset HOMEPAGE |
930 | # unset PKGTYPE <-- don't do that either; smage needs this var |
931 | unset INHERITS |
932 | unset DEPEND |
933 | unset SDEPEND |
934 | unset PROVIDE |
935 | unset preinstall |
936 | unset postinstall |
937 | unset preremove |
938 | unset postremove |
939 | } |
940 | |
941 | split_save_variables() |
942 | { |
943 | export SAVED_PNAME="${PNAME}" |
944 | export SAVED_PVER="${PVER}" |
945 | export SAVED_PBUILD="${PBUILD}" |
946 | export SAVED_PCAT="${PCAT}" |
947 | export SAVED_DESCRIPTION="${DESCRIPTION}" |
948 | export SAVED_HOMEPAGE="${HOMEPAGE}" |
949 | export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
950 | export SAVED_STATE="${STATE}" |
951 | export SAVED_PKGTYPE="${PKGTYPE}" |
952 | export SAVED_INHERITS="${INHERITS}" |
953 | export SAVED_DEPEND="${DEPEND}" |
954 | export SAVED_SDEPEND="${SDEPEND}" |
955 | export SAVED_PROVIDE="${PROVIDE}" |
956 | export SAVED_PKGTYPE="${PKGTYPE}" |
957 | |
958 | # special handling needed for mage features |
959 | # pkgbuild |
960 | mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild" |
961 | mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild" |
962 | # strip |
963 | mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip" |
964 | mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip" |
965 | # libtool |
966 | mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool" |
967 | mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool" |
968 | # compressdoc |
969 | mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc" |
970 | mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc" |
971 | |
972 | # bindir too |
973 | export SAVED_BINDIR="${BINDIR}" |
974 | |
975 | # export the SPLIT_PACKAGE_BASE |
976 | export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
977 | |
978 | # functions |
979 | if [[ ! -z $(typeset -f preinstall) ]] |
980 | then |
981 | # rename the old one |
982 | local saved_preinstall |
983 | saved_preinstall=SAVED_$(typeset -f preinstall) |
984 | eval "${saved_preinstall}" |
985 | export -f SAVED_preinstall |
986 | fi |
987 | |
988 | if [[ ! -z $(typeset -f postinstall) ]] |
989 | then |
990 | # rename the old one |
991 | local saved_postinstall |
992 | saved_postinstall=SAVED_$(typeset -f postinstall) |
993 | eval "${saved_postinstall}" |
994 | export -f SAVED_postinstall |
995 | fi |
996 | |
997 | if [[ ! -z $(typeset -f preremove) ]] |
998 | then |
999 | # rename the old one |
1000 | local saved_preremove |
1001 | saved_preremove=SAVED_$(typeset -f preremove) |
1002 | eval "${saved_preremove}" |
1003 | export -f SAVED_preremove |
1004 | fi |
1005 | |
1006 | if [[ ! -z $(typeset -f postremove) ]] |
1007 | then |
1008 | # rename the old one |
1009 | local saved_postremove |
1010 | saved_postremove=SAVED_$(typeset -f postremove) |
1011 | eval "${saved_postremove}" |
1012 | export -f SAVED_postremove |
1013 | fi |
1014 | } |
1015 | |
1016 | split_restore_variables() |
1017 | { |
1018 | export PNAME="${SAVED_PNAME}" |
1019 | export PVER="${SAVED_PVER}" |
1020 | export PBUILD="${SAVED_PBUILD}" |
1021 | export PCAT="${SAVED_PCAT}" |
1022 | export DESCRIPTION="${SAVED_DESCRIPTION}" |
1023 | export HOMEPAGE="${SAVED_HOMEPAGE}" |
1024 | export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
1025 | export STATE="${SAVED_STATE}" |
1026 | export PKGTYPE="${SAVED_PKGTYPE}" |
1027 | export INHERITS="${SAVED_INHERITS}" |
1028 | export DEPEND="${SAVED_DEPEND}" |
1029 | export SDEPEND="${SAVED_SDEPEND}" |
1030 | export PROVIDE="${SAVED_PROVIDE}" |
1031 | export PKGTYPE="${SAVED_PKGTYPE}" |
1032 | |
1033 | # special handling needed for mage features |
1034 | # pkgbuild |
1035 | FVERBOSE=off msetfeature "${SAVED_FEATURE_PKGBUILD}" |
1036 | # strip |
1037 | FVERBOSE=off msetfeature "${SAVED_FEATURE_STRIP}" |
1038 | # libtool |
1039 | FVERBOSE=off msetfeature "${SAVED_FEATURE_LIBTOOL}" |
1040 | # compressdoc |
1041 | FVERBOSE=off msetfeature "${SAVED_FEATURE_COMPRESSDOC}" |
1042 | |
1043 | # bindir too |
1044 | export BINDIR="${SAVED_BINDIR}" |
1045 | |
1046 | # functions |
1047 | if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
1048 | then |
1049 | # rename the old one |
1050 | local saved_preinstall |
1051 | saved_preinstall=$(typeset -f SAVED_preinstall) |
1052 | eval "${saved_preinstall/SAVED_/}" |
1053 | export -f preinstall |
1054 | fi |
1055 | |
1056 | if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
1057 | then |
1058 | # rename the old one |
1059 | local saved_postinstall |
1060 | saved_postinstall=$(typeset -f SAVED_postinstall) |
1061 | eval "${saved_postinstall/SAVED_/}" |
1062 | export -f postinstall |
1063 | fi |
1064 | |
1065 | if [[ ! -z $(typeset -f SAVED_preremove) ]] |
1066 | then |
1067 | # rename the old one |
1068 | local saved_preremove |
1069 | saved_preremove=$(typeset -f SAVED_preremove) |
1070 | eval "${saved_preremove/SAVED_/}" |
1071 | export -f preremove |
1072 | fi |
1073 | |
1074 | if [[ ! -z $(typeset -f SAVED_postremove) ]] |
1075 | then |
1076 | # rename the old one |
1077 | local saved_postremove |
1078 | saved_postremove=$(typeset -f SAVED_postremove) |
1079 | eval "${saved_postremove/SAVED_/}" |
1080 | export -f postremove |
1081 | fi |
1082 | } |
1083 | |
1084 | split_unset_variables() |
1085 | { |
1086 | # unset saved vars; not needed anymore |
1087 | unset SAVED_PNAME |
1088 | unset SAVED_PVER |
1089 | unset SAVED_PBUILD |
1090 | unset SAVED_PCAT |
1091 | unset SAVED_DESCRIPTION |
1092 | unset SAVED_HOMEPAGE |
1093 | unset SAVED_SPECIAL_VARS |
1094 | unset SAVED_STATE |
1095 | unset SAVED_PKGTYPE |
1096 | unset SAVED_INHERITS |
1097 | unset SAVED_DEPEND |
1098 | unset SAVED_SDEPEND |
1099 | unset SAVED_PROVIDE |
1100 | unset SAVED_BINDIR |
1101 | unset SAVED_PKGTYPE |
1102 | unset SAVED_FEATURE_PKGBUILD |
1103 | unset SAVED_FEATURE_STRIP |
1104 | unset SAVED_FEATURE_LIBTOOL |
1105 | unset SAVED_FEATURE_COMPRESSDOC |
1106 | unset SPLIT_PACKAGE_BASE |
1107 | unset -f SAVED_preinstall |
1108 | unset -f SAVED_postinstall |
1109 | unset -f SAVED_preremove |
1110 | unset -f SAVED_postremove |
1111 | } |
1112 | |
1113 | split_export_inherits() |
1114 | { |
1115 | local subpackage="$1" |
1116 | local func |
1117 | local newfunc |
1118 | |
1119 | for func in preinstall postinstall preremove postremove |
1120 | do |
1121 | if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1122 | then |
1123 | newfunc=$(typeset -f ${func}_${subpackage}) |
1124 | newfunc="${newfunc/_${subpackage} (/ (}" |
1125 | eval "${newfunc}" |
1126 | fi |
1127 | done |
1128 | } |
1129 | |
1130 | split_delete_inherits() |
1131 | { |
1132 | local subpackage="$1" |
1133 | local func |
1134 | |
1135 | for func in preinstall postinstall preremove postremove |
1136 | do |
1137 | if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1138 | then |
1139 | unset -f ${func} |
1140 | fi |
1141 | done |
1142 | } |
1143 | |
1144 | export_inherits() |
1145 | { |
1146 | local include="$1" |
1147 | shift |
1148 | |
1149 | while [ "$1" ] |
1150 | do |
1151 | local functions="$1" |
1152 | |
1153 | # sanity checks |
1154 | [ -z "${include}" ] && die "export_inherits(): \$include not given." |
1155 | [ -z "${functions}" ] && die "export_inherits(): \$functions not given." |
1156 | |
1157 | eval "${functions}() { ${include}_${functions} ; }" |
1158 | |
1159 | # debug |
1160 | [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
1161 | |
1162 | shift |
1163 | done |
1164 | } |
1165 | |
1166 | generate_package_md5sum() |
1167 | { |
1168 | local dest |
1169 | local pcat |
1170 | local pname |
1171 | local pver |
1172 | local pbuild |
1173 | local parch |
1174 | local target |
1175 | local pkgname |
1176 | |
1177 | # very basic getops |
1178 | for i in $* |
1179 | do |
1180 | case $1 in |
1181 | --pcat|-c) shift; pcat="$1" ;; |
1182 | --pname|-n) shift; pname="$1" ;; |
1183 | --pver|-v) shift; pver="$1" ;; |
1184 | --pbuild|-b) shift; pbuild="$1" ;; |
1185 | --parch|a) shift; parch="$1" ;; |
1186 | --target|t) shift; target="$1" ;; |
1187 | esac |
1188 | shift |
1189 | done |
1190 | |
1191 | # sanity checks; abort if not given |
1192 | [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given." |
1193 | [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given." |
1194 | [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given." |
1195 | [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given." |
1196 | [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given." |
1197 | |
1198 | # check needed global vars |
1199 | [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set." |
1200 | [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set." |
1201 | |
1202 | # fix target as it may be empty ! |
1203 | [ -n "${target}" ] && target="-${target}" |
1204 | |
1205 | # build pkgname |
1206 | pkgname="${pname}${target}-${pver}-${parch}$(print_distrotag)-${pbuild}" |
1207 | |
1208 | # build pkg-md5-sum only if requested |
1209 | if mqueryfeature regentree |
1210 | then |
1211 | echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
1212 | |
1213 | # abort if not exist |
1214 | if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] |
1215 | then |
1216 | echo -e "${COLRED}! exists${COLDEFAULT}" |
1217 | return 0 |
1218 | fi |
1219 | |
1220 | # if MAGE_TREE_DEST not set use BUILDDIR |
1221 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1222 | |
1223 | # setup md5 dir |
1224 | dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1225 | install -d ${dest} |
1226 | |
1227 | # gen md5sum |
1228 | ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ |
1229 | > ${dest}/${pkgname}.md5 |
1230 | echo -e "${COLGREEN}done${COLDEFAULT}" |
1231 | fi |
1232 | } |
1233 | |
1234 | source_pkg_build() |
1235 | { |
1236 | if [[ ${PKGTYPE} = virtual ]] |
1237 | then |
1238 | echo "Virtual package detected; src-pkg-tarball not necessary ..." |
1239 | return 0 |
1240 | fi |
1241 | |
1242 | if [[ ! -d ${SOURCEDIR}/${PNAME} ]] |
1243 | then |
1244 | echo "No SRC_URI defined; src-pkg-tarball not necessary ..." |
1245 | return 0 |
1246 | fi |
1247 | |
1248 | [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." |
1249 | |
1250 | echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
1251 | |
1252 | # include the smage2 file |
1253 | cp ${SMAGENAME} ${SOURCEDIR}/${PNAME} |
1254 | |
1255 | ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; ) |
1256 | [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR} |
1257 | mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} |
1258 | |
1259 | echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}\n" |
1260 | } |
1261 | |
1262 | step_by_step() |
1263 | { |
1264 | if mqueryfeature stepbystep |
1265 | then |
1266 | echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1267 | echo "Press [enter] to continue" |
1268 | read |
1269 | fi |
1270 | } |
1271 | |
1272 | resume_stamp() |
1273 | { |
1274 | local step="$1" |
1275 | [[ ! -d ${BUILDDIR}/.stamps ]] && install -d ${BUILDDIR}/.stamps |
1276 | touch ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step} |
1277 | } |
1278 | |
1279 | run_resume() |
1280 | { |
1281 | local step="$1" |
1282 | |
1283 | if mqueryfeature "resume" && [[ -f ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step} ]] |
1284 | then |
1285 | echo -e "${COLMAGENTA}${step} already processed; doing nothing${COLDEFAULT}" |
1286 | return 0 |
1287 | else |
1288 | return 1 |
1289 | fi |
1290 | } |