4 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
5 |
|
|
6 |
# SMAGE2 |
# SMAGE2 |
7 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.53 2007-03-19 19:09:59 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $ |
8 |
|
|
9 |
#01.10.2004 |
#01.10.2004 |
10 |
# added ccache support |
# added ccache support |
20 |
SMAGESUFFIX="smage2" |
SMAGESUFFIX="smage2" |
21 |
MLIBDIR=/usr/lib/mage |
MLIBDIR=/usr/lib/mage |
22 |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
23 |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
24 |
|
|
25 |
|
|
26 |
## only for tests -> normally in /etc/rc.d/init.d/functions |
## only for tests -> normally in /etc/rc.d/init.d/functions |
27 |
COLRED="\033[1;6m\033[31m" |
COLRED="\033[1;6m\033[31m" |
173 |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
174 |
fi |
fi |
175 |
|
|
176 |
|
# create the SOURCEDIR |
177 |
|
install -d ${my_SOURCEDIR} |
178 |
|
|
179 |
# if an mirrored file than replace first the mirror uri |
# if an mirrored file than replace first the mirror uri |
180 |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
181 |
then |
then |
191 |
--tries 3 \ |
--tries 3 \ |
192 |
--continue \ |
--continue \ |
193 |
--progress bar \ |
--progress bar \ |
194 |
--directory-prefix="${my_SOURCEDIR}" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
195 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
196 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
197 |
then |
then |
215 |
--tries 3 \ |
--tries 3 \ |
216 |
--continue \ |
--continue \ |
217 |
--progress bar \ |
--progress bar \ |
218 |
--directory-prefix="${my_SOURCEDIR}" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
219 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
220 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
221 |
then |
then |
239 |
--tries 3 \ |
--tries 3 \ |
240 |
--continue \ |
--continue \ |
241 |
--progress bar \ |
--progress bar \ |
242 |
--directory-prefix="${my_SOURCEDIR}" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
243 |
|
"${my_SRC_URI_MIRROR}" |
244 |
|
if [[ $? = 0 ]] |
245 |
|
then |
246 |
|
break |
247 |
|
else |
248 |
|
continue |
249 |
|
fi |
250 |
|
fi |
251 |
|
done |
252 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]] |
253 |
|
then |
254 |
|
for mirror in ${KDE_MIRRORS} |
255 |
|
do |
256 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")" |
257 |
|
|
258 |
|
if [[ ${FETCHING} = true ]] |
259 |
|
then |
260 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
261 |
|
wget \ |
262 |
|
--passive-ftp \ |
263 |
|
--tries 3 \ |
264 |
|
--continue \ |
265 |
|
--progress bar \ |
266 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
267 |
|
"${my_SRC_URI_MIRROR}" |
268 |
|
if [[ $? = 0 ]] |
269 |
|
then |
270 |
|
break |
271 |
|
else |
272 |
|
continue |
273 |
|
fi |
274 |
|
fi |
275 |
|
done |
276 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]] |
277 |
|
then |
278 |
|
for mirror in ${GNOME_MIRRORS} |
279 |
|
do |
280 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")" |
281 |
|
|
282 |
|
if [[ ${FETCHING} = true ]] |
283 |
|
then |
284 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
285 |
|
wget \ |
286 |
|
--passive-ftp \ |
287 |
|
--tries 3 \ |
288 |
|
--continue \ |
289 |
|
--progress bar \ |
290 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
291 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
292 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
293 |
then |
then |
306 |
--tries 3 \ |
--tries 3 \ |
307 |
--continue \ |
--continue \ |
308 |
--progress bar \ |
--progress bar \ |
309 |
--directory-prefix="${my_SOURCEDIR}" \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
310 |
"${my_SRC_URI}" |
"${my_SRC_URI}" |
311 |
fi |
fi |
312 |
fi |
fi |
367 |
./configure \ |
./configure \ |
368 |
--prefix=/usr \ |
--prefix=/usr \ |
369 |
--host=${CHOST} \ |
--host=${CHOST} \ |
370 |
|
--build=${CHOST} \ |
371 |
--mandir=/usr/share/man \ |
--mandir=/usr/share/man \ |
372 |
--infodir=/usr/share/info \ |
--infodir=/usr/share/info \ |
373 |
--datadir=/usr/share \ |
--datadir=/usr/share \ |
411 |
|
|
412 |
SRCFILE=$1 |
SRCFILE=$1 |
413 |
|
|
414 |
if [ -z "$2" ] |
if [[ -z $2 ]] |
415 |
then |
then |
416 |
DEST=${BUILDDIR} |
DEST=${BUILDDIR} |
417 |
else |
else |
426 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
427 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
428 |
then |
then |
429 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." |
430 |
|
else |
431 |
|
pushd ${DEST} > /dev/null |
432 |
|
bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." |
433 |
|
popd > /dev/null |
434 |
fi |
fi |
435 |
;; |
;; |
436 |
gz) |
gz) |
438 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
439 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
440 |
then |
then |
441 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." |
442 |
|
else |
443 |
|
pushd ${DEST} > /dev/null |
444 |
|
zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." |
445 |
|
popd > /dev/null |
446 |
fi |
fi |
447 |
;; |
;; |
448 |
tbz2) |
tbz2|mpks|mpk) |
449 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
450 |
;; |
;; |
451 |
tgz) |
tgz) |
452 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
453 |
|
;; |
454 |
|
rar) |
455 |
|
unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
456 |
|
;; |
457 |
|
zip|xpi) |
458 |
|
unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
459 |
|
;; |
460 |
|
rpm) |
461 |
|
pushd ${DEST} > /dev/null |
462 |
|
rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
463 |
|
tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
464 |
|
if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
465 |
|
then |
466 |
|
rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
467 |
|
fi |
468 |
;; |
;; |
469 |
*) |
*) |
470 |
die "munpack failed" |
die "munpack failed" |
476 |
{ |
{ |
477 |
local PATCHOPTS |
local PATCHOPTS |
478 |
local PATCHFILE |
local PATCHFILE |
479 |
|
local i |
480 |
|
|
481 |
PATCHOPTS=$1 |
PATCHOPTS=$1 |
482 |
PATCHFILE=$2 |
PATCHFILE=$2 |
483 |
|
|
484 |
|
if [[ -z $2 ]] |
485 |
|
then |
486 |
|
PATCHFILE=$1 |
487 |
|
|
488 |
|
## patch level auto-detection, get patch level |
489 |
|
for ((i=0; i < 10; i++)) |
490 |
|
do |
491 |
|
patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null |
492 |
|
if [[ $? = 0 ]] |
493 |
|
then |
494 |
|
PATCHOPTS="-Np${i}" |
495 |
|
break |
496 |
|
fi |
497 |
|
done |
498 |
|
fi |
499 |
|
|
500 |
echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
501 |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
502 |
} |
} |
503 |
|
|
504 |
|
mlibtoolize() |
505 |
|
{ |
506 |
|
local opts="$@" |
507 |
|
[[ -z ${opts} ]] && opts="--copy --force" |
508 |
|
|
509 |
|
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
510 |
|
} |
511 |
|
|
512 |
minstalldocs() |
minstalldocs() |
513 |
{ |
{ |
562 |
{ |
{ |
563 |
if [ -x /usr/bin/distcc ] |
if [ -x /usr/bin/distcc ] |
564 |
then |
then |
565 |
echo "Using DistCC for compilation ..." |
echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" |
566 |
export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
567 |
|
|
568 |
export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
577 |
{ |
{ |
578 |
if [ -x /usr/bin/ccache ] |
if [ -x /usr/bin/ccache ] |
579 |
then |
then |
580 |
echo "Using CCache for compilation ..." |
echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" |
581 |
export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
582 |
fi |
fi |
583 |
} |
} |
656 |
# special tags: |
# special tags: |
657 |
# PKGTYPE type of pkg |
# PKGTYPE type of pkg |
658 |
# INHERITS which functions get included |
# INHERITS which functions get included |
659 |
# SPECIAL_FUNCTIONS special functions wich should also be added |
# SPECIAL_FUNCTIONS special functions which should also be added |
660 |
# warning: they get killed before the build starts ! |
# warning: they get killed before the build starts ! |
661 |
# |
# |
662 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
692 |
> ${dest} |
> ${dest} |
693 |
|
|
694 |
# header |
# header |
695 |
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.53 2007-03-19 19:09:59 niro Exp $' >> ${dest} |
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest} |
696 |
echo >> ${dest} |
echo >> ${dest} |
697 |
|
|
698 |
# pgkname and state |
# pgkname and state |
800 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
801 |
# unset PKGNAME <-- don't do that; smage needs this var |
# unset PKGNAME <-- don't do that; smage needs this var |
802 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
803 |
for i in ${SPECIAL_FUNCTIONS} |
# for i in ${SPECIAL_FUNCTIONS} |
804 |
do |
# do |
805 |
unset "${i}" |
# unset "${i}" |
806 |
done |
# done |
807 |
unset SPECIAL_FUNCTIONS |
unset SPECIAL_FUNCTIONS |
808 |
for i in ${SPECIAL_VARS} |
# for i in ${SPECIAL_VARS} |
809 |
do |
# do |
810 |
unset "${i}" |
# unset "${i}" |
811 |
done |
# done |
812 |
unset SPECIAL_VARS |
unset SPECIAL_VARS |
813 |
unset STATE |
unset STATE |
814 |
unset DESCRIPTION |
unset DESCRIPTION |
885 |
# fix target as it may be empty ! |
# fix target as it may be empty ! |
886 |
[ -n "${target}" ] && target="-${target}" |
[ -n "${target}" ] && target="-${target}" |
887 |
|
|
888 |
|
|
889 |
# build pkgname |
# build pkgname |
890 |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
891 |
|
|
905 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
906 |
|
|
907 |
# setup md5 dir |
# setup md5 dir |
908 |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
909 |
install -d ${dest} |
install -d ${dest} |
910 |
|
|
911 |
# gen md5sum |
# gen md5sum |
943 |
echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" |
echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" |
944 |
} |
} |
945 |
|
|
946 |
|
step_by_step() |
947 |
|
{ |
948 |
|
if [[ ${STEP_BY_STEP} = true ]] |
949 |
|
then |
950 |
|
echo "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
951 |
|
echo "Press [enter] to continue" |
952 |
|
read |
953 |
|
fi |
954 |
|
} |
955 |
|
|
956 |
|
|
957 |
# print out our version |
# print out our version |
958 |
showversion |
showversion |
1073 |
|
|
1074 |
regen_mage_tree |
regen_mage_tree |
1075 |
|
|
1076 |
# build md5sum for existing packages |
# build several targets |
1077 |
generate_package_md5sum \ |
if [ -n "${MAGE_TARGETS}" ] |
1078 |
--pcat "${PCATEGORIE}" \ |
then |
1079 |
--pname "${PNAME}" \ |
for target in ${MAGE_TARGETS} |
1080 |
--pver "${PVER}" \ |
do |
1081 |
--pbuild "${PBUILD}" \ |
# build md5sum for existing packages |
1082 |
--parch "${ARCH}" \ |
generate_package_md5sum \ |
1083 |
--target "${target}" |
--pcat "${PCATEGORIE}" \ |
1084 |
|
--pname "${PNAME}" \ |
1085 |
|
--pver "${PVER}" \ |
1086 |
|
--pbuild "${PBUILD}" \ |
1087 |
|
--parch "${ARCH}" \ |
1088 |
|
--target "${target}" |
1089 |
|
done |
1090 |
|
else |
1091 |
|
# build md5sum for existing packages |
1092 |
|
generate_package_md5sum \ |
1093 |
|
--pcat "${PCATEGORIE}" \ |
1094 |
|
--pname "${PNAME}" \ |
1095 |
|
--pver "${PVER}" \ |
1096 |
|
--pbuild "${PBUILD}" \ |
1097 |
|
--parch "${ARCH}" \ |
1098 |
|
--target "${target}" |
1099 |
|
fi |
1100 |
|
|
1101 |
exit 0 |
exit 0 |
1102 |
fi |
fi |
1172 |
then |
then |
1173 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1174 |
then |
then |
1175 |
echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
1176 |
rm -rf ${SOURCEDIR}/${PNAME} |
rm -rf ${SOURCEDIR}/${PNAME} |
1177 |
fi |
fi |
1178 |
fi |
fi |
1235 |
mage rmstamp |
mage rmstamp |
1236 |
fi |
fi |
1237 |
|
|
1238 |
src_prepare || die "src_prepare failed" |
# setup build loggins |
1239 |
src_compile || die "src_compile failed" |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1240 |
src_install || die "src_install failed" |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1241 |
|
|
1242 |
|
src_prepare || die "src_prepare failed" | ${SMAGE_LOG_CMD} |
1243 |
|
step_by_step $_ |
1244 |
|
src_compile || die "src_compile failed" | ${SMAGE_LOG_CMD} |
1245 |
|
step_by_step $_ |
1246 |
|
src_install || die "src_install failed" | ${SMAGE_LOG_CMD} |
1247 |
|
step_by_step $_ |
1248 |
|
|
1249 |
|
|
1250 |
# compressing doc, info & man files |
# compressing doc, info & man files |
1325 |
;; |
;; |
1326 |
esac |
esac |
1327 |
|
|
1328 |
|
if [[ ${SMAGE_BUILD_LOGGING} != false ]] |
1329 |
|
then |
1330 |
|
bzip2 -9f /var/log/smage/${PKGNAME}.log |
1331 |
|
else |
1332 |
|
[[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log |
1333 |
|
fi |
1334 |
|
|
1335 |
# for sure |
# for sure |
1336 |
unset NOPKGBUILD |
unset NOPKGBUILD |
1337 |
unset NOSTRIP |
unset NOSTRIP |