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

Contents of /scripts/bootstrap-new.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download) (as text)
Mon Mar 28 01:03:31 2005 UTC (14 years, 6 months ago) by wolf31o2
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -2 lines
File MIME type: text/x-sh
FILE REMOVED
New bootstrap.sh script for 2005.0 and beyond

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

  ViewVC Help
Powered by ViewVC 1.1.20