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

Contents of /scripts/bootstrap-new.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download) (as text)
Thu Feb 10 16:00:38 2005 UTC (14 years, 8 months ago) by wolf31o2
Branch: MAIN
Changes since 1.4: +11 -5 lines
File MIME type: text/x-sh
Updated bootstrap-new.sh script, which is now being used as bootstrap.sh in the 2005.0 snapshot.

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

  ViewVC Help
Powered by ViewVC 1.1.20