/[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 1210 - (show annotations) (download) (as text)
Sat Apr 1 18:17:33 2006 UTC (8 years, 8 months ago) by exg
File MIME type: text/x-sh
File size: 7282 byte(s)
Add overlay extraction. Minor fixes.

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20