/[gentoo-alt]/trunk/prefix/scripts/bootstrap-prefix.sh
Gentoo

Contents of /trunk/prefix/scripts/bootstrap-prefix.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1219 - (show annotations) (download) (as text)
Sun Apr 2 13:38:15 2006 UTC (8 years, 7 months ago) by grobian
File MIME type: text/x-sh
File size: 9509 byte(s)
Explain *why* we fail if there is no such function the user requested


1 #! /usr/bin/env bash
2
3 trap 'exit 1' TERM KILL INT QUIT ABRT
4
5 # Source functions to have colors and nice output
6
7 if [ -e /etc/init.d/functions.sh ] ; then
8 source /etc/init.d/functions.sh
9
10 # Use our own custom script, else logger cause things to
11 # 'freeze' if we do not have a system logger running
12 esyslog() {
13 echo &> /dev/null
14 }
15 else
16 eerror() { echo "!!! $*"; }
17 einfo() { echo "* $*"; }
18 fi
19
20 ## Functions Start Here
21
22 make_tree() {
23 for x in etc usr/{,s}bin var/tmp usr/portage/distfiles var/lib/portage var/log/portage; do
24 [ -d "${ROOT}/${x}" ] || mkdir -p "${ROOT}/${x}"
25 done
26 fetch ${GENTOO_URL}/experimental/snapshots/portage-alt-prefix-latest.tar.bz2
27 if [ ! -e ${ROOT}/usr/portage-alt-prefix/.unpacked ]; then
28 cd ${ROOT}/usr
29 tar -jxf ${DISTDIR}/portage-alt-prefix-latest.tar.bz2
30 touch portage-alt-prefix/.unpacked
31 fi
32 }
33
34 econf() {
35 ./configure \
36 --prefix=${ROOT}/usr \
37 --host=${CHOST} \
38 --mandir=${ROOT}/usr/share/man \
39 --infodir=${ROOT}/usr/share/info \
40 --datadir=${ROOT}/usr/share \
41 --sysconfdir=${ROOT}/etc \
42 --localstatedir=${ROOT}/var/lib \
43 "$@" || exit 1
44 }
45
46 fetch() {
47 if [ ! -e "${DISTDIR}"/${1##*/} ] ; then
48 einfo "Fetching ${1##*/}"
49 cd "${DISTDIR}"
50 ${FETCH_COMMAND} "$1"
51 fi
52 }
53
54 # template
55 # bootstrap_() {
56 # PV=
57 # A=
58 # einfo "Bootstrapping ${A%-*}"
59
60 # fetch ${A}
61
62 # einfo "Unpacking ${A%-*}"
63 # export S="${PORTAGE_TMPDIR}/${PN}"
64 # rm -rf ${S}
65 # mkdir -p ${S}
66 # cd ${S}
67 # tar -zxf ${DISTDIR}/${A} || exit 1
68 # S=${S}/${PN}-${PV}
69 # cd ${S}
70
71 # einfo "Compiling ${A%-*}"
72 # econf
73 # make || exit 1
74
75 # einfo "Installing ${A%-*}"
76 # make install || exit 1
77
78 # einfo "${A%-*} succesfully bootstrapped"
79 # }
80
81 bootstrap_portage() {
82 PV=latest
83 A=portage-prefix-${PV}.tar.bz2
84 einfo "Bootstrapping ${A%-*}"
85
86 fetch ${PORTAGE_URL}/${A}
87
88 einfo "Unpacking ${A%-*}"
89 export S="${PORTAGE_TMPDIR}"/portage-${PV}
90 rm -rf "${S}" >& /dev/null
91 mkdir -p "${S}" >& /dev/null
92 cd "${S}"
93 tar -jxf "${DISTDIR}/${A}" || exit 1
94 mv "${S}"/portage-prefix* "${S}"/portage-prefix
95 S="${S}/portage-prefix"
96 cd "${S}"
97
98 einfo "Compiling ${A%-*}"
99 econf \
100 --with-offset-prefix="${ROOT}" \
101 --with-user=`id -un` \
102 --with-group=`id -gn` \
103 --with-wheelgid=`id -g` \
104 --with-rootuser=`id -un`
105 make || exit 1
106
107 einfo "Installing ${A%-*}"
108 make install || exit 1
109
110 einfo "setting up some guessed defaults"
111
112 local profile=""
113 local keywords=""
114 case ${CHOST} in
115 powerpc-*-darwin8)
116 profile="${PORTDIR}/profiles/default-darwin/macos/10.4/ppc"
117 keywords="~ppc-macos ppc-macos"
118 ;;
119 i*86-*-darwin8)
120 profile="${PORTDIR}/profiles/default-darwin/macos/10.4/x86"
121 keywords="~x86-macos x86-macos"
122 ;;
123 i*86-pc-linux-gnu)
124 profile="${PORTDIR}/profiles/default-linux/x86/2005.1"
125 keywords="~x86 x86"
126 ;;
127 x64_86-pc-linux-gnu)
128 profile="${PORTDIR}/profiles/default-linux/amd64/2005.1/no-multilib"
129 einfo "Your profile is set to ${profile}."
130 einfo "This is a no-multilib profile. Please adjust if you want multilib."
131 keywords="~amd64 amd64"
132 ;;
133 *)
134 einfo "You need to set up a make.profile symlink to a profile in ${PORTDIR}"
135 ;;
136 esac
137 if [ ! -z "${profile}" -a ! -e "${ROOT}"/etc/make.profile ];
138 then
139 ln -s "${profile}" "${ROOT}"/etc/make.profile
140 fi
141 local add_make_conf=0
142 if [ ! -z "${keywords}" -a ! -e "${ROOT}"/etc/make.conf ];
143 then
144 add_make_conf=1
145 echo "ACCEPT_KEYWORDS=\"${keywords}\"" >> "${ROOT}"/etc/make.conf
146 fi
147
148 # portage defaults to wget, but if we don't have it in the prefix
149 # (most probably, because it's empty) we need to make sure portage
150 # can find it.
151 if [ x$(type -t wget) == "xfile" -a ! -x "${ROOT}"/usr/bin/wget ];
152 then
153 # symlink wget to the prefix, an emerge wget will overwrite it
154 ln -s "`which wget`" "${ROOT}"/usr/bin/wget
155 elif [ x$(type -t curl) == "xfile" -a ! -x "${ROOT}"/usr/bin/curl ];
156 then
157 if [ ${add_make_conf} != 1 ];
158 then
159 while read line; do echo "${line}" >> ${ROOT}/etc/make.conf; done <<EOF
160 FETCHCOMMAND="${ROOT}/usr/bin/curl --connect-timeout 15 -# -f -o \${DISTDIR}/\${FILE} \${URI}"
161 RESUMECOMMAND="${ROOT}/usr/bin/curl --connect-timeout 15 -# -f -C - -o \${DISTDIR}/\${FILE} \${URI}"
162 EOF
163 fi
164 ln -s "`which curl`" "${ROOT}"/usr/bin/curl
165 fi
166
167 einfo "${A%-*} succesfully bootstrapped"
168 }
169
170 bootstrap_odcctools() {
171 PV=20060123
172 A=odcctools-${PV}.tar.bz2
173
174 fetch http://www.opendarwin.org/downloads/${A}
175
176 export S="${PORTAGE_TMPDIR}/odcctools-${PV}"
177 rm -rf ${S}
178 mkdir -p ${S}
179 cd ${S}
180 tar -jxf ${DISTDIR}/${A} || exit 1
181
182 rm -rf ${S}/build
183 mkdir -p ${S}/build
184 cd ${S}/build
185
186 ${S}/odcctools-${PV}/configure \
187 --prefix=${ROOT}/usr \
188 --mandir=${ROOT}/usr/share/man \
189 || exit 1
190 make || exit 1
191
192 make install || exit 1
193 }
194
195 prep_gcc-apple() {
196
197 GCC_PV=5247
198 GCC_A="gcc-${GCC_PV}.tar.gz"
199 TAROPTS="-zxf"
200
201 fetch ${GCC_APPLE_URL}/${GCC_A}
202
203 }
204
205 prep_gcc-fsf() {
206
207 GCC_PV=4.1.0
208 GCC_A=gcc-${GCC_PV}.tar.bz2
209 TAROPTS="-jxf"
210
211 fetch ${GNU_URL}/gcc/gcc-${GCC_PV}/${GCC_A}
212
213 }
214
215 bootstrap_gcc() {
216
217 case ${CHOST} in
218 *-*-darwin*)
219 prep_gcc-apple
220 ;;
221 *)
222 prep_gcc-fsf
223 ;;
224 esac
225
226 GCC_LANG="c,c++"
227
228 export S="${PORTAGE_TMPDIR}/gcc-${GCC_PV}"
229 rm -rf ${S}
230 mkdir -p ${S}
231 cd ${S}
232 tar ${TAROPTS} ${DISTDIR}/${GCC_A} || exit 1
233
234 rm -rf ${S}/build
235 mkdir -p ${S}/build
236 cd ${S}/build
237
238 gcc_config_opts="--prefix=${ROOT}/usr \
239 --host=${CHOST} \
240 --mandir=${ROOT}/usr/share/man \
241 --infodir=${ROOT}/usr/share/info \
242 --datadir=${ROOT}/usr/share \
243 --disable-checking \
244 --disable-werror \
245 --disable-nls \
246 --with-system-zlib \
247 --enable-languages=${GCC_LANG}"
248
249
250 ${S}/gcc-${GCC_PV}/configure \
251 ${gcc_config_opts} \
252 || exit 1
253 make ${MAKEOPTS} bootstrap-lean || exit 1
254
255 make install || exit 1
256 }
257
258 bootstrap_gnu() {
259 local PN PV A S
260 PN=$1
261 PV=$2
262 A=${PN}-${PV}.tar.gz
263 einfo "Bootstrapping ${A%-*}"
264
265 fetch ${GNU_URL}/${PN}/${A}
266
267 einfo "Unpacking ${A%-*}"
268 S="${PORTAGE_TMPDIR}/${PN}-${PV}"
269 rm -rf ${S}
270 mkdir -p ${S}
271 cd ${S}
272 tar -zxf ${DISTDIR}/${A} || exit 1
273 S=${S}/${PN}-${PV}
274 cd ${S}
275
276 einfo "Compiling ${A%-*}"
277 econf \
278 --disable-nls
279 make || exit 1
280
281 einfo "Installing ${A%-*}"
282 make install || exit 1
283
284 einfo "${A%-*} succesfully bootstrapped"
285 }
286
287 bootstrap_python() {
288 PV=2.4.2
289 A=Python-${PV}.tar.bz2
290 einfo "Bootstrapping ${A%-*}"
291
292 fetch http://www.python.org/ftp/python/${PV%_*}/${A}
293
294 einfo "Unpacking ${A%-*}"
295 export S="${PORTAGE_TMPDIR}/python-${PV}"
296 rm -rf ${S}
297 mkdir -p ${S}
298 cd ${S}
299 tar -jxf ${DISTDIR}/${A} || exit 1
300 S=${S}/Python-${PV}
301 cd ${S}
302
303 export PYTHON_DISABLE_MODULES="readline pyexpat dbm gdbm bsddb _curses _curses_panel _tkinter"
304 export PYTHON_DISABLE_SSL=1
305 export OPT="${CFLAGS}"
306
307 einfo "Compiling ${A%-*}"
308 econf \
309 --disable-toolbox-glue \
310 --enable-unicode=ucs4 \
311 --with-fpectl \
312 --enable-shared \
313 --disable-ipv6 \
314 --with-threads \
315 --with-cxx=no
316 make ${MAKEOPTS} || exit 1
317
318 einfo "Installing ${A%-*}"
319 make altinstall || exit 1
320 cd ${ROOT}/usr/bin
321 ln -sf python2.4 python
322
323 einfo "${A%-*} succesfully bootstrapped"
324 }
325
326 bootstrap_sed() {
327 bootstrap_gnu sed 4.1.4
328 }
329
330 bootstrap_findutils() {
331 bootstrap_gnu findutils 4.2.27
332 }
333
334 bootstrap_all() {
335 case ${CHOST} in
336 *-*-darwin*)
337 bootstrap_odcctools
338 esac
339 bootstrap_gcc
340 bootstrap_sed
341 bootstrap_findutils
342 bootstrap_python
343 bootstrap_portage
344 }
345
346 ## End Functions
347
348 ## some vars
349
350 # We do not want stray $TMP, $TMPDIR or $TEMP settings
351 unset TMP TMPDIR TEMP
352
353 # Try to guess the CHOST if not set. We currently only support Linux
354 # and Darwin guessing on a very sloppy base.
355 if [ -z "${CHOST}" ];
356 then
357 if [ x$(type -t uname) == "xfile" ];
358 then
359 case `uname -s` in
360 Linux)
361 CHOST="`uname -m`-pc-linux-gnu"
362 ;;
363 Darwin)
364 # we only support darwin 8
365 CHOST="`uname -p`-apple-darwin8"
366 ;;
367 *)
368 echo "!!! Nothing known about platform `uname -s`." 1>&2
369 echo "!!! Please set CHOST appropriately for your system" 1>&2
370 echo "!!! and rerun $0" 1>&2
371 exit 1
372 ;;
373 esac
374 fi
375 fi
376
377 # Try to find a download manager, we only deal with wget and curl
378 if [ x$(type -t wget) == "xfile" ];
379 then
380 FETCH_COMMAND="wget"
381 elif [ x$(type -t curl) == "xfile" ];
382 then
383 FETCH_COMMAND="curl -O"
384 else
385 echo "!!! no suitable download manager found (need wget or curl)" 1>&2
386 exit 1
387 fi
388
389 # Just guessing a prefix is kind of scary. Hence, to make it a bit less
390 # scary, we force the user to give the prefix location here. This also
391 # makes the script a bit less dangerous as it will die when just ran to
392 # "see what happens".
393 if [ -z "$1" ];
394 then
395 echo "usage: $0 <prefix-path> [action]"
396 echo
397 echo "You need to give the path offset for your Gentoo prefixed"
398 echo "portage installation, e.g. $HOME/prefix."
399 echo "The action to perform is optional and defaults to 'all'."
400 echo "See the source of this script for which actions exist."
401 echo
402 echo "$0: insufficient number of arguments" 1>&2
403 exit 1
404 fi
405
406 ROOT="$1"
407
408 CFLAGS="-O2 -pipe"
409 CXXFLAGS="${CFLAGS:--O2 -pipe}"
410 MAKEOPTS="${MAKEOPTS:--j2}"
411 PORTDIR=${ROOT}/usr/portage
412 DISTDIR=${PORTDIR}/distfiles
413 PORTAGE_TMPDIR=${ROOT}/var/tmp
414 PORTAGE_URL="http://dev.gentoo.org/~kito/distfiles"
415 GNU_URL="http://ftp.gnu.org/gnu"
416 GCC_APPLE_URL="http://darwinsource.opendarwin.org/DevToolsNov2005"
417 GENTOO_URL="http://gentoo.osuosl.org"
418
419 export CFLAGS CXXFLAGS
420
421
422 einfo "Bootstrapping Gentoo prefixed portage installation using"
423 einfo "host: ${CHOST}"
424 einfo "prefix: ${ROOT}"
425
426 TODO=${2:-all}
427 if [[ $(type -t bootstrap_${TODO}) == "function" ]];
428 then
429 echo "!!! bootstrap target ${TODO} unknown" 1>&2
430 exit 1
431 fi
432
433 make_tree
434 einfo "ready to bootstrap ${TODO}"
435 bootstrap_${TODO}

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20