/[gentoo-x86]/scripts/bootstrap-old.sh
Gentoo

Contents of /scripts/bootstrap-old.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Wed Jun 22 21:34:17 2005 UTC (14 years, 3 months ago) by wolf31o2
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
File MIME type: text/x-sh
FILE REMOVED
Removing bootstrap-old.sh, as it is no longer used.

1 #!/bin/bash
2 # Copyright 1999-2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo-x86/scripts/bootstrap-old.sh,v 1.1 2005/03/28 01:03:31 wolf31o2 Exp $
5
6 # people who were here:
7 # (drobbins, 06 Jun 2003)
8 # (solar, Jul 2004)
9 # (vapier, Aug 2004)
10 # (compnerd, Nov 2004)
11
12 if [ -e /etc/init.d/functions.sh ] ; then
13 source /etc/init.d/functions.sh
14
15 # Use our own custom script, else logger cause things to
16 # 'freeze' if we do not have a system logger running
17 esyslog() {
18 echo &> /dev/null
19 }
20 else
21 eerror() { echo "!!! $*"; }
22 einfo() { echo "* $*"; }
23 fi
24 show_status() {
25 local num=$1
26 shift
27 echo " [[ ($num/6) $* ]]"
28 }
29
30 # Track progress of the bootstrap process to allow for
31 # semi-transparent resuming
32 progressfile=/var/run/bootstrap-progress
33 [[ -e ${progressfile} ]] && source ${progressfile}
34 export BOOTSTRAP_STAGE=${BOOTSTRAP_STAGE:-1}
35 set_bootstrap_stage() {
36 [[ -z ${STRAP_RUN} ]] && return 0
37 export BOOTSTRAP_STAGE=$1
38 echo "BOOTSTRAP_STAGE=$1" > ${progressfile}
39 }
40
41 v_echo() {
42 einfo "Executing: $*"
43 env "$@"
44 }
45
46 usage() {
47 echo -e "Usage: ${HILITE}${0##*/}${NORMAL} ${GOOD}[options]${NORMAL}"
48 echo -e " ${GOOD}--debug (-d)${NORMAL} Run with debug information turned on"
49 echo -e " ${GOOD}--fetchonly (-f)${NORMAL} Just download all the source files"
50 echo -e " ${GOOD}--info (-i)${NORMAL} Show system related information"
51 echo -e " ${GOOD}--pretend (-p)${NORMAL} Display the packages that will be merged"
52 echo -e " ${GOOD}--tree (-t)${NORMAL} Display the dependency tree, forces -p"
53 echo -e " ${GOOD}--resume (-r)${NORMAL} Build/use binary packages"
54 }
55
56 unset STRAP_EMERGE_OPTS
57 STRAP_RUN=1
58 V_ECHO=env
59 DEBUG=0
60 GENTOO_VERS=2005.0 # Mostly for fluff ;)
61
62 for opt in "$@" ; do
63 case ${opt} in
64 --fetchonly|-f)
65 echo "Running in fetch-only mode ..."
66 STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -f"
67 unset STRAP_RUN;;
68 --help|-h)
69 usage
70 exit 0;;
71 --debug|-d) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} --debug"; DEBUG=1;;
72 --info|-i) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} --info" ; unset STRAP_RUN ;;
73 --pretend|-p) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -p" ; unset STRAP_RUN ;;
74 --tree|-t) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -p -t"; unset STRAP_RUN ;;
75 --resume|-r) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} --usepkg --buildpkg";;
76 --verbose|-v) STRAP_EMERGE_OPTS="${STRAP_EMERGE_OPTS} -v"; V_ECHO=v_echo;;
77 --version)
78 cvsver="$Header: /var/cvsroot/gentoo-x86/scripts/bootstrap-old.sh,v 1.1 2005/03/28 01:03:31 wolf31o2 Exp $"
79 cvsver=${cvsver##*,v }
80 einfo "Gentoo ${GENTOO_VERS} bootstrap ${cvsver%%Exp*}"
81 exit 0
82 ;;
83 *)
84 eerror "Unknown option '${opt}'"
85 usage
86 exit 1;;
87 esac
88 done
89
90 if [[ -n ${STRAP_RUN} ]] ; then
91 if [ ${BOOTSTRAP_STAGE} -ge 6 ] ; then
92 echo
93 einfo "System has been bootstrapped already!"
94 einfo "If you re-bootstrap the system, you must complete the entire bootstrap process"
95 einfo "otherwise you will have a broken system."
96 einfo "Press enter to continue or CTRL+C to abort ..."
97 read
98 set_bootstrap_stage 1
99 elif [ ${BOOTSTRAP_STAGE} -gt 1 ] ; then
100 einfo "Resuming bootstrap at internal stage #${BOOTSTRAP_STAGE} ..."
101 fi
102 else
103 export BOOTSTRAP_STAGE=0
104 fi
105
106 MYPROFILEDIR=$(readlink -f /etc/make.profile)
107 if [[ ! -d ${MYPROFILEDIR} ]] ; then
108 eerror "Error: '${MYPROFILEDIR}' does not exist. Exiting."
109 exit 1
110 fi
111
112 [[ -e /etc/profile ]] && source /etc/profile
113
114 echo -e "\n${GOOD}Gentoo Linux ${GENTOO_VERS}; ${BRACKET}http://www.gentoo.org/${NORMAL}"
115 echo -e "Copyright 1999-2005 Gentoo Foundation; Distributed under the GPLv2"
116 if [[ ${STRAP_EMERGE_OPTS:0:2} = "-f" ]] ; then
117 echo "Fetching all bootstrap-related archives ..."
118 elif [[ -n ${STRAP_RUN} ]] ; then
119 if [ ${BOOTSTRAP_STAGE} -gt 2 ] ; then
120 echo "Resuming Bootstrap of base system ..."
121 else
122 echo "Starting Bootstrap of base system ..."
123 fi
124 fi
125 echo -------------------------------------------------------------------------------
126 show_status 0 Locating packages
127
128 # This should not be set to get glibc to build properly. See bug #7652.
129 unset LD_LIBRARY_PATH
130
131 # We do not want stray $TMP, $TMPDIR or $TEMP settings
132 unset TMP TMPDIR TEMP
133
134 cleanup() {
135 if [[ -n ${STRAP_RUN} ]] ; then
136 if [[ -f /etc/make.conf.build ]] ; then
137 mv -f /etc/make.conf.build /etc/make.conf
138 fi
139 fi
140 exit $1
141 }
142
143 pycmd() {
144 [[ ${DEBUG} = "1" ]] && echo /usr/bin/python -c "$@" > /dev/stderr
145 /usr/bin/python -c "$@"
146 }
147
148 # Trap ctrl-c and stuff. This should fix the users make.conf
149 # not being restored.
150 [[ -n ${STRAP_RUN} ]] && cp -f /etc/make.conf /etc/make.conf.build
151
152 #TSTP messes ^Z of bootstrap up, so we don't trap it anymore.
153 trap "cleanup" TERM KILL INT QUIT ABRT
154
155 # USE may be set from the environment so we back it up for later.
156 export ORIGUSE=$(portageq envvar USE)
157
158 # Check for 'build' or 'bootstrap' in USE ...
159 INVALID_USE="`gawk -v ORIGUSE="${ORIGUSE}" '
160 BEGIN {
161 if (ORIGUSE ~ /[[:space:]]*(build|bootstrap)[[:space:]]*/)
162 print "yes"
163 }'`"
164
165 # Do not do the check for stage build scripts ...
166 if [[ ${INVALID_USE} = "yes" ]] ; then
167 echo
168 eerror "You have 'build' or 'bootstrap' in your USE flags. Please"
169 eerror "remove it before trying to continue, since these USE flags"
170 eerror "are used for internal purposes and shouldn't be specified"
171 eerror "by you."
172 echo
173 cleanup 1
174 fi
175
176 # bug #50158 (don't use `which` in a bootstrap).
177 if ! type -path portageq &>/dev/null ; then
178 echo
179 eerror "Your portage version is too old. Please use a newer stage1 image."
180 echo
181 cleanup 1
182 fi
183
184 # gettext should only be needed when used with nls
185 for opt in ${ORIGUSE} ; do
186 case "${opt}" in
187 nls) myGETTEXT="gettext";;
188 nptl)
189 if [[ -z $(portageq best_visible / '>=sys-kernel/linux26-headers-2.6.0') ]] ; then
190 eerror "You need to have >=sys-kernel/linux26-headers-2.6.0 unmasked!"
191 eerror "Please edit the latest >=sys-kernel/linux26-headers-2.6.0 package,"
192 eerror "and add your ARCH to KEYWORDS."
193 echo
194 cleanup 1
195 fi
196 if [[ -n $(portageq best_version / sys-kernel/linux-headers) ]] ; then
197 emerge -C sys-kernel/linux-headers
198 emerge --nodeps --oneshot sys-kernel/linux26-headers
199 fi
200 USE_NPTL=1
201 ;;
202 esac
203 done
204
205 # With cascading profiles, the packages profile at the leaf is not a
206 # complete system, just the restrictions to it for the specific profile.
207 # The complete profile consists of an aggregate of the leaf and all its
208 # parents. So we now call portage to read the aggregate profile and store
209 # that into a variable.
210
211 eval $(pycmd 'import portage; print portage.settings.packages;' |
212 sed 's/[][,]//g; s/ /\n/g; s/\*//g' | while read p; do n=${p##*/}; n=${n%\'};
213 n=${n%%-[0-9]*}; echo "my$(tr a-z- A-Z_ <<<$n)=$p; "; done)
214
215 # this stuff should never fail but will if not enough is installed.
216 #[[ -z ${myBASELAYOUT} ]] && myBASELAYOUT="$(portageq best_version / virtual/baselayout)"
217 [[ -z ${myBASELAYOUT} ]] && myBASELAYOUT="baselayout"
218 [[ -z ${myPORTAGE} ]] && myPORTAGE="portage"
219 [[ -z ${myBINUTILS} ]] && myBINUTILS="binutils"
220 [[ -z ${myGCC} ]] && myGCC="gcc"
221 [[ -z ${myLIBC} ]] && myLIBC="virtual/libc"
222 [[ -z ${myTEXINFO} ]] && myTEXINFO="sys-apps/texinfo"
223 [[ -z ${myZLIB} ]] && myZLIB="zlib"
224 [[ -z ${myNCURSES} ]] && myNCURSES="ncurses"
225
226 # Do we really have no 2.4.x nptl kernels in portage?
227 if [[ ${USE_NPTL} = "1" ]] ; then
228 myOS_HEADERS="$(portageq best_visible / '>=sys-kernel/linux26-headers-2.6.0')"
229 [[ -n ${myOS_HEADERS} ]] && myOS_HEADERS=">=${myOS_HEADERS}"
230 fi
231 [[ -z ${myOS_HEADERS} ]] && myOS_HEADERS="virtual/os-headers"
232
233 einfo "Using baselayout : ${myBASELAYOUT}"
234 einfo "Using portage : ${myPORTAGE}"
235 einfo "Using os-headers : ${myOS_HEADERS}"
236 einfo "Using binutils : ${myBINUTILS}"
237 einfo "Using gcc : ${myGCC}"
238 [[ -n ${myGETTEXT} ]] && einfo "Using gettext : ${myGETTEXT}"
239 einfo "Using libc : ${myLIBC}"
240 einfo "Using texinfo : ${myTEXINFO}"
241 einfo "Using zlib : ${myZLIB}"
242 einfo "Using ncurses : ${myNCURSES}"
243 echo -------------------------------------------------------------------------------
244 show_status 1 Configuring environment
245
246 # Get correct CFLAGS, CHOST, CXXFLAGS, MAKEOPTS since make.conf will be
247 # overwritten.
248
249 ENV_EXPORTS="GENTOO_MIRRORS PORTDIR DISTDIR PKGDIR PORTAGE_TMPDIR
250 CFLAGS CHOST CXXFLAGS MAKEOPTS ACCEPT_KEYWORDS PROXY HTTP_PROXY
251 FTP_PROXY FEATURES STAGE1_USE"
252
253 for opt in ${ENV_EXPORTS} ; do
254 val=$(portageq envvar "${opt}")
255 if [[ -n ${val} ]] ; then
256 einfo "${opt}='${val}'"
257 export ${opt}="${val}"
258 fi
259 done
260 echo -------------------------------------------------------------------------------
261
262 [[ -x /usr/sbin/gcc-config ]] && GCC_CONFIG="/usr/sbin/gcc-config"
263 [[ -x /usr/bin/gcc-config ]] && GCC_CONFIG="/usr/bin/gcc-config"
264
265 # Disable autoclean, or it b0rks
266 export AUTOCLEAN="no"
267
268 # Allow portage to overwrite stuff
269 export CONFIG_PROTECT="-*"
270
271 # disable collision-protection
272 export FEATURES="${FEATURES} -collision-protect"
273
274 if [ ${BOOTSTRAP_STAGE} -le 1 ] ; then
275 show_status 2 Updating portage
276 ${V_ECHO} USE="-* build bootstrap ${STAGE1_USE}" emerge ${STRAP_EMERGE_OPTS} ${myPORTAGE} || cleanup 1
277 echo -------------------------------------------------------------------------------
278 set_bootstrap_stage 2
279 fi
280 export USE="${ORIGUSE} bootstrap ${STAGE1_USE}"
281
282 # We can't unmerge headers which may or may not exist yet. If your
283 # trying to use nptl, it may be needed to flush out any old headers
284 # before fully bootstrapping.
285 if [ ${BOOTSTRAP_STAGE} -le 2 ] ; then
286 show_status 3 Emerging headers/binutils
287 #emerge ${STRAP_EMERGE_OPTS} -C virtual/os-headers || cleanup 1
288 ${V_ECHO} emerge ${STRAP_EMERGE_OPTS} ${myOS_HEADERS} ${myTEXINFO} ${myGETTEXT} ${myBINUTILS} || cleanup 1
289 echo -------------------------------------------------------------------------------
290 set_bootstrap_stage 3
291 fi
292
293 # If say both gcc and binutils were built for i486, and we then merge
294 # binutils for i686 without removing the i486 version (Note that this is
295 # _only_ when its exactly the same version of binutils ... if we have say
296 # 2.14.90.0.6 build for i486, and bootstrap then merge 2.14.90.0.7 for i686,
297 # we will not have issues. More below ...), gcc's search path will
298 # still have
299 #
300 # /usr/lib/gcc-lib/i486-pc-linux-gnu/<gcc_version>/../../../../i486-pc-linux-gnu/bin/
301 #
302 # before /usr/bin, and thus it will use the i486 versions of binutils binaries
303 # which causes issues. The reason for this issues is that when bootstrap merge
304 # exactly the same version for i686, both will have installed the same files to
305 # /usr/lib, and thus also USE the same libraries, cause as/ld to fail with
306 # unresolved symbols during compiling/linking.
307 #
308 # More info on this can be found by looking at bug #32140:
309 #
310 # http://bugs.gentoo.org/show_bug.cgi?id=32140
311 #
312 # We now thus run an 'emerge clean' just after merging binutils ...
313 #
314 # NB: thanks to <rac@gentoo.org> for bringing me on the right track
315 # (http://forums.gentoo.org/viewtopic.php?t=100263)
316 #
317 # <azarah@gentoo.org> (1 Nov 2003)
318 if [[ -n ${STRAP_RUN} ]] ; then
319 emerge clean || cleanup 1
320 fi
321
322 if [ ${BOOTSTRAP_STAGE} -le 3 ] ; then
323 show_status 4 Emerging gcc
324 ${V_ECHO} emerge ${STRAP_EMERGE_OPTS} ${myGCC} || cleanup 1
325 echo -------------------------------------------------------------------------------
326 set_bootstrap_stage 4
327 fi
328
329 # Basic support for gcc multi version/arch scheme ...
330 if [[ -n ${STRAP_RUN} ]] ; then
331 if [[ -x ${GCC_CONFIG} ]] && ${GCC_CONFIG} --get-current-profile &>/dev/null
332 then
333 # Make sure we get the old gcc unmerged ...
334 emerge clean || cleanup 1
335 # Make sure the profile and /lib/cpp and /usr/bin/cc are valid ...
336 ${GCC_CONFIG} "$(${GCC_CONFIG} --get-current-profile)" &>/dev/null
337 fi
338 fi
339
340 if [ ${BOOTSTRAP_STAGE} -le 4 ] ; then
341 show_status 5 Emerging libc/baselayout
342 ${V_ECHO} emerge ${STRAP_EMERGE_OPTS} ${myLIBC} ${myBASELAYOUT} ${myZLIB} || cleanup 1
343 echo -------------------------------------------------------------------------------
344 set_bootstrap_stage 5
345 fi
346
347 # ncurses-5.3 and up also build c++ bindings, so we need to rebuild it
348 export USE="${ORIGUSE}"
349 if [ ${BOOTSTRAP_STAGE} -le 5 ] ; then
350 show_status 6 Re-Emerging C++ apps
351 ${V_ECHO} emerge ${STRAP_EMERGE_OPTS} ${myNCURSES} || cleanup 1
352 echo -------------------------------------------------------------------------------
353 set_bootstrap_stage 6
354 fi
355
356 # Restore original make.conf
357 cleanup 0

  ViewVC Help
Powered by ViewVC 1.1.20