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