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