misc bugfixes
[catalyst.git] / targets / stage1 / stage1-chroot.sh
1 #!/bin/bash
2                 
3 env-update
4 source /etc/profile
5 if [ -n "${clst_ENVSCRIPT}" ]
6 then
7         source /tmp/envscript
8         rm -f /tmp/envscript
9 fi
10 case $1 in
11         build)
12                 #emerge and enable ccache before we set ROOT
13                 if [ -n "${clst_CCACHE}" ]
14                 then
15                         export FEATURES="ccache"        
16                         emerge --oneshot --nodeps ccache || exit 1
17                 fi
18                 if [ -n "${clst_DISTCC}" ]
19         then   
20                 export FEATURES="distcc"
21                 export DISTCC_HOSTS="${clst_distcc_hosts}"
22                 USE="-gtk -gnome" emerge --oneshot --nodeps distcc || exit 1
23                         echo "distcc:x:240:2:distccd:/dev/null:/bin/false" >> /etc/passwd
24                 /usr/bin/distcc-config --install 2>&1 > /dev/null
25                 /usr/bin/distccd 2>&1 > /dev/null
26         fi
27                 export ROOT=${2}
28                 install -d $ROOT
29                 if [ -n "${clst_PKGCACHE}" ]
30                 then
31                         export EMERGE_OPTS="--usepkg --buildpkg"
32                 fi
33                 for x in $(/tmp/build.sh)
34                 do
35                         echo $x >> /tmp/build.log
36                         USE="-* build" emerge ${EMERGE_OPTS} --noreplace $x || exit 1
37                 done
38         ;;
39
40         preclean)
41                 #normal chroot is fine here since this is our second chroot (no $clst_CHROOT needed)
42                 chroot ${2} /bin/bash << EOF
43                 #now, some finishing touches to initialize gcc-config....
44                 unset ROOT
45                 if [ -e /usr/sbin/gcc-config ]
46                 then
47                         mythang=\$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* )
48                         gcc-config \${mythang}; env-update; source /etc/profile
49                 fi
50                 #stage1 is not going to have anything in zoneinfo, so save our Factory timezone
51                 rm -f /etc/localtime
52                 cp /usr/share/zoneinfo/Factory /etc/localtime
53 EOF
54         ;;              
55 esac
56