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