/[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 1292 - (show annotations) (download) (as text)
Thu Jun 1 15:38:10 2006 UTC (8 years, 4 months ago) by exg
File MIME type: text/x-sh
File size: 9422 byte(s)
Call make_tree only in bootstrap_all. Bump odcctools version. Refactor code to setup profile/config removing the wget/curl hack, instead bootstrap wget.

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20