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
16 check_genkernel_version(){
17 if [ -x /usr/bin/genkernel ]
19 genkernel_version=$(genkernel --version)
20 genkernel_version_major=${genkernel_version%%.*}
21 genkernel_version_minor_sub=${genkernel_version#${genkernel_version_major}.}
22 genkernel_version_minor=${genkernel_version_minor_sub%%.*}
23 genkernel_version_sub=${genkernel_version##*.}
24 if [ -n "${genkernel_version}" -a "${genkernel_version_major}" -eq '3' -a "${genkernel_version_minor}" -ge '3' ]
26 echo "Genkernel version ${genkernel_version} found ... continuing"
28 echo "ERROR: Your genkernel version is too low in your seed stage. genkernel version 3.3.0"
29 echo "or greater is required."
38 if [ -n "${clst_CCACHE}" ]
40 export clst_myfeatures="${clst_myfeatures} ccache"
41 #if [ "${clst_AUTORESUME}" = "1" -a -e /tmp/.clst_ccache ]
43 # echo "CCACHE Autoresume point found not emerging ccache"
45 emerge --oneshot --nodeps -b -k ccache || exit 1
46 # touch /tmp/.clst_ccache
50 if [ -n "${clst_DISTCC}" ]
52 export clst_myfeatures="${clst_myfeatures} distcc"
53 export DISTCC_HOSTS="${clst_distcc_hosts}"
54 #if [ "${clst_AUTORESUME}" = "1" -a -e /tmp/.clst_distcc ]
56 # echo "DISTCC Autoresume point found not emerging distcc"
58 USE="-gtk -gnome" emerge --oneshot --nodeps -b -k distcc || exit 1
59 #touch /tmp/.clst_distcc
62 echo "${clst_distcc_hosts}" > /etc/distcc/hosts
67 if [ -n "${clst_PKGCACHE}" ]
69 export clst_myemergeopts="--usepkg --buildpkg --newuse"
70 export bootstrap_opts="-r"
72 if [ -n "${clst_FETCH}" ]
74 export bootstrap_opts="-f"
75 export clst_myemergeopts="${clst_myemergeopts} -f"
81 # portage needs to be merged manually with USE="build" set to avoid frying
82 # our make.conf. emerge system could merge it otherwise.
83 if [ "${clst_AUTORESUME}" = "1" -a -e /tmp/.clst_portage ]
85 echo "Portage Autoresume point found not emerging portage"
87 USE="build" run_emerge --oneshot --nodeps portage
88 touch /tmp/.clst_portage || exit 1
93 if [ -x /usr/bin/gcc-config ]
95 mythang=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* | head -n 1 )
96 if [ -z "${mythang}" ]
100 gcc-config ${mythang}; update_env_settings
105 if [ -x /usr/bin/binutils-config ]
107 mythang=$( cd /etc/env.d/binutils; ls ${clst_CHOST}-* | head -n 1 )
108 if [ -z "${mythang}" ]
112 binutils-config ${mythang}; update_env_settings
117 rm -rf /etc/distcc/hosts
120 update_env_settings(){
123 [ -f /tmp/envscript ] && source /tmp/envscript
145 # Sets up the ROOT= parameter
146 # with no options ROOT=/
147 make_destpath ${clst_root_path}
149 export EMERGE_WARNING_DELAY=0
151 export EBEEP_IGNORE=0
152 export EPAUSE_IGNORE=0
153 export CONFIG_PROTECT="-*"
155 if [ -n "${clst_VERBOSE}" ]
157 echo "ROOT=${ROOT} emerge ${clst_myemergeopts} -vpt $@" || exit 1
158 emerge ${clst_myemergeopts} -vpt $@ || exit 3
159 echo "Press any key within 15 seconds to pause the build..."
163 echo "Press any key to continue..."
168 echo "emerge ${clst_myemergeopts} $@" || exit 1
170 emerge ${clst_myemergeopts} $@ || exit 1
174 # Copy libs of a executable in the chroot
175 function copy_libs() {
176 # Check if it's a dynamix exec
177 ldd ${1} > /dev/null 2>&1 || return
179 for lib in `ldd ${1} | awk '{ print $3 }'`
184 if [ ! -e ${clst_root_path}/${lib} ]
187 [ -e "${clst_root_path}/${lib}" ] && \
188 strip -R .comment -R .note ${clst_root_path}/${lib} \
189 || echo "WARNING : Cannot strip lib ${clst_root_path}/${lib} !"
192 echo "WARNING : Some library was not found for ${lib} !"
197 function copy_symlink() {
199 [ "${STACK}" = "" ] && STACK=16 || STACK=$((${STACK} - 1 ))
201 if [ ${STACK} -le 0 ]
203 echo "WARNING : ${TARGET} : too many levels of symbolic links !"
207 [ ! -e ${clst_root_path}/`dirname ${1}` ] && \
208 mkdir -p ${clst_root_path}/`dirname ${1}`
209 [ ! -e ${clst_root_path}/${1} ] && \
210 cp -vfdp ${1} ${clst_root_path}/${1}
212 TARGET=`readlink -f ${1}`
215 copy_symlink ${TARGET} ${STACK}
221 function copy_file() {
226 echo "WARNING : File not found : ${f}"
230 [ ! -e ${clst_root_path}/`dirname ${f}` ] && \
231 mkdir -p ${clst_root_path}/`dirname ${f}`
232 [ ! -e ${clst_root_path}/${f} ] && \
233 cp -vfdp ${f} ${clst_root_path}/${f}
234 if [ -x ${f} -a ! -h ${f} ]
237 strip -R .comment -R .note ${clst_root_path}/${f} > /dev/null 2>&1