2 # Trap these signals and kill ourselves if recieved
3 # Force ourselves to die if any of these signals are recieved
4 # most likely our controlling terminal is gone
5 trap "echo SIGTERM signal recieved killing $0 with pid $$;kill -9 $$" SIGTERM
6 trap "echo SIGHUP signal recieved killing $0 with pid $$;kill -9 $$" SIGHUP
7 trap "echo SIGKILL signal recieved killing $0 with pid $$;kill -9 $$" SIGKILL
9 #SIGINT interrupt character (usually Ctrl-C)
10 # * example: high-level sequence of events
11 # * my process (call it "P") is running
13 # * kernel recognizes this and generates SIGINT signal
14 trap "echo SIGINT signal recieved killing $0 with pid $$;kill -9 $$" SIGINT
18 check_portage_version(){
19 portage_version=`/usr/lib/portage/bin/portageq best_version / sys-apps/portage \
20 | cut -d/ -f2 | cut -d- -f2,3`
21 if [ -n ${portage_version} -a `echo ${portage_version} | cut -d- -f1 | cut -d. -f3` -lt '51' ]
23 echo "ERROR: Your portage version is too low in your seed stage. Portage version"
24 echo "2.0.51 or greater is required."
29 check_genkernel_version(){
30 if [ -x /usr/bin/genkernel ]
32 genkernel_version=$(genkernel --version)
33 genkernel_version_major=${genkernel_version%%.*}
34 genkernel_version_minor_sub=${genkernel_version#${genkernel_version_major}.}
35 genkernel_version_minor=${genkernel_version_minor_sub%%.*}
36 genkernel_version_sub=${genkernel_version##*.}
37 if [ -n "${genkernel_version}" -a "${genkernel_version_major}" -eq '3' -a "${genkernel_version_minor}" -ge '2' ]
39 echo "Genkernel version ${genkernel_version} found ... continuing"
41 echo "ERROR: Your genkernel version is too low in your seed stage. genkernel version 3.2.0"
42 echo "or greater is required."
52 if [ -n "${clst_CCACHE}" ]
54 export clst_myfeatures="${clst_myfeatures} ccache"
55 #if [ "${clst_AUTORESUME}" = "1" -a -e /tmp/.clst_ccache ]
57 # echo "CCACHE Autoresume point found not emerging ccache"
59 emerge --oneshot --nodeps -b -k ccache || exit 1
60 # touch /tmp/.clst_ccache
64 if [ -n "${clst_DISTCC}" ]
66 export clst_myfeatures="${clst_myfeatures} distcc"
67 export DISTCC_HOSTS="${clst_distcc_hosts}"
68 #if [ "${clst_AUTORESUME}" = "1" -a -e /tmp/.clst_distcc ]
70 # echo "DISTCC Autoresume point found not emerging distcc"
72 USE="-gtk -gnome" emerge --oneshot --nodeps -b -k distcc || exit 1
73 #touch /tmp/.clst_distcc
79 if [ -n "${clst_PKGCACHE}" ]
81 export clst_myemergeopts="--usepkg --buildpkg --newuse"
82 export bootstrap_opts="-r"
85 if [ -n "${clst_FETCH}" ]
87 export clst_myemergeopts="${clst_myemergeopts} -f"
88 export bootstrap_opts="-f"
94 # portage needs to be merged manually with USE="build" set to avoid frying our
95 # make.conf. emerge system could merge it otherwise.
97 if [ "${clst_AUTORESUME}" = "1" -a -e /tmp/.clst_portage ]
99 echo "Portage Autoresume point found not emerging portage"
101 USE="build" emerge portage && touch /tmp/.clst_portage || exit 1
106 if [ -x /usr/bin/gcc-config ]
108 mythang=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 )
109 gcc-config ${mythang}; update_env_settings
113 update_env_settings(){
116 [ -f /tmp/envscript ] && source /tmp/envscript
139 # Sets up the ROOT= parameter
140 # with no options ROOT=/
141 make_destpath ${clst_root_path}
143 if [ -n "${clst_VERBOSE}" ]
145 echo "ROOT=${ROOT} emerge ${clst_myemergeopts} -vpt $@" || exit 1
146 emerge ${clst_myemergeopts} -vpt $@ || exit 3
147 echo "Press any key within 15 seconds to pause the build..."
151 echo "Press any key to continue..."
155 echo "emerge ${clst_myemergeopts} $@" || exit 1
156 emerge ${clst_myemergeopts} $@ || exit 1
160 # Copy libs of a executable in the chroot
161 function copy_libs() {
163 # Check if it's a dynamix exec
165 ldd ${1} > /dev/null 2>&1 || return
167 for lib in `ldd ${1} | awk '{ print $3 }'`
172 if [ ! -e ${clst_root_path}/${lib} ]
175 [ -e "${clst_root_path}/${lib}" ] && strip -R .comment -R .note ${clst_root_path}/${lib} || echo "WARNING : Cannot strip lib ${clst_root_path}/${lib} !"
178 echo "WARNING : Some library was not found for ${lib} !"
184 function copy_symlink() {
187 [ "${STACK}" = "" ] && STACK=16 || STACK=$((${STACK} - 1 ))
189 if [ ${STACK} -le 0 ]
191 echo "WARNING : ${TARGET} : too many levels of symbolic links !"
195 [ ! -e ${clst_root_path}/`dirname ${1}` ] && mkdir -p ${clst_root_path}/`dirname ${1}`
196 [ ! -e ${clst_root_path}/${1} ] && cp -vfdp ${1} ${clst_root_path}/${1}
198 TARGET=`readlink -f ${1}`
201 copy_symlink ${TARGET} ${STACK}
207 function copy_file() {
213 echo "WARNING : File not found : ${f}"
217 [ ! -e ${clst_root_path}/`dirname ${f}` ] && mkdir -p ${clst_root_path}/`dirname ${f}`
218 [ ! -e ${clst_root_path}/${f} ] && cp -vfdp ${f} ${clst_root_path}/${f}
219 if [ -x ${f} -a ! -h ${f} ]
222 strip -R .comment -R .note ${clst_root_path}/${f} > /dev/null 2>&1