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

Contents of /scripts/bootstrap.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.94 - (hide annotations) (download) (as text)
Thu Nov 17 01:51:06 2011 UTC (2 years, 8 months ago) by jmbsvicetto
Branch: MAIN
Changes since 1.93: +6 -6 lines
File MIME type: text/x-sh
Update bootstrap.sh to replace STAGE1_USE with BOOTSTRAP_USE - bug 390701.

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

  ViewVC Help
Powered by ViewVC 1.1.20