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