/[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 1569 - (show annotations) (download) (as text)
Fri Sep 22 09:16:02 2006 UTC (7 years, 10 months ago) by grobian
File MIME type: text/x-sh
File size: 9820 byte(s)
Actually, detect Panther


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20