wacky doodle updates
[catalyst.git] / targets / stage1 / stage1-chroot.sh
1 #!/bin/bash
2                 
3 env-update
4 source /etc/profile
5 case $1 in
6         build)
7                 export ROOT=${2}
8                 install -d $ROOT
9                 for x in $(/tmp/build.sh)
10                 do
11                         echo $x >> /tmp/build.log
12                         USE="-* build" emerge --usepkg --buildpkg --noreplace $x || exit 1
13                 done
14         ;;
15
16         clean)
17                 export ROOT=${2}
18                 keepers="sys-kernel/linux-headers sys-devel/binutils sys-devel/gcc sys-apps/baselayout sys-libs/glibc virtual/glibc virtual/kernel"
19                 if [ ${clst_rel_type} = "hardened" ]
20                 then
21                         keepers="${keepers} sys-devel/hardened-gcc"
22                 fi
23                 # set everything to uid 999 (nouser)
24                 cd ${ROOT}
25                 install -d var/db/pkg2
26                 for x in $keepers
27                 do
28                         category=${x%%/*}
29                         package=${x##*/}
30                         [ "`ls var/db/pkg/${x}* 2>/dev/null`" = "" ] && continue
31                         install -d var/db/pkg2/${category}
32                         mv var/db/pkg/${category}/${package}* var/db/pkg2/${category}
33                 done
34                 rm -rf var/db/pkg
35                 mv var/db/pkg2 var/db/pkg
36
37                 # clean out man, info and doc files
38                 rm -rf usr/share/{man,doc,info}/*
39
40                 # zap all .pyc and .pyo files
41                 find -iname "*.py[co]" -exec rm -f {} \;
42
43                 # cleanup all .a files except libgcc.a, *_nonshared.a and /usr/lib/portage/bin/*.a
44                 find -iname "*.a" | `find -iname "*.a" | grep -v 'libgcc.a' | grep -v 'nonshared.a' | grep -v '/usr/lib/portage/bin/' | grep -v 'libgcc_eh.a'` | xargs rm -f
45
46                 chroot ${ROOT} /bin/bash << EOF
47                 #now, some finishing touches to initialize gcc-config....
48                 unset ROOT
49                 if [ -e /usr/sbin/gcc-config ]
50                 then
51                         mythang=\$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* )
52                         gcc-config \${mythang}; env-update; source /etc/profile
53                 fi
54 EOF
55                 ;;
56 esac
57