Contents of /trunk/mage/usr/lib/mage/smage2.functions.sh
Parent Directory | Revision Log
Revision 3180 -
(show annotations)
(download)
(as text)
Mon Jul 31 09:19:58 2023 UTC (9 months, 1 week ago) by niro
File MIME type: application/x-sh
File size: 29721 byte(s)
Mon Jul 31 09:19:58 2023 UTC (9 months, 1 week ago) by niro
File MIME type: application/x-sh
File size: 29721 byte(s)
-fixed ARCH evaluation, escape the vars correctly
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 | pkg_setup() |
229 | { |
230 | echo "no pkg_setup defined; doing nothing ..." |
231 | return 0 |
232 | } |
233 | |
234 | # dummy function, used if that does not exist in smage file |
235 | src_prepare() |
236 | { |
237 | echo "no src_prepare defined; doing nothing ..." |
238 | return 0 |
239 | } |
240 | |
241 | # dummy function, used if that does not exist in smage file |
242 | src_compile() |
243 | { |
244 | echo "no src_compile defined; doing nothing ..." |
245 | return 0 |
246 | } |
247 | |
248 | # dummy function, used if that does not exist in smage file |
249 | src_check() |
250 | { |
251 | echo "no src_check defined; doing nothing ..." |
252 | return 0 |
253 | } |
254 | |
255 | # dummy function, used if that does not exist in smage file |
256 | src_install() |
257 | { |
258 | echo "no src_install defined; doing nothing ..." |
259 | return 0 |
260 | } |
261 | |
262 | mlibdir() |
263 | { |
264 | local libdir="${ABI_DEFAULT_LIBDIR}" |
265 | [[ ${ARCH} = i686 ]] && libdir="${ABI_X86_LIBDIR}" |
266 | [[ ${ARCH} = x86_64 ]] && libdir="${ABI_X86_64_LIBDIR}" |
267 | [[ -n ${ABI_LIBDIR} ]] && libdir="${ABI_LIBDIR}" |
268 | |
269 | echo "${libdir}" |
270 | } |
271 | |
272 | mconfigure() |
273 | { |
274 | local myopts |
275 | if [[ ! -z ${CTARGET} ]] |
276 | then |
277 | myopts+=" --target=${CTARGET}" |
278 | fi |
279 | |
280 | if [ -x ./configure ] |
281 | then |
282 | # if requested disable-static |
283 | if [[ ! -z $(./configure --help | grep -- '--.*able-static') ]] |
284 | then |
285 | if mqueryfeature '!static' |
286 | then |
287 | myopts+=" --disable-static" |
288 | else |
289 | myopts+=" --enable-static" |
290 | fi |
291 | fi |
292 | |
293 | # always enable shared by default but not for waf configure |
294 | if [[ ! -z $(./configure --help | grep -- '--.*able-shared') ]] && |
295 | [[ -z $(./configure --version | grep waf) ]] |
296 | then |
297 | myopts+=" --enable-shared" |
298 | fi |
299 | |
300 | ./configure \ |
301 | --prefix=/usr \ |
302 | --host=${CHOST} \ |
303 | --build=${CHOST} \ |
304 | --mandir=/usr/share/man \ |
305 | --infodir=/usr/share/info \ |
306 | --datadir=/usr/share \ |
307 | --sysconfdir=/etc \ |
308 | --localstatedir=/var/lib \ |
309 | --libdir=/usr/$(mlibdir) \ |
310 | ${myopts} \ |
311 | "$@" || die "mconfigure failed" |
312 | else |
313 | echo "configure is not an executable ..." |
314 | exit 1 |
315 | fi |
316 | } |
317 | |
318 | minstall() |
319 | { |
320 | if [ -f ./[mM]akefile -o -f ./GNUmakefile ] |
321 | then |
322 | make prefix=${BINDIR}/usr \ |
323 | datadir=${BINDIR}/usr/share \ |
324 | infodir=${BINDIR}/usr/share/info \ |
325 | localstatedir=${BINDIR}/var/lib \ |
326 | mandir=${BINDIR}/usr/share/man \ |
327 | sysconfdir=${BINDIR}/etc \ |
328 | libdir=${BINDIR}/usr/$(mlibdir) \ |
329 | "$@" install || die "minstall failed" |
330 | else |
331 | die "no Makefile found" |
332 | fi |
333 | } |
334 | |
335 | mmake() |
336 | { |
337 | make ${MAKEOPTS} ${EXTRA_EMAKE} "$@" |
338 | } |
339 | |
340 | munpack() |
341 | { |
342 | local SRCFILE |
343 | local IFTAR |
344 | local DEST |
345 | |
346 | SRCFILE=$1 |
347 | |
348 | if [[ -z $2 ]] |
349 | then |
350 | DEST=${BUILDDIR} |
351 | else |
352 | DEST=$2 |
353 | fi |
354 | |
355 | echo -e "${COLBLUE}>>>${COLGREEN} Unpacking ${SOURCEDIR}/${PNAME}/${SRCFILE}${COLDEFAULT}" |
356 | |
357 | [[ ! -d ${DEST} ]] && install -d ${DEST} |
358 | |
359 | case "${SRCFILE##*.}" in |
360 | bz2) |
361 | IFTAR="$(basename $SRCFILE .bz2)" |
362 | IFTAR="${IFTAR##*.}" |
363 | if [[ ${IFTAR} = tar ]] |
364 | then |
365 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." |
366 | else |
367 | pushd ${DEST} > /dev/null |
368 | bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." |
369 | popd > /dev/null |
370 | fi |
371 | ;; |
372 | gz) |
373 | IFTAR="$(basename $SRCFILE .gz)" |
374 | IFTAR="${IFTAR##*.}" |
375 | if [[ ${IFTAR} = tar ]] |
376 | then |
377 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." |
378 | else |
379 | pushd ${DEST} > /dev/null |
380 | zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." |
381 | popd > /dev/null |
382 | fi |
383 | ;; |
384 | xz) |
385 | IFTAR="$(basename $SRCFILE .xz)" |
386 | IFTAR="${IFTAR##*.}" |
387 | if [[ ${IFTAR} = tar ]] |
388 | then |
389 | tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed." |
390 | else |
391 | pushd ${DEST} > /dev/null |
392 | xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed." |
393 | popd > /dev/null |
394 | fi |
395 | ;; |
396 | lz) |
397 | IFTAR="$(basename $SRCFILE .lz)" |
398 | IFTAR="${IFTAR##*.}" |
399 | if [[ ${IFTAR} = tar ]] |
400 | then |
401 | tar --no-same-owner -xvf --lzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.lz unpack failed." |
402 | else |
403 | pushd ${DEST} > /dev/null |
404 | lzip -dc ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".lz unpack failed." |
405 | popd > /dev/null |
406 | fi |
407 | ;; |
408 | tbz2|mpks|mpk) |
409 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
410 | ;; |
411 | tgz) |
412 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
413 | ;; |
414 | txz|mpkzs|mpkz) |
415 | tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed." |
416 | ;; |
417 | rar) |
418 | unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
419 | ;; |
420 | zip|xpi|jar) |
421 | unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
422 | ;; |
423 | rpm) |
424 | pushd ${DEST} > /dev/null |
425 | rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
426 | tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
427 | if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
428 | then |
429 | rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
430 | fi |
431 | ;; |
432 | *) |
433 | die "munpack failed" |
434 | ;; |
435 | esac |
436 | } |
437 | |
438 | mpatch() |
439 | { |
440 | local PATCHOPTS |
441 | local PATCHFILE |
442 | local i |
443 | |
444 | PATCHOPTS=$1 |
445 | PATCHFILE=$2 |
446 | |
447 | if [[ -z $2 ]] |
448 | then |
449 | PATCHFILE=$1 |
450 | |
451 | ## patch level auto-detection, get patch level |
452 | for ((i=0; i < 10; i++)) |
453 | do |
454 | patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null |
455 | if [[ $? = 0 ]] |
456 | then |
457 | PATCHOPTS="-Np${i}" |
458 | break |
459 | fi |
460 | done |
461 | fi |
462 | |
463 | echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
464 | patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
465 | } |
466 | |
467 | mlibtoolize() |
468 | { |
469 | local opts="$@" |
470 | [[ -z ${opts} ]] && opts="--verbose --install --force" |
471 | |
472 | libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
473 | } |
474 | |
475 | mautoreconf() |
476 | { |
477 | local opts="$@" |
478 | [[ -z ${opts} ]] && opts="--verbose --install --force" |
479 | |
480 | autoreconf ${opts} || die "running: mautoreconf ${opts}" |
481 | } |
482 | |
483 | minstalldocs() |
484 | { |
485 | local docfiles |
486 | local doc |
487 | docfiles="$@" |
488 | |
489 | if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
490 | then |
491 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
492 | fi |
493 | |
494 | for doc in ${docfiles} |
495 | do |
496 | if [ -f ${doc} ] |
497 | then |
498 | if mqueryfeature "compressdoc" |
499 | then |
500 | cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "gzipping +installing ${doc}." |
501 | chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "fixing permissions of ${doc}." |
502 | else |
503 | install -m 0644 ${doc} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}." |
504 | fi |
505 | fi |
506 | done |
507 | } |
508 | |
509 | mstriplibs() |
510 | { |
511 | local stripdir="$@" |
512 | |
513 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
514 | [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug" |
515 | find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "[shared object|pie executable]" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null |
516 | } |
517 | |
518 | mstripbins() |
519 | { |
520 | local stripdir="$@" |
521 | |
522 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
523 | [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug" |
524 | find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep -v "pie executable" | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null |
525 | } |
526 | |
527 | mstripstatic() |
528 | { |
529 | local stripdir="$@" |
530 | |
531 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
532 | [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug" |
533 | 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 |
534 | } |
535 | |
536 | mstriplibtoolarchive() |
537 | { |
538 | local stripdir="$@" |
539 | |
540 | [[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
541 | 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 |
542 | } |
543 | |
544 | mpurgetargets() |
545 | { |
546 | local stripdir="$@" |
547 | local target |
548 | |
549 | [[ -z ${stripdir} ]] && stripdir=${BINDIR} |
550 | # nothing to do in this case |
551 | [[ -z ${PURGE_TARGETS[*]} ]] && return |
552 | |
553 | for target in ${PURGE_TARGETS[*]} |
554 | do |
555 | # check if target is a regex pattern without any slashes |
556 | if [[ ${target} = ${target//\/} ]] |
557 | then |
558 | find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null |
559 | else |
560 | rm -f -- ${target} 2> /dev/null |
561 | fi |
562 | done |
563 | } |
564 | |
565 | mcompressdocs() |
566 | { |
567 | local bindir="$@" |
568 | |
569 | if [ -d ${bindir}/usr/share/man ] |
570 | then |
571 | echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
572 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
573 | fi |
574 | |
575 | if [ -d ${bindir}/usr/share/info ] |
576 | then |
577 | echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
578 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
579 | fi |
580 | } |
581 | |
582 | sminclude() |
583 | { |
584 | local i |
585 | |
586 | if [[ -n "$@" ]] |
587 | then |
588 | for i in $@ |
589 | do |
590 | [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
591 | source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
592 | done |
593 | [[ ${SILENT} = 1 ]] || echo |
594 | fi |
595 | } |
596 | |
597 | march() |
598 | { |
599 | local retval |
600 | |
601 | if [[ ! -z ${ARCH} ]] |
602 | then |
603 | echo "${ARCH}" |
604 | retval=0 |
605 | else |
606 | retval=1 |
607 | fi |
608 | |
609 | return "${retval}" |
610 | } |
611 | |
612 | marchvariable() |
613 | { |
614 | local retval |
615 | local var="$1" |
616 | |
617 | [[ -n ${var} ]] || die "marchvariable(): missing variable" |
618 | |
619 | if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]] |
620 | then |
621 | eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n' |
622 | retval=0 |
623 | else |
624 | retval=1 |
625 | fi |
626 | |
627 | return "${retval}" |
628 | } |
629 | |
630 | marchsrcfile() |
631 | { |
632 | local retval |
633 | local var="$1" |
634 | |
635 | [[ -z ${var} ]] && var="SRCFILE" |
636 | |
637 | marchvariable "${var}" || die |
638 | } |
639 | |
640 | marchsrcdir() |
641 | { |
642 | local retval |
643 | local var="$1" |
644 | |
645 | [[ -z ${var} ]] && var="SRCDIR" |
646 | |
647 | marchvariable "${var}" || die |
648 | } |
649 | |
650 | marchdepend() |
651 | { |
652 | local retval |
653 | local var="$1" |
654 | |
655 | [[ -z ${var} ]] && var="DEPEND" |
656 | |
657 | if [[ ! -z $(eval echo \"\$${var}_${ARCH/i*86/x86}\") ]] |
658 | then |
659 | # evaluate with escape strings for the magefile if called by smage |
660 | # but do not escape if the smagefile was called by depwalker directly |
661 | if [[ ${SMAGE_DEPEND} = 1 ]] |
662 | then |
663 | eval echo \"\$${var}_${ARCH/i*86/x86}\" | tr ';' '\n' |
664 | else |
665 | echo "\$(eval echo \\\"\\\$${var}_\${ARCH/i*86/x86}\\\" | tr ';' '\n')" |
666 | fi |
667 | retval=0 |
668 | else |
669 | retval=1 |
670 | fi |
671 | |
672 | return "${retval}" |
673 | } |
674 | |
675 | marchsdepend() |
676 | { |
677 | local retval |
678 | local var="$1" |
679 | |
680 | [[ -z ${var} ]] && var="SDEPEND" |
681 | |
682 | if [[ ! -z $(eval echo \"\$${var}_${ARCH/i*86/x86}\") ]] |
683 | then |
684 | # evaluate with escape strings for the magefile if called by smage |
685 | # but do not escape if the smagefile was called by depwalker directly |
686 | if [[ ${SMAGE_DEPEND} = 1 ]] |
687 | then |
688 | eval echo \"\$${var}_${ARCH/i*86/x86}\" | tr ';' '\n' |
689 | else |
690 | echo "\$(eval echo \\\"\\\$${var}_\${ARCH/i*86/x86}\\\" | tr ';' '\n')" |
691 | fi |
692 | retval=0 |
693 | else |
694 | retval=1 |
695 | fi |
696 | |
697 | return "${retval}" |
698 | } |
699 | |
700 | setup_distcc_environment() |
701 | { |
702 | if [ -x /usr/bin/distcc ] |
703 | then |
704 | echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" |
705 | export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
706 | |
707 | export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
708 | |
709 | # creating distcc tempdir |
710 | install -o distcc -g daemon -d ${DISTCC_DIR} |
711 | chmod 1777 ${DISTCC_DIR} |
712 | fi |
713 | } |
714 | |
715 | setup_icecc_environment() |
716 | { |
717 | if [ -x /usr/bin/icecc ] |
718 | then |
719 | echo -e "${COLBLUE}---${COLGREEN} Using IceCC for compilation ...${COLDEFAULT}" |
720 | export PATH=/usr/$(mlibdir)/icecc/bin:${PATH} || die "icecc: could not export new $PATH" |
721 | fi |
722 | } |
723 | |
724 | setup_ccache_environment() |
725 | { |
726 | if [ -x /usr/bin/ccache ] |
727 | then |
728 | mqueryfeature "icecc" && export CCACHE_PREFIX=icecc |
729 | |
730 | echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" |
731 | export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
732 | fi |
733 | } |
734 | |
735 | # build_mage_script(): helper functions for regen_mage_tree() |
736 | # generates an mage file with given information in smage file |
737 | # needs at least: |
738 | # PNAME name of pkg |
739 | # PVER version |
740 | # PBUILD revision |
741 | # PCAT category of the pkg |
742 | # PCATEGORIE category of the pkg (deprecated, use PCAT!) |
743 | # STATE state of pkg stable|unstable|old |
744 | # DESCRIPTION a short description (opt) |
745 | # HOMEPAGE homepage (opt) |
746 | # LICENSE license information of the pkg (opt) |
747 | # DEPEND runtime dependencies (opt) |
748 | # SDEPEND adds needed deps to build the pkg (opt) |
749 | # PROVIDE provides a virtual (opt) |
750 | # |
751 | # special tags: |
752 | # PKGTYPE type of pkg |
753 | # INHERITS which functions get included |
754 | # SPECIAL_FUNCTIONS special functions which should also be added |
755 | # warning: they get killed before the build starts ! |
756 | # SPLIT_PACKAGES names of all subpackages which are splitted from parent |
757 | # SPLIT_PACKAGE_BASE base package name for splitpackages |
758 | # (only in the resulting magefile} |
759 | # |
760 | # MAGE_TREE_DEST target destination of the generated tree |
761 | # REGEN_MAGE_TREE set to 'true' to enable this |
762 | # |
763 | # gets called with build_mage_script target |
764 | build_mage_script() |
765 | { |
766 | local magefile |
767 | local dest |
768 | local split_pkg_base |
769 | local sym |
770 | local depname |
771 | |
772 | # if MAGE_TREE_DEST not set use BUILDDIR |
773 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
774 | |
775 | # mark package as splitpackage |
776 | [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
777 | |
778 | # name of magefile |
779 | magefile="${PNAME}-${PVER}-${PBUILD}.mage" |
780 | |
781 | # destination to magefile |
782 | dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}/${magefile}" |
783 | |
784 | # show what we are doing |
785 | echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" |
786 | echo "${dest}" |
787 | |
788 | install -d "$(dirname ${dest})" |
789 | # now build the mage file |
790 | > ${dest} |
791 | |
792 | # pgkname and state |
793 | echo "PKGNAME=\"${PNAME}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest} |
794 | echo "STATE=\"${STATE}\"" >> ${dest} |
795 | |
796 | # description and homepage |
797 | echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
798 | echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
799 | |
800 | # license information |
801 | echo "LICENSE=\"${LICENSE}\"" >> ${dest} |
802 | |
803 | # special tags and vars |
804 | echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
805 | |
806 | # split package base |
807 | echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
808 | |
809 | # add special vars |
810 | if [ -n "${SPECIAL_VARS}" ] |
811 | then |
812 | local i |
813 | for i in ${SPECIAL_VARS} |
814 | do |
815 | # being tricky here :) |
816 | echo "${i}=\"$(eval echo \"\$${i}\")\"" >> ${dest} |
817 | done |
818 | fi |
819 | |
820 | # add at least all includes |
821 | if [ -n "${INHERITS}" ] |
822 | then |
823 | echo -n "minclude" >> ${dest} |
824 | local i |
825 | for i in ${INHERITS} |
826 | do |
827 | echo -n " ${i}" >> ${dest} |
828 | done |
829 | # a CRLF is needed here! |
830 | echo >> ${dest} |
831 | fi |
832 | |
833 | # deps and provides |
834 | echo "DEPEND=\"${DEPEND}\"" >> ${dest} |
835 | echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} |
836 | echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
837 | |
838 | # add special functions |
839 | if [ -n "${SPECIAL_FUNCTIONS}" ] |
840 | then |
841 | local i |
842 | for i in ${SPECIAL_FUNCTIONS} |
843 | do |
844 | # add to mage (quotes needed !) |
845 | typeset -f "${i}" >> ${dest} |
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 for splitpackages |
864 | if [[ -n ${SPLIT_PACKAGES} ]] |
865 | then |
866 | local split_pkg_base="${PNAME}" |
867 | # save smage environment |
868 | split_save_variables |
869 | # build for each subpackage a mage file |
870 | # run it with several targets |
871 | echo |
872 | for subpackage in ${SPLIT_PACKAGES} |
873 | do |
874 | # get the right variables for the split |
875 | export PNAME="${subpackage}" |
876 | split_info_${subpackage} |
877 | # fix PCATEGORIE -> PCAT |
878 | if [[ ! -z ${PCATEGORIE} ]] |
879 | then |
880 | PCAT="${PCATEGORIE}" |
881 | unset PCATEGORIE |
882 | fi |
883 | # get the preinstall etc |
884 | split_export_inherits ${subpackage} |
885 | build_mage_script --split-pkg-base "${split_pkg_base}" |
886 | # delete split preinstall etc |
887 | split_delete_inherits ${subpackage} |
888 | # restore smage environment |
889 | split_restore_variables |
890 | done |
891 | echo |
892 | # unset all saved smage variables |
893 | split_unset_variables |
894 | |
895 | else |
896 | echo |
897 | build_mage_script |
898 | echo |
899 | fi |
900 | fi |
901 | |
902 | # now unset all uneeded vars to be safe |
903 | # unset PKGNAME <-- don't do that; smage needs this var |
904 | unset SPECIAL_FUNCTIONS |
905 | unset SPECIAL_VARS |
906 | unset STATE |
907 | unset DESCRIPTION |
908 | unset HOMEPAGE |
909 | # unset PKGTYPE <-- don't do that either; smage needs this var |
910 | unset INHERITS |
911 | unset DEPEND |
912 | unset SDEPEND |
913 | unset PROVIDE |
914 | unset preinstall |
915 | unset postinstall |
916 | unset preremove |
917 | unset postremove |
918 | } |
919 | |
920 | split_save_variables() |
921 | { |
922 | export SAVED_PNAME="${PNAME}" |
923 | export SAVED_PVER="${PVER}" |
924 | export SAVED_PBUILD="${PBUILD}" |
925 | export SAVED_PCAT="${PCAT}" |
926 | export SAVED_DESCRIPTION="${DESCRIPTION}" |
927 | export SAVED_HOMEPAGE="${HOMEPAGE}" |
928 | export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
929 | export SAVED_SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS}" |
930 | export SAVED_STATE="${STATE}" |
931 | export SAVED_INHERITS="${INHERITS}" |
932 | export SAVED_DEPEND="${DEPEND}" |
933 | export SAVED_SDEPEND="${SDEPEND}" |
934 | export SAVED_PROVIDE="${PROVIDE}" |
935 | export SAVED_PKGTYPE="${PKGTYPE}" |
936 | |
937 | # special handling needed for mage features |
938 | # pkgbuild |
939 | mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild" |
940 | mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild" |
941 | # strip |
942 | mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip" |
943 | mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip" |
944 | # libtool |
945 | mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool" |
946 | mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool" |
947 | # compressdoc |
948 | mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc" |
949 | mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc" |
950 | |
951 | # bindir too |
952 | export SAVED_BINDIR="${BINDIR}" |
953 | |
954 | # export the SPLIT_PACKAGE_BASE |
955 | export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
956 | |
957 | # functions |
958 | if [[ ! -z $(typeset -f preinstall) ]] |
959 | then |
960 | # rename the old one |
961 | local saved_preinstall |
962 | saved_preinstall=SAVED_$(typeset -f preinstall) |
963 | eval "${saved_preinstall}" |
964 | export -f SAVED_preinstall |
965 | fi |
966 | |
967 | if [[ ! -z $(typeset -f postinstall) ]] |
968 | then |
969 | # rename the old one |
970 | local saved_postinstall |
971 | saved_postinstall=SAVED_$(typeset -f postinstall) |
972 | eval "${saved_postinstall}" |
973 | export -f SAVED_postinstall |
974 | fi |
975 | |
976 | if [[ ! -z $(typeset -f preremove) ]] |
977 | then |
978 | # rename the old one |
979 | local saved_preremove |
980 | saved_preremove=SAVED_$(typeset -f preremove) |
981 | eval "${saved_preremove}" |
982 | export -f SAVED_preremove |
983 | fi |
984 | |
985 | if [[ ! -z $(typeset -f postremove) ]] |
986 | then |
987 | # rename the old one |
988 | local saved_postremove |
989 | saved_postremove=SAVED_$(typeset -f postremove) |
990 | eval "${saved_postremove}" |
991 | export -f SAVED_postremove |
992 | fi |
993 | } |
994 | |
995 | split_restore_variables() |
996 | { |
997 | export PNAME="${SAVED_PNAME}" |
998 | export PVER="${SAVED_PVER}" |
999 | export PBUILD="${SAVED_PBUILD}" |
1000 | export PCAT="${SAVED_PCAT}" |
1001 | export DESCRIPTION="${SAVED_DESCRIPTION}" |
1002 | export HOMEPAGE="${SAVED_HOMEPAGE}" |
1003 | export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
1004 | export SPECIAL_FUNCTIONS="${SAVED_SPECIAL_FUNCTIONS}" |
1005 | export STATE="${SAVED_STATE}" |
1006 | export INHERITS="${SAVED_INHERITS}" |
1007 | export DEPEND="${SAVED_DEPEND}" |
1008 | export SDEPEND="${SAVED_SDEPEND}" |
1009 | export PROVIDE="${SAVED_PROVIDE}" |
1010 | export PKGTYPE="${SAVED_PKGTYPE}" |
1011 | |
1012 | # special handling needed for mage features |
1013 | # pkgbuild |
1014 | FVERBOSE=off msetfeature "${SAVED_FEATURE_PKGBUILD}" |
1015 | # strip |
1016 | FVERBOSE=off msetfeature "${SAVED_FEATURE_STRIP}" |
1017 | # libtool |
1018 | FVERBOSE=off msetfeature "${SAVED_FEATURE_LIBTOOL}" |
1019 | # compressdoc |
1020 | FVERBOSE=off msetfeature "${SAVED_FEATURE_COMPRESSDOC}" |
1021 | |
1022 | # bindir too |
1023 | export BINDIR="${SAVED_BINDIR}" |
1024 | |
1025 | # functions |
1026 | if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
1027 | then |
1028 | # rename the old one |
1029 | local saved_preinstall |
1030 | saved_preinstall=$(typeset -f SAVED_preinstall) |
1031 | eval "${saved_preinstall/SAVED_/}" |
1032 | export -f preinstall |
1033 | fi |
1034 | |
1035 | if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
1036 | then |
1037 | # rename the old one |
1038 | local saved_postinstall |
1039 | saved_postinstall=$(typeset -f SAVED_postinstall) |
1040 | eval "${saved_postinstall/SAVED_/}" |
1041 | export -f postinstall |
1042 | fi |
1043 | |
1044 | if [[ ! -z $(typeset -f SAVED_preremove) ]] |
1045 | then |
1046 | # rename the old one |
1047 | local saved_preremove |
1048 | saved_preremove=$(typeset -f SAVED_preremove) |
1049 | eval "${saved_preremove/SAVED_/}" |
1050 | export -f preremove |
1051 | fi |
1052 | |
1053 | if [[ ! -z $(typeset -f SAVED_postremove) ]] |
1054 | then |
1055 | # rename the old one |
1056 | local saved_postremove |
1057 | saved_postremove=$(typeset -f SAVED_postremove) |
1058 | eval "${saved_postremove/SAVED_/}" |
1059 | export -f postremove |
1060 | fi |
1061 | } |
1062 | |
1063 | split_unset_variables() |
1064 | { |
1065 | # unset saved vars; not needed anymore |
1066 | unset SAVED_PNAME |
1067 | unset SAVED_PVER |
1068 | unset SAVED_PBUILD |
1069 | unset SAVED_PCAT |
1070 | unset SAVED_DESCRIPTION |
1071 | unset SAVED_HOMEPAGE |
1072 | unset SAVED_SPECIAL_VARS |
1073 | unset SAVED_SPECIAL_FUNCTIONS |
1074 | unset SAVED_STATE |
1075 | unset SAVED_PKGTYPE |
1076 | unset SAVED_INHERITS |
1077 | unset SAVED_DEPEND |
1078 | unset SAVED_SDEPEND |
1079 | unset SAVED_PROVIDE |
1080 | unset SAVED_BINDIR |
1081 | unset SAVED_PKGTYPE |
1082 | unset SAVED_FEATURE_PKGBUILD |
1083 | unset SAVED_FEATURE_STRIP |
1084 | unset SAVED_FEATURE_LIBTOOL |
1085 | unset SAVED_FEATURE_COMPRESSDOC |
1086 | unset SPLIT_PACKAGE_BASE |
1087 | unset -f SAVED_preinstall |
1088 | unset -f SAVED_postinstall |
1089 | unset -f SAVED_preremove |
1090 | unset -f SAVED_postremove |
1091 | } |
1092 | |
1093 | split_export_inherits() |
1094 | { |
1095 | local subpackage="$1" |
1096 | local func |
1097 | local newfunc |
1098 | |
1099 | for func in preinstall postinstall preremove postremove |
1100 | do |
1101 | if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1102 | then |
1103 | newfunc=$(typeset -f ${func}_${subpackage}) |
1104 | newfunc="${newfunc/_${subpackage} (/ (}" |
1105 | eval "${newfunc}" |
1106 | fi |
1107 | done |
1108 | } |
1109 | |
1110 | split_delete_inherits() |
1111 | { |
1112 | local subpackage="$1" |
1113 | local func |
1114 | |
1115 | for func in preinstall postinstall preremove postremove |
1116 | do |
1117 | if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1118 | then |
1119 | unset -f ${func} |
1120 | fi |
1121 | done |
1122 | } |
1123 | |
1124 | export_inherits() |
1125 | { |
1126 | local include="$1" |
1127 | shift |
1128 | |
1129 | while [ "$1" ] |
1130 | do |
1131 | local functions="$1" |
1132 | |
1133 | # sanity checks |
1134 | [ -z "${include}" ] && die "export_inherits(): \$include not given." |
1135 | [ -z "${functions}" ] && die "export_inherits(): \$functions not given." |
1136 | |
1137 | eval "${functions}() { ${include}_${functions} ; }" |
1138 | |
1139 | # debug |
1140 | [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" |
1141 | |
1142 | shift |
1143 | done |
1144 | } |
1145 | |
1146 | generate_package_md5sum() |
1147 | { |
1148 | local dest |
1149 | local pcat |
1150 | local pname |
1151 | local pver |
1152 | local pbuild |
1153 | local parch |
1154 | local pkgname |
1155 | |
1156 | # very basic getops |
1157 | for i in $* |
1158 | do |
1159 | case $1 in |
1160 | --pcat|-c) shift; pcat="$1" ;; |
1161 | --pname|-n) shift; pname="$1" ;; |
1162 | --pver|-v) shift; pver="$1" ;; |
1163 | --pbuild|-b) shift; pbuild="$1" ;; |
1164 | --parch|a) shift; parch="$1" ;; |
1165 | esac |
1166 | shift |
1167 | done |
1168 | |
1169 | # sanity checks; abort if not given |
1170 | [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given." |
1171 | [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given." |
1172 | [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given." |
1173 | [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given." |
1174 | [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given." |
1175 | |
1176 | # check needed global vars |
1177 | [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set." |
1178 | [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set." |
1179 | |
1180 | # build pkgname |
1181 | pkgname="${pname}-${pver}-${parch}$(print_distrotag)-${pbuild}" |
1182 | |
1183 | # build pkg-md5-sum only if requested |
1184 | if mqueryfeature regentree |
1185 | then |
1186 | echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
1187 | |
1188 | # abort if not exist |
1189 | if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] |
1190 | then |
1191 | echo -e "${COLRED}! exists${COLDEFAULT}" |
1192 | return 0 |
1193 | fi |
1194 | |
1195 | # if MAGE_TREE_DEST not set use BUILDDIR |
1196 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1197 | |
1198 | # setup md5 dir |
1199 | dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
1200 | install -d ${dest} |
1201 | |
1202 | # gen md5sum |
1203 | ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ |
1204 | > ${dest}/${pkgname}.md5 |
1205 | echo -e "${COLGREEN}done${COLDEFAULT}" |
1206 | fi |
1207 | } |
1208 | |
1209 | source_pkg_build() |
1210 | { |
1211 | if [[ ! -d ${SOURCEDIR}/${PNAME} ]] |
1212 | then |
1213 | install -d ${SOURCEDIR}/${PNAME} |
1214 | fi |
1215 | |
1216 | [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." |
1217 | |
1218 | echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
1219 | |
1220 | # include the smage2 file |
1221 | cp ${SMAGENAME} ${SOURCEDIR}/${PNAME} |
1222 | |
1223 | ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; ) |
1224 | [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR} |
1225 | mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} |
1226 | |
1227 | echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}\n" |
1228 | } |
1229 | |
1230 | step_by_step() |
1231 | { |
1232 | if mqueryfeature stepbystep |
1233 | then |
1234 | echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1235 | echo "Press [enter] to continue" |
1236 | read |
1237 | fi |
1238 | } |
1239 | |
1240 | resume_stamp() |
1241 | { |
1242 | local step="$1" |
1243 | [[ ! -d ${BUILDDIR}/.stamps ]] && install -d ${BUILDDIR}/.stamps |
1244 | touch ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step} |
1245 | } |
1246 | |
1247 | run_resume() |
1248 | { |
1249 | local step="$1" |
1250 | |
1251 | if mqueryfeature "resume" && [[ -f ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step} ]] |
1252 | then |
1253 | echo -e "${COLMAGENTA}${step} already processed; doing nothing${COLDEFAULT}" |
1254 | return 0 |
1255 | else |
1256 | return 1 |
1257 | fi |
1258 | } |
1259 | |
1260 | mqalint() |
1261 | { |
1262 | return 0 |
1263 | } |