/[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 1524 - (show annotations) (download) (as text)
Tue Sep 19 18:15:04 2006 UTC (7 years, 7 months ago) by grobian
File MIME type: text/x-sh
File size: 9656 byte(s)
Update boostrapped portage to latest version


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20