Annotation of /branches/mage-next/src/smage2.in
Parent Directory | Revision Log
Revision 1273 -
(hide annotations)
(download)
(as text)
Wed Apr 27 09:45:07 2011 UTC (13 years, 5 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/smage2.sh
File MIME type: application/x-sh
File size: 39540 byte(s)
Wed Apr 27 09:45:07 2011 UTC (13 years, 5 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/smage2.sh
File MIME type: application/x-sh
File size: 39540 byte(s)
-support busybox out-of-the-box
1 | niro | 24 | #!/bin/bash |
2 | |||
3 | # compiles/installs .smage2 source install scripts | ||
4 | # needs pkgbuild_dir (mage) | ||
5 | |||
6 | # SMAGE2 | ||
7 | niro | 635 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 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 | 439 | source /etc/mage.rc.global |
52 | niro | 419 | source ${MAGERC} |
53 | niro | 1273 | source ${MLIBDIR}/mage4.functions.sh |
54 | niro | 24 | |
55 | niro | 347 | # set PKGDIR and BUILDDIR and BINDIR to MROOT |
56 | if [[ -n ${MROOT} ]] | ||
57 | then | ||
58 | export PKGDIR=${MROOT}/${PKGDIR} | ||
59 | export BUILDDIR=${MROOT}/${BUILDDIR} | ||
60 | export BINDIR=${MROOT}/${BINDIR} | ||
61 | fi | ||
62 | |||
63 | niro | 306 | showversion() |
64 | { | ||
65 | niro | 24 | echo -en "Magellan Source Install v${SMAGEVERSION} " |
66 | echo -e "-- Niels Rogalla (niro@magellan-linux.de)" | ||
67 | } | ||
68 | |||
69 | niro | 306 | die() |
70 | { | ||
71 | niro | 24 | xtitleclean |
72 | niro | 413 | echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
73 | niro | 24 | echo "SMAGE failed: $@" |
74 | exit 1 | ||
75 | } | ||
76 | |||
77 | niro | 941 | die_pipestatus() |
78 | { | ||
79 | niro | 943 | # the status change if we do any parameter declarations!! |
80 | # dont do this anymore, keep this in mind! | ||
81 | # | ||
82 | # local pos="$1" | ||
83 | # local comment="$2" | ||
84 | # | ||
85 | # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" | ||
86 | # | ||
87 | [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" | ||
88 | niro | 941 | } |
89 | |||
90 | niro | 306 | xtitle() |
91 | { | ||
92 | if [[ ${TERM} = xterm ]] | ||
93 | niro | 24 | then |
94 | echo -ne "\033]0;[sMage: $@]\007" | ||
95 | fi | ||
96 | return 0 | ||
97 | } | ||
98 | |||
99 | niro | 306 | xtitleclean() |
100 | { | ||
101 | if [[ ${TERM} = xterm ]] | ||
102 | niro | 24 | then |
103 | echo -ne "\033]0;\007" | ||
104 | fi | ||
105 | return 0 | ||
106 | } | ||
107 | |||
108 | niro | 306 | syncsmage2() |
109 | { | ||
110 | niro | 24 | xtitle "Updating smage2-script tree ..." |
111 | local i | ||
112 | for i in ${SMAGE2RSYNC} | ||
113 | do | ||
114 | niro | 386 | rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR} |
115 | niro | 306 | if [[ $? = 0 ]] |
116 | niro | 24 | then |
117 | break | ||
118 | else | ||
119 | continue | ||
120 | fi | ||
121 | done | ||
122 | niro | 306 | |
123 | # clean up backup files (foo~) | ||
124 | niro | 24 | find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';' |
125 | niro | 306 | |
126 | niro | 24 | xtitleclean |
127 | } | ||
128 | |||
129 | niro | 59 | # $1 filename |
130 | niro | 306 | get_db_md5_sum() |
131 | { | ||
132 | niro | 59 | local DB_FILE |
133 | local MD5_FILE | ||
134 | local i | ||
135 | |||
136 | DB_ENTRY="$(basename $1)" | ||
137 | MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})" | ||
138 | |||
139 | i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)" | ||
140 | |||
141 | echo "${i}" | ||
142 | } | ||
143 | |||
144 | niro | 306 | download_sources() |
145 | { | ||
146 | niro | 59 | |
147 | niro | 61 | [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
148 | niro | 59 | |
149 | local EOA=${#SRC_URI[*]} | ||
150 | niro | 66 | local my_SRC_URI |
151 | local my_SRC_URI_DEST | ||
152 | local my_SRC_URI_MIRROR | ||
153 | local my_SOURCEDIR | ||
154 | niro | 59 | local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
155 | local FETCHING | ||
156 | local i mirror | ||
157 | niro | 1273 | local wget_opts |
158 | niro | 59 | |
159 | niro | 1273 | # filter wget command if busybox was found |
160 | wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" | ||
161 | niro | 306 | |
162 | # install SRCDIR/PNAME if not exist | ||
163 | niro | 59 | [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
164 | |||
165 | # check if FETCHING is needed | ||
166 | niro | 1273 | ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null ) |
167 | niro | 306 | if [[ $? = 0 ]] |
168 | niro | 59 | then |
169 | niro | 439 | # md5's ok, no fetching needed |
170 | niro | 59 | FETCHING=false |
171 | else | ||
172 | FETCHING=true | ||
173 | fi | ||
174 | niro | 306 | |
175 | niro | 59 | for ((i=0; i < EOA; i++)) |
176 | do | ||
177 | niro | 66 | # url to file |
178 | my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" | ||
179 | niro | 59 | |
180 | niro | 66 | # subdir in sources dir; the my_SRCI_URI file goes to there |
181 | my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" | ||
182 | |||
183 | # if my_src_uri_dest is not equal my_src_uri; than an other dir is used | ||
184 | if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] | ||
185 | then | ||
186 | my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}" | ||
187 | else | ||
188 | my_SOURCEDIR="${SOURCEDIR}/${PNAME}" | ||
189 | fi | ||
190 | |||
191 | niro | 885 | # create the SOURCEDIR |
192 | install -d ${my_SOURCEDIR} | ||
193 | |||
194 | niro | 59 | # if an mirrored file than replace first the mirror uri |
195 | niro | 439 | if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
196 | niro | 59 | then |
197 | for mirror in ${MIRRORS} | ||
198 | do | ||
199 | niro | 66 | my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
200 | niro | 59 | |
201 | niro | 306 | if [[ ${FETCHING} = true ]] |
202 | niro | 59 | then |
203 | niro | 439 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
204 | niro | 59 | wget \ |
205 | niro | 1273 | ${wget_opts} \ |
206 | niro | 883 | --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
207 | niro | 66 | "${my_SRC_URI_MIRROR}" |
208 | niro | 306 | if [[ $? = 0 ]] |
209 | niro | 59 | then |
210 | break | ||
211 | else | ||
212 | continue | ||
213 | fi | ||
214 | fi | ||
215 | done | ||
216 | niro | 439 | elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]] |
217 | then | ||
218 | for mirror in ${SOURCEFORGE_MIRRORS} | ||
219 | do | ||
220 | my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")" | ||
221 | |||
222 | if [[ ${FETCHING} = true ]] | ||
223 | then | ||
224 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" | ||
225 | wget \ | ||
226 | niro | 1273 | ${wget_opts} \ |
227 | niro | 883 | --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
228 | niro | 439 | "${my_SRC_URI_MIRROR}" |
229 | if [[ $? = 0 ]] | ||
230 | then | ||
231 | break | ||
232 | else | ||
233 | continue | ||
234 | fi | ||
235 | fi | ||
236 | done | ||
237 | elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]] | ||
238 | then | ||
239 | for mirror in ${GNU_MIRRORS} | ||
240 | do | ||
241 | my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")" | ||
242 | |||
243 | if [[ ${FETCHING} = true ]] | ||
244 | then | ||
245 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" | ||
246 | wget \ | ||
247 | niro | 1273 | ${wget_opts} \ |
248 | niro | 883 | --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
249 | niro | 439 | "${my_SRC_URI_MIRROR}" |
250 | if [[ $? = 0 ]] | ||
251 | then | ||
252 | break | ||
253 | else | ||
254 | continue | ||
255 | fi | ||
256 | fi | ||
257 | done | ||
258 | niro | 459 | elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]] |
259 | then | ||
260 | for mirror in ${KDE_MIRRORS} | ||
261 | do | ||
262 | my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")" | ||
263 | |||
264 | if [[ ${FETCHING} = true ]] | ||
265 | then | ||
266 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" | ||
267 | wget \ | ||
268 | niro | 1273 | ${wget_opts} \ |
269 | niro | 883 | --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
270 | niro | 459 | "${my_SRC_URI_MIRROR}" |
271 | if [[ $? = 0 ]] | ||
272 | then | ||
273 | break | ||
274 | else | ||
275 | continue | ||
276 | fi | ||
277 | fi | ||
278 | done | ||
279 | elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]] | ||
280 | then | ||
281 | for mirror in ${GNOME_MIRRORS} | ||
282 | do | ||
283 | my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")" | ||
284 | |||
285 | if [[ ${FETCHING} = true ]] | ||
286 | then | ||
287 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" | ||
288 | wget \ | ||
289 | niro | 1273 | ${wget_opts} \ |
290 | niro | 883 | --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
291 | niro | 459 | "${my_SRC_URI_MIRROR}" |
292 | if [[ $? = 0 ]] | ||
293 | then | ||
294 | break | ||
295 | else | ||
296 | continue | ||
297 | fi | ||
298 | fi | ||
299 | done | ||
300 | niro | 59 | else |
301 | niro | 306 | if [[ ${FETCHING} = true ]] |
302 | niro | 59 | then |
303 | niro | 439 | echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
304 | niro | 59 | wget \ |
305 | niro | 1273 | ${wget_opts} \ |
306 | niro | 883 | --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
307 | niro | 66 | "${my_SRC_URI}" |
308 | niro | 59 | fi |
309 | fi | ||
310 | niro | 306 | |
311 | niro | 66 | # unset them to be shure |
312 | unset my_SRC_URI | ||
313 | unset my_SRC_URI_DEST | ||
314 | unset my_SRC_URI_MIRROR | ||
315 | unset my_SOURCEDIR | ||
316 | niro | 59 | done |
317 | |||
318 | # recheck md5 sums | ||
319 | echo | ||
320 | niro | 439 | echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
321 | niro | 1273 | ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
322 | niro | 59 | echo |
323 | |||
324 | # not needed anymore | ||
325 | unset SRC_URI | ||
326 | } | ||
327 | |||
328 | niro | 24 | # dummy function, used if that not exist in smage file |
329 | niro | 306 | src_prepare() |
330 | { | ||
331 | niro | 24 | echo "no src_prepare defined" |
332 | sleep 2 | ||
333 | return 0 | ||
334 | } | ||
335 | |||
336 | # dummy function, used if that not exist in smage file | ||
337 | niro | 306 | src_compile() |
338 | { | ||
339 | niro | 24 | echo "no src_compile defined" |
340 | sleep 2 | ||
341 | return 0 | ||
342 | } | ||
343 | |||
344 | # dummy function, used if that not exist in smage file | ||
345 | niro | 306 | src_install() |
346 | { | ||
347 | niro | 24 | echo "no src_install defined" |
348 | sleep 2 | ||
349 | return 0 | ||
350 | } | ||
351 | |||
352 | niro | 351 | mlibdir() |
353 | { | ||
354 | local libdir=lib | ||
355 | [[ ${ARCH} = x86_64 ]] && libdir=lib64 | ||
356 | |||
357 | echo "${libdir}" | ||
358 | } | ||
359 | |||
360 | niro | 306 | mconfigure() |
361 | { | ||
362 | niro | 24 | if [ -x ./configure ] |
363 | then | ||
364 | niro | 306 | ./configure \ |
365 | --prefix=/usr \ | ||
366 | --host=${CHOST} \ | ||
367 | niro | 833 | --build=${CHOST} \ |
368 | niro | 306 | --mandir=/usr/share/man \ |
369 | --infodir=/usr/share/info \ | ||
370 | --datadir=/usr/share \ | ||
371 | --sysconfdir=/etc \ | ||
372 | --localstatedir=/var/lib \ | ||
373 | niro | 351 | --libdir=/usr/$(mlibdir) \ |
374 | niro | 306 | "$@" || die "mconfigure failed" |
375 | niro | 24 | else |
376 | echo "configure is not an executable ..." | ||
377 | exit 1 | ||
378 | fi | ||
379 | } | ||
380 | |||
381 | niro | 306 | minstall() |
382 | { | ||
383 | if [ -f ./[mM]akefile -o -f ./GNUmakefile ] | ||
384 | then | ||
385 | niro | 24 | make prefix=${BINDIR}/usr \ |
386 | datadir=${BINDIR}/usr/share \ | ||
387 | infodir=${BINDIR}/usr/share/info \ | ||
388 | localstatedir=${BINDIR}/var/lib \ | ||
389 | mandir=${BINDIR}/usr/share/man \ | ||
390 | sysconfdir=${BINDIR}/etc \ | ||
391 | niro | 351 | libdir=${BINDIR}/usr/$(mlibdir) \ |
392 | niro | 24 | "$@" install || die "minstall failed" |
393 | else | ||
394 | die "no Makefile found" | ||
395 | fi | ||
396 | } | ||
397 | |||
398 | niro | 306 | mmake() |
399 | { | ||
400 | niro | 24 | make ${MAKEOPTS} ${EXTRA_EMAKE} "$@" |
401 | } | ||
402 | |||
403 | niro | 306 | munpack() |
404 | { | ||
405 | niro | 24 | local SRCFILE |
406 | local IFTAR | ||
407 | local DEST | ||
408 | |||
409 | SRCFILE=$1 | ||
410 | niro | 306 | |
411 | niro | 597 | if [[ -z $2 ]] |
412 | niro | 24 | then |
413 | DEST=${BUILDDIR} | ||
414 | else | ||
415 | DEST=$2 | ||
416 | fi | ||
417 | niro | 306 | |
418 | niro | 411 | [[ ! -d ${DEST} ]] && install -d ${DEST} |
419 | |||
420 | niro | 24 | case "${SRCFILE##*.}" in |
421 | bz2) | ||
422 | IFTAR="$(basename $SRCFILE .bz2)" | ||
423 | IFTAR="${IFTAR##*.}" | ||
424 | niro | 306 | if [[ ${IFTAR} = tar ]] |
425 | niro | 24 | then |
426 | niro | 597 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." |
427 | else | ||
428 | pushd ${DEST} > /dev/null | ||
429 | bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." | ||
430 | popd > /dev/null | ||
431 | niro | 24 | fi |
432 | ;; | ||
433 | gz) | ||
434 | IFTAR="$(basename $SRCFILE .gz)" | ||
435 | IFTAR="${IFTAR##*.}" | ||
436 | niro | 306 | if [[ ${IFTAR} = tar ]] |
437 | niro | 24 | then |
438 | niro | 597 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." |
439 | else | ||
440 | pushd ${DEST} > /dev/null | ||
441 | zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." | ||
442 | popd > /dev/null | ||
443 | niro | 24 | fi |
444 | ;; | ||
445 | niro | 600 | tbz2|mpks|mpk) |
446 | niro | 597 | tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
447 | niro | 24 | ;; |
448 | tgz) | ||
449 | niro | 597 | tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
450 | niro | 24 | ;; |
451 | niro | 597 | rar) |
452 | unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." | ||
453 | ;; | ||
454 | niro | 600 | zip|xpi) |
455 | niro | 597 | unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
456 | ;; | ||
457 | rpm) | ||
458 | niro | 635 | pushd ${DEST} > /dev/null |
459 | niro | 597 | rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
460 | niro | 602 | tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
461 | niro | 635 | if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
462 | niro | 602 | then |
463 | niro | 635 | rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
464 | niro | 602 | fi |
465 | niro | 597 | ;; |
466 | niro | 24 | *) |
467 | die "munpack failed" | ||
468 | ;; | ||
469 | esac | ||
470 | } | ||
471 | |||
472 | niro | 306 | mpatch() |
473 | { | ||
474 | niro | 24 | local PATCHOPTS |
475 | local PATCHFILE | ||
476 | niro | 447 | local i |
477 | niro | 24 | |
478 | PATCHOPTS=$1 | ||
479 | PATCHFILE=$2 | ||
480 | |||
481 | niro | 447 | if [[ -z $2 ]] |
482 | then | ||
483 | PATCHFILE=$1 | ||
484 | |||
485 | ## patch level auto-detection, get patch level | ||
486 | for ((i=0; i < 10; i++)) | ||
487 | do | ||
488 | patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null | ||
489 | if [[ $? = 0 ]] | ||
490 | then | ||
491 | PATCHOPTS="-Np${i}" | ||
492 | break | ||
493 | fi | ||
494 | done | ||
495 | fi | ||
496 | |||
497 | niro | 384 | echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
498 | niro | 24 | patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
499 | } | ||
500 | |||
501 | niro | 497 | mlibtoolize() |
502 | { | ||
503 | local opts="$@" | ||
504 | [[ -z ${opts} ]] && opts="--copy --force" | ||
505 | niro | 24 | |
506 | niro | 497 | libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
507 | } | ||
508 | |||
509 | niro | 306 | minstalldocs() |
510 | { | ||
511 | niro | 24 | local docfiles |
512 | docfiles="$@" | ||
513 | niro | 306 | |
514 | niro | 24 | if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] |
515 | then | ||
516 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." | ||
517 | fi | ||
518 | niro | 306 | |
519 | niro | 953 | local i |
520 | niro | 24 | for i in ${docfiles} |
521 | do | ||
522 | niro | 953 | if [ -f ${i} ] |
523 | then | ||
524 | cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." | ||
525 | install -m 0644 ${SRCDIR}/${i}.gz \ | ||
526 | ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." | ||
527 | fi | ||
528 | niro | 24 | done |
529 | } | ||
530 | |||
531 | niro | 306 | mstriplibs() |
532 | { | ||
533 | niro | 79 | local stripdir="$@" |
534 | |||
535 | [ -z "${stripdir}" ] && stripdir=${BINDIR} | ||
536 | find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null | ||
537 | } | ||
538 | |||
539 | niro | 306 | mstripbins() |
540 | { | ||
541 | niro | 79 | local stripdir="$@" |
542 | |||
543 | [ -z "${stripdir}" ] && stripdir=${BINDIR} | ||
544 | find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null | ||
545 | } | ||
546 | |||
547 | niro | 943 | mcompressdocs() |
548 | { | ||
549 | local bindir="$@" | ||
550 | |||
551 | if [ -d ${bindir}/usr/share/man ] | ||
552 | then | ||
553 | echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" | ||
554 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man | ||
555 | fi | ||
556 | |||
557 | if [ -d ${bindir}/usr/share/info ] | ||
558 | then | ||
559 | echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" | ||
560 | ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info | ||
561 | fi | ||
562 | } | ||
563 | |||
564 | niro | 306 | sminclude() |
565 | { | ||
566 | niro | 172 | local i |
567 | |||
568 | niro | 183 | if [[ -n "$@" ]] |
569 | niro | 172 | then |
570 | for i in $@ | ||
571 | do | ||
572 | niro | 175 | echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
573 | niro | 172 | source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
574 | done | ||
575 | niro | 177 | echo |
576 | niro | 172 | fi |
577 | } | ||
578 | |||
579 | niro | 306 | setup_distcc_environment() |
580 | { | ||
581 | niro | 24 | if [ -x /usr/bin/distcc ] |
582 | then | ||
583 | niro | 441 | echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" |
584 | niro | 351 | export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
585 | niro | 24 | |
586 | export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" | ||
587 | |||
588 | niro | 306 | # creating distcc tempdir |
589 | niro | 24 | install -o distcc -g daemon -d ${DISTCC_DIR} |
590 | chmod 1777 ${DISTCC_DIR} | ||
591 | fi | ||
592 | } | ||
593 | |||
594 | niro | 306 | setup_ccache_environment() |
595 | { | ||
596 | niro | 24 | if [ -x /usr/bin/ccache ] |
597 | then | ||
598 | niro | 441 | echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" |
599 | niro | 351 | export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
600 | niro | 24 | fi |
601 | } | ||
602 | |||
603 | niro | 193 | |
604 | # fixes given dependencies to match a MAGE_TARGET | ||
605 | niro | 198 | # fix_mage_deps -target s/depend # <-- note -target ! |
606 | niro | 306 | fix_mage_deps() |
607 | { | ||
608 | niro | 193 | local target="$1" |
609 | local depend="$2" | ||
610 | local NDEPEND | ||
611 | local sym dep cat pver pname | ||
612 | |||
613 | # deps and provides are special | ||
614 | # they must be fixed to match the target | ||
615 | |||
616 | # run this only if target and depend is not empty | ||
617 | if [ -n "${target}" ] && [ -n "${depend}" ] | ||
618 | then | ||
619 | # fix DEPEND | ||
620 | while read sym dep | ||
621 | do | ||
622 | niro | 427 | # ignore empty lines |
623 | [[ -z ${dep} ]] && continue | ||
624 | |||
625 | niro | 193 | cat="$(dirname ${dep})" |
626 | niro | 199 | # change if not virtual |
627 | niro | 200 | if [[ ${cat} = virtual ]] |
628 | niro | 199 | then |
629 | niro | 200 | pname="$(basename ${dep})" |
630 | else | ||
631 | niro | 199 | # fix pver to target-pver |
632 | # to get pname-target-pver | ||
633 | niro | 193 | |
634 | niro | 199 | # doing it backwards ! |
635 | pver="${dep##*-}" | ||
636 | niro | 200 | # full pver |
637 | pname="$(basename ${dep/-${pver}/})${target}-${pver}" | ||
638 | niro | 199 | fi |
639 | niro | 193 | |
640 | # do not add empty lines | ||
641 | if [ -z "${NDEPEND}" ] | ||
642 | then | ||
643 | niro | 200 | NDEPEND="${sym} ${cat}/${pname}" |
644 | niro | 193 | else |
645 | NDEPEND="${NDEPEND} | ||
646 | niro | 201 | ${sym} ${cat}/${pname}" |
647 | niro | 193 | fi |
648 | |||
649 | unset cat pname pver | ||
650 | done << EOF | ||
651 | ${depend} | ||
652 | EOF | ||
653 | # set NDEPEND to DEPEND | ||
654 | depend="${NDEPEND}" | ||
655 | fi | ||
656 | |||
657 | echo "${depend}" | ||
658 | } | ||
659 | |||
660 | niro | 192 | # build_mage_script(): helper functions for regen_mage_tree() |
661 | niro | 191 | # generates an mage file with given information in smage file |
662 | # needs at least: | ||
663 | # PNAME name of pkg | ||
664 | # PVER version | ||
665 | # PBUILD revision | ||
666 | # PCATEGORIE categorie of the pkg | ||
667 | # STATE state of pkg stable|unstable|old | ||
668 | # DESCRIPTION va short description (opt) | ||
669 | # HOMEPAGE homepage (opt) | ||
670 | # DEPEND runtime dependencies (opt) | ||
671 | # SDEPEND add. needed deps to build the pkg (opt) | ||
672 | # PROVIDE provides a virtual (opt) | ||
673 | # | ||
674 | # special tags: | ||
675 | # PKGTYPE type of pkg | ||
676 | # INHERITS which functions get included | ||
677 | niro | 832 | # SPECIAL_FUNCTIONS special functions which should also be added |
678 | niro | 191 | # warning: they get killed before the build starts ! |
679 | niro | 943 | # SPLIT_PACKAGES names of all subpackages which are splitted from parent |
680 | # SPLIT_PACKAGE_BASE base package name for splitpackages | ||
681 | # (only in the resulting magefile} | ||
682 | niro | 191 | # |
683 | # MAGE_TREE_DEST target destination of the generated tree | ||
684 | # REGEN_MAGE_TREE set to 'true' to enable this | ||
685 | niro | 193 | # |
686 | niro | 195 | # gets called with build_mage_script target |
687 | niro | 192 | build_mage_script() |
688 | niro | 191 | { |
689 | local magefile | ||
690 | local dest | ||
691 | niro | 193 | local target |
692 | niro | 943 | local split_pkg_base |
693 | niro | 191 | local sym |
694 | local depname | ||
695 | |||
696 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
697 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
698 | |||
699 | # determinate which suffix this mage file should get, if any | ||
700 | niro | 943 | [[ $1 = --target ]] && shift && target="-$1" |
701 | niro | 191 | |
702 | niro | 943 | # mark package as splitpackage |
703 | [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" | ||
704 | |||
705 | niro | 191 | # name of magefile |
706 | niro | 193 | magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
707 | niro | 191 | |
708 | # destination to magefile | ||
709 | niro | 193 | dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
710 | niro | 191 | |
711 | # show what we are doing | ||
712 | niro | 439 | echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" |
713 | echo "${dest}" | ||
714 | niro | 191 | |
715 | install -d "$(dirname ${dest})" | ||
716 | # now build the mage file | ||
717 | > ${dest} | ||
718 | |||
719 | # header | ||
720 | niro | 635 | echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest} |
721 | niro | 191 | echo >> ${dest} |
722 | |||
723 | # pgkname and state | ||
724 | niro | 193 | echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
725 | niro | 191 | echo "STATE=\"${STATE}\"" >> ${dest} |
726 | echo >> ${dest} | ||
727 | |||
728 | # description and homepage | ||
729 | echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} | ||
730 | echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} | ||
731 | echo >> ${dest} | ||
732 | |||
733 | niro | 196 | # special tags and vars |
734 | niro | 191 | echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
735 | niro | 214 | |
736 | # echo MAGE_TARGETS ## note -target is needed ! | ||
737 | echo "MAGE_TARGETS=\"${target}\"" >> ${dest} | ||
738 | echo >> ${dest} | ||
739 | |||
740 | niro | 943 | # split package base |
741 | echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} | ||
742 | echo >> ${dest} | ||
743 | |||
744 | niro | 197 | # add special vars |
745 | if [ -n "${SPECIAL_VARS}" ] | ||
746 | niro | 191 | then |
747 | local i | ||
748 | niro | 197 | for i in ${SPECIAL_VARS} |
749 | niro | 191 | do |
750 | niro | 197 | # being tricky here :) |
751 | echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} | ||
752 | niro | 191 | done |
753 | echo >> ${dest} | ||
754 | fi | ||
755 | niro | 214 | |
756 | niro | 197 | # add at least all includes |
757 | if [ -n "${INHERITS}" ] | ||
758 | niro | 196 | then |
759 | niro | 197 | echo -n "minclude" >> ${dest} |
760 | niro | 196 | local i |
761 | niro | 197 | for i in ${INHERITS} |
762 | niro | 196 | do |
763 | niro | 197 | echo -n " ${i}" >> ${dest} |
764 | niro | 196 | done |
765 | echo >> ${dest} | ||
766 | fi | ||
767 | niro | 197 | echo >> ${dest} |
768 | niro | 196 | |
769 | niro | 191 | # deps and provides |
770 | niro | 193 | echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
771 | niro | 196 | echo >> ${dest} |
772 | niro | 193 | echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
773 | niro | 196 | echo >> ${dest} |
774 | niro | 191 | echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
775 | echo >> ${dest} | ||
776 | |||
777 | # add special functions | ||
778 | if [ -n "${SPECIAL_FUNCTIONS}" ] | ||
779 | then | ||
780 | local i | ||
781 | for i in ${SPECIAL_FUNCTIONS} | ||
782 | do | ||
783 | # add to mage (quotes needed !) | ||
784 | typeset -f "${i}" >> ${dest} | ||
785 | niro | 214 | echo >> ${dest} |
786 | niro | 191 | # unset to be safe (quotes needed !) |
787 | niro | 192 | #unset "${i}" <-- later to get every target built |
788 | niro | 191 | done |
789 | niro | 196 | echo >> ${dest} |
790 | niro | 191 | fi |
791 | |||
792 | # pre|post-install|removes | ||
793 | typeset -f preinstall >> ${dest} | ||
794 | echo >> ${dest} | ||
795 | typeset -f postinstall >> ${dest} | ||
796 | echo >> ${dest} | ||
797 | typeset -f preremove >> ${dest} | ||
798 | echo >> ${dest} | ||
799 | typeset -f postremove >> ${dest} | ||
800 | echo >> ${dest} | ||
801 | } | ||
802 | |||
803 | regen_mage_tree() | ||
804 | { | ||
805 | local i | ||
806 | |||
807 | # build them only if requested | ||
808 | if [[ ${REGEN_MAGE_TREE} = true ]] | ||
809 | then | ||
810 | niro | 195 | # run it without targets |
811 | niro | 943 | if [[ -n ${MAGE_TARGETS} ]] |
812 | niro | 195 | then |
813 | niro | 943 | # build for each target a mage file |
814 | # run it with several targets | ||
815 | niro | 191 | echo |
816 | niro | 943 | for i in ${MAGE_TARGETS} |
817 | do | ||
818 | build_mage_script --target "${i}" | ||
819 | done | ||
820 | niro | 191 | echo |
821 | niro | 195 | |
822 | niro | 943 | # run it for splitpackages |
823 | elif [[ -n ${SPLIT_PACKAGES} ]] | ||
824 | then | ||
825 | local split_pkg_base="${PNAME}" | ||
826 | # save smage environment | ||
827 | split_save_variables | ||
828 | # build for each subpackage a mage file | ||
829 | niro | 195 | # run it with several targets |
830 | niro | 943 | echo |
831 | for i in ${SPLIT_PACKAGES} | ||
832 | niro | 195 | do |
833 | niro | 943 | # get the right variables for the split |
834 | export PNAME="${i}" | ||
835 | split_info_${i} | ||
836 | build_mage_script --split-pkg-base "${split_pkg_base}" | ||
837 | niro | 951 | # restore smage environment |
838 | split_restore_variables | ||
839 | niro | 195 | done |
840 | niro | 943 | echo |
841 | niro | 951 | # unset all saved smage variables |
842 | split_unset_variables | ||
843 | niro | 943 | |
844 | else | ||
845 | echo | ||
846 | build_mage_script | ||
847 | echo | ||
848 | niro | 195 | fi |
849 | niro | 191 | fi |
850 | |||
851 | # now unset all uneeded vars to be safe | ||
852 | niro | 192 | # unset PKGNAME <-- don't do that; smage needs this var |
853 | # unset to be safe (quotes needed !) | ||
854 | niro | 477 | # for i in ${SPECIAL_FUNCTIONS} |
855 | # do | ||
856 | # unset "${i}" | ||
857 | # done | ||
858 | niro | 192 | unset SPECIAL_FUNCTIONS |
859 | niro | 477 | # for i in ${SPECIAL_VARS} |
860 | # do | ||
861 | # unset "${i}" | ||
862 | # done | ||
863 | niro | 194 | unset SPECIAL_VARS |
864 | niro | 191 | unset STATE |
865 | unset DESCRIPTION | ||
866 | unset HOMEPAGE | ||
867 | unset PKGTYPE | ||
868 | unset INHERITS | ||
869 | unset DEPEND | ||
870 | unset SDEPEND | ||
871 | unset PROVIDE | ||
872 | unset preinstall | ||
873 | unset postinstall | ||
874 | unset preremove | ||
875 | unset postremove | ||
876 | } | ||
877 | |||
878 | niro | 943 | split_save_variables() |
879 | { | ||
880 | export SAVED_PNAME="${PNAME}" | ||
881 | export SAVED_PVER="${PVER}" | ||
882 | export SAVED_PBUILD="${PBUILD}" | ||
883 | export SAVED_PCATEGORIE="${PCATEGORIE}" | ||
884 | export SAVED_DESCRIPTION="${DESCRIPTION}" | ||
885 | export SAVED_HOMEPAGE="${HOMEPAGE}" | ||
886 | export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" | ||
887 | export SAVED_STATE="${STATE}" | ||
888 | export SAVED_PKGTYPE="${PKGTYPE}" | ||
889 | export SAVED_INHERITS="${INHERITS}" | ||
890 | export SAVED_DEPEND="${DEPEND}" | ||
891 | export SAVED_SDEPEND="${SDEPEND}" | ||
892 | export SAVED_PROVIDE="${PROVIDE}" | ||
893 | niro | 945 | export SAVED_NOPKGBUILD="${NOPKGBUILD}" |
894 | niro | 943 | |
895 | niro | 945 | # bindir too |
896 | export SAVED_BINDIR="${BINDIR}" | ||
897 | |||
898 | # export the SPLIT_PACKAGE_BASE | ||
899 | export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" | ||
900 | |||
901 | niro | 943 | # functions |
902 | if [[ ! -z $(typeset -f preinstall) ]] | ||
903 | then | ||
904 | # rename the old one | ||
905 | local saved_preinstall | ||
906 | saved_preinstall=SAVED_$(typeset -f preinstall) | ||
907 | eval "${saved_preinstall}" | ||
908 | export -f SAVED_preinstall | ||
909 | fi | ||
910 | |||
911 | if [[ ! -z $(typeset -f postinstall) ]] | ||
912 | then | ||
913 | # rename the old one | ||
914 | local saved_postinstall | ||
915 | saved_postinstall=SAVED_$(typeset -f postinstall) | ||
916 | eval "${saved_postinstall}" | ||
917 | export -f SAVED_postinstall | ||
918 | fi | ||
919 | |||
920 | if [[ ! -z $(typeset -f preremove) ]] | ||
921 | then | ||
922 | # rename the old one | ||
923 | local saved_preremove | ||
924 | saved_preremove=SAVED_$(typeset -f preremove) | ||
925 | eval "${saved_preremove}" | ||
926 | export -f SAVED_preremove | ||
927 | fi | ||
928 | |||
929 | if [[ ! -z $(typeset -f postremove) ]] | ||
930 | then | ||
931 | # rename the old one | ||
932 | local saved_postremove | ||
933 | saved_postremove=SAVED_$(typeset -f postremove) | ||
934 | eval "${saved_postremove}" | ||
935 | export -f SAVED_postremove | ||
936 | fi | ||
937 | } | ||
938 | |||
939 | split_restore_variables() | ||
940 | { | ||
941 | export PNAME="${SAVED_PNAME}" | ||
942 | export PVER="${SAVED_PVER}" | ||
943 | export PBUILD="${SAVED_PBUILD}" | ||
944 | export PCATEGORIE="${SAVED_PCATEGORIE}" | ||
945 | export DESCRIPTION="${SAVED_DESCRIPTION}" | ||
946 | export HOMEPAGE="${SAVED_HOMEPAGE}" | ||
947 | export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" | ||
948 | export STATE="${SAVED_STATE}" | ||
949 | export PKGTYPE="${SAVED_PKGTYPE}" | ||
950 | export INHERITS="${SAVED_INHERITS}" | ||
951 | export DEPEND="${SAVED_DEPEND}" | ||
952 | export SDEPEND="${SAVED_SDEPEND}" | ||
953 | export PROVIDE="${SAVED_PROVIDE}" | ||
954 | niro | 945 | export NOPKGBUILD="${SAVED_NOPKGBUILD}" |
955 | niro | 943 | |
956 | niro | 945 | # bindir too |
957 | export BINDIR="${SAVED_BINDIR}" | ||
958 | |||
959 | niro | 943 | # functions |
960 | if [[ ! -z $(typeset -f SAVED_preinstall) ]] | ||
961 | then | ||
962 | # rename the old one | ||
963 | local saved_preinstall | ||
964 | saved_preinstall=$(typeset -f SAVED_preinstall) | ||
965 | eval "${saved_preinstall/SAVED_/}" | ||
966 | export -f preinstall | ||
967 | fi | ||
968 | |||
969 | if [[ ! -z $(typeset -f SAVED_postinstall) ]] | ||
970 | then | ||
971 | # rename the old one | ||
972 | local saved_postinstall | ||
973 | saved_postinstall=$(typeset -f SAVED_postinstall) | ||
974 | eval "${saved_postinstall/SAVED_/}" | ||
975 | export -f postinstall | ||
976 | fi | ||
977 | |||
978 | if [[ ! -z $(typeset -f SAVED_preremove) ]] | ||
979 | then | ||
980 | # rename the old one | ||
981 | local saved_preremove | ||
982 | saved_preremove=$(typeset -f SAVED_preremove) | ||
983 | eval "${saved_preremove/SAVED_/}" | ||
984 | export -f preremove | ||
985 | fi | ||
986 | |||
987 | if [[ ! -z $(typeset -f SAVED_postremove) ]] | ||
988 | then | ||
989 | # rename the old one | ||
990 | local saved_postremove | ||
991 | saved_postremove=$(typeset -f SAVED_postremove) | ||
992 | eval "${saved_postremove/SAVED_/}" | ||
993 | export -f postremove | ||
994 | fi | ||
995 | niro | 951 | } |
996 | niro | 943 | |
997 | niro | 951 | split_unset_variables() |
998 | { | ||
999 | niro | 943 | # unset saved vars; not needed anymore |
1000 | unset SAVED_PNAME | ||
1001 | unset SAVED_PVER | ||
1002 | unset SAVED_PBUILD | ||
1003 | unset SAVED_PCATEGORIE | ||
1004 | unset SAVED_DESCRIPTION | ||
1005 | unset SAVED_HOMEPAGE | ||
1006 | unset SAVED_SPECIAL_VARS | ||
1007 | unset SAVED_STATE | ||
1008 | unset SAVED_PKGTYPE | ||
1009 | unset SAVED_INHERITS | ||
1010 | unset SAVED_DEPEND | ||
1011 | unset SAVED_SDEPEND | ||
1012 | unset SAVED_PROVIDE | ||
1013 | niro | 945 | unset SAVED_BINDIR |
1014 | unset SAVED_NOPKGBUILD | ||
1015 | unset SPLIT_PACKAGE_BASE | ||
1016 | niro | 943 | unset -f SAVED_preinstall |
1017 | unset -f SAVED_postinstall | ||
1018 | unset -f SAVED_preremove | ||
1019 | unset -f SAVED_postremove | ||
1020 | } | ||
1021 | |||
1022 | niro | 253 | export_inherits() |
1023 | { | ||
1024 | local include="$1" | ||
1025 | shift | ||
1026 | |||
1027 | while [ "$1" ] | ||
1028 | do | ||
1029 | local functions="$1" | ||
1030 | |||
1031 | # sanity checks | ||
1032 | [ -z "${include}" ] && die "export_inherits(): \$include not given." | ||
1033 | [ -z "${functions}" ] && die "export_inherits(): \$functions not given." | ||
1034 | |||
1035 | eval "${functions}() { ${include}_${functions} ; }" | ||
1036 | |||
1037 | # debug | ||
1038 | [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" | ||
1039 | |||
1040 | shift | ||
1041 | done | ||
1042 | } | ||
1043 | |||
1044 | niro | 255 | generate_package_md5sum() |
1045 | { | ||
1046 | local dest | ||
1047 | local pcat | ||
1048 | local pname | ||
1049 | local pver | ||
1050 | local pbuild | ||
1051 | local parch | ||
1052 | local target | ||
1053 | local pkgname | ||
1054 | |||
1055 | # very basic getops | ||
1056 | for i in $* | ||
1057 | do | ||
1058 | case $1 in | ||
1059 | --pcat|-c) shift; pcat="$1" ;; | ||
1060 | --pname|-n) shift; pname="$1" ;; | ||
1061 | --pver|-v) shift; pver="$1" ;; | ||
1062 | --pbuild|-b) shift; pbuild="$1" ;; | ||
1063 | --parch|a) shift; parch="$1" ;; | ||
1064 | --target|t) shift; target="$1" ;; | ||
1065 | esac | ||
1066 | shift | ||
1067 | done | ||
1068 | |||
1069 | # sanity checks; abort if not given | ||
1070 | [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given." | ||
1071 | [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given." | ||
1072 | [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given." | ||
1073 | [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given." | ||
1074 | [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given." | ||
1075 | |||
1076 | # check needed global vars | ||
1077 | [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set." | ||
1078 | [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set." | ||
1079 | |||
1080 | # fix target as it may be empty ! | ||
1081 | [ -n "${target}" ] && target="-${target}" | ||
1082 | |||
1083 | niro | 890 | |
1084 | niro | 255 | # build pkgname |
1085 | pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" | ||
1086 | |||
1087 | # build pkg-md5-sum only if requested | ||
1088 | if [[ ${REGEN_MAGE_TREE} = true ]] | ||
1089 | then | ||
1090 | niro | 439 | echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
1091 | niro | 255 | |
1092 | # abort if not exist | ||
1093 | if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] | ||
1094 | then | ||
1095 | niro | 439 | echo -e "${COLRED}! exists${COLDEFAULT}" |
1096 | niro | 255 | return 0 |
1097 | fi | ||
1098 | |||
1099 | # if MAGE_TREE_DEST not set use BUILDDIR | ||
1100 | : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} | ||
1101 | |||
1102 | # setup md5 dir | ||
1103 | niro | 891 | dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1104 | niro | 255 | install -d ${dest} |
1105 | |||
1106 | # gen md5sum | ||
1107 | ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ | ||
1108 | niro | 256 | > ${dest}/${pkgname}.md5 |
1109 | niro | 439 | echo -e "${COLGREEN}done${COLDEFAULT}" |
1110 | niro | 255 | fi |
1111 | } | ||
1112 | |||
1113 | niro | 403 | source_pkg_build() |
1114 | { | ||
1115 | if [[ ${PKGTYPE} = virtual ]] | ||
1116 | then | ||
1117 | echo "Virtual package detected; src-pkg-tarball not necessary ..." | ||
1118 | return 0 | ||
1119 | fi | ||
1120 | |||
1121 | if [[ ! -d ${SOURCEDIR}/${PNAME} ]] | ||
1122 | then | ||
1123 | echo "No SRC_URI defined; src-pkg-tarball not necessary ..." | ||
1124 | return 0 | ||
1125 | fi | ||
1126 | |||
1127 | niro | 419 | [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." |
1128 | niro | 406 | |
1129 | niro | 403 | echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
1130 | niro | 412 | |
1131 | # include the smage2 file | ||
1132 | cp ${SMAGENAME} ${SOURCEDIR}/${PNAME} | ||
1133 | |||
1134 | niro | 403 | ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; ) |
1135 | niro | 406 | [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR} |
1136 | mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} | ||
1137 | niro | 403 | |
1138 | echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" | ||
1139 | } | ||
1140 | |||
1141 | niro | 859 | step_by_step() |
1142 | { | ||
1143 | if [[ ${STEP_BY_STEP} = true ]] | ||
1144 | then | ||
1145 | niro | 945 | echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1146 | niro | 859 | echo "Press [enter] to continue" |
1147 | read | ||
1148 | fi | ||
1149 | } | ||
1150 | niro | 403 | |
1151 | niro | 859 | |
1152 | niro | 59 | # print out our version |
1153 | showversion | ||
1154 | echo | ||
1155 | |||
1156 | niro | 24 | if [ -z "$1" ] |
1157 | then | ||
1158 | echo "No .smage2 file given. Exiting." | ||
1159 | echo | ||
1160 | exit 1 | ||
1161 | fi | ||
1162 | |||
1163 | niro | 192 | # updating smage2-scripts |
1164 | niro | 306 | if [[ $1 = update ]] |
1165 | niro | 24 | then |
1166 | niro | 59 | if [ ! -d ${SOURCEDIR} ] |
1167 | then | ||
1168 | install -d ${SOURCEDIR} | ||
1169 | fi | ||
1170 | syncsmage2 | ||
1171 | exit 0 | ||
1172 | fi | ||
1173 | |||
1174 | niro | 192 | # creates md5sums for smages to given dir |
1175 | niro | 306 | if [[ $1 = calcmd5 ]] |
1176 | niro | 59 | then |
1177 | niro | 1207 | if [ $# -ge 2 ] |
1178 | niro | 59 | then |
1179 | SMAGENAME="$2" | ||
1180 | MD5DIR="$3" | ||
1181 | niro | 1207 | [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1182 | |||
1183 | niro | 59 | source ${SMAGENAME} || die "download source failed" |
1184 | |||
1185 | niro | 66 | # overridable sourcedir; must be declared after source of the smage2 |
1186 | CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" | ||
1187 | |||
1188 | niro | 59 | [ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
1189 | |||
1190 | # end of array | ||
1191 | EOA=${#SRC_URI[*]} | ||
1192 | |||
1193 | [ ! -d ${MD5DIR} ] && install -d ${MD5DIR} | ||
1194 | |||
1195 | # clear md5sum file | ||
1196 | MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" | ||
1197 | echo -n > ${MY_MD5_FILE} | ||
1198 | |||
1199 | for ((i=0; i < EOA; i++)) | ||
1200 | do | ||
1201 | niro | 66 | # url to file |
1202 | my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" | ||
1203 | |||
1204 | # subdir in sources dir; the my_SRCI_URI file goes to there | ||
1205 | my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" | ||
1206 | |||
1207 | # if my_src_uri_dest is not equal my_src_uri; than an other dir is used | ||
1208 | if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] | ||
1209 | then | ||
1210 | MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" | ||
1211 | else | ||
1212 | MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" | ||
1213 | fi | ||
1214 | |||
1215 | niro | 59 | if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
1216 | then | ||
1217 | echo "calculating $(basename ${MY_SRC_FILE}) ..." | ||
1218 | ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} | ||
1219 | else | ||
1220 | echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." | ||
1221 | fi | ||
1222 | niro | 66 | |
1223 | # unset them to be shure | ||
1224 | unset my_SRC_URI | ||
1225 | unset my_SRC_URI_DEST | ||
1226 | unset my_SRC_URI_MIRROR | ||
1227 | unset my_SOURCEDIR | ||
1228 | niro | 59 | done |
1229 | niro | 306 | |
1230 | niro | 59 | echo |
1231 | echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." | ||
1232 | echo | ||
1233 | else | ||
1234 | echo "Usage: Calculating MD5 Sums:" | ||
1235 | niro | 1207 | echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1236 | niro | 59 | echo |
1237 | echo | ||
1238 | echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." | ||
1239 | echo | ||
1240 | exit 1 | ||
1241 | fi | ||
1242 | niro | 306 | |
1243 | niro | 59 | exit 0 |
1244 | fi | ||
1245 | |||
1246 | niro | 192 | # download sources |
1247 | niro | 59 | if [ "$1" == "download" -a -n "$2" ] |
1248 | then | ||
1249 | niro | 24 | if [ ! -d ${SMAGESCRIPTSDIR} ] |
1250 | then | ||
1251 | install -d ${SMAGESCRIPTSDIR} | ||
1252 | fi | ||
1253 | niro | 59 | |
1254 | # get smage | ||
1255 | SMAGENAME="$2" | ||
1256 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
1257 | source ${SMAGENAME} || die "download source failed" | ||
1258 | |||
1259 | download_sources | ||
1260 | niro | 24 | exit 0 |
1261 | fi | ||
1262 | |||
1263 | niro | 202 | # regen-mage-tree |
1264 | if [ "$1" == "only-regen-tree" -a -n "$2" ] | ||
1265 | then | ||
1266 | # set correct SMAGENAME | ||
1267 | SMAGENAME="$2" | ||
1268 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
1269 | source ${SMAGENAME} || die "regen: smage2 not found" | ||
1270 | |||
1271 | regen_mage_tree | ||
1272 | niro | 255 | |
1273 | niro | 890 | # build several targets |
1274 | niro | 943 | if [[ -n ${MAGE_TARGETS} ]] |
1275 | niro | 890 | then |
1276 | for target in ${MAGE_TARGETS} | ||
1277 | do | ||
1278 | # build md5sum for existing packages | ||
1279 | generate_package_md5sum \ | ||
1280 | --pcat "${PCATEGORIE}" \ | ||
1281 | --pname "${PNAME}" \ | ||
1282 | --pver "${PVER}" \ | ||
1283 | --pbuild "${PBUILD}" \ | ||
1284 | --parch "${ARCH}" \ | ||
1285 | --target "${target}" | ||
1286 | done | ||
1287 | niro | 943 | |
1288 | # build several subpackages | ||
1289 | elif [[ -n ${SPLIT_PACKAGES} ]] | ||
1290 | then | ||
1291 | split_save_variables | ||
1292 | niro | 964 | for subpackage in ${SPLIT_PACKAGES} |
1293 | niro | 943 | do |
1294 | # get the right variables for the split | ||
1295 | export PNAME="${subpackage}" | ||
1296 | split_info_${subpackage} | ||
1297 | # build md5sum for existing packages | ||
1298 | generate_package_md5sum \ | ||
1299 | --pcat "${PCATEGORIE}" \ | ||
1300 | --pname "${PNAME}" \ | ||
1301 | --pver "${PVER}" \ | ||
1302 | --pbuild "${PBUILD}" \ | ||
1303 | --parch "${ARCH}" | ||
1304 | niro | 951 | # restore smage environment |
1305 | split_restore_variables | ||
1306 | niro | 943 | done |
1307 | niro | 951 | # unset all saved smage variables |
1308 | split_unset_variables | ||
1309 | niro | 943 | |
1310 | niro | 890 | else |
1311 | # build md5sum for existing packages | ||
1312 | generate_package_md5sum \ | ||
1313 | --pcat "${PCATEGORIE}" \ | ||
1314 | --pname "${PNAME}" \ | ||
1315 | --pver "${PVER}" \ | ||
1316 | --pbuild "${PBUILD}" \ | ||
1317 | niro | 943 | --parch "${ARCH}" |
1318 | niro | 890 | fi |
1319 | niro | 255 | |
1320 | niro | 202 | exit 0 |
1321 | fi | ||
1322 | |||
1323 | niro | 412 | if [ "$1" == "--create-src-tarball" -a -n "$2" ] |
1324 | niro | 403 | then |
1325 | # set correct SMAGENAME | ||
1326 | SMAGENAME="$2" | ||
1327 | MD5DIR="$(dirname ${SMAGENAME})/md5" | ||
1328 | |||
1329 | niro | 412 | echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1330 | niro | 403 | |
1331 | source ${SMAGENAME} || die "regen: smage2 not found" | ||
1332 | |||
1333 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
1334 | then | ||
1335 | echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" | ||
1336 | rm -rf ${SOURCEDIR}/${PKGNAME} | ||
1337 | fi | ||
1338 | |||
1339 | download_sources | ||
1340 | source_pkg_build ${SMAGENAME} | ||
1341 | exit 0 | ||
1342 | fi | ||
1343 | |||
1344 | niro | 406 | if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ] |
1345 | niro | 403 | then |
1346 | niro | 412 | SRCPKGTARBALL="${2}" |
1347 | niro | 403 | USE_SRC_PKG_TARBALL=true |
1348 | |||
1349 | niro | 412 | # abort if given file is not a source pkg |
1350 | [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file." | ||
1351 | |||
1352 | # set correct SMAGENAME; use the one that the src_pkg provide | ||
1353 | # /path/to/SOURCEDIR/PNAME/SMAGENAME | ||
1354 | SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}" | ||
1355 | |||
1356 | niro | 403 | echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}" |
1357 | |||
1358 | [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR} | ||
1359 | |||
1360 | # unpack srctarball | ||
1361 | [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting." | ||
1362 | |||
1363 | tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}" | ||
1364 | niro | 412 | |
1365 | [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}" | ||
1366 | niro | 403 | fi |
1367 | |||
1368 | |||
1369 | niro | 306 | [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
1370 | [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && | ||
1371 | die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." | ||
1372 | niro | 419 | [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly." |
1373 | [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly." | ||
1374 | [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly." | ||
1375 | [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}" | ||
1376 | [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}" | ||
1377 | [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" | ||
1378 | [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" | ||
1379 | niro | 24 | |
1380 | source ${SMAGENAME} || die "source failed" | ||
1381 | niro | 255 | PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1382 | niro | 59 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
1383 | niro | 941 | SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1384 | niro | 24 | |
1385 | xtitle "Compiling ${PKGNAME}" | ||
1386 | niro | 439 | echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1387 | niro | 59 | |
1388 | niro | 191 | # auto regen mage tree if requested |
1389 | regen_mage_tree | ||
1390 | |||
1391 | niro | 403 | if [[ ${CREATE_SRC_PKG_TARBALL} = true ]] |
1392 | then | ||
1393 | if [[ -d ${SOURCEDIR}/${PNAME} ]] | ||
1394 | then | ||
1395 | niro | 441 | echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
1396 | niro | 408 | rm -rf ${SOURCEDIR}/${PNAME} |
1397 | niro | 403 | fi |
1398 | fi | ||
1399 | |||
1400 | niro | 192 | # download sources |
1401 | niro | 403 | [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources |
1402 | niro | 59 | |
1403 | niro | 192 | # fixes some issues with these functions |
1404 | niro | 24 | export -f src_prepare || die "src_prepare export failed" |
1405 | export -f src_compile || die "src_compile export failed" | ||
1406 | export -f src_install || die "src_install export failed" | ||
1407 | |||
1408 | niro | 192 | # fixes some compile issues |
1409 | niro | 24 | export CHOST="${CHOST}" || die "CHOST export failed" |
1410 | export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" | ||
1411 | export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" | ||
1412 | export BINDIR="${BINDIR}" || die "BINDIR export failed" | ||
1413 | export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" | ||
1414 | |||
1415 | |||
1416 | niro | 192 | # setup distcc |
1417 | niro | 351 | # setup for distcc goes *before* ccache, so ccache comes before distcc in path |
1418 | niro | 306 | [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment |
1419 | niro | 24 | |
1420 | niro | 192 | # setup ccache |
1421 | niro | 306 | [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
1422 | niro | 24 | |
1423 | # small sleep to show our settings | ||
1424 | sleep 1 | ||
1425 | |||
1426 | niro | 192 | # cleans up build if a previously one exists |
1427 | niro | 24 | if [ -d ${BUILDDIR} ] |
1428 | then | ||
1429 | rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." | ||
1430 | fi | ||
1431 | install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." | ||
1432 | |||
1433 | niro | 192 | # cleans up srcdir if a previously unpacked one exists |
1434 | niro | 24 | if [ -d ${SRCDIR} ] |
1435 | then | ||
1436 | rm -rf ${SRCDIR} | ||
1437 | fi | ||
1438 | |||
1439 | niro | 192 | # cleans up bindir if a previous build exists or creates a new one |
1440 | niro | 24 | if [ -d ${BINDIR} ] |
1441 | then | ||
1442 | rm -rf ${BINDIR} | ||
1443 | fi | ||
1444 | install -d ${BINDIR} || die "couldn't create \$BINDIR." | ||
1445 | |||
1446 | niro | 192 | # cleans up package temp dir if a previous build exists |
1447 | niro | 24 | if [ -d ${BUILDDIR}/${PKGNAME} ] |
1448 | then | ||
1449 | rm -rf ${BUILDDIR}/${PKGNAME} | ||
1450 | fi | ||
1451 | |||
1452 | niro | 192 | # cleans up timestamp if one exists |
1453 | niro | 24 | if [ -f /var/tmp/timestamp ] |
1454 | then | ||
1455 | mage rmstamp | ||
1456 | fi | ||
1457 | |||
1458 | niro | 875 | # setup build loggins |
1459 | [[ ! -d /var/log/smage ]] && install -d /var/log/smage | ||
1460 | echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log | ||
1461 | |||
1462 | niro | 941 | src_prepare | ${SMAGE_LOG_CMD} |
1463 | die_pipestatus 0 "src_prepare failed" | ||
1464 | niro | 859 | step_by_step $_ |
1465 | niro | 941 | |
1466 | src_compile | ${SMAGE_LOG_CMD} | ||
1467 | die_pipestatus 0 "src_compile failed" | ||
1468 | niro | 859 | step_by_step $_ |
1469 | niro | 941 | |
1470 | niro | 943 | # build several subpackages |
1471 | if [[ -n ${SPLIT_PACKAGES} ]] | ||
1472 | then | ||
1473 | niro | 945 | # save bindir & pname |
1474 | split_save_variables | ||
1475 | niro | 943 | export SAVED_BINDIR="${BINDIR}" |
1476 | for subpackage in ${SPLIT_PACKAGES} | ||
1477 | do | ||
1478 | if typeset -f src_install_${subpackage} > /dev/null | ||
1479 | then | ||
1480 | # export subpackage bindir | ||
1481 | export BINDIR="${SAVED_BINDIR}_${subpackage}" | ||
1482 | niro | 945 | # export PNAME, several internal function and include |
1483 | # rely on this variable | ||
1484 | export PNAME="${subpackage}" | ||
1485 | |||
1486 | echo | ||
1487 | echo -en "${COLBLUE}*** ${COLDEFAULT}" | ||
1488 | echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" | ||
1489 | echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" | ||
1490 | echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." | ||
1491 | |||
1492 | niro | 943 | src_install_${subpackage} | ${SMAGE_LOG_CMD} |
1493 | die_pipestatus 0 "src_install_${subpackage} failed" | ||
1494 | step_by_step $_ | ||
1495 | fi | ||
1496 | done | ||
1497 | niro | 945 | # restore bindir & pname |
1498 | split_restore_variables | ||
1499 | niro | 951 | # unset all saved smage variables |
1500 | split_unset_variables | ||
1501 | niro | 943 | else |
1502 | src_install | ${SMAGE_LOG_CMD} | ||
1503 | die_pipestatus 0 "src_install failed" | ||
1504 | step_by_step $_ | ||
1505 | fi | ||
1506 | niro | 24 | |
1507 | niro | 192 | # compressing doc, info & man files |
1508 | niro | 943 | if [[ -n ${SPLIT_PACKAGES} ]] |
1509 | niro | 24 | then |
1510 | niro | 964 | for subpackage in ${SPLIT_PACKAGES} |
1511 | niro | 943 | do |
1512 | mcompressdocs ${BINDIR}_${subpackage} | ||
1513 | done | ||
1514 | else | ||
1515 | mcompressdocs ${BINDIR} | ||
1516 | niro | 24 | fi |
1517 | |||
1518 | |||
1519 | niro | 79 | # stripping all bins and libs |
1520 | case ${NOSTRIP} in | ||
1521 | true|TRUE|yes|y) | ||
1522 | echo -e "NOSTRIP=true detected; Package will not be stripped ..." | ||
1523 | ;; | ||
1524 | *) | ||
1525 | niro | 943 | if [[ -n ${SPLIT_PACKAGES} ]] |
1526 | then | ||
1527 | niro | 964 | for subpackage in ${SPLIT_PACKAGES} |
1528 | niro | 943 | do |
1529 | niro | 1082 | echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1530 | niro | 943 | mstripbins ${BINDIR}_${subpackage} |
1531 | niro | 1082 | echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}" |
1532 | niro | 943 | mstriplibs ${BINDIR}_${subpackage} |
1533 | done | ||
1534 | else | ||
1535 | echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" | ||
1536 | mstripbins ${BINDIR} | ||
1537 | echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" | ||
1538 | mstriplibs ${BINDIR} | ||
1539 | fi | ||
1540 | niro | 79 | ;; |
1541 | esac | ||
1542 | |||
1543 | niro | 192 | # the new buildpkg command |
1544 | niro | 24 | case ${NOPKGBUILD} in |
1545 | true|TRUE|yes|y) | ||
1546 | echo -e "NOPGKBUILD=true detected; Package will not be build ..." | ||
1547 | ;; | ||
1548 | niro | 192 | *) |
1549 | niro | 306 | # build several targets |
1550 | niro | 943 | if [[ -n ${MAGE_TARGETS} ]] |
1551 | niro | 192 | then |
1552 | for target in ${MAGE_TARGETS} | ||
1553 | do | ||
1554 | # check if an special target_pkgbuild exists | ||
1555 | if typeset -f ${target}_pkgbuild > /dev/null | ||
1556 | then | ||
1557 | # run it | ||
1558 | ${target}_pkgbuild | ||
1559 | fi | ||
1560 | # now create the target package | ||
1561 | ${MLIBDIR}/pkgbuild_dir.sh \ | ||
1562 | niro | 255 | "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \ |
1563 | niro | 192 | ${BINDIR} || die "target: ${target} package-build failed" |
1564 | niro | 255 | |
1565 | # build pkg-md5-sum if requested | ||
1566 | generate_package_md5sum \ | ||
1567 | --pcat "${PCATEGORIE}" \ | ||
1568 | --pname "${PNAME}" \ | ||
1569 | --pver "${PVER}" \ | ||
1570 | --pbuild "${PBUILD}" \ | ||
1571 | --parch "${ARCH}" \ | ||
1572 | --target "${target}" | ||
1573 | |||
1574 | niro | 439 | echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1575 | niro | 192 | done |
1576 | niro | 943 | |
1577 | # build several subpackages | ||
1578 | elif [[ -n ${SPLIT_PACKAGES} ]] | ||
1579 | then | ||
1580 | split_save_variables | ||
1581 | for subpackage in ${SPLIT_PACKAGES} | ||
1582 | do | ||
1583 | # get the right variables for the split | ||
1584 | export PNAME="${subpackage}" | ||
1585 | split_info_${PNAME} | ||
1586 | |||
1587 | niro | 947 | # jump to next one if NOPKGBUILD is set in split_info |
1588 | case ${NOPKGBUILD} in | ||
1589 | true|TRUE|yes|y) continue ;; | ||
1590 | esac | ||
1591 | |||
1592 | niro | 943 | # check if an special subpackage_pkgbuild exists |
1593 | if typeset -f ${PNAME}_pkgbuild > /dev/null | ||
1594 | then | ||
1595 | # run it | ||
1596 | ${PNAME}_pkgbuild | ||
1597 | fi | ||
1598 | # now create the target package | ||
1599 | ${MLIBDIR}/pkgbuild_dir.sh \ | ||
1600 | "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ | ||
1601 | "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" | ||
1602 | |||
1603 | # build pkg-md5-sum if requested | ||
1604 | generate_package_md5sum \ | ||
1605 | --pcat "${PCATEGORIE}" \ | ||
1606 | --pname "${PNAME}" \ | ||
1607 | --pver "${PVER}" \ | ||
1608 | --pbuild "${PBUILD}" \ | ||
1609 | --parch "${ARCH}" | ||
1610 | |||
1611 | echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" | ||
1612 | niro | 951 | |
1613 | # restore smage environment | ||
1614 | split_restore_variables | ||
1615 | niro | 943 | done |
1616 | niro | 951 | # unset all saved smage variables |
1617 | split_unset_variables | ||
1618 | niro | 943 | |
1619 | niro | 192 | else |
1620 | ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" | ||
1621 | niro | 255 | |
1622 | # build pkg-md5-sum if requested | ||
1623 | generate_package_md5sum \ | ||
1624 | --pcat "${PCATEGORIE}" \ | ||
1625 | --pname "${PNAME}" \ | ||
1626 | --pver "${PVER}" \ | ||
1627 | --pbuild "${PBUILD}" \ | ||
1628 | --parch "${ARCH}" | ||
1629 | |||
1630 | niro | 439 | echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}" |
1631 | niro | 192 | fi |
1632 | niro | 403 | |
1633 | # build src-pkg-tarball if requested | ||
1634 | [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME} | ||
1635 | niro | 24 | ;; |
1636 | esac | ||
1637 | |||
1638 | niro | 875 | if [[ ${SMAGE_BUILD_LOGGING} != false ]] |
1639 | then | ||
1640 | bzip2 -9f /var/log/smage/${PKGNAME}.log | ||
1641 | else | ||
1642 | [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log | ||
1643 | fi | ||
1644 | |||
1645 | niro | 192 | # for sure |
1646 | niro | 24 | unset NOPKGBUILD |
1647 | niro | 85 | unset NOSTRIP |
1648 | niro | 351 | |
1649 | niro | 24 | xtitleclean |
Properties
Name | Value |
---|---|
svn:executable | * |