1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage-buildroot/mage-buildroot.sh,v 1.2 2006-01-26 19:58:06 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage-buildroot/mage-buildroot.sh,v 1.4 2008-04-23 16:07:00 niro Exp $ |
3 |
# |
# |
4 |
# mage buildroot |
# mage buildroot |
5 |
# creates a buildroot to compile programms |
# creates a buildroot to compile programms |
11 |
# default die function |
# default die function |
12 |
die() |
die() |
13 |
{ |
{ |
14 |
|
echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT} |
15 |
echo -e ${COLRED}"$@"${COLDEFAULT} |
echo -e ${COLRED}"$@"${COLDEFAULT} |
16 |
exit 1 |
exit 1 |
17 |
} |
} |
18 |
|
|
|
[[ $(id -u ) != 0 ]] && die "you must be root" |
|
|
|
|
|
# i need some settings and functions from mage |
|
|
[ -f /etc/rc.d/init.d/functions ] && \ |
|
|
source /etc/rc.d/init.d/functions || \ |
|
|
die "Your /etc/mage.rc is missing. Aborting." |
|
|
|
|
|
[ -f /etc/mage.rc.global ] && \ |
|
|
source /etc/mage.rc.global || \ |
|
|
die "/etc/mage.rc.global missing" |
|
|
|
|
|
[ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
|
|
die "Your /etc/mage.rc is missing. Aborting." |
|
|
|
|
|
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
|
|
source ${MLIBDIR}/mage4.functions.sh || \ |
|
|
die "mage functions missing" |
|
|
|
|
19 |
installrc() |
installrc() |
20 |
{ |
{ |
21 |
local var="$1" |
local var="$1" |
32 |
[ ! -d ${MROOT}/sys ] && install -d ${MROOT}/sys |
[ ! -d ${MROOT}/sys ] && install -d ${MROOT}/sys |
33 |
|
|
34 |
mount -t proc proc ${MROOT}/proc |
mount -t proc proc ${MROOT}/proc |
35 |
mount -t sysfs sysfs ${MROOT}/sys |
mount -t sysfs sysfs ${MROOT}/sys |
36 |
mount -o bind /dev ${MROOT}/dev |
mount -o bind /dev ${MROOT}/dev |
37 |
|
|
38 |
# chroot ${MROOT} /bin/bash -i /.installrc |
if [[ ${SMAGE_USE_CCACHE} = true ]] || [[ -f ${MROOT}/.ccache_enabled ]] |
39 |
chroot ${MROOT} /usr/bin/env -i \ |
then |
40 |
HOME=/root \ |
[ ! -d ${MROOT}/root/.ccache ] && install -d ${MROOT}/root/.ccache |
41 |
TERM="${TERM}" \ |
mount -o bind /root/.ccache ${MROOT}/root/.ccache |
42 |
PS1='\u:\w\$ ' \ |
fi |
43 |
|
|
44 |
|
chroot ${MROOT} /usr/bin/env -i \ |
45 |
|
HOME=/root \ |
46 |
|
TERM="${TERM}" \ |
47 |
|
PS1='\u:\w\$ ' \ |
48 |
PATH=/bin:/usr/bin:/sbin:/usr/sbin \ |
PATH=/bin:/usr/bin:/sbin:/usr/sbin \ |
49 |
/bin/bash -i /.installrc #|| die "chr00ting" |
/bin/bash /.installrc #|| die "chr00ting" |
50 |
|
|
51 |
umount ${MROOT}/dev |
umount ${MROOT}/dev |
52 |
umount ${MROOT}/proc |
umount ${MROOT}/proc |
53 |
umount ${MROOT}/sys |
umount ${MROOT}/sys |
54 |
|
|
55 |
#[ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc |
[ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc |
56 |
} |
} |
57 |
|
|
58 |
# some sane defaults |
# some sane defaults |
59 |
MROOT="$1" |
MROOT="$1" |
60 |
TARGET_PKG="$2" |
TARGET_PKG="$2" |
61 |
#MAGERC="/etc/mage.rc" |
MAGERC="/etc/mage.rc" |
62 |
MAGERC="/home/tjoke/mage.rc-buildroot" |
#MAGERC="/home/tjoke/mage.rc-buildroot" |
63 |
MAGE_PROFILE="$(basename $(readlink /etc/mage-profile))" |
MAGE_PROFILE="$(basename $(readlink /etc/mage-profile))" |
64 |
TOOLCHAIN=toolchain |
TOOLCHAIN=toolchain |
65 |
BASESYSTEM=common-devutils |
BASESYSTEM=common-devutils |
66 |
|
|
67 |
|
[[ $(id -u ) != 0 ]] && die "you must be root" |
68 |
|
|
69 |
|
# i need some settings and functions from mage |
70 |
|
[ -f /etc/rc.d/init.d/functions ] && \ |
71 |
|
source /etc/rc.d/init.d/functions || \ |
72 |
|
die "Your /etc/mage.rc is missing. Aborting." |
73 |
|
|
74 |
|
[ -f /etc/mage.rc.global ] && \ |
75 |
|
source /etc/mage.rc.global || \ |
76 |
|
die "/etc/mage.rc.global missing" |
77 |
|
|
78 |
|
[ -f ${MAGERC} ] && source ${MAGERC} || \ |
79 |
|
die "Your /etc/mage.rc is missing. Aborting." |
80 |
|
|
81 |
|
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
82 |
|
source ${MLIBDIR}/mage4.functions.sh || \ |
83 |
|
die "mage functions missing" |
84 |
|
|
85 |
|
# sanity checks |
86 |
|
[[ -z ${MROOT} ]] && die "\$MROOT not given." |
87 |
|
[[ -z ${TARGET_PKG} ]] && die "\$TARGET_PKG not given." |
88 |
|
|
89 |
# first install a toolchain and some common dev-utils using bootstrap2 |
# first install a toolchain and some common dev-utils using bootstrap2 |
90 |
# only if not already builded |
# only if not already builded |
91 |
if [ ! -f ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} ] |
if [ ! -f ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} ] |
92 |
then |
then |
93 |
#mage-bootstrap \ |
mage-bootstrap \ |
|
/home/tjoke/alx-cvs/magellan-src/bootstrap/scripts/mage-bootstrap.sh \ |
|
94 |
--root "${MROOT}" \ |
--root "${MROOT}" \ |
95 |
--magerc "${MAGERC}" \ |
--magerc "${MAGERC}" \ |
96 |
--profile "${MAGE_PROFILE}" \ |
--profile "${MAGE_PROFILE}" \ |
100 |
|
|
101 |
# mark this as builded |
# mark this as builded |
102 |
touch ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} || die "touch ok" |
touch ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} || die "touch ok" |
103 |
|
|
104 |
|
# enable ccache |
105 |
|
[[ ${SMAGE_USE_CCACHE} = true ]] && touch ${MROOT}/.ccache_enabled |
106 |
fi |
fi |
107 |
|
|
108 |
##################################################### |
##################################################### |
109 |
# setup a chroot environment # |
# setup a chroot environment # |
110 |
##################################################### |
##################################################### |
111 |
echo > ${MROOT}/.installrc || die |
:> ${MROOT}/.installrc || die |
112 |
|
|
113 |
# some needed env-vars and functions |
# some needed env-vars and functions |
114 |
installrc 'unset MROOT' |
installrc 'unset MROOT' |
115 |
installrc 'env-rebuild' |
installrc 'env-rebuild' |
116 |
installrc 'source /etc/profile' |
installrc 'source /etc/profile' |
117 |
installrc 'die() { echo -e ${COLRED}"$@"${COLDEFAULT}; exit 1; }' |
installrc 'die() { echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT};echo -e ${COLRED}"$@"${COLDEFAULT}; exit 1; }' |
118 |
installrc '[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions' # || die "Your /etc/mage.rc is missing. Aborting."' |
installrc '[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions' # || die "Your /etc/mage.rc is missing. Aborting."' |
119 |
installrc '[ -f /etc/mage.rc.global ] && . /etc/mage.rc.global' # || die "/etc/mage.rc.global missing"' |
installrc '[ -f /etc/mage.rc.global ] && . /etc/mage.rc.global' # || die "/etc/mage.rc.global missing"' |
120 |
installrc '[ -f /etc/mage.rc ] && . /etc/mage.rc' # || die "Your /etc/mage.rc is missing. Aborting."' |
installrc '[ -f /etc/mage.rc ] && . /etc/mage.rc' # || die "Your /etc/mage.rc is missing. Aborting."' |
160 |
fi |
fi |
161 |
|
|
162 |
# get all dependencies of this package |
# get all dependencies of this package |
163 |
|
echo |
164 |
|
echo -n "Calculating dependencies ... " |
165 |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
ALLDEPS="$(${MLIBDIR}/depwalker.sh \ |
166 |
--method srcinstall \ |
--method srcinstall \ |
167 |
--pcat ${PCAT} \ |
--pcat ${PCAT} \ |
168 |
--pname ${PNAME} \ |
--pname ${PNAME} \ |
169 |
--pver ${PVER} \ |
--pver ${PVER} \ |
170 |
--pbuild ${PBUILD})" |
--pbuild ${PBUILD})" |
171 |
|
echo "done" |
172 |
|
|
173 |
# remove TARGET_PKG from list |
# remove TARGET_PKG from list |
174 |
SRC_INSTALL_DEPS="$(get_highest_magefile ${PCAT} ${TARGET_PKG})" |
SRC_INSTALL_DEPS="$(get_highest_magefile ${PCAT} ${TARGET_PKG})" |
183 |
echo "----------------------" |
echo "----------------------" |
184 |
echo |
echo |
185 |
echo "---- dependencies ----" |
echo "---- dependencies ----" |
186 |
echo "SRC_INSTALL_DEPS: ${SRC_INSTALL_DEPS}" |
echo "SRC_INSTALL_DEPS:" |
187 |
echo "INSTALL_DEPS: ${INSTALL_DEPS}" |
for i in ${SRC_INSTALL_DEPS} |
188 |
|
do |
189 |
|
echo " * ${i}" |
190 |
|
done |
191 |
|
echo "INSTALL_DEPS:" |
192 |
|
for i in ${INSTALL_DEPS} |
193 |
|
do |
194 |
|
echo " * ${i}" |
195 |
|
done |
196 |
echo "----------------------" |
echo "----------------------" |
197 |
|
|
198 |
#read |
#read |
210 |
install_packages --src-install ${SRC_INSTALL_DEPS} || die "src-installing packages" |
install_packages --src-install ${SRC_INSTALL_DEPS} || die "src-installing packages" |
211 |
|
|
212 |
# done |
# done |
213 |
|
[[ ! -d /BUILDED ]] && install -d /BUILDED |
214 |
|
mv ${PKGDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.mpk /BUILDED || die "pkg move" |
215 |
echo -e "Package ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT} successfully builded." |
echo -e "Package ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT} successfully builded." |
216 |
echo "You will find this in ${FAKE_MROOT}/${PKGDIR}." |
echo "You will find this in ${FAKE_MROOT}/BUILDED." |
217 |
EOF |
EOF |
218 |
|
|
219 |
# run this stuff |
# run this stuff |