|
|
解开个stage1包([color="Blue"]可于这里下载),chroot并emerge sync后,首先设置glibc的locale编译项:
- # echo "sys-libs/glibc userlocales" >> /etc/portage/package.use
- # nano -w /etc/locales.build
复制代码
删掉已有的locales并加入以下几行:
- en_US.UTF-8/UTF-8
- zh_CN.GB18030/GB18030
- zh_CN.GBK/GBK
- zh_CN.UTF-8/UTF-8
- zh_CN/GB2312
- zh_HK.UTF-8/UTF-8
- zh_HK/BIG5-HKSCS
- zh_TW.EUC-TW/EUC-TW
- zh_TW.UTF-8/UTF-8
- zh_TW/BIG5
复制代码
升级gcc(因为2005.1里的stage包还在用gcc-3.3.5)
- # mkdir /etc/portage/profile
- # echo "sys-devel/gcc-3.3.6" >> /etc/portage/profile/package.provided
- # emerge -uav gcc
- # gcc-config 6
- # source /etc/profile
复制代码
修改/etc/make.conf(可参考这里http://www.gentoo.org/doc/zh_tw/handbook/handbook-x86.xml?part=1&chap=5#doc_chap5),主要是CFLAGS和mirror。USE方面最好只加个"nptl",其他USE等做完此贴的步骤再加也不迟。
将以下的脚本拷到/root里并使之可执行:
- # chmod u+x /root/emwrap.sh
复制代码- #!/bin/bash
- # Use at yee own risk. It works for me, but then I wrote it.
- # Thanks to ecatmur's dep script, gentoo forums, for help_fmt and print_help
- # Version 3.0.6 , 12-15-05 Added saveing of the failed to
- # roots dir. Cleaned up and fixed formating.
- # Version 3.0.7 Added build TC once flag such that TC is built only once instead of twice.
- # Added build file and failed file detection. If found emwrap.sh will offer to build them
- # instead of what you were going to do. Ergo failed is no longer moved to /root
- # Removed Portage gcc-config and binutils-config from TC filtering and from TC update
- # notification. When they're found they get built
- # 1-20-06 Minor updates to heip showing -S and -1 usage. Re-added resume filter to diff_emerge
- # 2-1-06 The end of a major rewrite and the addition of several new features includeing adding
- # libstdc to the TC Some minor things to do or not. Better input control? Do I want to trust a script
- # to switch gcc?
- # 2-13-06 removed tc_filter from sys.lst and wrld.lst in to fix filtering error and save an
- # unnessary step. Also fixed TC from runing -se in a -sept case. Added dagurasu suggection for a
- # CTRL-C trap.I will no longer be able to build a failed list for when I test :(
- # Bumped up Rev to 4.0.1
- # Fixed help. Added " exit " to prin_help. 2-18-06
- PROG="emwrap.sh"
- VERSION="4.0.1"
- TAG="cats is rats mit fuzzy tails"
- DESC="A wrapper for emerge so you can control toolchain updates"
- print_help(){
- cat <<END #|help_fmt
-
- ${GR}${PROG} v. ${VERSION} ${BL}"${TAG}"${NO}
- ${GR}${DESC}!${NO}
- Usage: ${PROG} [OPTION]
- Date 4-23-05
- Use at yee own risk. It works for me, but then I wrote it.
- This wrapper can do 3 things for you:
- 1. Test if there is a toolchain, TC, update in "emerge system/world -uD".
- 2. If there is and you want to, then you can rebuild all or part of your TC and then
- using an edited list to build the other items scheduled to be updated.
- 3. Do the update without updating the TC, toolchain.
- Options:
- These first flags are the same as what you use with emerge [options] See "man emerge"
- -h, help Display this help (default)
- -f Fetchs files only
- -u update
- -D deep
- -e Does an emerge "--emptytree" world/sytem
- -p Just like pretend in emerge. Works with all other flags.
- -N Tells emerge to include installed packages that are affected by the new USE flags
- that have changed since the program was built.
- -B/b build packages only or build them as you emerge packages
- resume, -r Continues emwrap from where it stoped. To use rerun the same command
- and add "r" ${Rd}DONT${Yl} USE EMWRAP.SH FOR ANYTHING ELSE UNTIL YOU RUN THE -r${NO}
- and emwrap will start from where it stopped without haveing to rebuild everything
- already done.
- -K/k use packages. For use if you have --buildpkg in your /etc/make.conf or use -B/b
- -G/g use packages from a PORTAGE_BINHOST server.
- system, -s "-s" is short for system.The same as "emerge system"
- world, -w "-w" is short for world. The same as "emerge world"
- For use by the script
- -t Rebuilds the toolchain componets only
- -b Rebuilds the toolchain and resumeinues the emerge.
- -1 For use with "t" or "b" only builds the TC once.
- -S This is short for a "emerge system --emptytree" build.
- -W builds the world files, "emerge world -e", BUT minus the system files.
- failed builds the files in the failed list.
- nc Turns off color in the script. You still get color in emerge out put.
-
- The flags are chainable and change whether your doing a system or world emerge and
- from -uD, -N, to -e. There is also a pretend mode, -p. Like emerge -p it
- shows you what will be emerged. I recomemnd that instead of boldy going forth, add
- the -p to the end of the switchs first, to see whats going to be emerged. Then you
- can remove it.
- Example emwrap.sh -sep ==> emerge system --emptytree -pretend. If you remove the
- -p it will do a build of all packages in system except for the TC.
- ${Yl}NOTE -se or -S do the same thing${NO}
- emwrap.sh -set or -wet ==> updates the entire TC. If the -b switch is used instead
- of -t then the entire TC is built and then all system/world packages minus
- toolchain files.
- Examples
- ${CY}emwrap.sh${NO} prints help.
- ${CY}emwrap.sh -wuDbp${NO} Checks for updates to the TC and in the world.
- ${CY}emwrap.sh -wuDt${NO}==> emerge world -uD and only does TC update if any.
- ${CY}emwrap.sh -wuDb${NO}==> updates, if any, the TC and then the world files.
- ${CY}emwrap.sh -f{other flags}${NO} will fetch the files for you.
- ${CY}emwrap.sh system -uDN${NO}==> emerge system -uDN, update deep newuse
- ${Cy}emwrap.sh -Sb1${NO}==> emerge system -e build TC once and then system files
- emwrap.sh can "emerge system -e" with or without the TC and remove all packages
- built during the system emerge for a following "emerge world -e". This is a major
- time savings as 130+ packages wont be rebuilt during the world half.
- ${RD}NOTE -d -c -r have been changed${Rd}. -d is now -S, -W takes on the old
- role of -r.-r is now resume and -c has been removed.${NO}
- ${CY}emwrap.sh -Sb${NO} ,builds TC and sytem -e. When it completes run
- ${CY}emwrap.sh -W${NO} ,this picks where -Sb stoped and builds the rest of
- the files in the " world -e ". Why use this, well if you want to break an
- " emerge world -e " up into 2 chunks for two different nights this will do it.
- Here are the TC build list used in this wraper when doing updates. The first 3 are
- double builds.
- If linux-headers TC="linux-headers glibc \$tc_conf binutils gcc glibc binutils gcc"
- If glibc TC_glb="glibc \$tc_conf binutils gcc glibc binutils gcc"
- If binutils or gcc TCmini="\$tc_conf binutils gcc binutils gcc"
- These are the single build TC list
- If linux-headers TC1="linux-headers glibc \$tc_conf binutils gcc "
- If glibc TC_glb1="glibc \$tc_conf binutils gcc "
- If binutils or gcc TCmini1="\$tc_conf binutils gcc"
- The TC build sripts are basicly fall through. If you have a linux-headers update
- then the srcipt will use TC, if its a glibc update then TC_glib and
- if binutils and/or gcc then TCmini. To force a full TC build use -set, -St or
- -wet or -seb, -Sb or -web.
-
- END
- exit
- }
- function color(){
- if [[ $nc != "yes" ]]; then
- #Set up colors
- NO=$'\x1b[0;0m'
- BR=$'\x1b[0;01m'
- RD=$'\x1b[31;01m' Rd=$'\x1b[00;31m'
- GR=$'\x1b[32;01m' Gr=$'\x1b[00;32m'
- YL=$'\x1b[33;01m' Yl=$'\x1b[00;33m'
- BL=$'\x1b[34;01m' Bl=$'\x1b[00;34m'
- FC=$'\x1b[35;01m' Fc=$'\x1b[00;35m'
- CY=$'\x1b[36;01m' Cy=$'\x1b[00;36m'
- COLUMNS=${COLUMNS:-80}
- spaces=$(for ((i=0;i<COLUMNS;++i)); do echo -n " "; done)
- fi
- }
- # Varables
- bclass="";eargs=""; count="0"
- nc="";tc="";do_tc=""tc_once="";do_sys="";do_wrld="";both="";resume="";ftch=""
- TIME=10 # sets the time the script displays faild_build info
- function info(){
- clear
- cat <<END
-
- $GR Runnig emwrap.sh
- $RdNew$GR if emwrap.sh is run and it detects a $CY"failed' or "build"
- $GR file then it will offer to build them. You can ignor this by not doing
- $GR anything and what you wanted todo will start after 10 seconds.$NO
- END
- }
- function build_info(){
- cat <<END
- ${Yl}You can now enter ${RD}" r "${Yl} to resume building. If you dont enter anything
- then the old build file will be deleted.and ${Rd}emwrap.sh $bclass -$eargs${Yl} will continue.
- If you want to stop and scratch your head do a CRTL-C${NO}
- END
- }
- function faild_info(){
- cat <<END
- ${Yl}You can now enter ${RD}" f "${Yl} to build the faild file list.If you dont enter anything
- then the faild file will be deleted and ${Rd}emwrap.sh $bclass -$eargs${Yl} will continue.
- You only need to run ${Rd}"emwrap.sh faild"${Yl} after doing a emptytree system or world.
- If you want to stop and scratch your head do a CRTL-C${NO}
- END
- }
- # changing work dir to /tmp/emwrap
- function wrk_dir(){
- # change file locations to /tmp/emwrap/{FILES}
- # Changed to explicit directory invoke, because if used to build a system from scratch,
- # ergo a new build, $HOME isnt set and every thing for root is writen to " / ".
- if [ ! -d /tmp/emwrap ];then
- mkdir /tmp/emwrap;chmod 776 /tmp/emwrap;chown portage:portage /tmp/emwrap;cd /tmp/emwrap
- else cd /tmp/emwrap
- fi
- if [ "$(pwd)" != "/tmp/emwrap" ] ;then
- echo;echo $RD"Did not change to /tmp/emwrap. Bailing out!"$NO;echo
- exit 15
- fi
- }
- function get_input(){
- read -t $TIME INPUT
- if [ "$INPUT" == "r" ]; then
- resume="yes"
-
- fi
- }
- function chk_failed_build(){
- if [ "$resume" != "yes" ]; then
- if [[ -e failed || -e build ]]; then
- if [ -s build ]; then
- echo $RD "these remain to build"$NO
- cat build
- build_info
- read -t $TIME INPUT
- if [ "$INPUT" == "r" ]; then
- resume="yes"
- elif [ -z $INPUT ]; then
- echo " $Yl Input was empty I will resumeinue with emwrap.sh $bclass -$eargs"
- rm /tmp/emwrap/build
- fi
- elif [[ -s failed && ! -e build ]]; then
- echo $RD "these failed to build"$NO
- cat failed
- faild_info
- if [ "$failed" != "yes" ];then
- read -t $TIME INPUT
- if [ "$INPUT" == "f" ]; then
- failed="yes"
- elif [ -z $INPUT ]; then
- echo " $Yl Input was empty I will continue with emwrap.sh $bclass -$eargs"
- rm /tmp/emwrap/failed
- fi
- fi
- if [ "$failed" == "yes" ];then
- cat failed > build
- rm failed
- resume="yes"
- fi
- fi
- fi
- fi
- }
- # For cleaning files. if's to keep rm from complaining
- function clean_up(){
- if [ -s failed ] ; then
- echo;echo ${RD} "these failed to build"${NO}
- cat failed
- elif [[ -e failed && ! -s failed ]]; then
- rm failed
- fi
- if [ -s build ] ; then
- echo;echo ${RD} "these remain to build" ${NO}
- cat build
- elif [[ -e build && ! -s build ]] ; then
- rm build
- fi
- if [ -e sys.lst ] ; then rm sys.lst ; fi
- if [ -e wrld.lst ] ; then rm wrld.lst ; fi
- if [ -e wrld.tmp ] ; then rm wrld.tmp ; fi
- }
- function getargs(){
- if [ $# -eq 0 ]; then
- print_help
- fi
- while [[ $1 != "" ]]; do
- if echo $1|grep -v - ; then
- case $1 in
- system ) bclass="system" ;;
- world ) bclass="world" ;;
- help ) print_help ;;
- resume ) resume="yes" ;;
- nc ) nc="yes" ;;
- failed ) failed="yes";;
- esac
- fi
- while getopts ":1bdDefgGhKkNoprSWstuw " OPT; do
- case $OPT in
- s ) bclass="system" ;;
- w ) bclass="world" ;;
- D ) eargs="${eargs}${OPT}" ;;
- e ) eargs="${eargs}${OPT}" ;;
- N ) eargs="${eargs}${OPT}" ;;
- u ) eargs="${eargs}${OPT}" ;;
- g ) eargs="${eargs}${OPT}" ;;
- G ) eargs="${eargs}${OPT}" ;;
- k ) eargs="${eargs}${OPT}" ;;
- K ) eargs="${eargs}${OPT}" ;;
- 1 ) tc_once="yes" ;;
- h | \? )print_help ;;
- p ) eargs="${eargs}${OPT}";prtnd="p" ;;
- f ) ftch="f" ;;
- S ) do_sys="yes";bclass="system";eargs="e" ;;
- W ) do_wrld="yes" ;bclass="system";eargs="e";;
- b ) both="yes";;
- r ) resume="yes" ;;
- t ) do_tc="yes" ; Tc="yes";;
- * ) echo block="$block $OPT";;
- esac
- done
- shift
- done
- }
- function build_count(){
- count="0" ; s=$(wc -l build)
- for z in $(< build) ;do
- count=$(( count + 1 ))
- echo;echo -n "${Yl}${count} of ${s}"${NO}
- emerge -${ftch} -${prtnd} --oneshot --nodeps =${z} || $1
- grep -v "${z}" build>tmp;cat tmp>build
- done
- }
- # merg_faild records which package fails to emerge buid_count
- function emerge_faild(){
- echo "${z}">> failed
- }
- #TC functions the next 4 functions
- # tc_faild bails out of the build_count if emerge error
- function tc_faild(){
- echo ${RD}"${z} failed to build. Stoping script."${NO};exit 65
- }
- function tc_filter(){
- awk "!/linux-head|glibc|gcc-[0-9]+|binutils-[0-9]+|libstdc+/"
- }
- function tc_check(){
- # 1-7-06 removed gcc-config binutils-config from TC update notice.
- # Removed portage from TC filtering.
- # testing for TC components.
- if grep -Eq linux-h wrld.lst
- then tc="linux-headers"
- elif grep -Eq glibc wrld.lst
- then tc="glibc"
- elif grep -Eq binutils-[[0-9]]? wrld.lst
- then tc="binutils"
- elif grep -Eq gcc-[[:digit:]]? wrld.lst
- then tc="gcc"
- elif grep -Eq libstdc+ wrld.lst
- then tc="libstdc"
- fi
-
- #shows what TC items have updates
- if [[ $do_tc == "yes" || $both == "yes" ]] ; then
- if [ -n "$tc" ] ;then
- echo $RD"ToolChain updates found"$NO;echo
- echo ${Rd}" $tc"${NO}
- echo $BL"======================================================"$NO
- echo
- else
- echo;echo ${RD}" No toolchain update "${NO};echo
- fi
- # for getting and building config tools in an TC build.
- bin="0"; gcc="0"; tc_conf=""
- if grep -Eq binutils-[[:alpha:]]? wrld.lst
- then tc_conf="binutils-config $tc_conf"; fi
- if grep -Eq gcc-[[:alpha:]]? wrld.lst
- then tc_conf="gcc-config $tc_conf"; fi
- fi
- }
- function tc_emerge(){
- # added tc-once to build TC once only which is what I do.
- TC="linux-headers glibc $tc_conf binutils gcc glibc binutils gcc libstdc++-v3"
- TC_glb="glibc $(echo $tc_conf) binutils gcc glibc binutils gcc libstdc++-v3"
- TCmini="$(echo $tc_conf) binutils gcc binutils gcc libstdc++-v3"
- TC1="linux-headers glibc $(echo $tc_conf) binutils gcc libstdc++-v3"
- TC_glb1="glibc $(echo $tc_conf) binutils gcc libstdc++-v3"
- TCmini1="$(echo $tc_conf) gcc binutils libstdc++-v3"
- if [[ "${resume}" != "yes" ]];then #prevents filling the build list after a failed TC resume
- if [[ $tc_once != "yes" ]];then
- case ${tc} in
- linux-headers ) tc_list=$TC;;
- glibc ) tc_list=$TC_glb;;
- gcc ) tc_list=$TCmini;;
- binutils ) tc_list=$TCmini;;
- libstdc ) tc_list=$TCmini;;
- esac
- else
- case ${tc} in
- linux-headers ) tc_list=$TC1;;
- glibc ) tc_list=$TC_glb1;;
- gcc ) tc_list=$TCmini1;;
- binutils ) tc_list=$TCmini1;;
- libstdc ) tc_list=$TCmini1;;
- esac
- fi
- fi
- # if for determining if build is empty
- if [ ! -e build ] || [[ -e build && ! -s build ]];then
- if [ "$resume" != "yes" ] ;then
- for t in $(echo $tc_list); do
- echo $t>>build
- done
- fi
- fi
- echo $RD"$(< build)"$NO
- build_count tc_faild
- if [ -e tmp ]; then rm tmp ;fi
- echo ${Rd}"End of ToolChain update"${NO};echo
- }
- # generates the the build list
- function wrld_lst(){
- # If for blocking regeneration of list resume or do-tc is used
- if [ "$resume" != "yes" ];then
- emerge $bclass -${eargs}p >wrld.lst
- # checking for blocked packages
- if grep "blocks" wrld.lst ; then
- echo
- cat <<END
- ${Yl}You have packages ${RD}blocking${Yl} each other. To fix run emerge and take care
- of the blockage${NO}
- END
- echo
- exit
- fi
- if grep "masked" wrld.lst ; then
- echo
- cat <<END
- ${Yl}You have ${RD}masked${Yl} ebuilds. If its keyword masked add it to /etc/portage/packege.keywords.
- For more info see man emerge.${NO}
- END
- echo
- exit
- fi
- cut -f2 -d "]" -s wrld.lst|cut -f1 -d "[" | cut -f2 -d " ">wrld.tmp
- cat wrld.tmp>wrld.lst
- if [ -e wrld.tmp ]; then rm wrld.tmp ;fi
- fi
- }
- # general purpose emerge
- function list_emerge(){
- # blocks do_tc from running list_emerge with prntd
- if [[ "$resume" != "yes" ]] ;then
- cat wrld.lst|tc_filter >> build
- fi
- # Now emerge
- echo;echo -n ${YL}"$(wc -l build)s to emerge "${NO}
- build_count emerge_faild
- if [ -e tmp ];then rm tmp ;fi
- }
- # This is for the generation of the world files minus the system files
- function diff_emerge(){
- # stops regerateing the build file if your resumeing build
- if [ "$resume" != "yes" ]; then
- # wrld_list already run for system files.
- cat wrld.lst >sys.lst
- # filter out sys files and puts the results into into the build list.
- if [ "${do_wrld}" == "yes" ] ; then
- bclass="world";eargs="e"
- wrld_lst >wrld.lst
- for i in $(< sys.lst);do
- grep -v $i wrld.lst>tmp;cat tmp>wrld.lst
- done
- cat wrld.lst >build
- if [ -e tmp ];then rm tmp ;fi
- fi
- fi
- # Now to build what was not removed by removeing the system files
- #echo $GR"$(wc -l build)s to emerge "$NO;echo
- sleep 1
- echo;echo -n ${YL}"$(wc -l build)s to emerge "${NO}
- build_count emerge_faild
- if [ -e tmp ];then rm tmp ;fi
- }
- # Main where the functions are called and things get done.
- trap "exit 1" 1 2 3 15
- color
- getargs $@
- info
- wrk_dir
- chk_failed_build
- wrld_lst
- #for doing resume
- if [ "$resume" == "yes" ]; then
- list_emerge
- fi
- # For building the TC
- if [[ "$do_tc" == "yes" || "$both" == "yes" ]];then
- tc_check;
- if [ -n "$tc" ];then
- tc_emerge
- fi
- fi
-
- # For most of the emerges inculding -S
- if [[ "$do_tc" != "yes" && "$do_wrld" != "yes" ]] && [[ "$both" == "yes" || -n "$bclass" ]]; then
- list_emerge
- fi
- # does world --emptytree MINUS the system files
- if [[ "$Tc" != "yes" && "$do_wrld" == "yes" ]]; then
- # system files already generated now removal
- diff_emerge
- fi
-
- clean_up
- exit
复制代码
执行
这个脚本会重建工具链并emerge system,然后就可以删除旧的gcc了:
- # emerge -aC =sys-devel/gcc-3.3*
复制代码 完成后便可以从handbook里的第7章继续下去了。
注:脚本来自:http://forums.gentoo.org/viewtopic-t-282474.html |
|