Annotation of /trunk/mage-buildroot/mage-buildroot.sh
Parent Directory | Revision Log
Revision 322 -
(hide annotations)
(download)
(as text)
Thu Jan 26 19:58:06 2006 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 5857 byte(s)
Thu Jan 26 19:58:06 2006 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 5857 byte(s)
- typos and info header
1 | niro | 309 | #!/bin/bash |
2 | niro | 322 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage-buildroot/mage-buildroot.sh,v 1.2 2006-01-26 19:58:06 niro Exp $ |
3 | niro | 309 | # |
4 | # mage buildroot | ||
5 | niro | 322 | # creates a buildroot to compile programms |
6 | niro | 309 | # may get later into mage |
7 | # | ||
8 | niro | 322 | # Niels Rogalla <niro@magellan-linux.de> |
9 | # | ||
10 | niro | 309 | |
11 | # default die function | ||
12 | die() | ||
13 | { | ||
14 | echo -e ${COLRED}"$@"${COLDEFAULT} | ||
15 | exit 1 | ||
16 | } | ||
17 | |||
18 | [[ $(id -u ) != 0 ]] && die "you must be root" | ||
19 | |||
20 | # i need some settings and functions from mage | ||
21 | [ -f /etc/rc.d/init.d/functions ] && \ | ||
22 | source /etc/rc.d/init.d/functions || \ | ||
23 | die "Your /etc/mage.rc is missing. Aborting." | ||
24 | |||
25 | [ -f /etc/mage.rc.global ] && \ | ||
26 | source /etc/mage.rc.global || \ | ||
27 | die "/etc/mage.rc.global missing" | ||
28 | |||
29 | [ -f /etc/mage.rc ] && source /etc/mage.rc || \ | ||
30 | die "Your /etc/mage.rc is missing. Aborting." | ||
31 | |||
32 | [ -f ${MLIBDIR}/mage4.functions.sh ] && \ | ||
33 | source ${MLIBDIR}/mage4.functions.sh || \ | ||
34 | die "mage functions missing" | ||
35 | |||
36 | installrc() | ||
37 | { | ||
38 | local var="$1" | ||
39 | |||
40 | # sanity checks | ||
41 | [ -z "${MROOT}" ] && die "\$MROOT not given." | ||
42 | echo "${var}" >> ${MROOT}/.installrc || die "add_initrc() adding \$var" | ||
43 | } | ||
44 | |||
45 | enter_chroot() | ||
46 | { | ||
47 | [ ! -d ${MROOT}/proc ] && install -d ${MROOT}/proc | ||
48 | [ ! -d ${MROOT}/dev ] && install -d ${MROOT}/dev | ||
49 | [ ! -d ${MROOT}/sys ] && install -d ${MROOT}/sys | ||
50 | |||
51 | mount -t proc proc ${MROOT}/proc | ||
52 | mount -t sysfs sysfs ${MROOT}/sys | ||
53 | mount -o bind /dev ${MROOT}/dev | ||
54 | |||
55 | # chroot ${MROOT} /bin/bash -i /.installrc | ||
56 | chroot ${MROOT} /usr/bin/env -i \ | ||
57 | HOME=/root \ | ||
58 | TERM="${TERM}" \ | ||
59 | PS1='\u:\w\$ ' \ | ||
60 | PATH=/bin:/usr/bin:/sbin:/usr/sbin \ | ||
61 | /bin/bash -i /.installrc #|| die "chr00ting" | ||
62 | |||
63 | umount ${MROOT}/dev | ||
64 | umount ${MROOT}/proc | ||
65 | umount ${MROOT}/sys | ||
66 | |||
67 | #[ -f ${MROOT}/.installrc ] && rm ${MROOT}/.installrc | ||
68 | } | ||
69 | |||
70 | # some sane defaults | ||
71 | MROOT="$1" | ||
72 | TARGET_PKG="$2" | ||
73 | #MAGERC="/etc/mage.rc" | ||
74 | MAGERC="/home/tjoke/mage.rc-buildroot" | ||
75 | MAGE_PROFILE="$(basename $(readlink /etc/mage-profile))" | ||
76 | TOOLCHAIN=toolchain | ||
77 | BASESYSTEM=common-devutils | ||
78 | |||
79 | # first install a toolchain and some common dev-utils using bootstrap2 | ||
80 | # only if not already builded | ||
81 | if [ ! -f ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} ] | ||
82 | then | ||
83 | #mage-bootstrap \ | ||
84 | /home/tjoke/alx-cvs/magellan-src/bootstrap/scripts/mage-bootstrap.sh \ | ||
85 | --root "${MROOT}" \ | ||
86 | --magerc "${MAGERC}" \ | ||
87 | --profile "${MAGE_PROFILE}" \ | ||
88 | --toolchain "${TOOLCHAIN}" \ | ||
89 | --basesystem "${BASESYSTEM}" \ | ||
90 | || die "bootstrapping toolchain" | ||
91 | |||
92 | # mark this as builded | ||
93 | touch ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} || die "touch ok" | ||
94 | fi | ||
95 | |||
96 | ##################################################### | ||
97 | # setup a chroot environment # | ||
98 | ##################################################### | ||
99 | echo > ${MROOT}/.installrc || die | ||
100 | |||
101 | # some needed env-vars and functions | ||
102 | installrc 'unset MROOT' | ||
103 | installrc 'env-rebuild' | ||
104 | installrc 'source /etc/profile' | ||
105 | installrc 'die() { echo -e ${COLRED}"$@"${COLDEFAULT}; exit 1; }' | ||
106 | installrc '[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions' # || die "Your /etc/mage.rc is missing. Aborting."' | ||
107 | installrc '[ -f /etc/mage.rc.global ] && . /etc/mage.rc.global' # || die "/etc/mage.rc.global missing"' | ||
108 | installrc '[ -f /etc/mage.rc ] && . /etc/mage.rc' # || die "Your /etc/mage.rc is missing. Aborting."' | ||
109 | installrc '[ -f ${MLIBDIR}/mage4.functions.sh ] && . ${MLIBDIR}/mage4.functions.sh' # || die "mage functions missing"' | ||
110 | installrc "export FAKE_MROOT=\"${MROOT}\"" | ||
111 | installrc "export TARGET_PKG=\"${TARGET_PKG}\"" | ||
112 | |||
113 | # update mage only if buildroot already exists | ||
114 | [ -f ${MROOT}/.buildroot_build_ok-${TOOLCHAIN}-${BASESYSTEM} ] && installrc 'mage update' | ||
115 | installrc 'smage2 update' | ||
116 | |||
117 | # run part | ||
118 | cat >> ${MROOT}/.installrc << "EOF" | ||
119 | |||
120 | ##################################################### | ||
121 | # now calculate the src-dependencies for TARGET_PKG # | ||
122 | ##################################################### | ||
123 | |||
124 | # before anything run mage_setup | ||
125 | mage_setup || die "error in mage_setup()" | ||
126 | |||
127 | # first of all get the right pkg which going to be installed | ||
128 | PCAT="$(pname2pcat ${TARGET_PKG})" | ||
129 | |||
130 | # package does not exists | ||
131 | [ -z "${PCAT}" ] && die "Package '${TARGET_PKG}' does not exist." | ||
132 | |||
133 | # source the highest magefile of this pkg | ||
134 | PKGNAME=$(get_value_from_magefile PKGNAME $(get_highest_magefile ${PCAT} ${TARGET_PKG})) | ||
135 | |||
136 | # convert PKGNAME to PNAME/PVER/PBUILD | ||
137 | # we're working *only* with these three vars from here on | ||
138 | PNAME="$(pkgname2pname ${PKGNAME})" | ||
139 | PVER="$(pkgname2pver ${PKGNAME})" | ||
140 | PBUILD="$(pkgname2pbuild ${PKGNAME})" | ||
141 | |||
142 | if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD} | ||
143 | then | ||
144 | echo -en "Package " | ||
145 | echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" | ||
146 | echo -e " already installed." | ||
147 | exit 3 | ||
148 | fi | ||
149 | |||
150 | # get all dependencies of this package | ||
151 | ALLDEPS="$(${MLIBDIR}/depwalker.sh \ | ||
152 | --method srcinstall \ | ||
153 | --pcat ${PCAT} \ | ||
154 | --pname ${PNAME} \ | ||
155 | --pver ${PVER} \ | ||
156 | --pbuild ${PBUILD})" | ||
157 | |||
158 | # remove TARGET_PKG from list | ||
159 | SRC_INSTALL_DEPS="$(get_highest_magefile ${PCAT} ${TARGET_PKG})" | ||
160 | INSTALL_DEPS="${ALLDEPS/${SRC_INSTALL_DEPS}/}" | ||
161 | |||
162 | echo | ||
163 | echo "---- environment -----" | ||
164 | echo "MROOT: ${FAKE_MROOT}" | ||
165 | echo "PKGDIR: ${PKGDIR}" | ||
166 | echo "BUILDDIR: ${BUILDDIR}" | ||
167 | echo "BINDIR: ${BINDIR}" | ||
168 | echo "----------------------" | ||
169 | echo | ||
170 | echo "---- dependencies ----" | ||
171 | echo "SRC_INSTALL_DEPS: ${SRC_INSTALL_DEPS}" | ||
172 | echo "INSTALL_DEPS: ${INSTALL_DEPS}" | ||
173 | echo "----------------------" | ||
174 | |||
175 | #read | ||
176 | |||
177 | # now install the packages (no srcinstall, when the user not explcitly want this) | ||
178 | fetch_packages ${INSTALL_DEPS} || die "fetching packages" | ||
179 | md5sum_packages ${INSTALL_DEPS} || die "md5 sum packages" | ||
180 | unpack_packages ${INSTALL_DEPS} || die "unpacking packages" | ||
181 | install_packages ${INSTALL_DEPS} || die "installing packages" | ||
182 | |||
183 | # whipe out all packages | ||
184 | mage clean | ||
185 | |||
186 | # now src-install TARGET_PKG | ||
187 | install_packages --src-install ${SRC_INSTALL_DEPS} || die "src-installing packages" | ||
188 | |||
189 | # done | ||
190 | echo -e "Package ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT} successfully builded." | ||
191 | echo "You will find this in ${FAKE_MROOT}/${PKGDIR}." | ||
192 | EOF | ||
193 | |||
194 | # run this stuff | ||
195 | enter_chroot |
Properties
Name | Value |
---|---|
svn:executable | * |