1
0
Fork 0

More bugfix for build.sh

This commit is contained in:
Stefan Reimer 2018-08-12 17:16:13 -07:00
parent ae1b12951a
commit f81785423b
1 changed files with 211 additions and 238 deletions

View File

@ -197,34 +197,6 @@ install_gentoo() {
[ -r ${KERNEL_CONF} ] || die "Cannot read kernel config ${KERNEL_CONF}"
cp ${KERNEL_CONF} ${CHROOT}/tmp/.config
# Hack
cp dracut.tgz ${CHROOT}/tmp/
# Install automatic CPU USE detection
echo "Installing CPU USE flags detection"
cat << 'EOF' > ${CHROOT}/etc/profile.d/portage.sh
# use as many cores as available
export MAKEOPTS="-j$(nproc)"
# USE
# Look at CPU and return all actually available USE flags
get_cpu_use() {
local _USE=""
local AVAILABLE_USE="mmx mmxext sse sse2 sse3 ssse3 sse4 sse4_1 avx 3dnow 3dnowext"
local CPU_FLAGS=$(cat /proc/cpuinfo | grep flags | cut -d" " -f2- | uniq)
for f in ${AVAILABLE_USE}; do
if [ "$CPU_FLAGS" != "${CPU_FLAGS/$f/}" ]; then
_USE="$_USE $f"
fi
done
echo $_USE
}
export USE=$(get_cpu_use)
EOF
# From here we create the install script and execute it within the chroot at the end
cat << 'EOF' > ${CHROOT}/tmp/install.sh
#!/bin/bash
@ -233,7 +205,7 @@ source /etc/profile
export PS1="(chroot) $PS1"
CPUS=$(nproc)
[ $CPUS -ge 4 ] && JOBS="--jobs $((CPUS/2))"
[ $CPUS -ge 8 ] && JOBS="--jobs 4"
EOF
# Sync portage if not mounted
if [ ${_PORTAGE_MOUNTED} -eq 0 ]; then
@ -360,10 +332,11 @@ EOF
# Clean up host
cleanup() {
for mnt in ${CHROOT}/dev/pts ${CHROOT}/run/shm ${CHROOT}/dev ${CHROOT}/sys ${CHROOT}/proc; do
findmnt $mnt > /dev/null && umount $mnt
for dir in proc dev sys; do
umount -R ${CHROOT}/$dir 2> /dev/null
done
if [ ${_PORTAGE_MOUNTED} != 0 ]; then
umount ${CHROOT}/usr/portage
else