Annotation of /trunk/mage/usr/lib/mage/smage2.sh
Parent Directory | Revision Log
Revision 427 -
(hide annotations)
(download)
(as text)
Fri Feb 23 14:42:17 2007 UTC (17 years, 7 months ago) by niro
File MIME type: application/x-sh
File size: 26138 byte(s)
Fri Feb 23 14:42:17 2007 UTC (17 years, 7 months ago) by niro
File MIME type: application/x-sh
File size: 26138 byte(s)
- ignore empty lines while fixing deps
1 | niro | 24 | #!/bin/bash |
2 | |||
3 | # compiles/installs .smage2 source install scripts | ||
4 | # needs pkgbuild_dir (mage) | ||
5 | |||
6 | # SMAGE2 | ||
7 | niro | 427 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.52 2007-02-23 14:42:17 niro Exp $ |
8 | niro | 24 | |
9 | #01.10.2004 | ||
10 | # added ccache support | ||
11 | # added distcc support | ||
12 | |||
13 | niro | 419 | # set default user mage.rc |
14 | : ${MAGERC="/etc/mage.rc"} | ||
15 | |||
16 | niro | 24 | ## setup ## |
17 | PKGSUFFIX="mpk" | ||
18 | niro | 403 | SRCPKGSUFFIX="mpks" |
19 | niro | 24 | SMAGENAME="$1" |
20 | SMAGESUFFIX="smage2" | ||
21 | MLIBDIR=/usr/lib/mage | ||
22 | niro | 186 | SMAGEVERSION="$( < ${MLIBDIR}/version)" |
23 | niro | 24 | |
24 | niro | 351 | ## only for tests -> normally in /etc/rc.d/init.d/functions |
25 | COLRED="\033[1;6m\033[31m" | ||
26 | COLGREEN="\033[1;6m\033[32m" | ||
27 | COLYELLOW="\033[1;6m\033[33m" | ||
28 | COLBLUE="\033[1;6m\033[34m" | ||
29 | COLMAGENTA="\033[1;6m\033[35m" | ||
30 | COLWHITE="\033[1;6m\033[37m" | ||
31 | COLGRAY="\033[0;6m\033[37m" | ||
32 | COLBOLD="\033[1m" | ||
33 | COLDEFAULT="\033[0m" | ||
34 | |||
35 | if [[ ${NOCOLORS} = true ]] | ||
36 | then | ||
37 | COLRED="" | ||
38 | COLGREEN="" | ||
39 | COLYELLOW="" | ||
40 | COLBLUE="" | ||
41 | COLMAGENTA="" | ||
42 | COLWHITE="" | ||
43 | COLGRAY="" | ||
44 | COLBOLD="" | ||
45 | COLDEFAULT="" | ||
46 | fi | ||
47 | |||
48 | niro | 169 | # export default C locale |
49 | export LC_ALL=C | ||
50 | |||
51 | niro | 419 | source ${MAGERC} |
52 | niro | 24 | |
53 | niro | 347 | # set PKGDIR and BUILDDIR and BINDIR to MROOT |
54 | if [[ -n ${MROOT} ]] | ||
55 | then | ||
56 | export PKGDIR=${MROOT}/${PKGDIR} | ||
57 | export BUILDDIR=${MROOT}/${BUILDDIR} | ||
58 | export BINDIR=${MROOT}/${BINDIR} | ||
59 | fi | ||
60 | |||
61 | niro | 306 | showversion() |
62 | { | ||
63 | niro | 24 | echo -en "Magellan Source Install v${SMAGEVERSION} " |
64 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" | ||
65 | } | ||
66 | |||
67 | niro | 306 | die() |
68 | { | ||
69 | niro | 24 | xtitleclean |
70 | niro | 413 | echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
71 | niro | 24 | echo "SMAGE failed: $@" |
72 | exit 1 | ||
73 | } | ||
74 | |||
75 | niro | 306 | xtitle() |
76 | { | ||
77 | if [[ ${TERM} = xterm ]] | ||
78 | niro | 24 | then |
79 | echo -ne "\033]0;[sMage: $@]\007" | ||
80 | fi | ||
81 | return 0 | ||
82 | } | ||
83 | |||
84 | niro | 306 | xtitleclean() |
85 | { | ||
86 | if [[ ${TERM} = xterm ]] | ||
87 | niro | 24 | then |
88 | echo -ne "\033]0;\007" | ||
89 | fi | ||
90 | return 0 | ||
91 | } | ||
92 | |||
93 | niro | 306 | syncsmage2() |
94 | { | ||
95 | niro | 24 | xtitle "Updating smage2-script tree ..." |
96 | local i | ||
97 | for i in ${SMAGE2RSYNC} | ||
98 | do | ||
99 | niro | 386 | rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR} |
100 | niro | 306 | if [[ $? = 0 ]] |
101 | niro | 24 | then |
102 | break | ||
103 | else | ||
104 | continue | ||
105 | fi | ||
106 | done | ||
107 | niro | 306 | |
108 | # clean up backup files (foo~) | ||
109 | niro | 24 | find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';' |
110 | niro | 306 | |
111 | niro | 24 | xtitleclean |
112 | } | ||
113 | |||
114 | niro | 59 | # $1 filename |
115 | niro | 306 | get_db_md5_sum() |
116 | { | ||
117 | niro | 59 | local DB_FILE |
118 | local MD5_FILE | ||
119 | local i | ||
120 | |||
121 | DB_ENTRY="$(basename $1)" | ||
122 | MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})" | ||
123 | |||
124 | i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)" | ||
125 | |||
126 | echo "${i}" | ||
127 | } | ||
128 | |||
129 | niro | 306 | download_sources() |
130 | { | ||
131 | niro | 59 | |
132 | niro | 61 | [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
133 | niro | 59 | |
134 | local EOA=${#SRC_URI[*]} | ||
135 | niro | 66 | local my_SRC_URI |
136 | local my_SRC_URI_DEST | ||
137 | local my_SRC_URI_MIRROR | ||
138 | local my_SOURCEDIR | ||
139 | niro | 59 | local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
140 | local FETCHING | ||
141 | local i mirror | ||
142 | |||
143 | niro | 306 | |
144 | # install SRCDIR/PNAME if not exist | ||
145 | niro | 59 | [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
146 | |||
147 | # check if FETCHING is needed | ||
148 | niro | 66 | ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
149 | niro | 306 | if [[ $? = 0 ]] |
150 | niro | 59 | then |
151 | # md5's ok, not fetching needed | ||
152 | FETCHING=false | ||
153 | else | ||
154 | FETCHING=true | ||
155 | fi | ||
156 | niro | 306 | |
157 | niro | 59 | for ((i=0; i < EOA; i++)) |
158 | do | ||
159 | niro | 66 | # url to file |
160 | my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" | ||
161 | niro | 59 | |
162 | niro | 66 | # subdir in sources dir; the my_SRCI_URI file goes to there |
163 | my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" | ||
164 | |||
165 | # if my_src_uri_dest is not equal my_src_uri; than an other dir is used | ||
166 | if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] | ||
167 | then | ||
168 | my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}" | ||
169 | else | ||
170 | my_SOURCEDIR="${SOURCEDIR}/${PNAME}" | ||
171 | fi | ||
172 | |||
173 | niro | 59 | # if an mirrored file than replace first the mirror uri |
174 | niro | 66 | if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] |
175 | niro | 59 | then |
176 | for mirror in ${MIRRORS} | ||
177 | do | ||
178 | niro | 66 | my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
179 | niro | 59 | |
180 | niro | 306 | if [[ ${FETCHING} = true ]] |
181 | niro | 59 | then |
182 | niro | 66 | echo "==> fetching ${my_SRC_URI_MIRROR}" |
183 | niro | 59 | wget \ |
184 | --passive-ftp \ | ||
185 | --tries 3 \ | ||
186 | --continue \ | ||
187 | --progress bar \ | ||
188 | niro | 66 | --directory-prefix="${my_SOURCEDIR}" \ |
189 | "${my_SRC_URI_MIRROR}" | ||
190 | niro | 306 | if [[ $? = 0 ]] |
191 | niro | 59 | then |
192 | break | ||
193 | else | ||
194 | continue | ||
195 | fi | ||
196 | fi | ||
197 | done | ||
198 | else | ||
199 | niro | 306 | if [[ ${FETCHING} = true ]] |
200 | niro | 59 | then |
201 | niro | 66 | echo "==> fetching ${my_SRC_URI}" |
202 | niro | 59 | wget \ |
203 | --passive-ftp \ | ||
204 | --tries 3 \ | ||
205 | --continue \ | ||
206 | --progress bar \ | ||
207 | niro | 66 | --directory-prefix="${my_SOURCEDIR}" \ |
208 | "${my_SRC_URI}" | ||
209 | niro | 59 | fi |
210 | fi | ||
211 | niro | 306 | |
212 | niro | 66 | # unset them to be shure |
213 | unset my_SRC_URI | ||
214 | unset my_SRC_URI_DEST | ||
215 | unset my_SRC_URI_MIRROR | ||
216 | unset my_SOURCEDIR | ||
217 | niro | 59 | done |
218 | |||
219 | # recheck md5 sums | ||
220 | echo | ||
221 | echo ">== Checking MD5 sums:" | ||
222 | niro | 63 | ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
223 | niro | 59 | echo |
224 | |||
225 | # not needed anymore | ||
226 | unset SRC_URI | ||
227 | } | ||
228 | |||
229 | niro | 24 | # dummy function, used if that not exist in smage file |
230 | niro | 306 | src_prepare() |
231 | { | ||
232 | niro | 24 | echo "no src_prepare defined" |
233 | sleep 2 | ||
234 | return 0 | ||
235 | } | ||
236 | |||
237 | # dummy function, used if that not exist in smage file | ||
238 | niro | 306 | src_compile() |
239 | { | ||
240 | niro | 24 | echo "no src_compile defined" |
241 | sleep 2 | ||
242 | return 0 | ||
243 | } | ||
244 | |||
245 | # dummy function, used if that not exist in smage file | ||
246 | niro | 306 | src_install() |
247 | { | ||
248 | niro | 24 | echo "no src_install defined" |
249 | sleep 2 | ||
250 | return 0 | ||
251 | } | ||
252 | |||
253 | niro | 351 | mlibdir() |
254 | { | ||
255 | local libdir=lib | ||
256 | [[ ${ARCH} = x86_64 ]] && libdir=lib64 | ||
257 | |||
258 | echo "${libdir}" | ||
259 | } | ||
260 | |||
261 | niro | 306 | mconfigure() |
262 | { | ||
263 | niro | 24 | if [ -x ./configure ] |
264 | then | ||
265 | niro | 306 | ./configure \ |
266 | --prefix=/usr \ | ||
267 | --host=${CHOST} \ | ||
268 | --mandir=/usr/share/man \ | ||
269 | --infodir=/usr/share/info \ | ||
270 | --datadir=/usr/share \ | ||
271 | --sysconfdir=/etc \ | ||
272 | --localstatedir=/var/lib \ | ||
273 | niro | 351 | --libdir=/usr/$(mlibdir) \ |
274 | niro | 306 | "$@" || die "mconfigure failed" |
275 | niro | 24 | else |
276 | echo "configure is not an executable ..." | ||
277 | exit 1 | ||
278 | fi | ||
279 | } | ||
280 | |||
281 | niro | 306 | minstall() |
282 | { | ||
283 | if [ -f ./[mM]akefile -o -f ./GNUmakefile ] | ||
284 | then | ||
285 | niro | 24 | make prefix=${BINDIR}/usr \ |
286 | datadir=${BINDIR}/usr/share \ | ||
287 | infodir=${BINDIR}/usr/share/info \ | ||
288 | localstatedir=${BINDIR}/var/lib \ | ||
289 | mandir=${BINDIR}/usr/share/man \ | ||
290 | sysconfdir=${BINDIR}/etc \ | ||
291 | niro | 351 | libdir=${BINDIR}/usr/$(mlibdir) \ |
292 | niro | 24 | "$@" install || die "minstall failed" |
293 | else | ||
294 | die "no Makefile found" | ||
295 | fi | ||
296 | } | ||
297 | |||
298 | niro | 306 | mmake() |
299 | { | ||
300 | niro | 24 | make ${MAKEOPTS} ${EXTRA_EMAKE} "$@" |
301 | } | ||
302 | |||
303 | niro | 306 | munpack() |
304 | { | ||
305 | niro | 24 | local SRCFILE |
306 | local IFTAR | ||
307 | local DEST | ||
308 | |||
309 | SRCFILE=$1 | ||
310 | niro | 306 | |
311 | niro | 24 | if [ -z "$2" ] |
312 | then | ||
313 | DEST=${BUILDDIR} | ||
314 | else | ||
315 | DEST=$2 | ||
316 | fi | ||
317 | niro | 306 | |
318 | niro | 411 | [[ ! -d ${DEST} ]] && install -d ${DEST} |
319 | |||
320 | niro | 24 | case "${SRCFILE##*.}" in |
321 | bz2) | ||
322 | IFTAR="$(basename $SRCFILE .bz2)" | ||
323 | IFTAR="${IFTAR##*.}" | ||
324 | niro | 306 | if [[ ${IFTAR} = tar ]] |
325 | niro | 24 | then |
326 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
327 | fi | ||
328 | ;; | ||
329 | gz) | ||
330 | IFTAR="$(basename $SRCFILE .gz)" | ||
331 | IFTAR="${IFTAR##*.}" | ||
332 | niro | 306 | if [[ ${IFTAR} = tar ]] |
333 | niro | 24 | then |
334 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
335 | fi | ||
336 | ;; | ||
337 | tbz2) | ||
338 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
339 | ;; | ||
340 | tgz) | ||
341 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
342 | ;; | ||
343 | *) | ||
344 | die "munpack failed" | ||
345 | ;; | ||
346 | esac | ||
347 | } | ||
348 | |||
349 | niro | 306 | mpatch() |
350 | { | ||
351 | niro | 24 | local PATCHOPTS |
352 | local PATCHFILE | ||
353 | |||
354 | PATCHOPTS=$1 | ||
355 | PATCHFILE=$2 | ||
356 | |||
357 | niro | 384 | echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
358 | niro | 24 | patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
359 | } | ||
360 | |||
361 | |||
362 | niro | 306 | minstalldocs() |
363 | { | ||
364 | niro | 24 | local docfiles |
365 | docfiles="$@" | ||
366 | niro | 306 | |
367 | niro | 24 | if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
368 | then | ||
369 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." | ||
370 | fi | ||
371 | niro | 306 | |
372 | niro | 24 | for i in ${docfiles} |
373 | do | ||
374 | cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." | ||
375 | install -m 0644 ${SRCDIR}/${i}.gz \ | ||
376 | ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." | ||
377 | done | ||
378 | } | ||
379 | |||
380 | niro | 306 | mstriplibs() |
381 | { | ||
382 | niro | 79 | local stripdir="$@" |
383 | |||
384 | [ -z "${stripdir}" ] && stripdir=${BINDIR} | ||
385 | find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null | ||
386 | } | ||
387 | |||
388 | niro | 306 | mstripbins() |
389 | { | ||
390 | niro | 79 | local stripdir="$@" |
391 | |||
392 | [ -z "${stripdir}" ] && stripdir=${BINDIR} | ||
393 | find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null | ||
394 | } | ||
395 | |||
396 | niro | 306 | sminclude() |
397 | { | ||
398 | niro | 172 | local i |
399 | |||
400 | niro | 183 | if [[ -n "$@" ]] |
401 | niro | 172 | then |
402 | for i in $@ | ||
403 | do | ||
404 | niro | 175 | echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
405 | niro | 172 | source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
406 | done | ||
407 | niro | 177 | echo |
408 | niro | 172 | fi |
409 | } | ||
410 | |||
411 | niro | 306 | setup_distcc_environment() |
412 | { | ||
413 | niro | 24 | if [ -x /usr/bin/distcc ] |
414 | then | ||
415 | echo "Using DistCC for compilation ..." | ||
416 | niro | 351 | export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
417 | niro | 24 | |
418 | export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" | ||
419 | |||
420 | niro | 306 | # creating distcc tempdir |
421 | niro | 24 | install -o distcc -g daemon -d ${DISTCC_DIR} |
422 | chmod 1777 ${DISTCC_DIR} | ||
423 | fi | ||
424 | } | ||
425 | |||
426 | niro | 306 | setup_ccache_environment() |
427 | { | ||
428 | niro | 24 | if [ -x /usr/bin/ccache ] |
429 | then | ||
430 | echo "Using CCache for compilation ..." | ||
431 | niro | 351 | export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
432 | niro | 24 | fi |
433 | } | ||
434 | |||
435 | niro | 193 | |
436 | # fixes given dependencies to match a MAGE_TARGET | ||
437 | niro | 198 | # fix_mage_deps -target s/depend # <-- note -target ! |
438 | niro | 306 | fix_mage_deps() |
439 | { | ||
440 | niro | 193 | local target="$1" |
441 | local depend="$2" | ||
442 | local NDEPEND | ||
443 | local sym dep cat pver pname | ||
444 | |||
445 | # deps and provides are special | ||
446 | # they must be fixed to match the target | ||
447 | |||
448 | # run this only if target and depend is not empty | ||
449 | if [ -n "${target}" ] && [ -n "${depend}" ] | ||
450 | then | ||
451 | # fix DEPEND | ||
452 | while read sym dep | ||
453 | do | ||
454 | niro | 427 | # ignore empty lines |
455 | [[ -z ${dep} ]] && continue | ||
456 | |||
457 | niro | 193 | cat="$(dirname ${dep})" |
458 | niro | 199 | # change if not virtual |
459 | niro | 200 | if [[ ${cat} = virtual ]] |
460 | niro | 199 | then |
461 | niro | 200 | pname="$(basename ${dep})" |
462 | else | ||
463 | niro | 199 | # fix pver to target-pver |
464 | # to get pname-target-pver | ||
465 | niro | 193 | |
466 | niro | 199 | # doing it backwards ! |
467 | pver="${dep##*-}" | ||
468 | niro | 200 | # full pver |
469 | pname="$(basename ${dep/-${pver}/})${target}-${pver}" | ||
470 | niro | 199 | fi |
471 | niro | 193 | |
472 | # do not add empty lines | ||
473 | if [ -z "${NDEPEND}" ] | ||
474 | then | ||
475 | niro | 200 | NDEPEND="${sym} ${cat}/${pname}" |
476 | niro | 193 | else |
477 | NDEPEND="${NDEPEND} | ||
478 | niro | 201 | ${sym} ${cat}/${pname}" |
479 | niro | 193 | fi |
480 | |||
481 | unset cat pname pver | ||
482 | done << EOF | ||
483 | ${depend} | ||
484 | EOF | ||
485 | # set NDEPEND to DEPEND | ||
486 | depend="${NDEPEND}" | ||
487 | fi | ||
488 | |||
489 | echo "${depend}" | ||
490 | } | ||
491 | |||
492 | niro | 192 | # build_mage_script(): helper functions for regen_mage_tree() |
493 | niro | 191 | # generates an mage file with given information in smage file |
494 | # needs at least: | ||
495 | # PNAME name of pkg | ||
496 | # PVER version | ||
497 | # PBUILD revision | ||
498 | # PCATEGORIE categorie of the pkg | ||
499 | # STATE state of pkg stable|unstable|old | ||
500 | # DESCRIPTION va short description (opt) | ||
501 | # HOMEPAGE homepage (opt) | ||
502 | # DEPEND runtime dependencies (opt) | ||
503 | # SDEPEND add. needed deps to build the pkg (opt) | ||
504 | # PROVIDE provides a virtual (opt) | ||
505 | # | ||
506 | # special tags: | ||
507 | # PKGTYPE type of pkg | ||
508 | # INHERITS which functions get included | ||
509 | # SPECIAL_FUNCTIONS special functions wich should also be added | ||
510 | # warning: they get killed before the build starts ! | ||
511 | # | ||
512 | # MAGE_TREE_DEST target destination of the generated tree | ||
513 | # REGEN_MAGE_TREE set to 'true' to enable this | ||
514 | niro | 193 | # |
515 | niro | 195 | # gets called with build_mage_script target |
516 | niro | 192 | build_mage_script() |
517 | niro | 191 | { |
518 | local magefile | ||
519 | local dest | ||
520 | niro | 193 | local target |
521 | niro | 191 | local sym |
522 | local depname | ||
523 | |||
524 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
525 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
526 | |||
527 | # determinate which suffix this mage file should get, if any | ||
528 | niro | 195 | [ -n "$1" ] && target="-$1" |
529 | niro | 191 | |
530 | # name of magefile | ||
531 | niro | 193 | magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
532 | niro | 191 | |
533 | # destination to magefile | ||
534 | niro | 193 | dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
535 | niro | 191 | |
536 | # show what we are doing | ||
537 | echo "Generating Mage file:" | ||
538 | echo " ${dest}" | ||
539 | |||
540 | install -d "$(dirname ${dest})" | ||
541 | # now build the mage file | ||
542 | > ${dest} | ||
543 | |||
544 | # header | ||
545 | niro | 427 | echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.52 2007-02-23 14:42:17 niro Exp $' >> ${dest} |
546 | niro | 191 | echo >> ${dest} |
547 | |||
548 | # pgkname and state | ||
549 | niro | 193 | echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
550 | niro | 191 | echo "STATE=\"${STATE}\"" >> ${dest} |
551 | echo >> ${dest} | ||
552 | |||
553 | # description and homepage | ||
554 | echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} | ||
555 | echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} | ||
556 | echo >> ${dest} | ||
557 | |||
558 | niro | 196 | # special tags and vars |
559 | niro | 191 | echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
560 | niro | 214 | |
561 | # echo MAGE_TARGETS ## note -target is needed ! | ||
562 | echo "MAGE_TARGETS=\"${target}\"" >> ${dest} | ||
563 | echo >> ${dest} | ||
564 | |||
565 | niro | 197 | # add special vars |
566 | if [ -n "${SPECIAL_VARS}" ] | ||
567 | niro | 191 | then |
568 | local i | ||
569 | niro | 197 | for i in ${SPECIAL_VARS} |
570 | niro | 191 | do |
571 | niro | 197 | # being tricky here :) |
572 | echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} | ||
573 | niro | 191 | done |
574 | echo >> ${dest} | ||
575 | fi | ||
576 | niro | 214 | |
577 | niro | 197 | # add at least all includes |
578 | if [ -n "${INHERITS}" ] | ||
579 | niro | 196 | then |
580 | niro | 197 | echo -n "minclude" >> ${dest} |
581 | niro | 196 | local i |
582 | niro | 197 | for i in ${INHERITS} |
583 | niro | 196 | do |
584 | niro | 197 | echo -n " ${i}" >> ${dest} |
585 | niro | 196 | done |
586 | echo >> ${dest} | ||
587 | fi | ||
588 | niro | 197 | echo >> ${dest} |
589 | niro | 196 | |
590 | niro | 191 | # deps and provides |
591 | niro | 193 | echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
592 | niro | 196 | echo >> ${dest} |
593 | niro | 193 | echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
594 | niro | 196 | echo >> ${dest} |
595 | niro | 191 | echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
596 | echo >> ${dest} | ||
597 | |||
598 | # add special functions | ||
599 | if [ -n "${SPECIAL_FUNCTIONS}" ] | ||
600 | then | ||
601 | local i | ||
602 | for i in ${SPECIAL_FUNCTIONS} | ||
603 | do | ||
604 | # add to mage (quotes needed !) | ||
605 | typeset -f "${i}" >> ${dest} | ||
606 | niro | 214 | echo >> ${dest} |
607 | niro | 191 | # unset to be safe (quotes needed !) |
608 | niro | 192 | #unset "${i}" <-- later to get every target built |
609 | niro | 191 | done |
610 | niro | 196 | echo >> ${dest} |
611 | niro | 191 | fi |
612 | |||
613 | # pre|post-install|removes | ||
614 | typeset -f preinstall >> ${dest} | ||
615 | echo >> ${dest} | ||
616 | typeset -f postinstall >> ${dest} | ||
617 | echo >> ${dest} | ||
618 | typeset -f preremove >> ${dest} | ||
619 | echo >> ${dest} | ||
620 | typeset -f postremove >> ${dest} | ||
621 | echo >> ${dest} | ||
622 | } | ||
623 | |||
624 | regen_mage_tree() | ||
625 | { | ||
626 | local i | ||
627 | |||
628 | # build them only if requested | ||
629 | if [[ ${REGEN_MAGE_TREE} = true ]] | ||
630 | then | ||
631 | niro | 195 | # run it without targets |
632 | if [ -z "${MAGE_TARGETS}" ] | ||
633 | then | ||
634 | niro | 191 | echo |
635 | niro | 195 | build_mage_script |
636 | niro | 191 | echo |
637 | niro | 195 | else |
638 | |||
639 | # build for each target an mage file | ||
640 | # run it with several targets | ||
641 | for i in ${MAGE_TARGETS} | ||
642 | do | ||
643 | echo | ||
644 | build_mage_script "${i}" | ||
645 | echo | ||
646 | done | ||
647 | fi | ||
648 | niro | 191 | fi |
649 | |||
650 | # now unset all uneeded vars to be safe | ||
651 | niro | 192 | # unset PKGNAME <-- don't do that; smage needs this var |
652 | # unset to be safe (quotes needed !) | ||
653 | for i in ${SPECIAL_FUNCTIONS} | ||
654 | do | ||
655 | unset "${i}" | ||
656 | done | ||
657 | unset SPECIAL_FUNCTIONS | ||
658 | niro | 194 | for i in ${SPECIAL_VARS} |
659 | do | ||
660 | unset "${i}" | ||
661 | done | ||
662 | unset SPECIAL_VARS | ||
663 | niro | 191 | unset STATE |
664 | unset DESCRIPTION | ||
665 | unset HOMEPAGE | ||
666 | unset PKGTYPE | ||
667 | unset INHERITS | ||
668 | unset DEPEND | ||
669 | unset SDEPEND | ||
670 | unset PROVIDE | ||
671 | unset preinstall | ||
672 | unset postinstall | ||
673 | unset preremove | ||
674 | unset postremove | ||
675 | } | ||
676 | |||
677 | niro | 253 | export_inherits() |
678 | { | ||
679 | local include="$1" | ||
680 | shift | ||
681 | |||
682 | while [ "$1" ] | ||
683 | do | ||
684 | local functions="$1" | ||
685 | |||
686 | # sanity checks | ||
687 | [ -z "${include}" ] && die "export_inherits(): \$include not given." | ||
688 | [ -z "${functions}" ] && die "export_inherits(): \$functions not given." | ||
689 | |||
690 | eval "${functions}() { ${include}_${functions} ; }" | ||
691 | |||
692 | # debug | ||
693 | [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" | ||
694 | |||
695 | shift | ||
696 | done | ||
697 | } | ||
698 | |||
699 | niro | 255 | generate_package_md5sum() |
700 | { | ||
701 | local dest | ||
702 | local pcat | ||
703 | local pname | ||
704 | local pver | ||
705 | local pbuild | ||
706 | local parch | ||
707 | local target | ||
708 | local pkgname | ||
709 | |||
710 | # very basic getops | ||
711 | for i in $* | ||
712 | do | ||
713 | case $1 in | ||
714 | --pcat|-c) shift; pcat="$1" ;; | ||
715 | --pname|-n) shift; pname="$1" ;; | ||
716 | --pver|-v) shift; pver="$1" ;; | ||
717 | --pbuild|-b) shift; pbuild="$1" ;; | ||
718 | --parch|a) shift; parch="$1" ;; | ||
719 | --target|t) shift; target="$1" ;; | ||
720 | esac | ||
721 | shift | ||
722 | done | ||
723 | |||
724 | # sanity checks; abort if not given | ||
725 | [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given." | ||
726 | [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given." | ||
727 | [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given." | ||
728 | [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given." | ||
729 | [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given." | ||
730 | |||
731 | # check needed global vars | ||
732 | [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set." | ||
733 | [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set." | ||
734 | |||
735 | # fix target as it may be empty ! | ||
736 | [ -n "${target}" ] && target="-${target}" | ||
737 | |||
738 | # build pkgname | ||
739 | pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" | ||
740 | |||
741 | # build pkg-md5-sum only if requested | ||
742 | if [[ ${REGEN_MAGE_TREE} = true ]] | ||
743 | then | ||
744 | echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... " | ||
745 | |||
746 | # abort if not exist | ||
747 | if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] | ||
748 | then | ||
749 | echo "! exists" | ||
750 | return 0 | ||
751 | fi | ||
752 | |||
753 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
754 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
755 | |||
756 | # setup md5 dir | ||
757 | dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" | ||
758 | install -d ${dest} | ||
759 | |||
760 | # gen md5sum | ||
761 | ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ | ||
762 | niro | 256 | > ${dest}/${pkgname}.md5 |
763 | niro | 255 | echo "done" |
764 | fi | ||
765 | } | ||
766 | |||
767 | niro | 403 | source_pkg_build() |
768 | { | ||
769 | if [[ ${PKGTYPE} = virtual ]] | ||
770 | then | ||
771 | echo "Virtual package detected; src-pkg-tarball not necessary ..." | ||
772 | return 0 | ||
773 | fi | ||
774 | |||
775 | if [[ ! -d ${SOURCEDIR}/${PNAME} ]] | ||
776 | then | ||
777 | echo "No SRC_URI defined; src-pkg-tarball not necessary ..." | ||
778 | return 0 | ||
779 | fi | ||
780 | |||
781 | niro | 419 | [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." |
782 | niro | 406 | |
783 | niro | 403 | echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
784 | niro | 412 | |
785 | # include the smage2 file | ||
786 | cp ${SMAGENAME} ${SOURCEDIR}/${PNAME} | ||
787 | |||
788 | niro | 403 | ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; ) |
789 | niro | 406 | [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR} |
790 | mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} | ||
791 | niro | 403 | |
792 | echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" | ||
793 | } | ||
794 | |||
795 | |||
796 | niro | 59 | # print out our version |
797 | showversion | ||
798 | echo | ||
799 | |||
800 | niro | 24 | if [ -z "$1" ] |
801 | then | ||
802 | echo "No .smage2 file given. Exiting." | ||
803 | echo | ||
804 | exit 1 | ||
805 | fi | ||
806 | |||
807 | niro | 192 | # updating smage2-scripts |
808 | niro | 306 | if [[ $1 = update ]] |
809 | niro | 24 | then |
810 | niro | 59 | if [ ! -d ${SOURCEDIR} ] |
811 | then | ||
812 | install -d ${SOURCEDIR} | ||
813 | fi | ||
814 | syncsmage2 | ||
815 | exit 0 | ||
816 | fi | ||
817 | |||
818 | niro | 192 | # creates md5sums for smages to given dir |
819 | niro | 306 | if [[ $1 = calcmd5 ]] |
820 | niro | 59 | then |
821 | if [ $# -ge 3 ] | ||
822 | then | ||
823 | SMAGENAME="$2" | ||
824 | MD5DIR="$3" | ||
825 | source ${SMAGENAME} || die "download source failed" | ||
826 | |||
827 | niro | 66 | # overridable sourcedir; must be declared after source of the smage2 |
828 | CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" | ||
829 | |||
830 | niro | 59 | [ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
831 | |||
832 | # end of array | ||
833 | EOA=${#SRC_URI[*]} | ||
834 | |||
835 | [ ! -d ${MD5DIR} ] && install -d ${MD5DIR} | ||
836 | |||
837 | # clear md5sum file | ||
838 | MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" | ||
839 | echo -n > ${MY_MD5_FILE} | ||
840 | |||
841 | for ((i=0; i < EOA; i++)) | ||
842 | do | ||
843 | niro | 66 | # url to file |
844 | my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" | ||
845 | |||
846 | # subdir in sources dir; the my_SRCI_URI file goes to there | ||
847 | my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" | ||
848 | |||
849 | # if my_src_uri_dest is not equal my_src_uri; than an other dir is used | ||
850 | if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] | ||
851 | then | ||
852 | MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" | ||
853 | else | ||
854 | MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" | ||
855 | fi | ||
856 | |||
857 | niro | 59 | if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
858 | then | ||
859 | echo "calculating $(basename ${MY_SRC_FILE}) ..." | ||
860 | ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} | ||
861 | else | ||
862 | echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." | ||
863 | fi | ||
864 | niro | 66 | |
865 | # unset them to be shure | ||
866 | unset my_SRC_URI | ||
867 | unset my_SRC_URI_DEST | ||
868 | unset my_SRC_URI_MIRROR | ||
869 | unset my_SOURCEDIR | ||
870 | niro | 59 | done |
871 | niro | 306 | |
872 | niro | 59 | echo |
873 | echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." | ||
874 | echo | ||
875 | else | ||
876 | echo "Usage: Calculating MD5 Sums:" | ||
877 | echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" | ||
878 | echo | ||
879 | echo | ||
880 | echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." | ||
881 | echo | ||
882 | exit 1 | ||
883 | fi | ||
884 | niro | 306 | |
885 | niro | 59 | exit 0 |
886 | fi | ||
887 | |||
888 | niro | 192 | # download sources |
889 | niro | 59 | if [ "$1" == "download" -a -n "$2" ] |
890 | then | ||
891 | niro | 24 | if [ ! -d ${SMAGESCRIPTSDIR} ] |
892 | then | ||
893 | install -d ${SMAGESCRIPTSDIR} | ||
894 | fi | ||
895 | niro | 59 | |
896 | # get smage | ||
897 | SMAGENAME="$2" | ||
898 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
899 | source ${SMAGENAME} || die "download source failed" | ||
900 | |||
901 | download_sources | ||
902 | niro | 24 | exit 0 |
903 | fi | ||
904 | |||
905 | niro | 202 | # regen-mage-tree |
906 | if [ "$1" == "only-regen-tree" -a -n "$2" ] | ||
907 | then | ||
908 | # set correct SMAGENAME | ||
909 | SMAGENAME="$2" | ||
910 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
911 | source ${SMAGENAME} || die "regen: smage2 not found" | ||
912 | |||
913 | regen_mage_tree | ||
914 | niro | 255 | |
915 | # build md5sum for existing packages | ||
916 | generate_package_md5sum \ | ||
917 | --pcat "${PCATEGORIE}" \ | ||
918 | --pname "${PNAME}" \ | ||
919 | --pver "${PVER}" \ | ||
920 | --pbuild "${PBUILD}" \ | ||
921 | --parch "${ARCH}" \ | ||
922 | --target "${target}" | ||
923 | |||
924 | niro | 202 | exit 0 |
925 | fi | ||
926 | |||
927 | niro | 412 | if [ "$1" == "--create-src-tarball" -a -n "$2" ] |
928 | niro | 403 | then |
929 | # set correct SMAGENAME | ||
930 | SMAGENAME="$2" | ||
931 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
932 | |||
933 | niro | 412 | echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
934 | niro | 403 | |
935 | source ${SMAGENAME} || die "regen: smage2 not found" | ||
936 | |||
937 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
938 | then | ||
939 | echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" | ||
940 | rm -rf ${SOURCEDIR}/${PKGNAME} | ||
941 | fi | ||
942 | |||
943 | download_sources | ||
944 | source_pkg_build ${SMAGENAME} | ||
945 | exit 0 | ||
946 | fi | ||
947 | |||
948 | niro | 406 | if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ] |
949 | niro | 403 | then |
950 | niro | 412 | SRCPKGTARBALL="${2}" |
951 | niro | 403 | USE_SRC_PKG_TARBALL=true |
952 | |||
953 | niro | 412 | # abort if given file is not a source pkg |
954 | [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file." | ||
955 | |||
956 | # set correct SMAGENAME; use the one that the src_pkg provide | ||
957 | # /path/to/SOURCEDIR/PNAME/SMAGENAME | ||
958 | SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}" | ||
959 | |||
960 | niro | 403 | echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}" |
961 | |||
962 | [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR} | ||
963 | |||
964 | # unpack srctarball | ||
965 | [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting." | ||
966 | |||
967 | tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}" | ||
968 | niro | 412 | |
969 | [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}" | ||
970 | niro | 403 | fi |
971 | |||
972 | |||
973 | niro | 306 | [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
974 | [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && | ||
975 | die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." | ||
976 | niro | 419 | [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly." |
977 | [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly." | ||
978 | [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly." | ||
979 | [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}" | ||
980 | [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}" | ||
981 | [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" | ||
982 | [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" | ||
983 | niro | 24 | |
984 | source ${SMAGENAME} || die "source failed" | ||
985 | niro | 255 | PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
986 | niro | 59 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
987 | niro | 24 | |
988 | xtitle "Compiling ${PKGNAME}" | ||
989 | niro | 59 | echo "Compiling ${PKGNAME}" |
990 | |||
991 | niro | 191 | # auto regen mage tree if requested |
992 | regen_mage_tree | ||
993 | |||
994 | niro | 403 | if [[ ${CREATE_SRC_PKG_TARBALL} = true ]] |
995 | then | ||
996 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
997 | then | ||
998 | echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" | ||
999 | niro | 408 | rm -rf ${SOURCEDIR}/${PNAME} |
1000 | niro | 403 | fi |
1001 | fi | ||
1002 | |||
1003 | niro | 192 | # download sources |
1004 | niro | 403 | [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources |
1005 | niro | 59 | |
1006 | niro | 192 | # fixes some issues with these functions |
1007 | niro | 24 | export -f src_prepare || die "src_prepare export failed" |
1008 | export -f src_compile || die "src_compile export failed" | ||
1009 | export -f src_install || die "src_install export failed" | ||
1010 | |||
1011 | niro | 192 | # fixes some compile issues |
1012 | niro | 24 | export CHOST="${CHOST}" || die "CHOST export failed" |
1013 | export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" | ||
1014 | export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" | ||
1015 | export BINDIR="${BINDIR}" || die "BINDIR export failed" | ||
1016 | export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" | ||
1017 | |||
1018 | |||
1019 | niro | 192 | # setup distcc |
1020 | niro | 351 | # setup for distcc goes *before* ccache, so ccache comes before distcc in path |
1021 | niro | 306 | [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment |
1022 | niro | 24 | |
1023 | niro | 192 | # setup ccache |
1024 | niro | 306 | [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
1025 | niro | 24 | |
1026 | # small sleep to show our settings | ||
1027 | sleep 1 | ||
1028 | |||
1029 | niro | 192 | # cleans up build if a previously one exists |
1030 | niro | 24 | if [ -d ${BUILDDIR} ] |
1031 | then | ||
1032 | rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." | ||
1033 | fi | ||
1034 | install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." | ||
1035 | |||
1036 | niro | 192 | # cleans up srcdir if a previously unpacked one exists |
1037 | niro | 24 | if [ -d ${SRCDIR} ] |
1038 | then | ||
1039 | rm -rf ${SRCDIR} | ||
1040 | fi | ||
1041 | |||
1042 | niro | 192 | # cleans up bindir if a previous build exists or creates a new one |
1043 | niro | 24 | if [ -d ${BINDIR} ] |
1044 | then | ||
1045 | rm -rf ${BINDIR} | ||
1046 | fi | ||
1047 | install -d ${BINDIR} || die "couldn't create \$BINDIR." | ||
1048 | |||
1049 | niro | 192 | # cleans up package temp dir if a previous build exists |
1050 | niro | 24 | if [ -d ${BUILDDIR}/${PKGNAME} ] |
1051 | then | ||
1052 | rm -rf ${BUILDDIR}/${PKGNAME} | ||
1053 | fi | ||
1054 | |||
1055 | niro | 192 | # cleans up timestamp if one exists |
1056 | niro | 24 | if [ -f /var/tmp/timestamp ] |
1057 | then | ||
1058 | mage rmstamp | ||
1059 | fi | ||
1060 | |||
1061 | src_prepare || die "src_prepare failed" | ||
1062 | src_compile || die "src_compile failed" | ||
1063 | src_install || die "src_install failed" | ||
1064 | |||
1065 | |||
1066 | niro | 192 | # compressing doc, info & man files |
1067 | niro | 24 | echo -e "Compressing man-pages ..." |
1068 | if [ -d ${BUILDDIR}/builded/usr/share/man ] | ||
1069 | then | ||
1070 | ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man | ||
1071 | fi | ||
1072 | |||
1073 | echo -e "Compressing info-pages ..." | ||
1074 | if [ -d ${BUILDDIR}/builded/usr/share/info ] | ||
1075 | then | ||
1076 | ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info | ||
1077 | fi | ||
1078 | |||
1079 | niro | 79 | # stripping all bins and libs |
1080 | case ${NOSTRIP} in | ||
1081 | true|TRUE|yes|y) | ||
1082 | echo -e "NOSTRIP=true detected; Package will not be stripped ..." | ||
1083 | ;; | ||
1084 | *) | ||
1085 | echo -e "Stripping binaries ..." | ||
1086 | mstripbins ${BINDIR} | ||
1087 | echo -e "Stripping libraries ..." | ||
1088 | mstriplibs ${BINDIR} | ||
1089 | ;; | ||
1090 | esac | ||
1091 | |||
1092 | niro | 192 | # the new buildpkg command |
1093 | niro | 24 | case ${NOPKGBUILD} in |
1094 | true|TRUE|yes|y) | ||
1095 | echo -e "NOPGKBUILD=true detected; Package will not be build ..." | ||
1096 | ;; | ||
1097 | niro | 192 | *) |
1098 | niro | 306 | # build several targets |
1099 | niro | 192 | if [ -n "${MAGE_TARGETS}" ] |
1100 | then | ||
1101 | for target in ${MAGE_TARGETS} | ||
1102 | do | ||
1103 | # check if an special target_pkgbuild exists | ||
1104 | if typeset -f ${target}_pkgbuild > /dev/null | ||
1105 | then | ||
1106 | # run it | ||
1107 | ${target}_pkgbuild | ||
1108 | fi | ||
1109 | # now create the target package | ||
1110 | ${MLIBDIR}/pkgbuild_dir.sh \ | ||
1111 | niro | 255 | "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \ |
1112 | niro | 192 | ${BINDIR} || die "target: ${target} package-build failed" |
1113 | niro | 255 | |
1114 | # build pkg-md5-sum if requested | ||
1115 | generate_package_md5sum \ | ||
1116 | --pcat "${PCATEGORIE}" \ | ||
1117 | --pname "${PNAME}" \ | ||
1118 | --pver "${PVER}" \ | ||
1119 | --pbuild "${PBUILD}" \ | ||
1120 | --parch "${ARCH}" \ | ||
1121 | --target "${target}" | ||
1122 | |||
1123 | echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n" | ||
1124 | niro | 192 | done |
1125 | else | ||
1126 | ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" | ||
1127 | niro | 255 | |
1128 | # build pkg-md5-sum if requested | ||
1129 | generate_package_md5sum \ | ||
1130 | --pcat "${PCATEGORIE}" \ | ||
1131 | --pname "${PNAME}" \ | ||
1132 | --pver "${PVER}" \ | ||
1133 | --pbuild "${PBUILD}" \ | ||
1134 | --parch "${ARCH}" | ||
1135 | |||
1136 | niro | 192 | echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
1137 | fi | ||
1138 | niro | 403 | |
1139 | # build src-pkg-tarball if requested | ||
1140 | [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME} | ||
1141 | niro | 24 | ;; |
1142 | esac | ||
1143 | |||
1144 | niro | 192 | # for sure |
1145 | niro | 24 | unset NOPKGBUILD |
1146 | niro | 85 | unset NOSTRIP |
1147 | niro | 351 | |
1148 | niro | 24 | xtitleclean |
Properties
Name | Value |
---|---|
svn:executable | * |