Annotation of /trunk/mage/usr/lib/mage/smage2.sh
Parent Directory | Revision Log
Revision 403 -
(hide annotations)
(download)
(as text)
Fri Dec 29 22:42:22 2006 UTC (17 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 25305 byte(s)
Fri Dec 29 22:42:22 2006 UTC (17 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 25305 byte(s)
added --src-tarball functionality -> creation and use of src-tarballs
1 | niro | 24 | #!/bin/bash |
2 | |||
3 | # compiles/installs .smage2 source install scripts | ||
4 | # needs pkgbuild_dir (mage) | ||
5 | |||
6 | # SMAGE2 | ||
7 | niro | 403 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.45 2006-12-29 22:42:22 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 | 24 | case "${SRCFILE##*.}" in |
315 | bz2) | ||
316 | IFTAR="$(basename $SRCFILE .bz2)" | ||
317 | IFTAR="${IFTAR##*.}" | ||
318 | niro | 306 | if [[ ${IFTAR} = tar ]] |
319 | niro | 24 | then |
320 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
321 | fi | ||
322 | ;; | ||
323 | gz) | ||
324 | IFTAR="$(basename $SRCFILE .gz)" | ||
325 | IFTAR="${IFTAR##*.}" | ||
326 | niro | 306 | if [[ ${IFTAR} = tar ]] |
327 | niro | 24 | then |
328 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
329 | fi | ||
330 | ;; | ||
331 | tbz2) | ||
332 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
333 | ;; | ||
334 | tgz) | ||
335 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} | ||
336 | ;; | ||
337 | *) | ||
338 | die "munpack failed" | ||
339 | ;; | ||
340 | esac | ||
341 | } | ||
342 | |||
343 | niro | 306 | mpatch() |
344 | { | ||
345 | niro | 24 | local PATCHOPTS |
346 | local PATCHFILE | ||
347 | |||
348 | PATCHOPTS=$1 | ||
349 | PATCHFILE=$2 | ||
350 | |||
351 | niro | 384 | echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
352 | niro | 24 | patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
353 | } | ||
354 | |||
355 | |||
356 | niro | 306 | minstalldocs() |
357 | { | ||
358 | niro | 24 | local docfiles |
359 | docfiles="$@" | ||
360 | niro | 306 | |
361 | niro | 24 | if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
362 | then | ||
363 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." | ||
364 | fi | ||
365 | niro | 306 | |
366 | niro | 24 | for i in ${docfiles} |
367 | do | ||
368 | cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." | ||
369 | install -m 0644 ${SRCDIR}/${i}.gz \ | ||
370 | ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." | ||
371 | done | ||
372 | } | ||
373 | |||
374 | niro | 306 | mstriplibs() |
375 | { | ||
376 | niro | 79 | local stripdir="$@" |
377 | |||
378 | [ -z "${stripdir}" ] && stripdir=${BINDIR} | ||
379 | find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null | ||
380 | } | ||
381 | |||
382 | niro | 306 | mstripbins() |
383 | { | ||
384 | niro | 79 | local stripdir="$@" |
385 | |||
386 | [ -z "${stripdir}" ] && stripdir=${BINDIR} | ||
387 | find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null | ||
388 | } | ||
389 | |||
390 | niro | 306 | sminclude() |
391 | { | ||
392 | niro | 172 | local i |
393 | |||
394 | niro | 183 | if [[ -n "$@" ]] |
395 | niro | 172 | then |
396 | for i in $@ | ||
397 | do | ||
398 | niro | 175 | echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
399 | niro | 172 | source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
400 | done | ||
401 | niro | 177 | echo |
402 | niro | 172 | fi |
403 | } | ||
404 | |||
405 | niro | 306 | setup_distcc_environment() |
406 | { | ||
407 | niro | 24 | if [ -x /usr/bin/distcc ] |
408 | then | ||
409 | echo "Using DistCC for compilation ..." | ||
410 | niro | 351 | export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
411 | niro | 24 | |
412 | export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" | ||
413 | |||
414 | niro | 306 | # creating distcc tempdir |
415 | niro | 24 | install -o distcc -g daemon -d ${DISTCC_DIR} |
416 | chmod 1777 ${DISTCC_DIR} | ||
417 | fi | ||
418 | } | ||
419 | |||
420 | niro | 306 | setup_ccache_environment() |
421 | { | ||
422 | niro | 24 | if [ -x /usr/bin/ccache ] |
423 | then | ||
424 | echo "Using CCache for compilation ..." | ||
425 | niro | 351 | export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
426 | niro | 24 | fi |
427 | } | ||
428 | |||
429 | niro | 193 | |
430 | # fixes given dependencies to match a MAGE_TARGET | ||
431 | niro | 198 | # fix_mage_deps -target s/depend # <-- note -target ! |
432 | niro | 306 | fix_mage_deps() |
433 | { | ||
434 | niro | 193 | local target="$1" |
435 | local depend="$2" | ||
436 | local NDEPEND | ||
437 | local sym dep cat pver pname | ||
438 | |||
439 | # deps and provides are special | ||
440 | # they must be fixed to match the target | ||
441 | |||
442 | # run this only if target and depend is not empty | ||
443 | if [ -n "${target}" ] && [ -n "${depend}" ] | ||
444 | then | ||
445 | # fix DEPEND | ||
446 | while read sym dep | ||
447 | do | ||
448 | cat="$(dirname ${dep})" | ||
449 | niro | 199 | # change if not virtual |
450 | niro | 200 | if [[ ${cat} = virtual ]] |
451 | niro | 199 | then |
452 | niro | 200 | pname="$(basename ${dep})" |
453 | else | ||
454 | niro | 199 | # fix pver to target-pver |
455 | # to get pname-target-pver | ||
456 | niro | 193 | |
457 | niro | 199 | # doing it backwards ! |
458 | pver="${dep##*-}" | ||
459 | niro | 200 | # full pver |
460 | pname="$(basename ${dep/-${pver}/})${target}-${pver}" | ||
461 | niro | 199 | fi |
462 | niro | 193 | |
463 | # do not add empty lines | ||
464 | if [ -z "${NDEPEND}" ] | ||
465 | then | ||
466 | niro | 200 | NDEPEND="${sym} ${cat}/${pname}" |
467 | niro | 193 | else |
468 | NDEPEND="${NDEPEND} | ||
469 | niro | 201 | ${sym} ${cat}/${pname}" |
470 | niro | 193 | fi |
471 | |||
472 | unset cat pname pver | ||
473 | done << EOF | ||
474 | ${depend} | ||
475 | EOF | ||
476 | # set NDEPEND to DEPEND | ||
477 | depend="${NDEPEND}" | ||
478 | fi | ||
479 | |||
480 | echo "${depend}" | ||
481 | } | ||
482 | |||
483 | niro | 192 | # build_mage_script(): helper functions for regen_mage_tree() |
484 | niro | 191 | # generates an mage file with given information in smage file |
485 | # needs at least: | ||
486 | # PNAME name of pkg | ||
487 | # PVER version | ||
488 | # PBUILD revision | ||
489 | # PCATEGORIE categorie of the pkg | ||
490 | # STATE state of pkg stable|unstable|old | ||
491 | # DESCRIPTION va short description (opt) | ||
492 | # HOMEPAGE homepage (opt) | ||
493 | # DEPEND runtime dependencies (opt) | ||
494 | # SDEPEND add. needed deps to build the pkg (opt) | ||
495 | # PROVIDE provides a virtual (opt) | ||
496 | # | ||
497 | # special tags: | ||
498 | # PKGTYPE type of pkg | ||
499 | # INHERITS which functions get included | ||
500 | # SPECIAL_FUNCTIONS special functions wich should also be added | ||
501 | # warning: they get killed before the build starts ! | ||
502 | # | ||
503 | # MAGE_TREE_DEST target destination of the generated tree | ||
504 | # REGEN_MAGE_TREE set to 'true' to enable this | ||
505 | niro | 193 | # |
506 | niro | 195 | # gets called with build_mage_script target |
507 | niro | 192 | build_mage_script() |
508 | niro | 191 | { |
509 | local magefile | ||
510 | local dest | ||
511 | niro | 193 | local target |
512 | niro | 191 | local sym |
513 | local depname | ||
514 | |||
515 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
516 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
517 | |||
518 | # determinate which suffix this mage file should get, if any | ||
519 | niro | 195 | [ -n "$1" ] && target="-$1" |
520 | niro | 191 | |
521 | # name of magefile | ||
522 | niro | 193 | magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
523 | niro | 191 | |
524 | # destination to magefile | ||
525 | niro | 193 | dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
526 | niro | 191 | |
527 | # show what we are doing | ||
528 | echo "Generating Mage file:" | ||
529 | echo " ${dest}" | ||
530 | |||
531 | install -d "$(dirname ${dest})" | ||
532 | # now build the mage file | ||
533 | > ${dest} | ||
534 | |||
535 | # header | ||
536 | niro | 403 | echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.45 2006-12-29 22:42:22 niro Exp $' >> ${dest} |
537 | niro | 191 | echo >> ${dest} |
538 | |||
539 | # pgkname and state | ||
540 | niro | 193 | echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
541 | niro | 191 | echo "STATE=\"${STATE}\"" >> ${dest} |
542 | echo >> ${dest} | ||
543 | |||
544 | # description and homepage | ||
545 | echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} | ||
546 | echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} | ||
547 | echo >> ${dest} | ||
548 | |||
549 | niro | 196 | # special tags and vars |
550 | niro | 191 | echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
551 | niro | 214 | |
552 | # echo MAGE_TARGETS ## note -target is needed ! | ||
553 | echo "MAGE_TARGETS=\"${target}\"" >> ${dest} | ||
554 | echo >> ${dest} | ||
555 | |||
556 | niro | 197 | # add special vars |
557 | if [ -n "${SPECIAL_VARS}" ] | ||
558 | niro | 191 | then |
559 | local i | ||
560 | niro | 197 | for i in ${SPECIAL_VARS} |
561 | niro | 191 | do |
562 | niro | 197 | # being tricky here :) |
563 | echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} | ||
564 | niro | 191 | done |
565 | echo >> ${dest} | ||
566 | fi | ||
567 | niro | 214 | |
568 | niro | 197 | # add at least all includes |
569 | if [ -n "${INHERITS}" ] | ||
570 | niro | 196 | then |
571 | niro | 197 | echo -n "minclude" >> ${dest} |
572 | niro | 196 | local i |
573 | niro | 197 | for i in ${INHERITS} |
574 | niro | 196 | do |
575 | niro | 197 | echo -n " ${i}" >> ${dest} |
576 | niro | 196 | done |
577 | echo >> ${dest} | ||
578 | fi | ||
579 | niro | 197 | echo >> ${dest} |
580 | niro | 196 | |
581 | niro | 191 | # deps and provides |
582 | niro | 193 | echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
583 | niro | 196 | echo >> ${dest} |
584 | niro | 193 | echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
585 | niro | 196 | echo >> ${dest} |
586 | niro | 191 | echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
587 | echo >> ${dest} | ||
588 | |||
589 | # add special functions | ||
590 | if [ -n "${SPECIAL_FUNCTIONS}" ] | ||
591 | then | ||
592 | local i | ||
593 | for i in ${SPECIAL_FUNCTIONS} | ||
594 | do | ||
595 | # add to mage (quotes needed !) | ||
596 | typeset -f "${i}" >> ${dest} | ||
597 | niro | 214 | echo >> ${dest} |
598 | niro | 191 | # unset to be safe (quotes needed !) |
599 | niro | 192 | #unset "${i}" <-- later to get every target built |
600 | niro | 191 | done |
601 | niro | 196 | echo >> ${dest} |
602 | niro | 191 | fi |
603 | |||
604 | # pre|post-install|removes | ||
605 | typeset -f preinstall >> ${dest} | ||
606 | echo >> ${dest} | ||
607 | typeset -f postinstall >> ${dest} | ||
608 | echo >> ${dest} | ||
609 | typeset -f preremove >> ${dest} | ||
610 | echo >> ${dest} | ||
611 | typeset -f postremove >> ${dest} | ||
612 | echo >> ${dest} | ||
613 | } | ||
614 | |||
615 | regen_mage_tree() | ||
616 | { | ||
617 | local i | ||
618 | |||
619 | # build them only if requested | ||
620 | if [[ ${REGEN_MAGE_TREE} = true ]] | ||
621 | then | ||
622 | niro | 195 | # run it without targets |
623 | if [ -z "${MAGE_TARGETS}" ] | ||
624 | then | ||
625 | niro | 191 | echo |
626 | niro | 195 | build_mage_script |
627 | niro | 191 | echo |
628 | niro | 195 | else |
629 | |||
630 | # build for each target an mage file | ||
631 | # run it with several targets | ||
632 | for i in ${MAGE_TARGETS} | ||
633 | do | ||
634 | echo | ||
635 | build_mage_script "${i}" | ||
636 | echo | ||
637 | done | ||
638 | fi | ||
639 | niro | 191 | fi |
640 | |||
641 | # now unset all uneeded vars to be safe | ||
642 | niro | 192 | # unset PKGNAME <-- don't do that; smage needs this var |
643 | # unset to be safe (quotes needed !) | ||
644 | for i in ${SPECIAL_FUNCTIONS} | ||
645 | do | ||
646 | unset "${i}" | ||
647 | done | ||
648 | unset SPECIAL_FUNCTIONS | ||
649 | niro | 194 | for i in ${SPECIAL_VARS} |
650 | do | ||
651 | unset "${i}" | ||
652 | done | ||
653 | unset SPECIAL_VARS | ||
654 | niro | 191 | unset STATE |
655 | unset DESCRIPTION | ||
656 | unset HOMEPAGE | ||
657 | unset PKGTYPE | ||
658 | unset INHERITS | ||
659 | unset DEPEND | ||
660 | unset SDEPEND | ||
661 | unset PROVIDE | ||
662 | unset preinstall | ||
663 | unset postinstall | ||
664 | unset preremove | ||
665 | unset postremove | ||
666 | } | ||
667 | |||
668 | niro | 253 | export_inherits() |
669 | { | ||
670 | local include="$1" | ||
671 | shift | ||
672 | |||
673 | while [ "$1" ] | ||
674 | do | ||
675 | local functions="$1" | ||
676 | |||
677 | # sanity checks | ||
678 | [ -z "${include}" ] && die "export_inherits(): \$include not given." | ||
679 | [ -z "${functions}" ] && die "export_inherits(): \$functions not given." | ||
680 | |||
681 | eval "${functions}() { ${include}_${functions} ; }" | ||
682 | |||
683 | # debug | ||
684 | [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" | ||
685 | |||
686 | shift | ||
687 | done | ||
688 | } | ||
689 | |||
690 | niro | 255 | generate_package_md5sum() |
691 | { | ||
692 | local dest | ||
693 | local pcat | ||
694 | local pname | ||
695 | local pver | ||
696 | local pbuild | ||
697 | local parch | ||
698 | local target | ||
699 | local pkgname | ||
700 | |||
701 | # very basic getops | ||
702 | for i in $* | ||
703 | do | ||
704 | case $1 in | ||
705 | --pcat|-c) shift; pcat="$1" ;; | ||
706 | --pname|-n) shift; pname="$1" ;; | ||
707 | --pver|-v) shift; pver="$1" ;; | ||
708 | --pbuild|-b) shift; pbuild="$1" ;; | ||
709 | --parch|a) shift; parch="$1" ;; | ||
710 | --target|t) shift; target="$1" ;; | ||
711 | esac | ||
712 | shift | ||
713 | done | ||
714 | |||
715 | # sanity checks; abort if not given | ||
716 | [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given." | ||
717 | [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given." | ||
718 | [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given." | ||
719 | [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given." | ||
720 | [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given." | ||
721 | |||
722 | # check needed global vars | ||
723 | [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set." | ||
724 | [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set." | ||
725 | |||
726 | # fix target as it may be empty ! | ||
727 | [ -n "${target}" ] && target="-${target}" | ||
728 | |||
729 | # build pkgname | ||
730 | pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" | ||
731 | |||
732 | # build pkg-md5-sum only if requested | ||
733 | if [[ ${REGEN_MAGE_TREE} = true ]] | ||
734 | then | ||
735 | echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... " | ||
736 | |||
737 | # abort if not exist | ||
738 | if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] | ||
739 | then | ||
740 | echo "! exists" | ||
741 | return 0 | ||
742 | fi | ||
743 | |||
744 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
745 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
746 | |||
747 | # setup md5 dir | ||
748 | dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" | ||
749 | install -d ${dest} | ||
750 | |||
751 | # gen md5sum | ||
752 | ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ | ||
753 | niro | 256 | > ${dest}/${pkgname}.md5 |
754 | niro | 255 | echo "done" |
755 | fi | ||
756 | } | ||
757 | |||
758 | niro | 403 | source_pkg_build() |
759 | { | ||
760 | if [[ ${PKGTYPE} = virtual ]] | ||
761 | then | ||
762 | echo "Virtual package detected; src-pkg-tarball not necessary ..." | ||
763 | return 0 | ||
764 | fi | ||
765 | |||
766 | if [[ ! -d ${SOURCEDIR}/${PNAME} ]] | ||
767 | then | ||
768 | echo "No SRC_URI defined; src-pkg-tarball not necessary ..." | ||
769 | return 0 | ||
770 | fi | ||
771 | |||
772 | echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" | ||
773 | ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; ) | ||
774 | [[ ! -d ${PKGDIR}/sources ]] && install -d ${PKGDIR}/sources | ||
775 | mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PKGDIR}/sources/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} | ||
776 | |||
777 | echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" | ||
778 | } | ||
779 | |||
780 | |||
781 | niro | 59 | # print out our version |
782 | showversion | ||
783 | echo | ||
784 | |||
785 | niro | 24 | if [ -z "$1" ] |
786 | then | ||
787 | echo "No .smage2 file given. Exiting." | ||
788 | echo | ||
789 | exit 1 | ||
790 | fi | ||
791 | |||
792 | niro | 192 | # updating smage2-scripts |
793 | niro | 306 | if [[ $1 = update ]] |
794 | niro | 24 | then |
795 | niro | 59 | if [ ! -d ${SOURCEDIR} ] |
796 | then | ||
797 | install -d ${SOURCEDIR} | ||
798 | fi | ||
799 | syncsmage2 | ||
800 | exit 0 | ||
801 | fi | ||
802 | |||
803 | niro | 192 | # creates md5sums for smages to given dir |
804 | niro | 306 | if [[ $1 = calcmd5 ]] |
805 | niro | 59 | then |
806 | if [ $# -ge 3 ] | ||
807 | then | ||
808 | SMAGENAME="$2" | ||
809 | MD5DIR="$3" | ||
810 | source ${SMAGENAME} || die "download source failed" | ||
811 | |||
812 | niro | 66 | # overridable sourcedir; must be declared after source of the smage2 |
813 | CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" | ||
814 | |||
815 | niro | 59 | [ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
816 | |||
817 | # end of array | ||
818 | EOA=${#SRC_URI[*]} | ||
819 | |||
820 | [ ! -d ${MD5DIR} ] && install -d ${MD5DIR} | ||
821 | |||
822 | # clear md5sum file | ||
823 | MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" | ||
824 | echo -n > ${MY_MD5_FILE} | ||
825 | |||
826 | for ((i=0; i < EOA; i++)) | ||
827 | do | ||
828 | niro | 66 | # url to file |
829 | my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" | ||
830 | |||
831 | # subdir in sources dir; the my_SRCI_URI file goes to there | ||
832 | my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" | ||
833 | |||
834 | # if my_src_uri_dest is not equal my_src_uri; than an other dir is used | ||
835 | if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] | ||
836 | then | ||
837 | MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" | ||
838 | else | ||
839 | MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" | ||
840 | fi | ||
841 | |||
842 | niro | 59 | if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
843 | then | ||
844 | echo "calculating $(basename ${MY_SRC_FILE}) ..." | ||
845 | ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} | ||
846 | else | ||
847 | echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." | ||
848 | fi | ||
849 | niro | 66 | |
850 | # unset them to be shure | ||
851 | unset my_SRC_URI | ||
852 | unset my_SRC_URI_DEST | ||
853 | unset my_SRC_URI_MIRROR | ||
854 | unset my_SOURCEDIR | ||
855 | niro | 59 | done |
856 | niro | 306 | |
857 | niro | 59 | echo |
858 | echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." | ||
859 | echo | ||
860 | else | ||
861 | echo "Usage: Calculating MD5 Sums:" | ||
862 | echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" | ||
863 | echo | ||
864 | echo | ||
865 | echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." | ||
866 | echo | ||
867 | exit 1 | ||
868 | fi | ||
869 | niro | 306 | |
870 | niro | 59 | exit 0 |
871 | fi | ||
872 | |||
873 | niro | 192 | # download sources |
874 | niro | 59 | if [ "$1" == "download" -a -n "$2" ] |
875 | then | ||
876 | niro | 24 | if [ ! -d ${SMAGESCRIPTSDIR} ] |
877 | then | ||
878 | install -d ${SMAGESCRIPTSDIR} | ||
879 | fi | ||
880 | niro | 59 | |
881 | # get smage | ||
882 | SMAGENAME="$2" | ||
883 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
884 | source ${SMAGENAME} || die "download source failed" | ||
885 | |||
886 | download_sources | ||
887 | niro | 24 | exit 0 |
888 | fi | ||
889 | |||
890 | niro | 202 | # regen-mage-tree |
891 | if [ "$1" == "only-regen-tree" -a -n "$2" ] | ||
892 | then | ||
893 | # set correct SMAGENAME | ||
894 | SMAGENAME="$2" | ||
895 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
896 | source ${SMAGENAME} || die "regen: smage2 not found" | ||
897 | |||
898 | regen_mage_tree | ||
899 | niro | 255 | |
900 | # build md5sum for existing packages | ||
901 | generate_package_md5sum \ | ||
902 | --pcat "${PCATEGORIE}" \ | ||
903 | --pname "${PNAME}" \ | ||
904 | --pver "${PVER}" \ | ||
905 | --pbuild "${PBUILD}" \ | ||
906 | --parch "${ARCH}" \ | ||
907 | --target "${target}" | ||
908 | |||
909 | niro | 202 | exit 0 |
910 | fi | ||
911 | |||
912 | niro | 403 | if [ "$1" == "only-src-pkg" -a -n "$2" ] |
913 | then | ||
914 | # set correct SMAGENAME | ||
915 | SMAGENAME="$2" | ||
916 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
917 | |||
918 | echo -e "${COLGREEN}only-src-pkg called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" | ||
919 | |||
920 | source ${SMAGENAME} || die "regen: smage2 not found" | ||
921 | |||
922 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
923 | then | ||
924 | echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" | ||
925 | rm -rf ${SOURCEDIR}/${PKGNAME} | ||
926 | fi | ||
927 | |||
928 | download_sources | ||
929 | source_pkg_build ${SMAGENAME} | ||
930 | exit 0 | ||
931 | fi | ||
932 | |||
933 | if [ "$1" == "--src-tarball" -a -n "$2" -a -n "$3" ] | ||
934 | then | ||
935 | # set correct SMAGENAME | ||
936 | SMAGENAME="$3" | ||
937 | SRCPKGTARBALL="$2" | ||
938 | USE_SRC_PKG_TARBALL=true | ||
939 | |||
940 | echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}" | ||
941 | |||
942 | [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR} | ||
943 | |||
944 | # unpack srctarball | ||
945 | [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting." | ||
946 | |||
947 | tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}" | ||
948 | fi | ||
949 | |||
950 | |||
951 | niro | 306 | [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
952 | [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && | ||
953 | die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." | ||
954 | [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your mage.rc correctly." | ||
955 | [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly." | ||
956 | [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly." | ||
957 | [ -z "${BINDIR}" ] && die "no BINDIR variable found in /etc/mage.rc" | ||
958 | [ -z "${CHOST}" ] && die "no CHOST variable found in /etc/mage.rc" | ||
959 | [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in /etc/mage.rc" | ||
960 | [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in /etc/mage.rc" | ||
961 | niro | 24 | |
962 | source ${SMAGENAME} || die "source failed" | ||
963 | niro | 255 | PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
964 | niro | 59 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
965 | niro | 24 | |
966 | xtitle "Compiling ${PKGNAME}" | ||
967 | niro | 59 | echo "Compiling ${PKGNAME}" |
968 | |||
969 | niro | 191 | # auto regen mage tree if requested |
970 | regen_mage_tree | ||
971 | |||
972 | niro | 403 | if [[ ${CREATE_SRC_PKG_TARBALL} = true ]] |
973 | then | ||
974 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
975 | then | ||
976 | echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" | ||
977 | rm -rf ${SOURCEDIR}/${PKGNAME} | ||
978 | fi | ||
979 | fi | ||
980 | |||
981 | niro | 192 | # download sources |
982 | niro | 403 | [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources |
983 | niro | 59 | |
984 | niro | 192 | # fixes some issues with these functions |
985 | niro | 24 | export -f src_prepare || die "src_prepare export failed" |
986 | export -f src_compile || die "src_compile export failed" | ||
987 | export -f src_install || die "src_install export failed" | ||
988 | |||
989 | niro | 192 | # fixes some compile issues |
990 | niro | 24 | export CHOST="${CHOST}" || die "CHOST export failed" |
991 | export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" | ||
992 | export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" | ||
993 | export BINDIR="${BINDIR}" || die "BINDIR export failed" | ||
994 | export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" | ||
995 | |||
996 | |||
997 | niro | 192 | # setup distcc |
998 | niro | 351 | # setup for distcc goes *before* ccache, so ccache comes before distcc in path |
999 | niro | 306 | [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment |
1000 | niro | 24 | |
1001 | niro | 192 | # setup ccache |
1002 | niro | 306 | [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
1003 | niro | 24 | |
1004 | # small sleep to show our settings | ||
1005 | sleep 1 | ||
1006 | |||
1007 | niro | 192 | # cleans up build if a previously one exists |
1008 | niro | 24 | if [ -d ${BUILDDIR} ] |
1009 | then | ||
1010 | rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." | ||
1011 | fi | ||
1012 | install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." | ||
1013 | |||
1014 | niro | 192 | # cleans up srcdir if a previously unpacked one exists |
1015 | niro | 24 | if [ -d ${SRCDIR} ] |
1016 | then | ||
1017 | rm -rf ${SRCDIR} | ||
1018 | fi | ||
1019 | |||
1020 | niro | 192 | # cleans up bindir if a previous build exists or creates a new one |
1021 | niro | 24 | if [ -d ${BINDIR} ] |
1022 | then | ||
1023 | rm -rf ${BINDIR} | ||
1024 | fi | ||
1025 | install -d ${BINDIR} || die "couldn't create \$BINDIR." | ||
1026 | |||
1027 | niro | 192 | # cleans up package temp dir if a previous build exists |
1028 | niro | 24 | if [ -d ${BUILDDIR}/${PKGNAME} ] |
1029 | then | ||
1030 | rm -rf ${BUILDDIR}/${PKGNAME} | ||
1031 | fi | ||
1032 | |||
1033 | niro | 192 | # cleans up timestamp if one exists |
1034 | niro | 24 | if [ -f /var/tmp/timestamp ] |
1035 | then | ||
1036 | mage rmstamp | ||
1037 | fi | ||
1038 | |||
1039 | src_prepare || die "src_prepare failed" | ||
1040 | src_compile || die "src_compile failed" | ||
1041 | src_install || die "src_install failed" | ||
1042 | |||
1043 | |||
1044 | niro | 192 | # compressing doc, info & man files |
1045 | niro | 24 | echo -e "Compressing man-pages ..." |
1046 | if [ -d ${BUILDDIR}/builded/usr/share/man ] | ||
1047 | then | ||
1048 | ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man | ||
1049 | fi | ||
1050 | |||
1051 | echo -e "Compressing info-pages ..." | ||
1052 | if [ -d ${BUILDDIR}/builded/usr/share/info ] | ||
1053 | then | ||
1054 | ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info | ||
1055 | fi | ||
1056 | |||
1057 | niro | 79 | # stripping all bins and libs |
1058 | case ${NOSTRIP} in | ||
1059 | true|TRUE|yes|y) | ||
1060 | echo -e "NOSTRIP=true detected; Package will not be stripped ..." | ||
1061 | ;; | ||
1062 | *) | ||
1063 | echo -e "Stripping binaries ..." | ||
1064 | mstripbins ${BINDIR} | ||
1065 | echo -e "Stripping libraries ..." | ||
1066 | mstriplibs ${BINDIR} | ||
1067 | ;; | ||
1068 | esac | ||
1069 | |||
1070 | niro | 192 | # the new buildpkg command |
1071 | niro | 24 | case ${NOPKGBUILD} in |
1072 | true|TRUE|yes|y) | ||
1073 | echo -e "NOPGKBUILD=true detected; Package will not be build ..." | ||
1074 | ;; | ||
1075 | niro | 192 | *) |
1076 | niro | 306 | # build several targets |
1077 | niro | 192 | if [ -n "${MAGE_TARGETS}" ] |
1078 | then | ||
1079 | for target in ${MAGE_TARGETS} | ||
1080 | do | ||
1081 | # check if an special target_pkgbuild exists | ||
1082 | if typeset -f ${target}_pkgbuild > /dev/null | ||
1083 | then | ||
1084 | # run it | ||
1085 | ${target}_pkgbuild | ||
1086 | fi | ||
1087 | # now create the target package | ||
1088 | ${MLIBDIR}/pkgbuild_dir.sh \ | ||
1089 | niro | 255 | "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \ |
1090 | niro | 192 | ${BINDIR} || die "target: ${target} package-build failed" |
1091 | niro | 255 | |
1092 | # build pkg-md5-sum if requested | ||
1093 | generate_package_md5sum \ | ||
1094 | --pcat "${PCATEGORIE}" \ | ||
1095 | --pname "${PNAME}" \ | ||
1096 | --pver "${PVER}" \ | ||
1097 | --pbuild "${PBUILD}" \ | ||
1098 | --parch "${ARCH}" \ | ||
1099 | --target "${target}" | ||
1100 | |||
1101 | echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n" | ||
1102 | niro | 192 | done |
1103 | else | ||
1104 | ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" | ||
1105 | niro | 255 | |
1106 | # build pkg-md5-sum if requested | ||
1107 | generate_package_md5sum \ | ||
1108 | --pcat "${PCATEGORIE}" \ | ||
1109 | --pname "${PNAME}" \ | ||
1110 | --pver "${PVER}" \ | ||
1111 | --pbuild "${PBUILD}" \ | ||
1112 | --parch "${ARCH}" | ||
1113 | |||
1114 | niro | 192 | echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
1115 | fi | ||
1116 | niro | 403 | |
1117 | # build src-pkg-tarball if requested | ||
1118 | [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME} | ||
1119 | niro | 24 | ;; |
1120 | esac | ||
1121 | |||
1122 | niro | 192 | # for sure |
1123 | niro | 24 | unset NOPKGBUILD |
1124 | niro | 85 | unset NOSTRIP |
1125 | niro | 351 | |
1126 | niro | 24 | xtitleclean |
Properties
Name | Value |
---|---|
svn:executable | * |